Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added telemetry support. #448

Merged
merged 6 commits into from
Oct 27, 2023
Merged

Added telemetry support. #448

merged 6 commits into from
Oct 27, 2023

Conversation

3coins
Copy link
Collaborator

@3coins 3coins commented Oct 26, 2023

Description

This PR adds support for telemetry and emits data for different events in the Scheduler components. A new plugin is provided that receives the event data. Implementors can disable the default plugin and provide their own implementation that will pass the telemetry data to their handler.

Event log examples

Advanced options expanded

{
    "body": {
        "name": "org.jupyter.jupyter-scheduler.create-job.advanced-options.expand"
    },
    "timestamp": "2023-10-26T17:17:44.350Z"
}

Create job cancel button clicked

{
    "body": {
        "name": "org.jupyter.jupyter-scheduler.create-job.cancel"
    },
    "timestamp": "2023-10-26T17:18:53.323Z"
}

Create job run on schedule option selected

{
    "body": {
        "name": "org.jupyter.jupyter-scheduler.create-job.job-type.run-on-schedule"
    },
    "timestamp": "2023-10-26T17:19:28.917Z"
}

Providing your implementation to process telemetry events

Create a new handler and a plugin that provides the handler.

const myTelemetryHandler: async (eventLog: Scheduler.IEventLog): Promise<void> => {
    // process the eventLog 
}

const myTelemetryPlugin: JupyterFrontEndPlugin<Scheduler.TelemetryHandler> = {
  id: '@jupyterlab/scheduler:MyTelemetryHandler',
  autoStart: true,
  provides: Scheduler.TelemetryHandler,
  activate: (app: JupyterFrontEnd) => {
    return myTelemetryHandler;
  }
};

Disable the default plugin in the package.json file of your extension package.

"jupyterlab": {
    "extension": true,
    "disabledExtensions": [
      "@jupyterlab/scheduler:TelemetryHandler"
    ]
  }

Attaching new events to telemetry handler

A new hook useLogger is available that could be accessed in any component.

const log = useLogger();

Any event handler can then call the log to pass in the event name.

log("job-detail.<my-event>")

@3coins 3coins added the enhancement New feature or request label Oct 26, 2023
dlqqq

This comment was marked as resolved.

src/notebook-jobs-panel.tsx Outdated Show resolved Hide resolved
src/notebook-jobs-panel.tsx Outdated Show resolved Hide resolved
@3coins 3coins marked this pull request as ready for review October 27, 2023 00:19
Copy link
Collaborator

@JasonWeill JasonWeill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General comment: I was confused by the use of log and GetLogger for telemetry events. We use very similar names for functions that log things to stdout/stderr, for example. Could we use something like logTelemetryEvent or telemetryEvent to be more noticeably different?

src/mainviews/create-job.tsx Show resolved Hide resolved
@3coins
Copy link
Collaborator Author

3coins commented Oct 27, 2023

@JasonWeill

I was confused by the use of log and GetLogger for telemetry events.

See the comments from David's review explaining the rationale behind this.

@JasonWeill
Copy link
Collaborator

While I agree that "telemetry" isn't a verb, the verb shouldn't just be "log" for telemetry events; that's ambiguous. I'd prefer that log be kept for stdout/stderr logging, and logTelemetryEvent or logEvent be used for telemetry event logging.

@3coins
Copy link
Collaborator Author

3coins commented Oct 27, 2023

@JasonWeill @dlqqq
Made final updates for the names.

Copy link
Collaborator

@dlqqq dlqqq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work!

@3coins 3coins merged commit 646e6c9 into jupyter-server:main Oct 27, 2023
6 checks passed
3coins added a commit to 3coins/jupyter-scheduler that referenced this pull request Oct 31, 2023
* Added telemetry support.

* Fixed lint errors

* Refactored to use a logger hook.

* Corrected the handler and token names.

* Corrected the plugin id to match the token.

* Updated names for hook and handler
3coins added a commit that referenced this pull request Oct 31, 2023
* Added telemetry support.

* Fixed lint errors

* Refactored to use a logger hook.

* Corrected the handler and token names.

* Corrected the plugin id to match the token.

* Updated names for hook and handler
@dlqqq dlqqq mentioned this pull request Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants