Observability

Add logging, metrics, and tracing to your self-hosted c15t backend.

The c15t backend supports structured logging and opt-in OpenTelemetry integration for production observability.

OpenTelemetry

Telemetry is disabled by default. To enable it, pass your own tracer and meter instances:

Info

You need to set up your own OpenTelemetry SDK and exporter (e.g. Jaeger, Datadog, Grafana). The c15t backend creates spans and metrics using the instances you provide.

Metrics

When telemetry is enabled, the following metrics are recorded:

Business Metrics

MetricTypeDescription
consentCreatedCounterConsent record created (by type, jurisdiction)
consentAcceptedCounterConsent accepted (by type)
consentRejectedCounterConsent rejected (by type)
subjectCreatedCounterNew subject created
subjectLinkedCounterSubject linked to external ID
initCountCounter/init endpoint called

HTTP Metrics

MetricTypeDescription
httpRequestDurationHistogramRequest duration (by method, route, status)
httpRequestCountCounterTotal requests
httpErrorCountCounterError responses

Database Metrics

MetricTypeDescription
dbQueryDurationHistogramQuery duration (by operation, entity)
dbQueryCountCounterTotal queries
dbErrorCountCounterQuery errors

Cache Metrics

MetricTypeDescription
cacheHitCounterCache hits (by layer)
cacheMissCounterCache misses (by layer)
cacheLatencyHistogramCache operation latency

Tracing

Every request creates a span with:

  • HTTP method and route
  • Response status code
  • Tenant ID (if multi-tenant)
  • API key authentication status
  • Geo-location resolution

Child spans are created for database queries and cache operations.

Logging

Configure the log level:

Logs are structured (JSON-compatible) and include trace context when telemetry is enabled, making it easy to correlate logs with traces.