Skip to main content

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

Metadata

Release files for jupyterlab-telemetry 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jupyterlab-telemetry 1.0.3
File Size Uploaded
jupyterlab_telemetry-1.0.3.tar.gz 16.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jupyterlab-telemetry 1.0.3
File Interpreter ABI Platform
jupyterlab_telemetry-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 23.2 kB

Release files / jupyterlab_telemetry-1.0.3.tar.gz

Download URL jupyterlab_telemetry-1.0.3.tar.gz
Size 16.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b2f9a784795fb7a8f001dafc51174797a24488b5086c0c1d7a034dedfd4da4f2
BLAKE2b-256 checksum
How to use checksums
65d528aad4b524477693967bf22209f9afa88804b0aec0eb5b508142f2f81e1c
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / jupyterlab_telemetry-1.0.3-py3-none-any.whl

Download URL jupyterlab_telemetry-1.0.3-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4c62b3cc3c779c21a18a4b238ec2c7aae480b4bc29ca1b81e562f7c538a872e7
BLAKE2b-256 checksum
How to use checksums
bdc0963dd46a7901ccb31c882f5bd15c9b60561704abc00e9ee88efd459344c8
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page