diff --git a/instrumentation.node.ts b/instrumentation.node.ts index 3efb2ec1..148823f9 100644 --- a/instrumentation.node.ts +++ b/instrumentation.node.ts @@ -9,18 +9,20 @@ import { SeverityNumber } from "@opentelemetry/api-logs"; import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http"; import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http"; import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http"; +import { Resource } from "@opentelemetry/resources"; import { BatchLogRecordProcessor, ConsoleLogRecordExporter, LoggerProvider, } from "@opentelemetry/sdk-logs"; import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics"; +import { NodeSDK } from "@opentelemetry/sdk-node"; import { ConsoleSpanExporter, SimpleSpanProcessor, } from "@opentelemetry/sdk-trace-base"; import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-node"; -import { registerOTel } from "@vercel/otel"; +import { SemanticResourceAttributes } from "@opentelemetry/semantic-conventions"; const headers = { "signoz-access-token": process.env.SIGNOZ_INGESTION_TOKEN, @@ -67,13 +69,17 @@ if (process.env.NODE_ENV !== "production") { const logRecordProcessor = new BatchLogRecordProcessor(logExporter); loggerProvider.addLogRecordProcessor(logRecordProcessor); -registerOTel({ - serviceName: "giselle", +const sdk = new NodeSDK({ + resource: new Resource({ + [SemanticResourceAttributes.SERVICE_NAME]: "giselle", + environment: process.env.NEXT_PUBLIC_VERCEL_ENV || "not-set", + }), metricReader: metricReader, spanProcessors: [spanProcessor, debugSpanProcessor], traceExporter: traceExporter, logRecordProcessor: logRecordProcessor, }); +sdk.start(); export const logger = loggerProvider.getLogger("giselle"); console.log("-- OTEL registered with metrics, traces, and logs --");