Episode 15traces

Pulumi can trace every deploy

The Pulumi CLI has OpenTelemetry built in. One flag on pulumi up exports the whole deploy as a trace, with every provider in it.

Ship telemetry toUse an OTLP endpoint you already have, from another vendor or your platform team. This one needs a one-time setup step: save your endpoint and the episodes fill it in.Set your endpointRun an OpenTelemetry Collector on your machine and watch telemetry arrive in its terminal. No account needed.More detailsShip straight to Bronto. You need an account and an API key with ingest permission.More details

Switch it on

Add the --otel-traces flag to the pulumi up line in bin/deploy, the script your CI runs. The next deploy is one trace, with the CLI, the language host and every provider in it.

#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
OTEL="https://ingestion.eu.bronto.io"
OTEL+="?x-bronto-api-key=$BRONTO_API_KEY"
OTEL+="&x-bronto-dataset=pulumi"
pulumi up --stack production \
  --yes --skip-preview \
  --otel-traces "$OTEL"
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
pulumi up --stack production \
  --yes --skip-preview \
  --otel-traces "http://localhost:4318"

This assumes a Collector listening on localhost:4318; the Local Collector setup shows how to start one.

This uses the endpoint and auth header you saved in the setup guide. Pulumi turns query parameters into headers and decodes them, so jq percent-encodes the header first; a raw +, & or # would change it.

#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
OTEL="YOUR_OTLP_ENDPOINT"
OTEL+="?$(jq -rn --arg h 'YOUR_AUTH_HEADER' --arg v 'YOUR_AUTH_VALUE' '"\($h|@uri)=\($v|@uri)"')"
pulumi up --stack production \
  --yes --skip-preview \
  --otel-traces "$OTEL"