OTEP: Context-scoped Attributes - #4931
Conversation
dashpole
left a comment
There was a problem hiding this comment.
Go has had a "labeler" concept specific to http that is similar to this proposal: https://pkg.go.dev/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp#ContextWithLabeler. I would love to see a more cohesive and generic design for this!
|
FYI @open-telemetry/go-maintainers I think whatever comes from this proposal is what should replace our otelhttp.Labeler. |
Co-authored-by: Cijo Thomas <cithomas@microsoft.com>
aa5770a to
fb85ea6
Compare
MrAlias
left a comment
There was a problem hiding this comment.
Thanks for continuing to tighten this. I think the repeated context-write semantics and measurement-time merge point are in much better shape now. I left one metrics edge case that should be clarified, plus a couple of wording/configuration cleanups.
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
|
@MrAlias Thanks for the last pieces of feedback. This is ready for another review cycle. |
|
@open-telemetry/technical-committee I plan to merge this as part of the #5164 - let me know if you'd rather have me put this PR on hold ;) |
### Context - Clarify that environment variable propagation carriers normalize requested keys, carrier keys, and returned keys. ([open-telemetry#5102](open-telemetry#5102)) - Specify that environment variable propagation carriers only read and return normalized environment variable names. ([open-telemetry#5144](open-telemetry#5144)) - Specify that an empty environment variable propagation name is non-normalized and normalizes to `_`. ([open-telemetry#5163](open-telemetry#5163)) ### Profiles - Remove duplicate information from and extend Profiles documentation (README.md, pprof.md). ([open-telemetry#4932](open-telemetry#4932)) ### Entities - Add specification for communicating entity information as structured log events. ([open-telemetry#4836](open-telemetry#4836)) ### Common - Add an in-development [SDK self-observability](specification/self-observability.md) section, referenced from the Tracing, Metrics, and Logs SDK specs. ([open-telemetry#5087](open-telemetry#5087)) - Clarify non-OTLP representation guidance for nested `AnyValue` values in arrays and maps. ([open-telemetry#5053](open-telemetry#5053)) - Add in-development guidance recommending a JSON object as the string representation for an attribute in non-OTLP protocols. ([open-telemetry#5028](open-telemetry#5028)) - Add in-development guidance recommending a JSON object as the string representation for an attribute collection in non-OTLP protocols. ([open-telemetry#5110](open-telemetry#5110)) ### Compatibility - Deprecate OpenCensus compatibility requirements in the specification. ([open-telemetry#5138](open-telemetry#5138)) - Stabilize sections of Prometheus Metrics Exporter. - Clarify resource attributes configuration. ([open-telemetry#5084](open-telemetry#5084)) - Stabilize the conversion of OTLP Summaries into Prometheus Summaries. ([open-telemetry#5107](open-telemetry#5107)) - Stabilize client libs section. ([open-telemetry#5106](open-telemetry#5106)) - Stabilize Prometheus Metrics Exporter default aggregation configuration. ([open-telemetry#5113](open-telemetry#5113)) - Stabilize sections of Prometheus and OpenMetrics Compatibility. - Stabilize OpenTelemetry Histogram to Prometheus Histogram transformation. ([open-telemetry#5091](open-telemetry#5091)) - Add optional OpenTelemetry Histogram to Prometheus Native Histogram with Custom Buckets transformation. ([open-telemetry#5091](open-telemetry#5091)) ### SDK Configuration - Add link to declarative config IdGenerator type ([open-telemetry#5133](open-telemetry#5133)) ### OTEPs - Context-scoped Attributes. ([open-telemetry#4931](open-telemetry#4931)) --------- Co-authored-by: Reiley Yang <reyang@microsoft.com>
Add Context-scoped telemetry attributes which typically apply to all signals associated with a trace as it crosses a single service.
Resurrecting open-telemetry/oteps#207 while updating some changes that have happened since (e.g. changes in
InstrumentationScopebeing a runtime concept rather than a compile-time one). Originally proposed by @Oberon00Additionally:
Processoralternative being discarded as we would need to add an additional preOnStartcall in order to support Samplers.Baggageshould be included as part of stamping attributes to individual telemetry items (similar enough functionality).Java prototype for traces/logs: https://github.com/open-telemetry/opentelemetry-java/compare/main...carlosalberto:context-scoped-attrs-proto?expand=1
Summary
This OTEP aims to address various related demands that have been brought up in the past, where the scope of Resource attributes is too broad, but the scope of Span attributes is too narrow. For example, this happens where there is a mismatch between the OpenTelemetry SDK’s (and thus TracerProvider’s, MeterProvider’s) process-wide initialization and the semantic scope of a (sub)service.
The context-scoped attributes allows you to attach attributes to all telemetry signals emitted within a Context. Context-scoped attributes are normal attributes, which means you can use strings, integers, floating point numbers, booleans or arrays thereof, just like for Span or Resource attributes. Context-scoped attributes are associated with all telemetry signals emitted while the Context containing the Context-scoped attributes is active and are available to telemetry exporters. For spans, the context within which the span is started applies. Like other telemetry APIs, Context-scoped attributes are write-only for applications. You cannot query the currently set Context-scoped attributes, they are only available on the SDK level (e.g. to Samplers and SpanProcessors and exporters).
Context-scoped attributes should be thought of equivalent to adding the attribute directly to each single telemetry item it applies to.