-
Notifications
You must be signed in to change notification settings - Fork 1.1k
refactor: consolidate platform-specific code #6208
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
Merged
overbalance
merged 8 commits into
open-telemetry:main
from
embrace-io:overbalance/consolidate-platform
Dec 19, 2025
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e72efa4
refactor: consolidate platform-specific code
overbalance 3bee519
Merge remote-tracking branch 'upstream/main' into overbalance/consoli…
overbalance 7b7e656
Merge branch 'main' into overbalance/consolidate-platform
overbalance 5b6b746
Merge remote-tracking branch 'upstream/main' into overbalance/consoli…
overbalance 5621cb4
refactor(api): remove platform-specific globalThis implementations
overbalance be2f9a4
use real types
overbalance c4e5c4e
add changelogs
overbalance 61d0bbb
not exported
overbalance 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
File renamed without changes.
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
18 changes: 0 additions & 18 deletions
18
packages/opentelemetry-core/src/platform/browser/performance.ts
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
packages/opentelemetry-core/src/platform/node/globalThis.ts
This file was deleted.
Oops, something went wrong.
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
20 changes: 0 additions & 20 deletions
20
packages/opentelemetry-core/src/platform/node/performance.ts
This file was deleted.
Oops, something went wrong.
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
19 changes: 0 additions & 19 deletions
19
packages/opentelemetry-resources/src/platform/browser/default-service-name.ts
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
packages/opentelemetry-resources/src/platform/browser/index.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
packages/opentelemetry-resources/src/platform/node/index.ts
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
packages/opentelemetry-resources/test/default-service-name.test.ts
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,46 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import * as assert from 'assert'; | ||
| import { defaultServiceName } from '../src/default-service-name'; | ||
|
|
||
| const isNode = typeof process === 'object' && typeof process.argv0 === 'string'; | ||
|
|
||
| describe('defaultServiceName', () => { | ||
| it('returns unknown_service prefix', () => { | ||
| const serviceName = defaultServiceName(); | ||
| assert.ok(serviceName.startsWith('unknown_service')); | ||
| }); | ||
|
|
||
| if (isNode) { | ||
| it('includes process.argv0 in Node.js', () => { | ||
| const serviceName = defaultServiceName(); | ||
| assert.ok(serviceName.startsWith('unknown_service:')); | ||
| assert.ok(serviceName.length > 'unknown_service:'.length); | ||
| }); | ||
| } else { | ||
| it('returns plain unknown_service in browser', () => { | ||
| const serviceName = defaultServiceName(); | ||
| assert.strictEqual(serviceName, 'unknown_service'); | ||
| }); | ||
| } | ||
|
|
||
| it('returns consistent value on multiple calls', () => { | ||
| const serviceName1 = defaultServiceName(); | ||
| const serviceName2 = defaultServiceName(); | ||
| assert.strictEqual(serviceName1, serviceName2); | ||
| }); | ||
| }); |
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.
@overbalance
This breaks on vercel edge environments
Uh oh!
There was an error while loading. Please reload this page.
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.
Hi @overbalance, as @chargome mentioned, this unfortunately breaks our vercel-edge environment due to
process.argv0being a node api.We ended up having to bundle in
@opentelemetry/resourcesand any code that uses it. It's not ideal.Any way we can figure out a workaround here?
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.
@chargome @andreiborza check out this other PR I've had out for review. Do you think it would solve your issue: #6257
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.
hey, that might work! Thanks for tackling this 🙏
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.
@andreiborza You said this "breaks"? What is the break? Inferring from @overbalance's PR there is warning from vercel-edge static analysis of some sort? Can you show an example?
For example, I don't recall here about warnings/breakages from this old change that was feature-testing for Node.js'
processobject: https://github.com/open-telemetry/opentelemetry-js/pull/4604/files#diff-7775cbc8f9eed30ff77488613bcbabec57446d86f655166fbdb5f7db4579a0b6R29In that case it was checking
global.process?.<something>.If the code here in this PR used
global.processinstead ofprocess, would that make the static analysis warnings go away?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.
Here's an example run of a nextjs app using our vercel-edge SDK: https://github.com/getsentry/sentry-javascript/actions/runs/20844816035/job/59886209607?pr=18734#step:16:157
We end up getting
issues when building the app.
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.
Thanks @andreiborza I was able to replicate and solve the issue: #6257