Skip to main content
Localdev shows the logs, metrics and traces your services send over OpenTelemetry (OTLP). This page shows how to set up the OpenTelemetry SDK in Go, Python and Node.js. Each example sends logs linked to traces, traces, and a jobs.done metric.

What Localdev configures for you

Localdev sets these variables for every service:
OpenTelemetry SDKs read them, so there’s no endpoint to set in your code. Each service’s telemetry is labelled with its name from the Projectfile. To change these values, see Environment variables. The collector receives OTLP gRPC on port 4998 and OTLP HTTP on port 4999. Go, Python and Node.js all work with the gRPC default. Node.js’s SDK defaults to HTTP, but follows OTEL_EXPORTER_OTLP_PROTOCOL.

Before you start

  • Send metrics more often. SDKs export metrics every 60 seconds by default. For local work, 5 seconds is more useful:
  • Link logs to traces. A log is linked to a trace when it’s written while a span is active. In Go, pass the span’s context to the logger. In Python and Node.js, auto-instrumentation does it for you.
  • Flush on the way out. Localdev stops services with SIGTERM. Shut the SDK down when your service exits, so the last batch of telemetry still arrives.

Go

Tested with go.opentelemetry.io/otel 1.47.0 and go.opentelemetry.io/contrib/bridges/otelslog 0.21.0. Save this as main.go:
main.go
Build it:
Then add it to the Projectfile:
The Go SDK doesn’t link logs to traces by itself. Use the …Context logging methods (InfoContext, ErrorContext, …) with the span’s context, as above.

Python

Tested with Python 3.13, opentelemetry-sdk 1.45.2 and opentelemetry-distro 0.66b2. Install the packages into a virtual environment:
Save this as app.py:
app.py
Run it through opentelemetry-instrument, which sets up the SDK before your code starts:
Without these two variables, Python sends traces and metrics, but not logs.

Node.js

Tested with Node.js 24.4 and @opentelemetry/auto-instrumentations-node 0.83.1. Install the packages:
Save this as app.js:
app.js
Load the auto-instrumentation with --require in the command, and turn on the three exporters:
  • The usual NODE_OPTIONS=--require … doesn’t work: Localdev refuses NODE_OPTIONS. Put --require in the command instead.
  • --require is resolved from the working directory, which is the Projectfile’s directory. node_modules must be there.

Other languages

Any OpenTelemetry SDK works if it exports OTLP to port 4998 (gRPC) or 4999 (HTTP). Only Go, Python and Node.js have been tested. To use OTLP over HTTP, set both the protocol and the endpoint:
If you changed the collector’s ports with collector.receivers, use those instead.

Traces across services

A request that goes through several services shows as one trace only if each service passes the trace context on. In Go, wrap your HTTP clients and handlers with otelhttp (go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp). In Python and Node.js, auto-instrumentation does it for the libraries it supports.

Incomplete and interrupted traces

  • INCOMPLETE means the trace’s root span hasn’t arrived. Spans are sent when they end, so a long request or job shows as incomplete until it finishes. The list then shows the earliest span, marked root missing.
  • INTERRUPTED means a service in the trace stopped (crashed or exited) before the trace finished. Spans it hadn’t sent yet are lost. Check the service’s Output.

Services without instrumentation

A service that doesn’t use OpenTelemetry still runs, and the UI still shows whether it’s running, stopped or crashed. It sends no logs, metrics or traces. To see what it printed, open Project → Services and select Output, or read its output files (see Files).

If nothing arrives

  • Wait 10 seconds. SDKs send spans and logs in batches, and metrics every 60 seconds unless you set OTEL_METRIC_EXPORT_INTERVAL.
  • Check the service’s stderr under Output. Some SDKs report export errors there; others fail without a word.
  • If you set OTEL_EXPORTER_OTLP_PROTOCOL or OTEL_EXPORTER_OTLP_ENDPOINT yourself, check that they match: grpc with port 4998, or http/protobuf with port 4999.