pnpm add @effect/opentelemetrypnpm add @opentelemetry/exporter-trace-otlp-httppnpm add @opentelemetry/sdk-trace-basepnpm add @opentelemetry/sdk-trace-nodepnpm add @opentelemetry/sdk-trace-webpnpm add @opentelemetry/sdk-metricspnpm add @opentelemetry/exporter-prometheuspnpm add @opentelemetry/auto-instrumentations-node
สร้าง folder telemetry
src├── configure├── controllers├── index.ts├── repositories├── runtimes│ └── index.ts├── schema├── services├── telemetry│ └── node-sdk.ts└── types
1import { NodeSdk } from "@effect/opentelemetry"2import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node"3import { PrometheusExporter } from "@opentelemetry/exporter-prometheus"4import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http"5import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-base"6 7export const NodeSdkLive = NodeSdk.layer(() => {8 return {9 instrumentations: [getNodeAutoInstrumentations()],10 metricReader: new PrometheusExporter({11 port: 9464,12 }),13 resource: {14 serviceName: "Overtime Tracking API",15 },16 spanProcessor: new BatchSpanProcessor(17 new OTLPTraceExporter({18 url: "http://34.126.124.178:4318/v1/traces", // Tempo OTLP HTTP19 }),20 ),21 }22})