-
Notifications
You must be signed in to change notification settings - Fork 893
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
Change Processor and Exporter interface to pass resource #508
Comments
In Java SpanData contains the Resource, but that can change if we decide to implement this. Also same discussion should apply for InstrumentationLibrary. |
discussed today at tech sync and the question is whether having Resource reference from SpanData is a possibility. This is how many languages implement it today. |
Relatedly, we don't have a "readable span" or "span data" interface in the spec at all currently, so the object that is passed to the exporter is left to the language SIGs to design. See #158. |
Languages without the ability to use references to a shared object, like Erlang/Elixir, have to copy the Resource and instrumentation library info to every Span. I'm in the process of figuring out a better way for us, involving a single copy in the tracer provider. Still working on the interface (like should the batch processor or exporter request the resource from the tracer provider on every export so that the Resource can be updated? Mainly thinking about how the Resource is setup during boot and not having to wait to initialize the processor until the Resource is fully initialized) |
Have we decided to coalesce resources into span attributes? I believe we have. |
The protos currently keep them separate. The requests to export spans with the Otel protocol requires Resource as a field along with a repeated field of |
To save tons of bandwidth that would be used up by duplicated resource information? (Or alternatively, lots of CPU cycles that would be used for compression). EDIT: Also, resources are a prime candidate for caching on the backend due to being immutable, see #515. EDIT: Or I might be misunderstanding you here? |
I believe we talked about that on a SIG call and everyone there seemed to be in favor IIRC, but it's not documented anywhere. |
Yes, I 100% agree with this. Also, some vendors probably want to map these attributes to different ones that are conventional on their platforms, and having it able to be done once is very preferable. |
None of the existing OSS export protocols have this support built in, so I'm skeptical that we'll save resources by this decision alone. Also this makes distributed processing of span data more difficult. Compression is cheap. Surely resources will be repetitive, but span attributes and metric labels will be too. If we had API support for resource scopes, then I can see how we would cheaply be able to avoid repetition for all kinds of attribute. open-telemetry/oteps#78 |
It already helps for forwarding to the OTel collector. Also at Dynatrace we plan to support this kind of "deduplication". |
This issue comes up regularly, so I thought I'd at least write down what I know about it in one place, so I can refer to it later. If this comment, or some version of it, would be useful elsewhere, let me know. The underlying reason why resources need to be attached to the spans and metrics they generate, is that OpenTelemetry allows multiple resources per process. This allows a process to have multiple "logical applications". A consequence of this design, is that exporters need to be aware that telemetry can come from multiple resources, and handle the data accordingly. In practice this means grouping spans or metrics by resource, and exporting them in batches. This choice prevents an exporter from being tied to a single resource. The mechanism by which this is currently possible is by having multiple tracer providers. Each provider can have a different resource, but share the same export pipeline. There are proposals, such as @jmacd's Resource Scopes, where multiple Resources can be managed via Context: open-telemetry/oteps#78. This shares the same requirements for telemetry and the export pipeline as the multiple tracer provider use case. If we decided that Resources mapped 1-1 to processes, we could simplify the export pipeline by passing a Resource to an exporter directly and avoid having to attach a resource to every span or metric recorded. |
My opinion on this is: Any Exporter MUST NOT be attached to more than one SpanProcessor unless it explicitly states that it supports it. Any SpanProcessor MUST NOT be attached to more than one TracerProvider unless it (and any attached exporters) explicitly support it. I think we implicitly have the first requirement (only one SpanProcessor per Exporter) already when we say at https://github.com/open-telemetry/opentelemetry-specification/blob/da9f4593af21961683606be7a1e80d2cf4cd0242/specification/trace/sdk.md#exportbatch:
This is nigh impossible to implement if an exporter can be attached to more than one SpanProcessor at the same time. (NB: Someone pointed out the defect that SimpleSpanProcessor implementations typically will also break this rule somewhere). |
In current resources specification, resource is associated with a Trace Provider. Semantically, that makes sense as well. However, there is problem retrieving resource in a SpanProcessor. SpanProcessor has no reference to TraceProvider to which it is registered. The problem is only in async path.
In Go (and most likely other languages as well), when span ends, the data flow is as follows.
Sync Path: Tracer (ctx1) -->Simple Span Processor (ctx1, SpanData) --> Exporter (ctx1, SpanData).
Async Path: Tracer (ctx1)-->Batched Span Processor (ctx1, SpanData) --> Exporter (ctx2, []SpanData)
In sync path, there are no issues. Resources can be added to SpanData and Exporter can send the resource to its backend after remapping the resource if necessary.
In async path, however, it is not efficient to duplicate the same resource with all the SpanData. After all we have common resource for a batch of spans in proto for a reason. How do we achieve the efficiency?
Alternatively,
The text was updated successfully, but these errors were encountered: