feat: add end-to-end observability (metrics, health, mobile RUM, dashboards, alerts) #32
@@ -14,20 +14,21 @@ import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentation
|
||||
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc';
|
||||
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-grpc';
|
||||
import * as resources from '@opentelemetry/resources';
|
||||
import { ATTR_SERVICE_NAME, ATTR_SERVICE_NAMESPACE } from '@opentelemetry/semantic-conventions';
|
||||
import { PinoInstrumentation } from '@opentelemetry/instrumentation-pino';
|
||||
|
||||
const serviceName = process.env.OTEL_SERVICE_NAME || 'farmaclic-backend';
|
||||
const otlpEndpoint = process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4317';
|
||||
|
||||
// Use plain string attribute keys (not the semantic-conventions named exports)
|
||||
// so we don't depend on a specific @opentelemetry/semantic-conventions version.
|
||||
const resource = typeof resources.resourceFromAttributes === 'function'
|
||||
? resources.resourceFromAttributes({
|
||||
[ATTR_SERVICE_NAME]: serviceName,
|
||||
[ATTR_SERVICE_NAMESPACE]: 'farmaclic',
|
||||
'service.name': serviceName,
|
||||
'service.namespace': 'farmaclic',
|
||||
})
|
||||
: new resources.Resource({
|
||||
[ATTR_SERVICE_NAME]: serviceName,
|
||||
[ATTR_SERVICE_NAMESPACE]: 'farmaclic',
|
||||
'service.name': serviceName,
|
||||
'service.namespace': 'farmaclic',
|
||||
});
|
||||
|
||||
// Metrics → OTLP → Alloy → Prometheus remote_write. The PeriodicExportingMetricReader
|
||||
|
||||
Reference in New Issue
Block a user