Skip to content

Ideas on how to InstrumentationLibrary -> Scope #2307

@bogdandrutu

Description

@bogdandrutu

This is a try to document what is the ideal scenario to extend the protocol to support the notion of "instrumentation scope", and allow the tracer/meter/logger to share the same concepts.

There were multiple proposals, disagreements, ideas in lots of places:

OTLP ideal end goal, based on lots of discussions/comments:

// Resource information.
message Resource {
  // Set of labels that describe the resource.
  repeated opentelemetry.proto.common.v1.AttributeKeyValue attributes = 1;
}

// Scope is a message representing the instrumentation scope
message Scope {
  // TBD: Do we need a first class "name" concept?
  // Set of labels that describe the instrumentation scope.
  repeated opentelemetry.proto.common.v1.AttributeKeyValue attributes = 1;
}

// A collection of ScopeMetrics from a Resource.
message ResourceMetrics {
  // The Resource for the metrics in this message.
  // If this field is not set then no Resource is known.
  Resource resource = 1;
  // A list of metrics that originate from a Resource and their scope.
  repeated ScopeMetrics scope_metrics = 2;
}

// A collection of Metrics from a Scope within a Resource.
message ScopeMetrics {
  // The Instrumentation scope information for the metrics in this message.
  // If this field is not set then no Scope is known.
  Scope scope = 1;

  // A list of metrics that originate from an Instrumentation scope.
  repeated Metric metrics = 2;
}

How to get there?

There are few places where changes are necessary:

  1. The OTLP protocol can be changed following a "backwards" compatible approach:
    • Rename "InstrumentationLibrary" to "Scope".
    • Add "attributes" to the new Scope concept.
    • Deprecate the current "name"/"version" in favor of semantic conventions for these fields in the new "attributes".
  2. The current "TracerProvider.get()" API:
    • Probably it is fine to relax the need to have this as defined right now "instrumentation library name" and suggest that as a "MAY".
    • When doing this change probably the SDK should stop populating the old "instrumentation library name" field in the protocol, and start using the new semantic convention (or proposed solution) for "scope.name". This will cause current receivers to receive an empty instrumentation library name which is ok, since the "instrumentation" itself is not stable.
    • Alternative we can simply continue to populate, the change of this "meaning" cannot cause that much inconvenience to the receivers. Not sure what receivers can do with this value, since is more or less a semantic convention anyway in regard to the format of the name and uniqueness, etc.
  3. The SDK (InstrumentationLibrary struct/class)
    • Ideally, if possible to rename/deprecate and add the new concept. This is probably very language specific. Need to collect more feedback from the maintainers.

Metadata

Metadata

Labels

area:apiCross language API specification issuespec:logsRelated to the specification/logs directoryspec:metricsRelated to the specification/metrics directoryspec:protocolRelated to the specification/protocol 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