mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-07 10:04:07 +00:00
add docs for event-logging
This commit is contained in:
@@ -5,3 +5,4 @@ alabaster_jupyterhub
|
|||||||
recommonmark==0.5.0
|
recommonmark==0.5.0
|
||||||
sphinx-copybutton
|
sphinx-copybutton
|
||||||
sphinx>=1.7
|
sphinx>=1.7
|
||||||
|
sphinx-jsonschema
|
@@ -19,6 +19,7 @@ extensions = [
|
|||||||
'sphinx.ext.napoleon',
|
'sphinx.ext.napoleon',
|
||||||
'autodoc_traits',
|
'autodoc_traits',
|
||||||
'sphinx_copybutton',
|
'sphinx_copybutton',
|
||||||
|
'sphinx-jsonschema'
|
||||||
]
|
]
|
||||||
|
|
||||||
templates_path = ['_templates']
|
templates_path = ['_templates']
|
||||||
|
50
docs/source/events/index.rst
Normal file
50
docs/source/events/index.rst
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
Eventlogging and Telemetry
|
||||||
|
==========================
|
||||||
|
|
||||||
|
JupyterHub can be configured to record structured events from a running server using Jupyter's `Telemetry System`_. The types of events that JupyterHub emits are defined by `JSON schemas`_ listed below_
|
||||||
|
|
||||||
|
emitted as JSON data, defined and validated by the JSON schemas listed below.
|
||||||
|
|
||||||
|
|
||||||
|
.. _logging: https://docs.python.org/3/library/logging.html
|
||||||
|
.. _`Telemetry System`: https://github.com/jupyter/telemetry
|
||||||
|
.. _`JSON schemas`: https://json-schema.org/
|
||||||
|
|
||||||
|
How to emit events
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Eventlogging is handled by its ``Eventlog`` object. This leverages Python's standing logging_ library to emit, filter, and collect event data.
|
||||||
|
|
||||||
|
|
||||||
|
To begin recording events, you'll need to set two configurations:
|
||||||
|
|
||||||
|
1. ``handlers``: tells the EventLog *where* to route your events. This trait is a list of Python logging handlers that route events to
|
||||||
|
2. ``allows_schemas``: tells the EventLog *which* events should be recorded. No events are emitted by default; all recorded events must be listed here.
|
||||||
|
|
||||||
|
Here's a basic example:
|
||||||
|
|
||||||
|
.. code-block::
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
c.EventLog.handlers = [
|
||||||
|
logging.FileHandler('event.log'),
|
||||||
|
]
|
||||||
|
|
||||||
|
c.EventLog.allowed_schemas = [
|
||||||
|
'hub.jupyter.org/server-action'
|
||||||
|
]
|
||||||
|
|
||||||
|
The output is a file, ``"event.log"``, with events recorded as JSON data.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.. _below:
|
||||||
|
|
||||||
|
Event schemas
|
||||||
|
-------------
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 2
|
||||||
|
|
||||||
|
server-actions.rst
|
1
docs/source/events/server-actions.rst
Normal file
1
docs/source/events/server-actions.rst
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.. jsonschema:: ../../../jupyterhub/event-schemas/server-actions/v1.yaml
|
@@ -134,6 +134,14 @@ helps keep our community welcoming to as many people as possible.
|
|||||||
contributing/roadmap
|
contributing/roadmap
|
||||||
contributing/security
|
contributing/security
|
||||||
|
|
||||||
|
Eventlogging and Telemetry
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 1
|
||||||
|
|
||||||
|
events/index
|
||||||
|
|
||||||
Upgrading JupyterHub
|
Upgrading JupyterHub
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user