Closed2

open telemetry x cloud trace

TKTK

apolloで利用したケース
initialize時に必要

  const provider = new NodeTracerProvider();

  // Register server-related instrumentation
  const graphqlInstrumentation = new GraphQLInstrumentation()
  graphqlInstrumentation.setTracerProvider(provider);
  graphqlInstrumentation.enable();
  registerInstrumentations({
    tracerProvider: provider,
    instrumentations: [
      new HttpInstrumentation(),
      new ExpressInstrumentation(),
      graphqlInstrumentation,
    ]
  });

    // Export to console in local environment or cloud trace in GCP environment
    const exporter = NODE_ENV === 'local' ? new ConsoleSpanExporter() : new TraceExporter({
      projectId: PROJECT_ID,
    })
    provider.addSpanProcessor(
      new SimpleSpanProcessor(exporter)
    );

    // Register the provider to begin tracing
    provider.register();

    opentelemetry.trace.setGlobalTracerProvider(provider);
このスクラップは2022/12/23にクローズされました