open-telemetry / open-telemetry/opentelemetry-python
Time units are underdocumented in the API
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.6k
- Forks
- 1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 19
Description
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:
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:
opentelemetry.trace.span.Span.end: (this also fails to document the end_time argument)
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the docstrings for Tracer.start_span and Tracer.start_as_current_span in opentelemetry-api/src/opentelemetry/trace/init.py, then Span.end in opentelemetry-api/src/opentelemetry/trace/span.py. Compare them with the time-unit note in the OpenTracing shim and document the representation and end_time units consistently in the API documentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100