Skip to content

Move nano timestamp calculation to common gem #1889

@kaylareopelle

Description

@kaylareopelle

Metrics and Spans have a method to coerce a timestamp into nanoseconds that are essentially the same:

def now_in_nano
(Time.now.to_r * 1_000_000_000).to_i
end

def now_in_nano
(Time.now.to_r * 1_000_000_000).to_i
end

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.

def exportable_timestamp(time = Time.now)
(time.to_r * 1_000_000_000).to_i
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions