Higher Quality, Stronger Performance, Increased Stability, Better Developer Experience, discover everything we've shipped recently!

Strapi plugin logo for Open Telemetry

Open Telemetry

Export traces, metrics, and logs from Strapi to any OTLP-compatible observability backend — Grafana Tempo, Jaeger, Honeycomb, SigNoz, Datadog via OTLP, or your own OpenTelemetry Collector. Unlike Prometheus scrape plugins, this plugin pushes telemetry using the OpenTelemetry Protocol (OTLP) over gRPC or HTTP.

Strapi OpenTelemetry Plugin

Export traces, metrics, and logs from Strapi to any OTLP-compatible observability backend (Grafana Tempo, Prometheus via Collector, Honeycomb, SigNoz, your own server, etc.).

Unlike Prometheus scrape plugins, this plugin pushes telemetry using the OpenTelemetry Protocol (OTLP) over gRPC or HTTP/protobuf.

Features

  • OTLP export for traces, metrics, and logs (each signal independently configurable)
  • Standard OTEL_* environment variables supported out of the box
  • Auto-instrumentation for HTTP, Koa, PostgreSQL, DNS, and Net
  • Runtime & host metrics (event loop, GC, CPU, memory)
  • Strapi HTTP metrics with route normalization to control cardinality
  • Database lifecycle metrics & traces for create/update/delete/find operations
  • Early instrumentation entrypoint for maximum auto-instrumentation coverage
  • Strapi v5 compatible

Installation

pnpm add strapi-plugin-opentelemetry
# or
npm install strapi-plugin-opentelemetry

Enable the plugin in config/plugins.ts:

export default ({ env }) => ({
  opentelemetry: {
    enabled: true,
    config: {
      serviceName: env('OTEL_SERVICE_NAME', 'my-strapi-app'),
      traces: { enabled: true, exporter: 'otlp', protocol: 'grpc' },
      metrics: {
        enabled: true,
        exporter: 'otlp',
        protocol: 'grpc',
        exportIntervalMillis: 60_000,
        runtimeNode: true,
        hostMetrics: true,
        httpMetrics: true,
        lifecycleMetrics: true,
      },
      logs: { enabled: false, exporter: 'otlp', protocol: 'grpc' },
    },
  },
});

Environment variables

When useEnvironmentVariables is true (default), standard OpenTelemetry environment variables are respected:

VariableDescription
OTEL_SERVICE_NAMEService name for all signals
OTEL_SERVICE_VERSIONService version
OTEL_SERVICE_INSTANCE_IDInstance identifier
OTEL_RESOURCE_ATTRIBUTESComma-separated key=value resource attributes
OTEL_EXPORTER_OTLP_ENDPOINTBase OTLP endpoint
OTEL_EXPORTER_OTLP_TRACES_ENDPOINTTraces endpoint override
OTEL_EXPORTER_OTLP_METRICS_ENDPOINTMetrics endpoint override
OTEL_EXPORTER_OTLP_LOGS_ENDPOINTLogs endpoint override
OTEL_EXPORTER_OTLP_PROTOCOLgrpc, http/protobuf, or http/json
OTEL_EXPORTER_OTLP_HEADERSComma-separated key=value headers
OTEL_TRACES_EXPORTERotlp or none
OTEL_METRICS_EXPORTERotlp or none
OTEL_LOGS_EXPORTERotlp or none
OTEL_METRIC_EXPORT_INTERVALMetrics export interval in ms
OTEL_LOG_LEVELDiagnostic log level (error by default; use debug only when troubleshooting)

Example: push to a local OpenTelemetry Collector

OTEL_SERVICE_NAME=strapi-cms
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
OTEL_EXPORTER_OTLP_PROTOCOL=grpc
OTEL_TRACES_EXPORTER=otlp
OTEL_METRICS_EXPORTER=otlp

Configuration reference

All options can be set in config/plugins.ts under opentelemetry.config:

Top-level

OptionTypeDefaultDescription
enabledbooleantrueMaster switch
useEnvironmentVariablesbooleantrueMerge standard OTEL_* env vars
serviceNamestringstrapiService name
serviceVersionstringService version
serviceInstanceIdstringhostnameInstance ID
resourceAttributesRecord<string, string>{}Extra resource attributes
diagLogLevelstringerrorOTel internal diagnostics

traces, metrics, logs

Each signal supports:

OptionTypeDefaultDescription
enabledbooleantraces/metrics: true, logs: falseEnable this signal
exporterotlp | noneotlpExporter type
protocolgrpc | http/protobuf | http/jsongrpcOTLP transport
endpointstringSignal-specific OTLP URL
headersRecord<string, string>Auth / custom headers
timeoutMillisnumberExport timeout

metrics (additional)

OptionTypeDefaultDescription
exportIntervalMillisnumber60000Export interval
runtimeNodebooleantrueNode.js runtime metrics
hostMetricsbooleantrueHost CPU/memory metrics
httpMetricsbooleantrueHTTP request metrics middleware
lifecycleMetricsbooleantrueDB lifecycle duration metrics

instrumentations

OptionTypeDefault
enabledbooleantrue
httpbooleantrue
koabooleantrue
pgbooleantrue
dnsbooleantrue
netbooleantrue

http

OptionTypeDefaultDescription
enabledbooleantrueRegister HTTP metrics middleware
ignorePathsstring[]['/favicon.ico', '/_health', …]Paths to skip
normalize[string, string][] | functionStrapi-aware rulesRoute normalization
recordPayloadSizesbooleantrueRecord request/response sizes

lifecycles

OptionTypeDefaultDescription
enabledbooleantrueTrack DB lifecycle events
eventsLifecycleEvent[]all supportedEvents to instrument
contentTypesstring[][] (all)Content-type UIDs to filter

Early instrumentation (recommended for production)

For the best auto-instrumentation coverage, load the SDK before Strapi boots:

{
  "scripts": {
    "start": "NODE_OPTIONS='--import strapi-plugin-opentelemetry/instrumentation' strapi start"
  }
}

Optional JSON config via env when using early instrumentation:

STRAPI_OTEL_CONFIG='{"serviceName":"strapi-cms","metrics":{"exportIntervalMillis":30000}}'

Collected metrics

HTTP (middleware)

MetricTypeAttributes
http.server.request.durationHistogramhttp.request.method, http.route, http.response.status_code
http.server.active_requestsUpDownCounterhttp.request.method, http.route
http.server.request.body.sizeHistogramhttp.request.method, http.route
http.server.response.body.sizeHistogramhttp.request.method, http.route, http.response.status_code

Database lifecycles

MetricTypeAttributes
strapi.db.lifecycle.durationHistogramstrapi.content_type, strapi.lifecycle.event

Auto-instrumentation additionally exports standard OTel HTTP, Koa, and PostgreSQL spans/metrics.

Compatibility

StrapiPlugin
v5.xv0.x (pre-release)

Note: v0.x is experimental. Pin a specific version in production until v1.0.0.

License

MIT

Install now

npm install strapi-plugin-opentelemetry

STATS

No GitHub star yet364 weekly downloads

Last updated

2 days ago

Strapi Version

5.4.0 and above

Author

github profile image for oktapodia
oktapodia

Useful links

Create your own plugin

Check out the available plugin resources that will help you to develop your plugin or provider and get it listed on the marketplace.