-
Notifications
You must be signed in to change notification settings - Fork 273
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
add utility function for retrieving a trace id #1663
Conversation
Retrieve a unique trace id which can be used to link together processing steps in a plugin (or anywhere else in the router). If an execution trace context cannot be established, the return value will be INVALID_TRACE (all zeros). Watch out for this. Two invalid traces will be equal to each other. In other words, to correctly confirm that two things are linked you would have to check: let other_id = apollo_router::trace_id(); let my_id = apollo_router::trace_id(); if my_id != INVALID_TRACE && my_id == other_id { <blah...> } Without that first check, i.e.: if my_id == other_id { <blah...> } you could be linking together two unrelated things which both had invalid ids. fixes: #1536
and add a changelog
to changelog
or circleci isn't happy.
Add a to_u128() fn and modify Display to use this. Also, replace to_bytes() with as_bytes().
why not return an |
@@ -69,6 +69,7 @@ pub mod services; | |||
mod spec; | |||
mod state_machine; | |||
mod test_harness; | |||
pub mod tracer; |
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.
Would prefer tracing
as I could see us adding other trace related things in future.
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'll change it.
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.
sigh... If I rename to tracing
it creates several hundred ambiguity errors with the tracing
crate. Probably best to leave as tracer
.
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.
Approved, but see comment on module name.
I had that first, but decided to mirror the behaviour in the existing interface (which does this). I do think the nice thing about the I'll have a look at re-shaping this with an Option and see if it looks better. |
If we get TraceId::INVALID, then return None from the constructor.
to match implementation
By adding a mutex to the tests to serialize them with respect to global resources.
to make it better
add utility function for retrieving a trace id
Retrieve a unique trace id which can be used to link together processing
steps in a plugin (or anywhere else in the router).
If an execution trace context cannot be established, the return value
will be
None
To correctly confirm that two things are linked youwould have to check:
Without that first check, i.e.:
you could be linking together two unrelated things.
fixes: #1536