Skip to content

fix(opentelemetry): Respect OTEL_SERVICE_NAME, OTEL_RESOURCE_ATTRIBUTES - #20509

Merged
isaacs merged 1 commit into
developfrom
isaacschlueter/js-2280-respect-otel_service_name-and-otel_resource_attributes
May 4, 2026
Merged

fix(opentelemetry): Respect OTEL_SERVICE_NAME, OTEL_RESOURCE_ATTRIBUTES#20509
isaacs merged 1 commit into
developfrom
isaacschlueter/js-2280-respect-otel_service_name-and-otel_resource_attributes

Conversation

@isaacs

Copy link
Copy Markdown
Member

This uses the string passed into getSentryResource as a fallback, preferring instead to use the value in env.OTEL_SERVICE_NAME if set, or the service.name field in the comma-delimited key=value pairs in env.OTEL_RESOURCE_ATTRIBUTES pairs.

Additional env.OTEL_RESOURCE_ATTRIBUTES are also attached to the resource attributes.

fix: js-2280
fix: #20502

  • If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).
  • Link an issue if there is one related to your pull request. If no issue is linked, one will be auto-generated and linked.

Closes#20502

@isaacs
isaacs requested a review from mydeaApril 25, 2026 01:08
@linear-code

Copy link
Copy Markdown

Comment threadpackages/opentelemetry/src/resource.ts
Comment threadpackages/opentelemetry/src/resource.ts
@github-actions

github-actionsBot commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

⚠️Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

PathSize% ChangeChange
@sentry/browser26.31 kB--
@sentry/browser - with treeshaking flags24.8 kB--
@sentry/browser (incl. Tracing)44.2 kB--
@sentry/browser (incl. Tracing + Span Streaming)46.42 kB--
@sentry/browser (incl. Tracing, Profiling)49.16 kB--
@sentry/browser (incl. Tracing, Replay)83.58 kB--
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags73.04 kB--
@sentry/browser (incl. Tracing, Replay with Canvas)88.26 kB--
@sentry/browser (incl. Tracing, Replay, Feedback)100.87 kB--
@sentry/browser (incl. Feedback)43.47 kB--
@sentry/browser (incl. sendFeedback)31.12 kB--
@sentry/browser (incl. FeedbackAsync)36.21 kB--
@sentry/browser (incl. Metrics)27.62 kB--
@sentry/browser (incl. Logs)27.75 kB--
@sentry/browser (incl. Metrics & Logs)28.45 kB--
@sentry/react28.05 kB--
@sentry/react (incl. Tracing)46.42 kB--
@sentry/vue31.18 kB--
@sentry/vue (incl. Tracing)46.04 kB--
@sentry/svelte26.34 kB--
CDN Bundle28.91 kB--
CDN Bundle (incl. Tracing)46.95 kB--
CDN Bundle (incl. Logs, Metrics)30.34 kB--
CDN Bundle (incl. Tracing, Logs, Metrics)48.06 kB--
CDN Bundle (incl. Replay, Logs, Metrics)69.41 kB--
CDN Bundle (incl. Tracing, Replay)84.11 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics)85.16 kB--
CDN Bundle (incl. Tracing, Replay, Feedback)89.91 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics)91.01 kB--
CDN Bundle - uncompressed84.72 kB--
CDN Bundle (incl. Tracing) - uncompressed140.31 kB--
CDN Bundle (incl. Logs, Metrics) - uncompressed88.92 kB--
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed143.77 kB--
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed212.86 kB--
CDN Bundle (incl. Tracing, Replay) - uncompressed258.11 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed261.56 kB--
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed271.81 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed275.25 kB--
@sentry/nextjs (client)48.92 kB--
@sentry/sveltekit (client)44.67 kB--
@sentry/node-core59.13 kB+0.02%+10 B 🔺
@sentry/node170.57 kB+0.1%+158 B 🔺
@sentry/node - without tracing97.17 kB+0.19%+179 B 🔺
@sentry/aws-serverless113.99 kB+0.16%+174 B 🔺
@sentry/cloudflare (withSentry) - minified165.2 kB--
@sentry/cloudflare (withSentry)417.71 kB--

View base workflow run

@isaacs
isaacsforce-pushed the isaacschlueter/js-2280-respect-otel_service_name-and-otel_resource_attributes branch from 65f6897 to d056014CompareApril 26, 2026 23:02
@isaacs
isaacsforce-pushed the isaacschlueter/js-2280-respect-otel_service_name-and-otel_resource_attributes branch from d056014 to bdf3bbaCompareApril 30, 2026 00:06
@isaacs
isaacs requested a review from a team as a code ownerApril 30, 2026 00:06
isaacs added a commit that referenced this pull request Apr 30, 2026
…ES (#20509)
This uses the string passed into `getSentryResource` as a fallback,
preferring instead to use the value in `env.OTEL_SERVICE_NAME` if set,
or the `service.name` field in the comma-delimited key=value pairs in
`env.OTEL_RESOURCE_ATTRIBUTES` pairs.
Additional `env.OTEL_RESOURCE_ATTRIBUTES` are also attached to the
resource attributes.
fix: js-2280
fix: #20502
@isaacs
isaacsforce-pushed the isaacschlueter/js-2280-respect-otel_service_name-and-otel_resource_attributes branch from bdf3bba to f572279CompareApril 30, 2026 00:46
@isaacs
isaacs enabled auto-merge (rebase) April 30, 2026 00:47

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f572279. Configure here.

Comment threadpackages/opentelemetry/test/resource.test.ts Outdated
Comment threadpackages/opentelemetry/src/resource.ts
isaacs added a commit that referenced this pull request Apr 30, 2026
…ES (#20509)
This uses the string passed into `getSentryResource` as a fallback,
preferring instead to use the value in `env.OTEL_SERVICE_NAME` if set,
or the `service.name` field in the comma-delimited key=value pairs in
`env.OTEL_RESOURCE_ATTRIBUTES` pairs.
Additional `env.OTEL_RESOURCE_ATTRIBUTES` are also attached to the
resource attributes.
fix: js-2280
fix: #20502
@isaacs
isaacsforce-pushed the isaacschlueter/js-2280-respect-otel_service_name-and-otel_resource_attributes branch from f572279 to ff8d125CompareApril 30, 2026 18:57
isaacs added a commit that referenced this pull request Apr 30, 2026
…ES (#20509)
This uses the string passed into `getSentryResource` as a fallback,
preferring instead to use the value in `env.OTEL_SERVICE_NAME` if set,
or the `service.name` field in the comma-delimited key=value pairs in
`env.OTEL_RESOURCE_ATTRIBUTES` pairs.
Additional `env.OTEL_RESOURCE_ATTRIBUTES` are also attached to the
resource attributes.
fix: js-2280
fix: #20502
@isaacs
isaacsforce-pushed the isaacschlueter/js-2280-respect-otel_service_name-and-otel_resource_attributes branch from ff8d125 to f1dac69CompareApril 30, 2026 19:13
…ES (#20509)
This uses the string passed into `getSentryResource` as a fallback,
preferring instead to use the value in `env.OTEL_SERVICE_NAME` if set,
or the `service.name` field in the comma-delimited key=value pairs in
`env.OTEL_RESOURCE_ATTRIBUTES` pairs.
Additional `env.OTEL_RESOURCE_ATTRIBUTES` are also attached to the
resource attributes.
fix: js-2280
fix: #20502
@JPeer264
JPeer264force-pushed the isaacschlueter/js-2280-respect-otel_service_name-and-otel_resource_attributes branch from f1dac69 to 783bc85CompareMay 4, 2026 12:06

@JPeer264JPeer264 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


beforeEach(() => {
// Clone env so mutations are isolated
process.env = { ...originalEnv };

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW vi.stubEnv works pretty nicely as well and with that we wouldn't need to store the original env

@isaacs
isaacs merged commit 803d715 into developMay 4, 2026
209 checks passed
@isaacs
isaacs deleted the isaacschlueter/js-2280-respect-otel_service_name-and-otel_resource_attributes branch May 4, 2026 12:23
Sign up for freeto 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.

Respect OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES

4 participants

@isaacs@mydea@JPeer264@andreiborza