Skip to content

A support package for instrumenting Docker CLI and Docker Buildx with OpenTelemetry

Notifications You must be signed in to change notification settings

socheatsok78/docker-cli-otel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

About

A support package for instrumenting Docker CLI and Docker Buildx with OpenTelemetry

Usgae

docker run -p 3000:3000 -p 4317:4317 -p 4318:4318 --rm -ti grafana/otel-lgtm

See https://grafana.com/blog/2024/03/13/an-opentelemetry-backend-in-a-docker-image-introducing-grafana/otel-lgtm/ for more information about the OpenTelemetry backend in a Docker image.

Docker CLI

The Docker CLI supports OpenTelemetry instrumentation for emitting metrics about command invocations. This is disabled by default. You can configure the CLI to start emitting metrics to the endpoint that you specify. This allows you to capture information about your docker command invocations for more insight into your Docker usage.

The Docker CLI doesn't emit telemetry data by default. Only if you've set an environment variable on your system will Docker CLI attempt to emit OpenTelemetry metrics, to the endpoint that you specify.

export DOCKER_CLI_OTEL_EXPORTER_OTLP_ENDPOINT=http://0.0.0.0:4317

See https://docs.docker.com/engine/cli/otel/ for more information about the OpenTelemetry support in Docker CLI.

BuildKit

BuildKit supports OpenTelemetry for buildkitd gRPC API and buildctl commands. To capture the trace to OpenTelemetry, set OTEL_EXPORTER_OTLP_ENDPOINT environment variable to the collection address.

export OTEL_EXPORTER_OTLP_ENDPOINT=http://0.0.0.0:4317
# restart buildkitd and buildctl so they know OTEL_EXPORTER_OTLP_ENDPOINT
# any buildctl command should be traced to http://127.0.0.1:3000/

See https://docs.docker.com/build/debug/opentelemetry/ for more information about the OpenTelemetry support in BuildKit.

Troubleshooting

Note

I find that setting the environment variable OTEL_EXPORTER_OTLP_ENDPOINT to http://0.0.0.0:4317 works best for my environment running macOS. You can set it http://127.0.0.1:4317 as well as seen in the official documentation.

About

A support package for instrumenting Docker CLI and Docker Buildx with OpenTelemetry

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published