You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our dashboards query root span transactions and their attributes. Some important transaction attributes are not available until some internal span (after messages have been unpacked, processed, etc.). We would like a way to copy a subset of internal span attributes up to the local root span. Our application is auto-instrumented with otel java agent, and our own custom extension to it, so we have the ability to add custom attribute extractors and span processors to the instrumentation chain.
Would this be best done in an AttributesExtractor, or a SpanProcessor (or something else)?
If SpanProcessor, in the onStart method, could we do something like this:
public void onStart(Context parentContext, ReadWriteSpan span) {
Span localRootSpan = LocalRootSpan.fromContextOrNull(parentContext)
// copy some attrs from span to localRootspan
}
In the onEnd method, context is not passed as a param, so how can we gain reference to the local root span? This is needed as some internal spans would set important attributes in their onEnd phase.
public void onEnd(ReadableSpan span) {
// How to get reference to the local root span?
}
If AttributesExtractor, both onStart and onEnd provide reference to AttributesBuilder and Context, so I assume in both we could do:
onStart(AttributesBuilder attributes, Context parentContext, ...) {
Span localRootSpan = LocalRootSpan.fromContextOrNull(context);
// copy some attrs from attributesBuilder to localRootspan
}
onEnd(AttributesBuilder attributesBuilder, Context parentContext, ...) {
Span localRootSpan = LocalRootSpan.fromContextOrNull(context);
// copy some attrs from attributesBuilder to localRootspan
}
Lastly, is there any way to "put-if-absent" on a local root span (or on other spans which are not ReadableSpan or ReadWriteSpan) ? We would like that once an attribute with a given name is set, it is not changeable if some subsequent span, but Span does not seem to provide the ability to read it's set attributes (unless it's ReadableSpan or ReadWriteSpan)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Our dashboards query root span transactions and their attributes. Some important transaction attributes are not available until some internal span (after messages have been unpacked, processed, etc.). We would like a way to copy a subset of internal span attributes up to the local root span. Our application is auto-instrumented with otel java agent, and our own custom extension to it, so we have the ability to add custom attribute extractors and span processors to the instrumentation chain.
Would this be best done in an AttributesExtractor, or a SpanProcessor (or something else)?
If SpanProcessor, in the onStart method, could we do something like this:
In the onEnd method, context is not passed as a param, so how can we gain reference to the local root span? This is needed as some internal spans would set important attributes in their onEnd phase.
If AttributesExtractor, both onStart and onEnd provide reference to AttributesBuilder and Context, so I assume in both we could do:
Lastly, is there any way to "put-if-absent" on a local root span (or on other spans which are not ReadableSpan or ReadWriteSpan) ? We would like that once an attribute with a given name is set, it is not changeable if some subsequent span, but Span does not seem to provide the ability to read it's set attributes (unless it's ReadableSpan or ReadWriteSpan)
And to help others that might be searching for the same, or similar, we also want to do the the reverse -- copy attributes from parent span to current span, and that seems be done here:
https://github.com/microsoft/ApplicationInsights-Java/blob/main/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/InheritedAttributesSpanProcessor.java
Beta Was this translation helpful? Give feedback.
All reactions