mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-03 12:19:50 -06:00
28 lines
927 B
TypeScript
28 lines
927 B
TypeScript
import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";
|
|
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
|
|
import { Resource } from "@opentelemetry/resources";
|
|
import { NodeSDK } from "@opentelemetry/sdk-node";
|
|
import { SimpleSpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
import { SEMRESATTRS_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
|
|
|
|
export const startInstrumentationForNode = (url: string) => {
|
|
try {
|
|
const exporter = new OTLPTraceExporter({
|
|
url,
|
|
});
|
|
|
|
const sdk = new NodeSDK({
|
|
resource: new Resource({
|
|
[SEMRESATTRS_SERVICE_NAME]: "Formbricks",
|
|
}),
|
|
traceExporter: exporter,
|
|
spanProcessor: new SimpleSpanProcessor(exporter),
|
|
instrumentations: [getNodeAutoInstrumentations()],
|
|
});
|
|
|
|
sdk.start();
|
|
} catch (err) {
|
|
console.error(`Unable to setup Telemetry: ${err}`);
|
|
}
|
|
};
|