Get started with auto-instrumentation ΒΆ
Auto-instrumentation injects an OpenTelemetry agent into your application at startup. The agent hooks into popular libraries and frameworks to collect traces and runtime metrics β without code changes. Log export via OpenTelemetry is available as an opt-in.
Supported runtimes: Java/Kotlin, Node.js, Python, and SDK-only mode for Go and other languages that provide their own OpenTelemetry setup.
What you get ΒΆ
Once enabled, the agent automatically instruments:
| Category | Examples (vary by runtime) |
|---|---|
| HTTP servers | Spring MVC, Ktor, Express, Flask, Koa |
| HTTP clients | OkHttp, Apache HttpClient, node-fetch, requests |
| Databases | PostgreSQL (JDBC, node-postgres), Valkey/Redis |
| Messaging | Kafka producers/consumers |
| gRPC | Client and server calls |
| Frameworks | Spring Boot, Ktor, Micrometer bridge |
This data powers the Nais APM dashboards β service inventory, RED metrics (Rate/Errors/Duration), dependency maps, and runtime metrics β with no extra configuration.
Enable auto-instrumentation ΒΆ
Add the following to your nais.yaml and deploy:
spec:
observability:
autoInstrumentation:
enabled: true
runtime: javaspec:
observability:
autoInstrumentation:
enabled: true
runtime: nodejsspec:
observability:
autoInstrumentation:
enabled: true
runtime: pythonThis sets up the OpenTelemetry environment variables but does not inject an agent. Use this when your application configures the OpenTelemetry SDK itself.
spec:
observability:
autoInstrumentation:
enabled: true
runtime: sdkVerify it works ΒΆ
After deploying, check that traces are flowing:
- Open the Nais APM service inventory
- Find your application in the list β it should appear within a few minutes
- Click through to see RED dashboards, operations breakdown, and dependencies
If your app does not appear, check the auto-instrumentation configuration reference for troubleshooting environment variables, and make sure your application is receiving traffic.
You can also verify in Grafana Explore using the Tempo data source:
{resource.service.name="<your-app-name>"}Next steps ΒΆ
- Add custom spans and metrics for business-specific tracing
- Avoid false errors from expected 4xx responses β fix inflated error rates in APM