Skip to main content

A JupyterLab library for logging and telemetry of usage data

Project description

jupyterlab_telemetry

Github Actions Status

A JupyterLab library for logging and telemetry of usage data

This extension is composed of a Python package named jupyterlab_telemetry for the server extension and a NPM package named @jupyterlab/jupyterlab-telemetry for the front end library.

Requirements

  • JupyterLab >= 3.0

Install

To install the server extension, execute:

pip install jupyterlab_telemetry

To install the front end library, add "@jupyterlab/jupyterlab-telemetry": "^1.0.0" to dependencies in package.json.

Uninstall

To remove the server extension, execute:

pip uninstall jupyterlab_telemetry

To remove the front end library, remove "@jupyterlab/jupyterlab-telemetry": "^1.0.0" from dependencies in package.json.

Troubleshoot

If you have installed the frontend library, but it is not able to connect to telemetry endpoint, check that the server extension is enabled:

jupyter server extension list

Usage

Define handlers that can receive events from the EventLog

import { EventLog } from '@jupyterlab/jupyterlab-telemetry';

function consoleHandler(el: EventLog, events: EventLog.RecordedEvent[]) {
  console.log(`[Handler1] Received events ${JSON.stringify(events)}`);
}

function consoleHandler2(el: EventLog, events: EventLog.RecordedEvent[]) {
  console.log(`[Handler2] Received events ${JSON.stringify(events)}`);
}

Create an instance of the EventLog and configure the handler and other options from EventLog.IOptions

const el = new EventLog({
  handlers: [consoleHandler, consoleHandler2],
  allowedSchemas: [
    'org.jupyter.foo',
    'org.jupyterlab.commands.docmanager:open'
  ],
  commandRegistry: app.commands,
  commandEmitIntervalSeconds: 2
});

Send custom events via the recordEvents interface. If the commandRegistry instance was passed, then the EventLog will subscribe to commands executed in the JupyterLab application and send the whitelisted ones to each configured handler.

el.recordEvent({
  schema: 'org.jupyter.foo',
  version: 1,
  body: {
    foo: 'bar'
  }
});

Dispose the event log after use

el.dispose();

Contributing

Development install

Note: You will need NodeJS to build the extension package.

The jlpm command is JupyterLab's pinned version of yarn that is installed with JupyterLab. You may use yarn or npm in lieu of jlpm below.

# Clone the repo to your local environment
git clone https://github.com/jupyterlab/jupyterlab-telemetry.git

# Change directory to the jupyterlab-telemetry directory
cd jupyterlab-telemetry

# Install package in development mode
pip install -e .

# Server extension must be manually installed in develop mode
jupyter server extension enable jupyterlab_telemetry

# Build the Typescript source after making changes
jlpm build

Testing

The server extension has python tests which can be updated and tested before pushing the new changes.

# Install the test dependencies
pip install .[test]

# Run the tests
pytest

The front end library is using jest for testing, and is setup to produce test coverage when the test target is run.

# To run the tests with coverage
jlpm test

Development uninstall

# Server extension must be manually disabled in develop mode
jupyter server extension disable jupyterlab_telemetry
pip uninstall jupyterlab_telemetry

Packaging the extension

See RELEASE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyterlab_telemetry-1.0.3.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

jupyterlab_telemetry-1.0.3-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file jupyterlab_telemetry-1.0.3.tar.gz.

File metadata

  • Download URL: jupyterlab_telemetry-1.0.3.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for jupyterlab_telemetry-1.0.3.tar.gz
Algorithm Hash digest
SHA256 b2f9a784795fb7a8f001dafc51174797a24488b5086c0c1d7a034dedfd4da4f2
MD5 b242ac34c0634a8db6d494290858e0de
BLAKE2b-256 65d528aad4b524477693967bf22209f9afa88804b0aec0eb5b508142f2f81e1c

See more details on using hashes here.

File details

Details for the file jupyterlab_telemetry-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: jupyterlab_telemetry-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for jupyterlab_telemetry-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4c62b3cc3c779c21a18a4b238ec2c7aae480b4bc29ca1b81e562f7c538a872e7
MD5 bf8f78e2c6a38d9de0f03baed6d64997
BLAKE2b-256 bdc0963dd46a7901ccb31c882f5bd15c9b60561704abc00e9ee88efd459344c8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page