Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time units are underdocumented in the API #4193

Open
elisw93 opened this issue Sep 17, 2024 · 0 comments
Open

Time units are underdocumented in the API #4193

elisw93 opened this issue Sep 17, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@elisw93
Copy link

elisw93 commented Sep 17, 2024

Describe your environment

(not relevant)

What happened?

It is noted in the OpenTracing shim documentation that OTel internally uses an int of nanoseconds since epoch to represent time values:

Note:
While the OpenTracing Python API represents time values as the number of
**seconds** since the epoch expressed as :obj:`float` values, the
OpenTelemetry Python API represents time values as the number of
**nanoseconds** since the epoch expressed as :obj:`int` values. This fact
requires the OpenTracing shim to convert time values back and forth between
the two representations, which involves floating point arithmetic.

However, the units are not described when working with time values in the API.

Steps to Reproduce

I will list the examples that I know of:

opentelemetry.trace.Tracer.start_span and opentelemetry.trace.Tracer.start_as_current_span:

start_time: Sets the start time of a span

start_time: Sets the start time of a span

opentelemetry.trace.span.Span.end: (this also fails to document the end_time argument)

"""Sets the current time as the span's end time.
The span's end time is the wall time at which the operation finished.

Expected Result

I would expect to understand how my time values ought to be represented by reading the API documentation.

Actual Result

The relevant units are not mentioned in the documentation and I must find out about them by other means (reading other parts of the documentation; searching on Stack Overflow; etc.)

Additional context

I have considered the possibility that these units are left intentionally unspecified in order that subclasses of Tracer and Span might be free to use their own representation of time. However, in this case I don't understand the motivation of requiring that this type must be int.

Would you like to implement a fix?

Yes

@elisw93 elisw93 added the bug Something isn't working label Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant