index.md
August 27, 2026 · View on GitHub
These four types describe every signal, across all three telemetry pillars — tracing, logging, and metrics. Every span, log record, and metric data point is annotated with Attributes; every provider accepts a Resource; every scope instance is tagged with an InstrumentationScope. Understanding these four types unlocks the rest of the module.
Types
| Type | Description |
|---|---|
| Attributes | Immutable, unboxed parallel-array collection of typed key-value pairs. Carried by every signal: Span, LogRecord, Counter, Resource, and InstrumentationScope. |
| AttributeKey | Typed key for an Attributes entry. Binds a string name to one of eight value types (String, Long, Double, Boolean, and their Seq variants). |
| AttributeValue | Boxed existential wrapper for the same eight kinds, used at API boundaries — Logger's vararg attributes, Span#setAttribute, metric label maps — where the type isn't known ahead of time. |
| Resource | Immutable Attributes wrapper that describes the entity producing telemetry (service name, SDK version, deployment environment). Shared across all three providers. |
| InstrumentationScope | Named and versioned identity for the library or component that created a signal. Set when calling TracerProvider.get, LoggerProvider.get, or MeterProvider.get. |
Design
All four types are designed for hot-path telemetry code:
AttributesstoresLong,Double, andBooleanvalues unboxed in a parallel primitive array via bit-casting. Reading a value back boxes it — throughget,foreach, or a conversion toMap— so hot paths that only write stay allocation-free.AttributeKeyis a small case class carrying the name and the value type, so a typo in a name or a mismatched type is a compile error rather than a silently separate series.Resourceis immutable and stamped onto a signal when it is created, not at export:Tracerputs it on every span andLoggeron every log record. Metric instruments do not carry it — aMeterProviderholds aResource, but theMeterand the collectedMetricDatanever see it.InstrumentationScopeis constructed once per scope by the provider and referenced from all signals that scope creates.