-
Notifications
You must be signed in to change notification settings - Fork 303
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
Adding custom attributes to traces at step runtime #2620
Comments
hi @pfiaux! this sounds like a great idea, and we'd be happy to accept PRs to this effect. i think the CLI definition you've proposed looks good, though if we were bring it more in line with the current CLI tools it'd probably be more like:
i think that adding attributes statically at agent start time should be relatively straightforward - we could just add another cli flag. adding them during a job run would be more complicated, but definitely still doable. the best way forward would likely be the Job API, a REST API that allows hooks (like the command hook, which is what runs your job) to communicate with the state of the job as a whole. you can check out the Job API in action in the |
We were interested in adding it at job time, it's a little bit less important for us now because we can't use the traces for the metrics we wanted to grab (the agent traces are unfortunately at the step rather than the pipeline level but that's another topic). I agree that your proposal is more like the current interface, but I'm not sure how to handle the types using that signature.
That's why I suggested JSON, which is supported by some commands like pipeline upload so it's not entirely strange... It would make it less straight forward to implement, but it could help with multiple values in 1 go:
I'm not sure I got what you meant by using the Job API. This one right https://buildkite.com/docs/apis/rest-api/jobs? You mean instead of using the cli to set a the value we could use the API or the implementation of the CLI should use the API? |
Is your feature request related to a problem? Please describe.
Currently the attributes added to a trace (in open telemetry at least) by buildkite are static. For example a trace stored in tempo had the following attribute keys on the root span:
There's no way to add another attribute dynamically at run time (or statically either currently).
Yet this could be useful to allow filtering by different dimensions:
This would give flexibility to extend traces as needed without having to cover too many cases statically in the agent and makes them very powerful.
Describe the solution you'd like
The CLI could allow setting an attribute (ideally at the root span level) dynamically at run time:
This would then be propagated to the spans (except already closed ones, i.e. all the pre-run ones).
According to the open telemetry attribute docs the value can be primitives, or an array of primitives. Using json encoded would make it easy to tell if for example 1 is a string or a number and to make arrays as opposed to a plain string value. Or it could be another encoding.
Describe alternatives you've considered
There's lots of ways attributes could be added/requested and this could be done at different times of the lifecycle.
There would be other ways to explicitly or implicitly expose attributes:
trace_*
)TRACE_*
or more backend specificOTEL_ATTR_*
)Additional context
I'm not sure how close or different datadog is from open telemetry, ideally this feature could be done in a way that supports both backends to avoid as much backend specific code as possible.
Would buildkite accept a PR allowing addition of trace attributes? If so what kind of solution/approach would be accepted?
The text was updated successfully, but these errors were encountered: