Skip to content

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
wants to merge 2 commits into
base: v2
Choose a base branch
from

Conversation

EmrysMyrddin
Copy link
Collaborator

@EmrysMyrddin EmrysMyrddin commented Jul 18, 2025

@EmrysMyrddin EmrysMyrddin force-pushed the fix/otel/start-time-precision branch from afafe0e to e42ccc8 Compare July 18, 2025 13:55
@theguild-bot
Copy link
Collaborator

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphql-tools/batch-delegate 10.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-tools/batch-execute 10.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-tools/delegate 11.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-tools/executor-common 1.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-tools/executor-graphql-ws 3.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-tools/executor-http 3.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-tools/federation 4.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-mesh/fusion-runtime 1.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-hive/gateway 2.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-hive/importer 2.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-hive/logger 1.0.1-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-hive/nestjs 2.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-hive/plugin-aws-sigv4 2.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-hive/plugin-deduplicate-request 2.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-mesh/hmac-upstream-signature 2.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-mesh/plugin-jwt-auth 2.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-mesh/plugin-opentelemetry 2.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-mesh/plugin-prometheus 2.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-hive/pubsub 2.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-hive/gateway-runtime 2.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-hive/signal 2.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-tools/stitch 10.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-tools/stitching-directives 4.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-mesh/transport-common 1.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-mesh/transport-http 1.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-mesh/transport-http-callback 1.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-mesh/transport-ws 2.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎
@graphql-tools/wrap 11.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1 npm ↗︎ unpkg ↗︎

@@ -71,7 +71,7 @@
"@opentelemetry/resources": "^2.0.1",
"@opentelemetry/sdk-logs": "^0.203.0",
"@opentelemetry/sdk-node": "^0.203.0",
"@opentelemetry/sdk-trace-base": "^2.0.1",
"@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",
Copy link
Member

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.

Copy link
Collaborator Author

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 ?

Copy link
Member

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?

Copy link
Collaborator Author

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...

Copy link
Member

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.

Copy link
Collaborator Author

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.

@theguild-bot
Copy link
Collaborator

🚀 Snapshot Release (Binary for Linux-ARM64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

🚀 Snapshot Release (Binary for Linux-X64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

🚀 Snapshot Release (Binary for macOS-ARM64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

🚀 Snapshot Release (Binary for macOS-X64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

🚀 Snapshot Release (Bun Docker Image)

The latest changes of this PR are available as image on GitHub Container Registry (based on the declared changesets):

ghcr.io/graphql-hive/gateway:2.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1-bun

@theguild-bot
Copy link
Collaborator

🚀 Snapshot Release (Binary for Windows-X64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

🚀 Snapshot Release (Node Docker Image)

The latest changes of this PR are available as image on GitHub Container Registry (based on the declared changesets):

ghcr.io/graphql-hive/gateway:2.0.0-alpha-5e6098404239267121abde7700e66aca66ec76b1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants