Skip to content

Commit c1ccdff

Browse files
authored
Merge pull request #669 from travelping/fix/undefined-units
don't export unit fields in metrics when the unit is undefined
2 parents c3db261 + cb0f9ac commit c1ccdff

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

apps/opentelemetry_experimental/src/otel_otlp_metrics.erl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,14 @@ to_proto(#metric{name=Name,
6060
description=Description,
6161
unit=Unit,
6262
data=Data}) ->
63-
#{name => otel_otlp_common:to_binary(Name),
64-
description => Description,
65-
unit => otel_otlp_common:to_binary(Unit),
66-
data => to_data(Data)}.
63+
Metric =
64+
#{name => otel_otlp_common:to_binary(Name),
65+
description => Description,
66+
data => to_data(Data)},
67+
case Unit of
68+
undefined -> Metric;
69+
_ -> Metric#{unit => otel_otlp_common:to_binary(Unit)}
70+
end.
6771

6872
to_data(#sum{aggregation_temporality=Temporality,
6973
is_monotonic=IsMonotonic,

0 commit comments

Comments
 (0)