Instrument and test your application

In this milestone, you instrument an application using Beyla running in a Docker container. You can use your own application, or if you don’t have one, use the sample application provided.

To instrument an application with Beyla, complete the following steps:

  1. Start the application you want to instrument.

    If you don’t have an application, run the following command to start a sample Go blog application:

    Bash
    docker run --rm -d \
      --name goblog \
      -p 8443:8443 \
      mariomac/goblog:dev

    The sample application runs in the background and listens on port 8443.

  2. Set your OTLP environment variables.

    Run the following commands, replacing the placeholders with the values you saved in the previous milestone:

    Bash
    export OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf"
    export OTEL_EXPORTER_OTLP_ENDPOINT="https://otlp-gateway-prod-<region>.grafana.net/otlp"
    export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Basic <your-credentials>"
  3. Run the following command to start Beyla as a sidecar container:

    If you are using your own application, replace container:goblog with container:<YOUR_CONTAINER_NAME> and BEYLA_OPEN_PORT=8443 with your application’s port.

    Bash
    docker run --rm \
      --pid="container:goblog" \
      --privileged \
      -e BEYLA_OPEN_PORT=8443 \
      -e BEYLA_TRACE_PRINTER=text \
      -e OTEL_EXPORTER_OTLP_PROTOCOL \
      -e OTEL_EXPORTER_OTLP_ENDPOINT \
      -e OTEL_EXPORTER_OTLP_HEADERS \
      grafana/beyla:latest

    Beyla requires administrative privileges. Ensure you have the necessary permissions to run Docker containers with --privileged.

    This command configures Beyla to inspect the application container, share its PID namespace, and print traces to the console (BEYLA_TRACE_PRINTER=text).

  4. Open a new terminal window.

  5. Generate application traffic from a browser or a terminal.

    If using your own application, make a request to its listening port using the appropriate protocol. For example, for an HTTP application:

    Bash
    curl http://localhost:<YOUR_PORT>/

    If using the sample application, run the following command:

    Bash
    curl -k https://localhost:8443/
  6. Return to the terminal window where Beyla is running and verify the trace output.

    You should see output similar to the following:

    text
    2026-02-02 14:03:53 (19.06ms) [200] GET /

    This output confirms that Beyla intercepted the request and generated a trace.

In the next milestone, you explore the distributed traces in Grafana Cloud.


page 4 of 6