Skip to content
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

Send OpenTelemetry data from Browser #209

Open
pondorasti opened this issue Jul 14, 2024 · 0 comments
Open

Send OpenTelemetry data from Browser #209

pondorasti opened this issue Jul 14, 2024 · 0 comments

Comments

@pondorasti
Copy link

Intro

I want to instrument the client side part of my Next.js app using OpenTelemetry's Browser SDK. As references, here's what my instrumentation setup currently looks like:

const instrumentationClientSdk = async () => {
  const { ZoneContextManager } = await import("@opentelemetry/context-zone")

  const provider = new WebTracerProvider({
    resource: new Resource({ [SEMRESATTRS_SERVICE_NAME]: "test" }).merge(
      detectResourcesSync({ detectors: [browserDetector] }),
    ),
  })

  provider.addSpanProcessor(new SimpleSpanProcessor(new OTLPTraceExporter()))

  provider.addSpanProcessor(
    new BatchSpanProcessor(
      new OTLPTraceExporter({
        url: "https://api.axiom.co/v1/traces",
        headers: {
          Authorization: `Bearer ${env.NEXT_PUBLIC_AXIOM_TOKEN}`,
          "X-Axiom-Dataset": "open_telemetry",
        },
      }),
    ),
  )

  const contextManager = new ZoneContextManager()

  provider.register({
    contextManager,
    propagator: new CompositePropagator({
      propagators: [new W3CBaggagePropagator(), new W3CTraceContextPropagator()],
    }),
  })

  registerInstrumentations({
    tracerProvider: provider,
    instrumentations: [
      getWebAutoInstrumentations(),
    ],
  })
}

I looked over the Send OpenTelemetry data to Axiom guide and I was not able to find any resources on how to get this working.

Proposal

I would like to have an additional Next.js rewrite for ${config.proxyPath}/traces along with public token authentication.

const axiomRewrites: Rewrite[] = [
{
source: `${config.proxyPath}/web-vitals`,
destination: webVitalsEndpoint,
basePath: false,
},
{
source: `${config.proxyPath}/logs`,
destination: logsEndpoint,
basePath: false,
},
];

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

No branches or pull requests

1 participant