-
Notifications
You must be signed in to change notification settings - Fork 268
Description
Metrics and Spans have a method to coerce a timestamp into nanoseconds that are essentially the same:
opentelemetry-ruby/metrics_sdk/lib/opentelemetry/sdk/metrics/state/asynchronous_metric_stream.rb
Lines 74 to 76 in ad5ee25
def now_in_nano | |
(Time.now.to_r * 1_000_000_000).to_i | |
end |
opentelemetry-ruby/metrics_sdk/lib/opentelemetry/sdk/metrics/state/metric_store.rb
Lines 42 to 44 in 7098818
def now_in_nano | |
(Time.now.to_r * 1_000_000_000).to_i | |
end |
opentelemetry-ruby/sdk/lib/opentelemetry/sdk/trace/span.rb
Lines 460 to 462 in cdce3cc
def time_in_nanoseconds(timestamp) | |
(timestamp.to_r * 1_000_000_000).to_i | |
end |
Refactor the method, move it to the common
gem, likely as a utility, and update the method calls in the SDK and Metrics SDK gems.
A similar method also exists in the test helpers, and we could consider refactoring that one as well.
opentelemetry-ruby/test_helpers/lib/opentelemetry/test_helpers.rb
Lines 44 to 46 in 583fe04
def exportable_timestamp(time = Time.now) | |
(time.to_r * 1_000_000_000).to_i | |
end |