telemetry
telemetry copied to clipboard
Cleaner syntax for linking event schemas to event methods
This is a syntax sugar. It adds a new decorator, event_schema
, that can be called above a method to describe what telemetry data is collected by that method. This cleanly separates the telemetry definition logic from the application logic.
Before:
def method_to_record(self):
...
self.eventlog.record_event(
schema_name="my_event",
version=1,
event=...
)
After this PR:
@event_schema(
schema_name="my_event",
version=1
)
def method_to_record(self):
...
self.eventlog.record_event(event=...)
Normally, I don't think this kind of syntax sugar is necessary. In this case, though, it makes the code more readable. You can quickly scan through multiple methods to see which methods emit telemetry data and what data each method emits. No need to sift through the source code of the methods themselves.
This is fully backwards compatible. It's merely for readability.
@kiendang, what do you think of this PR? (ignoring the linting errors for now 😆 )
I like the syntax. Currently waiting until the jupyter_server PR get merged so we can test this with the events over there.