Skip to content

Commit

Permalink
convert _otel_scope_info metrics back into instrumentation scope
Browse files Browse the repository at this point in the history
  • Loading branch information
dashpole committed Jul 29, 2022
1 parent 5c76ab5 commit 518cee5
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion specification/metrics/data-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ linkTitle: Data Model
+ [Dropped Types](#dropped-types)
+ [Start Time](#start-time)
+ [Exemplars](#exemplars-1)
+ [Instrumentation Scope](#instrumentation-scope)
+ [Resource Attributes](#resource-attributes)
* [OTLP Metric points to Prometheus](#otlp-metric-points-to-prometheus)
+ [Metric Metadata](#metric-metadata-1)
+ [Instrumentation Scope](#instrumentation-scope)
+ [Instrumentation Scope](#instrumentation-scope-1)
+ [Gauges](#gauges-1)
+ [Sums](#sums-1)
+ [Histograms](#histograms-1)
Expand Down Expand Up @@ -1274,6 +1275,49 @@ retrieved from the `trace_id` and `span_id` label keys, respectively. All
labels not used for the trace and span ids MUST be added to the OpenTelemetry
exemplar as attributes.

#### Instrumentation Scope

Each metric matching `<prefix>_otel_scope_info` present in a batch of metrics
SHOULD be dropped from the incoming scrape, and converted to an instrumentation
scope. The `name` and `version` labels, if present MUST be converted to the
Name and Version of the Instrumentation Scope. The prefix of the metric MUST be
added to the Instrumentation Scope as the value for the `scope.short_name`
attribute. Additional labels MUST be added as scope attributes, with keys and
values unaltered. Other metrics in the batch which have a prefix equal to the
prefix of the `<prefix>_otel_scope_info` metric have the matching prefix
removed, and are placed within that Instrumentation Scope. For example, the
Prometheus metrics:

```
# TYPE otelhttp_otel_scope_info gauge
otelhttp_otel_scope_info{name=go.opentelemetry.io.contrib.instrumentation.net.http.otelhttp,version=v0.24.0,library_mascot=bear} 1
# TYPE otelhttp_http_server_duration counter
otelhttp_http_server_duration{...} 1
```

becomes:

```yaml
# within a resource_metrics
scope_metrics:
scope:
name: go.opentelemetry.io.contrib.instrumentation.net.http.otelhttp
version: v0.24.0
attributes:
scope.short_name: otelhttp
library_mascot: bear
metrics:
- name: http_server_duration
data:
sum:
data_points:
- value: 1
```
Metrics which are not found to be associated with an instrumentation scope are
all placed within an empty instrumentation scope, and do not have any prefixes
trimmed.
#### Resource Attributes
When scraping a Prometheus endpoint, resource attributes MUST be added to the
Expand Down

0 comments on commit 518cee5

Please sign in to comment.