-
Notifications
You must be signed in to change notification settings - Fork 21
fix(opentelemetry): Patch otel sdk for span start time with nanosecond precision #1343
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
Open
EmrysMyrddin
wants to merge
2
commits into
v2
Choose a base branch
from
fix/otel/start-time-precision
base: v2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@graphql-hive/gateway': patch | ||
--- | ||
|
||
dependencies updates: | ||
|
||
- Updated dependency [`@opentelemetry/sdk-trace-base@patch:@opentelemetry/sdk-trace-base@patch%3A@opentelemetry/sdk-trace-base@npm%253A2.0.1%23~/.yarn/patches/@opentelemetry-sdk-trace-base-npm-2.0.1-ebe4f8e34e.patch%3A%3Aversion=2.0.1&hash=212481#~/.yarn/patches/@opentelemetry-sdk-trace-base-patch-0b7dbf6a30.patch` ↗︎](https://www.npmjs.com/package/@opentelemetry/sdk-trace-base/v/3.0.0) (from `^2.0.1`, in `dependencies`) |
7 changes: 7 additions & 0 deletions
7
.changeset/@graphql-mesh_plugin-opentelemetry-1343-dependencies.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@graphql-mesh/plugin-opentelemetry': patch | ||
--- | ||
|
||
dependencies updates: | ||
|
||
- Updated dependency [`@opentelemetry/sdk-trace-base@patch:@opentelemetry/sdk-trace-base@patch%3A@opentelemetry/sdk-trace-base@npm%253A2.0.1%23~/.yarn/patches/@opentelemetry-sdk-trace-base-npm-2.0.1-ebe4f8e34e.patch%3A%3Aversion=2.0.1&hash=212481#~/.yarn/patches/@opentelemetry-sdk-trace-base-patch-0b7dbf6a30.patch` ↗︎](https://www.npmjs.com/package/@opentelemetry/sdk-trace-base/v/3.0.0) (from `^2.0.1`, in `dependencies`) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@graphql-mesh/plugin-opentelemetry': patch | ||
'@graphql-hive/gateway': patch | ||
--- | ||
|
||
Patch the `@opentelemetry/sdk-trace-base` package to fix span start time precision being millisecond instead of nanosecond. |
39 changes: 39 additions & 0 deletions
39
.yarn/patches/@opentelemetry-sdk-trace-base-npm-2.0.1-ebe4f8e34e.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
diff --git a/build/esm/Span.js b/build/esm/Span.js | ||
index 185835fdc5667eddb072891618607ce213bb6625..5554c8bde3f6f44504587a88e115104a01d39ec4 100644 | ||
--- a/build/esm/Span.js | ||
+++ b/build/esm/Span.js | ||
@@ -66,7 +66,7 @@ export class SpanImpl { | ||
this.parentSpanContext = opts.parentSpanContext; | ||
this.kind = opts.kind; | ||
this.links = opts.links || []; | ||
- this.startTime = this._getTime(opts.startTime ?? now); | ||
+ this.startTime = this._getTime(opts.startTime ?? hrTime(this._performanceStartTime + this._performanceOffset)); | ||
this.resource = opts.resource; | ||
this.instrumentationScope = opts.scope; | ||
if (opts.attributes != null) { | ||
diff --git a/build/esnext/Span.js b/build/esnext/Span.js | ||
index 185835fdc5667eddb072891618607ce213bb6625..5554c8bde3f6f44504587a88e115104a01d39ec4 100644 | ||
--- a/build/esnext/Span.js | ||
+++ b/build/esnext/Span.js | ||
@@ -66,7 +66,7 @@ export class SpanImpl { | ||
this.parentSpanContext = opts.parentSpanContext; | ||
this.kind = opts.kind; | ||
this.links = opts.links || []; | ||
- this.startTime = this._getTime(opts.startTime ?? now); | ||
+ this.startTime = this._getTime(opts.startTime ?? hrTime(this._performanceStartTime + this._performanceOffset)); | ||
this.resource = opts.resource; | ||
this.instrumentationScope = opts.scope; | ||
if (opts.attributes != null) { | ||
diff --git a/build/src/Span.js b/build/src/Span.js | ||
index 5a807fe223a70e5e077b66ad74b8efe2eaabd8fa..6388deff9c1e83946f16b04cbfaf884b6f350d29 100644 | ||
--- a/build/src/Span.js | ||
+++ b/build/src/Span.js | ||
@@ -69,7 +69,7 @@ class SpanImpl { | ||
this.parentSpanContext = opts.parentSpanContext; | ||
this.kind = opts.kind; | ||
this.links = opts.links || []; | ||
- this.startTime = this._getTime(opts.startTime ?? now); | ||
+ this.startTime = this._getTime(opts.startTime ?? hrTime(this._performanceStartTime + this._performanceOffset)); | ||
this.resource = opts.resource; | ||
this.instrumentationScope = opts.scope; | ||
if (opts.attributes != null) { |
13 changes: 13 additions & 0 deletions
13
.yarn/patches/@opentelemetry-sdk-trace-base-patch-0b7dbf6a30.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/build/src/Span.js b/build/src/Span.js | ||
index 12c33551fa559f3657e1d9074cadb34b7e73a675..63ac0075b94eae4c519d94c5c141c7002d21e412 100644 | ||
--- a/build/src/Span.js | ||
+++ b/build/src/Span.js | ||
@@ -69,7 +69,7 @@ class SpanImpl { | ||
this.parentSpanContext = opts.parentSpanContext; | ||
this.kind = opts.kind; | ||
this.links = opts.links || []; | ||
- this.startTime = this._getTime(opts.startTime ?? hrTime(this._performanceStartTime + this._performanceOffset)); | ||
+ this.startTime = this._getTime(opts.startTime ?? core_1.hrTime(this._performanceStartTime + this._performanceOffset)); | ||
this.resource = opts.resource; | ||
this.instrumentationScope = opts.scope; | ||
if (opts.attributes != null) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Publishing this will break installs. Patches are only for local things. If patching the library is the only way to go, then we need to handle it differently - on Hive Console side.
P.S. Node has only millisecond precision, so we cannot expect it to give out accurate nanoseconds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes, I should only add this to the root package.json.
It's more an experiment at this point for @n1ru4l
We can ship this in the binary, but not sure we should have such behavior diff between binary and node usage.
I'm trying to make a PR on opentelemetry side. Perhaps I can publish a fork ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think pushing this PR to OTEL is a good way to go. But we dont have to do all that just for one change, do you think they'd release soon or would it take months?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on other PR dates, it takes loooong time to merge things, even for member of the repo...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And we cannot handle it in Hive Console @n1ru4l? I can imagine others using Hive Console's observability features having the same issues, especially if based on OTEL's libs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can't be on Hive Console side, since it's the data producer that has the "bug".
It's span creation that uses a low precision timestamp...
A workaround for us waiting for a proper upstream fix would be to manually provide the start and end times. This way, we are sure that at least our spans have correct precision.