Not able to fetch OpenTelemetry environment variables in React app & facing CORS issue on OTEL_EXPORTER_OTLP_ENDPOINT #6930
Unanswered
waqarahmed0340
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Issue Details:
I’m working on integrating OpenTelemetry with my React application. However, I’m facing two key challenges:
The Frontend side code is below. Right now in this code, I am using the hard-coded values.
`import { WebTracerProvider } from "@opentelemetry/sdk-trace-web";
import {
ConsoleSpanExporter,
SimpleSpanProcessor,
BatchSpanProcessor,
} from "@opentelemetry/sdk-trace-base";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
import { DocumentLoadInstrumentation } from "@opentelemetry/instrumentation-document-load";
import { FetchInstrumentation } from "@opentelemetry/instrumentation-fetch";
import { XMLHttpRequestInstrumentation } from "@opentelemetry/instrumentation-xml-http-request";
import { registerInstrumentations } from "@opentelemetry/instrumentation";
import { Resource } from "@opentelemetry/resources";
import { SemanticResourceAttributes } from "@opentelemetry/semantic-conventions";
import { ZoneContextManager } from "@opentelemetry/context-zone";
const provider = new WebTracerProvider({
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: "multifamilyportal",
}),
});
provider.addSpanProcessor(
new SimpleSpanProcessor(
new OTLPTraceExporter({
url:
https://localhost:21216/v1/traces
,),
);
provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
provider.register({
contextManager: new ZoneContextManager(),
});
registerInstrumentations({
instrumentations: [
new DocumentLoadInstrumentation(),
new FetchInstrumentation(),
new XMLHttpRequestInstrumentation(),
],
});
export const tracer = provider.getTracer("react-client-tracer");
`
Beta Was this translation helpful? Give feedback.
All reactions