-
Notifications
You must be signed in to change notification settings - Fork 825
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
How to handle common / global attributes? #4274
Comments
If this ends up in SDK I would expect it to be similar across techs. If this happens it likely needs to be an optional component/api there because techs are already different in some areas (like automatic context propagation). Is this only applicable to browsers or also to node.js/deno/... Which component is responsible for such global changes?
Is it allowed to have more parallel sessions running? Is it allowed that spans on the same trace are on different sessions? |
|
I agree that it is similar, but there is a subtle difference. The MultiSpanProcessor is more generic; it can take any SpanProcessor and invoke its processing, which could be doing anything. My proposal with the
Having "GlobalAttribute" in the name denotes that this processor adds attributes that are considered global. In other words, this just describes what this processor does. |
The use cases I am aware of are for client applications. They are not only for web JS though; Android and Swift SDKs have the same use cases. There might be other use cases for non-client applications that I am not aware of; perhaps I should move this discussion to the spec repo.
It would not be an instrumentation. I envision this to be similar to resource providers.
I don't think there would be multiple parallel sessions, at least not represented using the same attribute. But I think this can be a separate conversation independent of how global attributes are handled in general.
Good question, I would say no, but it needs to be defined. |
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
This issue was closed because it has been stale for 14 days with no activity. |
The intent of this issue is to open a discussion about how to implement handling of common/shared attributes. Common attributes are similar to resource attributes in that they apply to all spans and logs, but they are different in that they are mutable.
Background
Client instrumentation has several use cases for attributes that should be associated with all spans and logs generated within a given time period. The primary use case is to represent a session (the session.id attribute has recently been added to semantic conventions), but there are other use cases including:
Compared with Resource attributes
We originally wanted to send these as resource attributes (see this OTEP). However, the challenge with these attributes is that their values can change during the lifetime of the SDK. Therefore, the direction we have received from the TC is to add them to each signal instead.
Compared with Context attributes
A distinction also needs to be made with trace-context attributes, as proposed in this OTEP. Client attributes, like session ID, need to be applied to many traces and standalone events generated by a client application, not just a single trace.
Questions
Should there be a standard mechanism in the SDK to handle these attributes?
Should this be standardized across all SDKs and documented in the specification?
Discussion
The options that I can think of:
Option 1: Each attribute is added by a separate span/log processor
The implementation would be straight-forward. However, adding many attributes means managing many processors: two processors (span and log) for each attribute. This may be difficult to configure and manage.
Setting and retrieving the attribute values could be handled on a case-by-case basis. A processor, for example, could itself include the detection of the value. Or, it could expose methods to set the value from an external code.
Example:
Option 2: There is a single span/log processor used to add all common attributes
There would be two processors only: one for spans and one for logs. The question is how would attributes be added and updated. The processor could accept a collection of attribute providers, or it could retrieve the attributes from a global attribute store (provided by the SDK). A prototype of the latter is available here.
For the first option, an interface would need to be defined for the attribute providers. These providers would need to be configured and passed to the processor during initialization.
Option 3: The mechanism to add these attributes is built-in to the SDK
With this option, there is no span/log processor. The SDK provides an API to set/update global attributes, and it automatically adds them when a span or log is created.
For example:
or perhaps:
Existing implementations
The Android SDK currently has a SessionIdSpanAppender span processor that adds the session ID attribute to all spans. It also has the GlobalAttributesSpanAppender span processor that can add multiple attributes at the same time.
We have also implemented a prototype in JavaScript that introduces a
GlobalAttributesSpanProcessor
andGlobalAttributesLogRecordProcessor
processors. The attributes are retrieved from a global store, which allows for any component to add global attributes.
The text was updated successfully, but these errors were encountered: