open-telemetry / open-telemetry/opentelemetry-python

Implement higher precision clock than time_ns

Open
#4,367 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement sdk
Dominant language
Python
Stars
2.6k
Forks
1k
Avg merge
4d 15h
Merged PRs (30d)
19

Description

Followup to https://github.com/open-telemetry/opentelemetry-python/issues/1594

Currently, we use time_ns() to denote current time in ns -> like here https://github.com/open-telemetry/opentelemetry-python/blob/3ae113816d151af3320b8ce17816a91ebd20e44e/opentelemetry-sdk/src/opentelemetry/sdk/_events/__init__.py#L54

According to Pep0564, the precision varies based off of OS (with testing the average step is that of ~1ms in Windows). Java has implemented an AnchoredClock class which provides much more precise readings of ns (100~ns). We might want to do something similar in our SDKs.

Relevant issue: https://github.com/open-telemetry/semantic-conventions/issues/1621#issuecomment-2552335590

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the time_ns() usage in opentelemetry-sdk/src/opentelemetry/sdk/_events/init.py and read PEP 564's Windows precision notes. Compare the proposed approach with Java's AnchoredClock and the linked semantic-conventions discussion. Done means the Python SDK has an agreed higher-precision clock design and corresponding coverage across the affected SDK usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
observability-sre, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.