-
Notifications
You must be signed in to change notification settings - Fork 140
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
Telemetry #408
Telemetry #408
Conversation
43212c0
to
1f2ca2a
Compare
1a244ec
to
d34e876
Compare
src/build.ts
Outdated
@@ -144,6 +145,7 @@ export async function build( | |||
await effects.copyFile(sourcePath, outputPath); | |||
} | |||
} | |||
telemetry.record({event: "build", step: "finish"}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I bet this kind of "start/end" telemetry is going to often be interesting for us. Is it possible to link ends to their starts at all? Maybe telemetry.record
could return a message ID that we could note in the end event?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the session id will be stable across tied events.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the workflow on the analytic side would be to find a start event, and then look for end events with the same session id? Will that be annoying if there is an event that happens multiple times in a telemetry session?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, do you mean like in the case of maybe two builds happening concurrently and the events get interleaved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean if we have a start event for something more granular, like one per page. Is that just not what this is for? Having average time-per-page and number-of-pages metrics would be useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, we could do something like that. so just easier rolled-up timings of blocks of code, right? maybe a premature idea would be to provide a telemetry.measure({event: "something"}, () => { /* block */ })
. I guess I'm still not sure exactly what we'll want to measure so am willing to iterate a bunch and probably throw out old data as we do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could return an identifier (a counter probably that just increases with every call to record
) if people want to reference these in other events:
const ts = telemetry.record({event: "build", step: "start"});
// ...
telemetry.record({event: "build", step: "milestone", start: ts});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The block version is familiar, but it feels heavy handed. I'd really like language support for something like destructors, which makes this very nice, but we don't have those.
I think the ts
version makes sense, and I'd be happy with that.
Another idea I had was to have the return value of record
be a function or object with methods so you could do something like
const telemetrySpan = telemetry.startSpan({event: "build", step: "start"});
// ...
telemetrySpan.note({step: "milestone", foo: "bar"});
// ...
telemetrySpan.end({step: "end", status: "success"})
That's probably overkill though. Having .record
always give back an auto incrementing ID sounds like a good approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concerns about the start/end pairing are a theoretical thing that don't apply directly to any telemetry events added in this PR. We can deal with that if we actually add events that need that.
❯ yarn dev
❯ git bisect bad |
🛑 Same blocking error for yarn build |
|
probably something I tried during an earlier exploration; I like to make things break :) I had this:
setting it to writeable solved the issue |
* Record anonymous usage telemetry * Stricter types * Better persistence * Detect CI and Docker environments * Don't fail tests * Configurable origin * Fix lint * Better time information * Add isWSL heuristic * Some tests * Show a banner on first run * Test debug disables telemetry too * More testable * Ironically, disable telemetry during tests * Base telemetry origin on ui origin * Some documentation of what we're collecting * Manage our own singleton-ness * Initial telemetry documentation
Resolves #327
Depends on https://github.com/observablehq/observablehq/pull/15524
Questions for reviewers:
todo:
Probably in a follow up PR based on everyone's feedback:
Collects and sends telemetry to https://events.observablehq.com/cli. What's currently collected:
Presents a banner once, when first run with a URL pointing to more information. Showing the banner saves timestamp to ~/.observablehq to know we've already shown it. That means checking to see if we should show it is async and therefore the banner could show up "late" and interspersed with other log messages. Is there a better way to check and save banner state?