Skip to content

Commit 29580a6

Browse files
committed
add scope schema URL and attributes to prom attributes
1 parent a756317 commit 29580a6

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
@@ -77,6 +77,8 @@ final class Otel2PrometheusConverter {
7777
private static final ThrottlingLogger THROTTLING_LOGGER = new ThrottlingLogger(LOGGER);
7878
private static final String OTEL_SCOPE_NAME = "otel_scope_name";
7979
private static final String OTEL_SCOPE_VERSION = "otel_scope_version";
80+
private static final String OTEL_SCOPE_SCHEMA_URL = "otel_scope_schema_url";
81+
private static final String OTEL_SCOPE_ATTRIBUTE_PREFIX = "otel_scope_";
8082
private static final long NANOS_PER_MILLISECOND = TimeUnit.MILLISECONDS.toNanos(1);
8183
static final int MAX_CACHE_SIZE = 10;
8284

@@ -488,6 +490,16 @@ private Labels convertAttributes(
488490
if (scope.getVersion() != null) {
489491
labelNameToValue.putIfAbsent(OTEL_SCOPE_VERSION, scope.getVersion());
490492
}
493+
String schemaUrl = scope.getSchemaUrl();
494+
if (schemaUrl != null) {
495+
labelNameToValue.putIfAbsent(OTEL_SCOPE_SCHEMA_URL, schemaUrl);
496+
}
497+
scope
498+
.getAttributes()
499+
.forEach(
500+
(key, value) ->
501+
labelNameToValue.putIfAbsent(
502+
OTEL_SCOPE_ATTRIBUTE_PREFIX + key.getKey(), value.toString()));
491503
}
492504

493505
if (resource != null) {

0 commit comments

Comments
 (0)