Skip to content

Change Processor and Exporter interface to pass resource #508

@rghetia

Description

@rghetia

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?

  • Group all SpanData on BSP by resources. It requires
    • OnEnd(SpanData) interface to change to onEnd(Resource, SpanData) to contain reference to the Resource. Batcher can simply keep one reference for all the accumulated SpanData.
    • Export(Batch) must be changed to Export(Resourc, Batch) to contain reference to the Resource.
    • Restrict BSP to be associated only with one Trace Provider (current spec doesn't restrict associating BSP with multiple Trace Provider).
      • If it must be allowed to associate with Multiple Provider then use reference to Resource (assuming same resource object will be provided with each onEnd() call) to group SpanData by Resource. Then call Export(Resource, []SpanData) for each group.

Alternatively,

  • Create resource at Exporter.

Metadata

Metadata

Assignees

Labels

area:sdkRelated to the SDKrelease:after-gaNot required before GA release, and not going to work on before GAspec:resourceRelated to the specification/resource directoryspec:traceRelated to the specification/trace directory

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions