Skip to content

Commit b8121e5

Browse files
committed
add scope schema URL and attributes to prom attributes
1 parent cc7d085 commit b8121e5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

exporters/prometheus/src/main/java/io/opentelemetry/exporter/prometheus/Otel2PrometheusConverter.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ final class Otel2PrometheusConverter {
7575
private static final ThrottlingLogger THROTTLING_LOGGER = new ThrottlingLogger(LOGGER);
7676
private static final String OTEL_SCOPE_NAME = "otel_scope_name";
7777
private static final String OTEL_SCOPE_VERSION = "otel_scope_version";
78+
private static final String OTEL_SCOPE_SCHEMA_URL = "otel_scope_schema_url";
79+
private static final String OTEL_SCOPE_ATTRIBUTE_PREFIX = "otel_scope_";
7880
private static final long NANOS_PER_MILLISECOND = TimeUnit.MILLISECONDS.toNanos(1);
7981
static final int MAX_CACHE_SIZE = 10;
8082

@@ -484,6 +486,16 @@ private Labels convertAttributes(
484486
if (scope.getVersion() != null) {
485487
labelNameToValue.putIfAbsent(OTEL_SCOPE_VERSION, scope.getVersion());
486488
}
489+
String schemaUrl = scope.getSchemaUrl();
490+
if (schemaUrl != null) {
491+
labelNameToValue.putIfAbsent(OTEL_SCOPE_SCHEMA_URL, schemaUrl);
492+
}
493+
scope
494+
.getAttributes()
495+
.forEach(
496+
(key, value) ->
497+
labelNameToValue.putIfAbsent(
498+
OTEL_SCOPE_ATTRIBUTE_PREFIX + key.getKey(), value.toString()));
487499
}
488500

489501
if (resource != null) {

0 commit comments

Comments
 (0)