-
Notifications
You must be signed in to change notification settings - Fork 284
Expand file tree
/
Copy pathtest_helper.rb
More file actions
37 lines (30 loc) · 1.71 KB
/
Copy pathtest_helper.rb
File metadata and controls
37 lines (30 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# frozen_string_literal: true
# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0
require 'simplecov'
require 'opentelemetry-test-helpers'
require 'opentelemetry/exporter/otlp_metrics'
require 'minitest/autorun'
require 'webmock/minitest'
OpenTelemetry.logger = Logger.new(File::NULL)
module MockSum
def collect(start_time, end_time, data_points)
start_time = 1_699_593_427_329_946_585 # rubocop:disable Lint/ShadowedArgument
end_time = 1_699_593_427_329_946_586 # rubocop:disable Lint/ShadowedArgument
super
end
end
OpenTelemetry::SDK::Metrics::Aggregation::Sum.prepend(MockSum)
OpenTelemetry::SDK::Metrics::Aggregation::ExplicitBucketHistogram.prepend(MockSum)
OpenTelemetry::SDK::Metrics::Aggregation::LastValue.prepend(MockSum)
OpenTelemetry::SDK::Metrics::Aggregation::ExponentialBucketHistogram.prepend(MockSum)
def create_metrics_data(name: '', description: '', unit: '', instrument_kind: :counter, resource: nil,
instrumentation_scope: OpenTelemetry::SDK::InstrumentationScope.new('', 'v0.0.1'),
data_points: nil, aggregation_temporality: :delta, start_time_unix_nano: 0, time_unix_nano: 0)
data_points ||= [OpenTelemetry::SDK::Metrics::Aggregation::NumberDataPoint.new(attributes: {}, start_time_unix_nano: 0, time_unix_nano: 0, value: 1, exemplars: nil)]
resource ||= OpenTelemetry::SDK::Resources::Resource.telemetry_sdk
OpenTelemetry::SDK::Metrics::State::MetricData.new(name, description, unit, instrument_kind,
resource, instrumentation_scope, data_points,
aggregation_temporality, start_time_unix_nano, time_unix_nano)
end