-
Run the docker compose file in the root of the repo, which will boot the OTLP collector:
docker compose up
-
Run the http server by preloading the instrumentation code.
node -r "./trace-instrumentation.js" http-server.js
- Access the app at http://localhost:8080
The request handler function in http-server will create a log entry. Since pino is instrumented with @opentelemetry/instrumentation-pino in trace-instrumentation.js
, it will also add the span context values as attributes (trace_id
, span_id
, trace_flags
).
pino-opentelemetry-transport will read those attributes and add them to the current context. The resulting LogRecord will have those fields populated. Fields trace_id
, span_id
, trace_flags
will not be visible in the LogRecord attributes.
Observe the logs with:
tail -f /tmp/test-logs/otlp-logs.log