mechanism for adding information to a span after completion #7531
Unanswered
hughlunnon
asked this question in
Q&A
Replies: 2 comments 2 replies
|
I’m not entirely sure, so take this for reference only: I’m thinking that perhaps we only need to wrap one of the existing |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi
At the moment we're using the
go.opentelemetry.io/otel/sdk/tracetrace provider, with a few options. I'd like to be able to add a little metadata (specifically, the amount of time the span spent on cpu, which I'm calculating elsewhere, but isn't available for maybe 1 second after the span finishes) before thego.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpcpushes it to our collector.It looked like a
SpanProcessorwould be a nice way to do this, as it supports theOnEndfunction, and is called in order, so I could have a processor that adds my data, then go into the normal stack - however it seems this is only called with asnapshotof the span, which is immutable (so "can't" be edited).Now, the attributes on the snapshot are a normal slice (I think), and as slices are passed by pointer I think I could modify some placeholder value with the actual value, but it seems like generally editing the value of a
ReadOnlySpanshould not be done.I could also copy-paste the code from within the exporter, and add some custom code hook to do what I'm after just before we ship the data, but this also seems like an un-necessarily messy method.
Am I missing another hook that I can use to inject an attribute after span finish?
Thanks
Hugh
All reactions