Jupyter Telemetry

raw JSON →
0.1.0 verified Fri May 01 auth: no python maintenance

Library for emitting telemetry events from Jupyter applications. Provides a configurable event logging system with support for schemas and output sinks. Version 0.1.0 is the latest (stable). Development is relatively slow; no major releases since 2020.

pip install jupyter-telemetry
error AttributeError: module 'jupyter_telemetry' has no attribute 'EventLog'
cause Incorrect import path; attempting to import from the top-level namespace but the module might be missing or installed incorrectly.
fix
Use: from jupyter_telemetry import EventLog; or check installation: pip show jupyter-telemetry
error KeyError: 'event'
cause Emitting an event with a schema name that hasn't been registered. The library silently ignores, but if you access the event log later, it may raise KeyError.
fix
Register the event schema before emitting: log.register_event_schema('my_event', schema)
error No handlers could be found for logger "jupyter_telemetry"
cause Python's logging module emits this warning if no handlers are configured for the telemetry logger.
fix
Set up logging: import logging; logging.basicConfig() or add a handler for 'jupyter_telemetry' logger.
gotcha Event schemas must be registered before emitting. If you emit an event for an unregistered schema, the library silently drops the event with no error.
fix Ensure all event types are registered via log.register_event_schema before calling log.emit.
gotcha The library uses logging under the hood. If you don't configure logging output, events are sent to stderr via a default logging handler. In environments like Jupyter Notebook, this can cause cluttered output.
fix Configure logging to suppress or redirect: import logging; logging.getLogger('jupyter_telemetry').setLevel(logging.WARNING)
deprecated Python 3.5 and 3.6 are no longer supported upstream. The library's requires_python is >=3.5, but tests may fail on Python 3.9+ due to removed APIs (e.g., collections.abc vs collections).
fix Use Python 3.7 or 3.8. For newer Python, consider patching or using an alternative.

Basic usage: import EventLog, register a JSON schema, and emit events.

from jupyter_telemetry import EventLog

# Create an EventLog instance
log = EventLog()

# Register a schema (using traitlets-based schema)
from traitlets import Dict, Unicode

class MyEvent:
    def __init__(self):
        self.schema = {
            'type': 'object',
            'properties': {
                'user': {'type': 'string'},
                'action': {'type': 'string'},
                'value': {'type': 'integer'}
            },
            'required': ['user', 'action', 'value']
        }

log.register_event_schema('my_event', MyEvent().schema)

# Emit an event
log.emit('my_event', {'user': 'alice', 'action': 'click', 'value': 42})

# Events are logged via the configured output (default: logging.Logger to stderr)