Slide 29
Slide 29 text
29
実装サンプル
const exporterOptions = {
url: process.env.OTLP_TRACE_ENDPOINT ?? 'http://127.0.0.1:4318/v1/traces',
}
const traceExporter = new OTLPTraceExporter(exporterOptions)
export const otelSDK = new NodeSDK({
textMapPropagator: new AWSXRayPropagator(),
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: 'example service',
}),
traceExporter,
instrumentations: [
new HttpInstrumentation(),
new MySQL2Instrumentation(),
new PinoInstrumentation(),
],
})
const tracerConfig = {
idGenerator: new AWSXRayIdGenerator(),
}
const spanProcessor = new BatchSpanProcessor(traceExporter)
otelSDK.configureTracerProvider(tracerConfig, spanProcessor)