JavaVersionSpecific returns millisecond precision for currentTimeNanos()

未关闭
#6,233 7 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
java

调研方向

从 opentelemetry-sdk-common artifact 中的 JavaVersionSpecific.currentTimeNanos() 开始,跟踪如何为没有 parent 的 span 创建 AnchoredClock。在 Java 8 上重现两个 span 的顺序,然后验证 Span.startEpochNanos 使用最接近的可用精度,并且不会早于前一个 span 的结束时间。

由索引模型根据 Issue 内容生成。

描述

Bug

From a Java 8 JVM perspective there are limitations to the precision of time, however looking at the implementation of JavaVersionSpecific.currentTimeNanos() for Java 8, this should return as close as possible, the nanosecond precision since epoch, however it is currently only to millisecond precision.

Steps to reproduce
Create two Spans in the following order

  1. Create and start Span 1 - startEpochNanos is set to millisecond precision
  2. End Span 1 - endEpochNanos is set to nanosecond precision
  3. Create and start Span 2 - startEpochNanos is set to millisecond precision
  4. End Span 2 - endEpochNanos is set to nanosecond precision

It looks like a new AnchoredClock is created for each Span if it is not inheriting from a parentSpan, therefore if the spans are created in less than 1 millisecond of each other, there is a potential the Span1.endEpochNanos is greater than Span2.startEpochNanos

What did you expect to see?
I would expect Span.startEpochNanos to be at nanosecond precision

What did you see instead?
Span.startEpochNanos is at millisecond precision

What version and what artifacts are you using?
Artifacts: opentelemetry-sdk-common
Version: 1.35

Environment
OS: Centos
Runtime: Java 8 OpenJdk

主要语言
Java
星标
2.5k
派生
1.1k
平均合并
5 天 11 小时
30 天内合并 PR
41

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

open-telemetry/opentelemetry-java 的其他 Issue

查看 open-telemetry/opentelemetry-java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。