-
Notifications
You must be signed in to change notification settings - Fork 214
@W-18759755 - Creating tests and a server for open telemetry within the pwa-kit-rea… #2617
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
Changes from 9 commits
ae56f79
b442012
6f50178
c6c1d89
f03ca23
245f60d
a6d0bb7
dc48667
e246905
40c3da9
8095da0
6cc769a
c2f1b91
9130b9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,74 @@ | ||||
| /* | ||||
| * Copyright (c) 2025, Salesforce, Inc. | ||||
| * All rights reserved. | ||||
| * SPDX-License-Identifier: BSD-3-Clause | ||||
| * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||||
| */ | ||||
|
|
||||
| import {NodeTracerProvider} from '@opentelemetry/sdk-trace-node' | ||||
| import {SimpleSpanProcessor} from '@opentelemetry/sdk-trace-base' | ||||
| import {B3Propagator} from '@opentelemetry/propagator-b3' | ||||
| import {Resource} from '@opentelemetry/resources' | ||||
| import {SemanticResourceAttributes} from '@opentelemetry/semantic-conventions' | ||||
| import {propagation} from '@opentelemetry/api' | ||||
|
|
||||
| const SERVICE_NAME = 'pwa-kit-react-sdk' | ||||
|
|
||||
| let provider = null | ||||
|
|
||||
| /** | ||||
| * Initialize OpenTelemetry tracing for server-side rendering | ||||
| * @returns {NodeTracerProvider|null} The initialized provider or null if initialization failed | ||||
| */ | ||||
| export const initializeServerTracing = () => { | ||||
| try { | ||||
| // Initialize the tracer provider | ||||
| provider = new NodeTracerProvider({ | ||||
| resource: new Resource({ | ||||
| [SemanticResourceAttributes.SERVICE_NAME]: SERVICE_NAME | ||||
|
||||
| }) | ||||
| }) | ||||
|
|
||||
| // Add B3 propagator | ||||
| provider.addSpanProcessor(new SimpleSpanProcessor()) | ||||
| propagation.setGlobalPropagator(new B3Propagator()) | ||||
| provider.register() | ||||
|
|
||||
| return provider | ||||
| } catch (error) { | ||||
| // Log errors from OpenTelemetry initialization | ||||
| console.warn('Failed to initialize OpenTelemetry provider:', error.message) | ||||
|
||||
| logger.error(cause, {namespace: 'react-rendering.render'}) |
Outdated
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.
Same, let's use logger instead of directly using console.
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.
Would you consider making the telemetry configurable by passing options to the initializeServerTracing?
Something like this: