OpenTelemetry CLI
Send OpenTelemetry traces from the command line
On this page
What is it?
otel-cli
is a tool for sending OpenTelemetry traces to a collector from the command line. By using otel-cli
, you can easily add tracing to shell scripts and to other applications where tracing is not well-supported natively.
How do you use it?
To learn more about installing and using otel-cli
, read the Getting Started docs.
Assuming you have Go installed:
go install github.com/equinix-labs/otel-cli@latest
If you don't have Go installed, see the link above for other install options, including brew
.
Once otel-cli
is installed, you can try it out locally with the built-in OTLP server. Configure the otel-cli
environment to use the local server and traces will be shown on the console.
otel-cli server tui
export OTEL_EXPORTER_OTLP_ENDPOINT=localhost:4317 # address:port of the server created above
Run a program inside a span:
otel-cli exec --service my-service --name "curl example" curl https://example.com
otel-cli
propagates context using environment variables so you can chain context through child spans:
otel-cli exec --kind producer "otel-cli exec --kind consumer sleep 1"
If a traceparent environment variable is set it will be automatically picked up and used by span and exec. You can use --tp-ignore-env
to ignore it even when present.
export TRACEPARENT=00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01
You can pass the traceparent to a child via arguments as well by using the template text {{traceparent}}
in any of the command's arguments.
otel-cli exec --name "curl api" -- \
curl -H 'traceparent: {{traceparent}}' https://example.com/v1/coolstuff
For more advanced examples, see the examples in the project.
Let us know about your experience with this project on the Equinix Community.
Submit new feature requests on the otel-cli GitHub Issues page.
Configure Otel-CLI
See Advanced Examples.
Last updated
23 September, 2024Category
Type
ToolsShare this
Ready to kick the tires?
Use code DEPLOYNOW for $300 credit