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

Make telemetry use platform only. #10437

Merged
merged 3 commits into from
Jun 13, 2022
Merged

Make telemetry use platform only. #10437

merged 3 commits into from
Jun 13, 2022

Conversation

rebornix
Copy link
Member

@rebornix rebornix commented Jun 13, 2022

Re #10152

Attempt to enforce using platform modules only in telemetry. The PR includes two changes:

  • Move kernel and notebook specific telemetry registration into notebooks/kernel
  • Separate IEventNamePropertyMapping with the rest of basic helpers in telemetry. Make sure we only import platform in telemetry, except `IEventNamePropertyMapping

The reason IEventNamePropertyMapping is an exception is this mapping is used to track all our telemetry points and they also serve type checking

sendTelemetryEvent(eventName, eventValue)

We will check eventValue against IEventNamePropertyMapping[eventName). This means current approach will have to import types from all other modules. To move off this we would need to a different approach of type checking, for example

interface IDebuggingTelemetry {
  'ipykernel6Status': {
        status: 'installed' | 'notInstalled';
    }
}

sendTelemetryEvent<IDebuggingTelemetry>('ipykernel6Status', { status })

which won't require us to register all the typings in IEventNamePropertyMapping. Considering this is a rather big change and would also require changes for our tooling, I'll keep layer breaking imports in this file only.

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR).
  • Title summarizes what is changing.
  • Has a news entry file (remember to thank yourself!).
  • Appropriate comments and documentation strings in the code.
  • Has sufficient logging.
  • Has telemetry for feature-requests.
  • Unit tests & system/integration tests are added/updated.
  • Test plan is updated as appropriate.
  • package-lock.json has been regenerated by running npm install (if dependencies have changed).

@rebornix rebornix requested a review from a team as a code owner June 13, 2022 21:47
@rebornix rebornix self-assigned this Jun 13, 2022
@amunger
Copy link
Contributor

amunger commented Jun 13, 2022

Did telemtry.md get removed completely? I think Soojin still finds that file useful

@amunger
Copy link
Contributor

amunger commented Jun 13, 2022

There's also a husky pre-commit check that generates that file, maybe that ran and deleted everything after this change?

TELEMETRY.md Outdated
@@ -2,9498 +2,3 @@

Expand each section to see more information about that event.

<details>
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah looks like telemetry generation is broken. You likely need to change the telemetry generator too.

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems the generator fails to work after moving files around, fix it now.

@@ -95,3 +112,1229 @@ export interface IInterpreterPackages {
getPackageVersion(interpreter: PythonEnvironment, packageName: string): Promise<string | undefined>;
trackPackages(interpreterUri: InterpreterUri, ignoreCache?: boolean): void;
}

export interface IEventNamePropertyMapping {
Copy link
Contributor

Choose a reason for hiding this comment

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

ah the telemetry generator has to look here instead of index.ts for the telemetry information. That's why telemetry.md is empty.

Copy link
Contributor

Choose a reason for hiding this comment

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

See this file here:

if (refNode && r.fileName.endsWith('src/telemetry/index.ts')) {

Copy link
Member Author

Choose a reason for hiding this comment

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

🍺 thanks!

@rebornix
Copy link
Member Author

@amunger @rchiodo thanks! The telemetry.md should now be fixed.

@codecov-commenter
Copy link

codecov-commenter commented Jun 13, 2022

Codecov Report

Merging #10437 (2aafaea) into main (0a9f600) will decrease coverage by 0%.
The diff coverage is 92%.

@@          Coverage Diff           @@
##            main   #10437   +/-   ##
======================================
- Coverage     70%      70%   -1%     
======================================
  Files        478      480    +2     
  Lines      28956    28971   +15     
  Branches    4859     4859           
======================================
+ Hits       20535    20540    +5     
- Misses      6512     6528   +16     
+ Partials    1909     1903    -6     
Impacted Files Coverage Δ
src/platform/terminals/types.ts 100% <ø> (ø)
src/telemetry/serviceRegistry.node.ts 100% <ø> (ø)
src/kernels/telemetry/sendKernelTelemetryEvent.ts 84% <84%> (ø)
src/kernels/telemetry/helper.ts 93% <93%> (ø)
src/interactive-window/interactiveWindow.ts 73% <100%> (ø)
src/kernels/execution/kernelExecution.ts 70% <100%> (+<1%) ⬆️
src/kernels/helpers.node.ts 69% <100%> (ø)
...ls/jupyter/launcher/liveshare/hostJupyterServer.ts 75% <100%> (ø)
src/kernels/jupyter/launcher/notebookProvider.ts 76% <100%> (+<1%) ⬆️
src/kernels/kernel.base.ts 82% <100%> (+<1%) ⬆️
... and 19 more

@rebornix rebornix requested a review from rchiodo June 13, 2022 22:40
import { INotebookControllerManager } from '../types';
import { IInstaller, Product } from '../../kernels/installer/types';
import { IVSCodeNotebookController } from '../controllers/types';
import { trackKernelResourceInformation } from '../../kernels/telemetry/helper';
Copy link
Contributor

@DonJayamanne DonJayamanne Jun 13, 2022

Choose a reason for hiding this comment

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

A side effect is, stuff that didn't depend on kernels, now pulls in dependency from kernels folder.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess that's what we're trying to fix here, and this PR is just one of many.

Copy link
Member Author

Choose a reason for hiding this comment

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

@DonJayamanne you are right. This particular module InterpreterPackageTracker needs to read INotebookControllerManager, ./src/kernels, and ./src/telemetry. The best place for it is probably out of./src/notebooks and placed in a folder where we have all the moduels that glue things together.

@rebornix rebornix merged commit 3845edb into main Jun 13, 2022
@rebornix rebornix deleted the rebornix/telemetry branch June 13, 2022 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants