saleor-apps-redis_apl/apps/search/src/otel.ts

28 lines
1,006 B
TypeScript
Raw Normal View History

2023-08-03 08:27:48 +00:00
import { trace } from "@opentelemetry/api";
2023-08-03 07:15:22 +00:00
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
import { Resource } from "@opentelemetry/resources";
2023-08-03 08:27:48 +00:00
import { NodeSDK } from "@opentelemetry/sdk-node";
2023-08-03 07:15:22 +00:00
import { SimpleSpanProcessor } from "@opentelemetry/sdk-trace-node";
2023-08-03 08:27:48 +00:00
import { SemanticResourceAttributes } from "@opentelemetry/semantic-conventions";
const { PinoInstrumentation } = require("@opentelemetry/instrumentation-pino");
2023-08-03 07:15:22 +00:00
const sdk = new NodeSDK({
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: "saleor.app.search",
}),
spanProcessor: new SimpleSpanProcessor(new OTLPTraceExporter()),
2023-08-03 08:27:48 +00:00
instrumentations: [
new PinoInstrumentation({
// Optional hook to insert additional context to log object.
logHook: (span, record, level) => {
record["resource.service.name"] = "saleor.app.search";
},
}),
// other instrumentations
],
2023-08-03 07:15:22 +00:00
});
sdk.start();
2023-08-03 07:58:12 +00:00
export const tracer = trace.getTracer("saleor.app.search");