-
Notifications
You must be signed in to change notification settings - Fork 336
Rest API endpoints for Events #851
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main #851 +/- ##
==========================================
+ Coverage 70.20% 70.22% +0.02%
==========================================
Files 65 65
Lines 7621 7650 +29
Branches 1268 1273 +5
==========================================
+ Hits 5350 5372 +22
- Misses 1887 1895 +8
+ Partials 384 383 -1
Continue to review full report at Codecov.
|
We may need to consider the issues raised by jupyter/telemetry#21 in this PR. How do we know if the event source is "trusted"? We might want to consider adding some signing mechanism to verify that the event came from a trusted source. This is more critical in a telemetry use-case, but also seems relevant for generic events. Thoughts? |
This looks great, @3coins! Thank you for working on this. |
Thanks for bringing this up. A few questions come to mind:
|
Reading the original issue about signing, it raises a few questions and observations. Let's consider a case where we have a client-side piece of functionality ( {
"schema_name": "ui:theme-change",
"version": "0.1",
"timestamp": 1653391523679,
"event": {
"from": "Solarized",
"to": "Nord",
"mode": "Light"
}
} Here we assume the I think the comments by @betatim and @jaipreet-s in the issue are right that we might not be able to validate a Of the examples I gave above: only a browser plugin or a I would suggest that for the first iteration, we leave What do you think? |
de42380
to
eb76158
Compare
FYI @3coins, I rebased and pushed to your branch! |
eb76158
to
01aece0
Compare
Thanks @afshin |
Thanks, @afshin. Great example and explanation. I agree, let's worry about this in future iterations. At the very least, it's helpful to have these thoughts documented here for future reference. |
@3coins, what do you think about including a unit test that checks the whole flow? This test would register an event schema, add it to the For reference, you can borrow work that @kiendang did in his previous telemetry PR: jupyter_server/examples/client_eventlog_example/tests/test_client_eventlog.py Lines 1 to 36 in e15dd9b
|
Good idea! Will add this soon. |
@3coins here's the relevant fixture jupyter_server/jupyter_server/pytest_plugin.py Lines 439 to 448 in e15dd9b
|
@3coins, this is looking good! Just one more minor comment around error handling that I noticed. |
|
||
try: | ||
if "timestamp" in payload: | ||
timestamp = datetime.strptime(payload["timestamp"], "%Y-%m-%d %H:%M:%S") |
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 think it would be a good idea to include microseconds in this kind of timestamp since we should be producing sub-second events.
I would also recommend recording the UTC offset so that "rollup/analysis" applications can operate on data from different timezones. Using an offset is probably more user-friendly wrt today's Jupyter users than going with UTC-based timestamps directly (although more difficult for analysis).
timestamp = datetime.strptime(payload["timestamp"], "%Y-%m-%d %H:%M:%S") | |
timestamp = datetime.strptime(payload["timestamp"], "%Y-%m-%d %H:%M:%S.%f %z") |
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.
Thanks for that suggestion. I will update in the next push.
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.
@kevin-bates I ended up removing the microseconds from the date format because EventLog is dropping this in the record_event method; isoformat
by default drops the microseconds.
https://github.com/jupyter/telemetry/blob/master/jupyter_telemetry/eventlog.py#L237
Let me know if we can handle this in a better way.
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.
@kevin-bates makes a good point here. I think this is an issue with jupyter_telemetry. We should fix this there, then circle back to this line of code later.
@3coins, I'm working on getting |
If |
Perhaps, we should update this to be |
Ah I see, thanks for the clarification. I'll defer to you on whichever field you decide 🚀 I was mostly hoping to avoid an |
This looks good to me. Thanks, @3coins! I'll work on switching to |
Part of #780