lib/opentelemetry/exporter/otlp/metrics/metrics_exporter.rb in opentelemetry-exporter-otlp-metrics-0.2.0 vs lib/opentelemetry/exporter/otlp/metrics/metrics_exporter.rb in opentelemetry-exporter-otlp-metrics-0.2.1
- old
+ new
@@ -282,16 +282,23 @@
max: hdp.max
)
end
def number_data_point(ndp)
- Opentelemetry::Proto::Metrics::V1::NumberDataPoint.new(
+ args = {
attributes: ndp.attributes.map { |k, v| as_otlp_key_value(k, v) },
- as_int: ndp.value,
start_time_unix_nano: ndp.start_time_unix_nano,
time_unix_nano: ndp.time_unix_nano,
exemplars: ndp.exemplars # exemplars not implemented yet from metrics sdk
- )
+ }
+
+ if ndp.value.is_a?(Float)
+ args[:as_double] = ndp.value
+ else
+ args[:as_int] = ndp.value
+ end
+
+ Opentelemetry::Proto::Metrics::V1::NumberDataPoint.new(**args)
end
# may not need this
def reset
SUCCESS