Skip to content

Commit

Permalink
dry and test
Browse files Browse the repository at this point in the history
  • Loading branch information
garoazinha committed Jan 15, 2025
1 parent f8edb27 commit 46a5505
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,21 +231,7 @@ def as_otlp_metrics(metrics)
)
)

when :up_down_counter
Opentelemetry::Proto::Metrics::V1::Metric.new(
name: metrics.name,
description: metrics.description,
unit: metrics.unit,
sum: Opentelemetry::Proto::Metrics::V1::Sum.new(
aggregation_temporality: as_otlp_aggregation_temporality(metrics.aggregation_temporality),
data_points: metrics.data_points.map do |ndp|
number_data_point(ndp)
end,
is_monotonic: metrics.is_monotonic
)
)

when :counter
when :counter, :up_down_counter
Opentelemetry::Proto::Metrics::V1::Metric.new(
name: metrics.name,
description: metrics.description,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,9 @@
counter = meter.create_counter('test_counter', unit: 'smidgen', description: 'a small amount of something')
counter.add(5, attributes: { 'foo' => 'bar' })

up_down_counter = meter.create_up_down_counter('test_up_down_counter', unit: 'smidgen', description: 'a small amount of something')
up_down_counter.add(5, attributes: { 'foo' => 'bar' })

histogram = meter.create_histogram('test_histogram', unit: 'smidgen', description: 'a small amount of something')
histogram.record(10, attributes: { 'oof' => 'rab' })

Expand Down Expand Up @@ -627,6 +630,26 @@
aggregation_temporality: Opentelemetry::Proto::Metrics::V1::AggregationTemporality::AGGREGATION_TEMPORALITY_DELTA
)
),
Opentelemetry::Proto::Metrics::V1::Metric.new(
name: 'test_up_down_counter',
description: 'a small amount of something',
unit: 'smidgen',
sum: Opentelemetry::Proto::Metrics::V1::Sum.new(
data_points: [
Opentelemetry::Proto::Metrics::V1::NumberDataPoint.new(
attributes: [
Opentelemetry::Proto::Common::V1::KeyValue.new(key: 'foo', value: Opentelemetry::Proto::Common::V1::AnyValue.new(string_value: 'bar'))
],
as_int: 5,
start_time_unix_nano: 1_699_593_427_329_946_585,
time_unix_nano: 1_699_593_427_329_946_586,
exemplars: nil
)
],
is_monotonic: false,
aggregation_temporality: Opentelemetry::Proto::Metrics::V1::AggregationTemporality::AGGREGATION_TEMPORALITY_DELTA
)
),
Opentelemetry::Proto::Metrics::V1::Metric.new(
name: 'test_histogram',
description: 'a small amount of something',
Expand Down

0 comments on commit 46a5505

Please sign in to comment.