Skip to content

How do I integrate NextJS' OpenTelemetry support with .Net Aspire? #5304

Answered by KennethHoff
KennethHoff asked this question in Q&A
Discussion options

You must be logged in to vote

This is my actual code:

// instrumentation.ts


import { registerOTel } from '@vercel/otel';

export async function register() {
  if (process.env.NEXT_RUNTIME === 'nodejs') {
    const { spanProcessors } = await import('./instrumentation.node');
    registerOTel({ spanProcessors: spanProcessors });
  }
}

// instrumentation.node.js


import { AzureMonitorTraceExporter } from '@azure/monitor-opentelemetry-exporter';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc';
import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-node';

const spanProcessors = [new BatchSpanProcessor(new OTLPTraceExporter())];

if (process.env.APPLICATIONINSIGHTS_CONNECTION_STRING) {
  

Replies: 1 comment 24 replies

Comment options

You must be logged in to vote
24 replies
@KennethHoff
Comment options

@KennethHoff
Comment options

@enemyss
Comment options

@KennethHoff
Comment options

Answer selected by KennethHoff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants