-
Notifications
You must be signed in to change notification settings - Fork 87
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
Generate trace IDs as ULIDs by default #783
Conversation
Deploying logfire-docs with Cloudflare Pages
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #783 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 137 138 +1
Lines 10985 11013 +28
Branches 780 781 +1
=========================================
+ Hits 10985 11013 +28 ☔ View full report in Codecov by Sentry. |
Co-authored-by: Alex Hall <[email protected]>
@alexmojaki any idea why this test is failing only on 3.8? https://github.com/pydantic/logfire/actions/runs/12675633556/job/35327091346?pr=783 |
The test was broken, it would always sort by the random part of the trace ID and never disambiguate by start time. Only 3.8 picked this up because f-string magic is disabled there. Otherwise the span name was always the f-string template. |
Ah good call. Should have used message! |
Thanks for your help Alex! |
The idea is to use a ULID to generate trace IDs.
This has the huge benefit of making trace IDs sortable and correlated with time.
For our backend this means much faster queries and much less data to index them.
This should not cause any issues with other backends, sampling or anything else.
This is already the default for logs and has been proposed to become the default for traces.
Why not use UUID v7 or set the bits for UUID v4 compatibility?
Mainly for safety of current implementations.
Existing implementations (including the OTEL Python SDK) should expect no more than 64 bits or randomness (see here).
Using a pure ULID (80 bits of randomness) ensures compatibility, using a UUID would leave us with only 7 (contiguous lower) bytes of randomness at most.
In the future if OTEL adopts https://www.w3.org/TR/trace-context-2/#random-trace-id-flag we can revisit.