From 90547629b03ff535d010d84768e5142d346ec7a7 Mon Sep 17 00:00:00 2001 From: Adnan Rahic Date: Tue, 15 Oct 2024 17:50:43 +0200 Subject: [PATCH] docs(getstarted): add beyla for Docker --- .../configure-trace-ingestion.mdx | 48 +++++++++++++++++++ .../docker/docker-compose.yaml | 18 +++++++ examples/quick-start-nodejs/Dockerfile | 2 +- .../quick-start-nodejs/docker-compose.yaml | 7 ++- examples/quick-start-nodejs/package.json | 3 +- 5 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 examples/getting-started/docker/docker-compose.yaml diff --git a/docs/docs/getting-started/configure-trace-ingestion.mdx b/docs/docs/getting-started/configure-trace-ingestion.mdx index e9e2762b5b..6e36a5bf6b 100644 --- a/docs/docs/getting-started/configure-trace-ingestion.mdx +++ b/docs/docs/getting-started/configure-trace-ingestion.mdx @@ -388,6 +388,54 @@ rails server -p 8080 [Visit the example in GitHub, here.](https://github.com/kubeshop/tracetest/tree/main/examples/getting-started/ruby) ::: + + + +You can configure [Grafana Beyla](https://grafana.com/oss/beyla-ebpf/) to autoinstrument Docker services and export traces to Tracetest. + +1. Add Beyla to your `docker-compose.yaml` + +```yaml title="docker-compose.yaml" +services: + autoinstrument: + image: grafana/beyla:latest + privileged: true + environment: + OTEL_EXPORTER_OTLP_ENDPOINT: "http://:4317" + # OTEL_EXPORTER_OTLP_HEADERS: "x-tracetest-token:" + BEYLA_OPEN_PORT: "3000,8080" # Beyla will autoinstrument services on these ports + BEYLA_TRACE_PRINTER: "text" + +# ... +``` + +2. Add `pid: service:autoinstrument` to services in `docker-compose.yaml` + +```yaml title="docker-compose.yaml" +services: + # ... + + service1: + pid: service:autoinstrument # Add this line for Beyla to know what to instrument + build: ./service1 + ports: + - "3000:3000" + + service2: + pid: service:autoinstrument # Add this line for Beyla to know what to instrument + build: ./service2 + ports: + - "8080:8080" +``` + +3. Run Docker Compose + +```bash title="Terminal" +docker compose up +``` + +This will automatically instrument your Docker Compose services with Beyla using eBPF and send the traces to Tracetest. + diff --git a/examples/getting-started/docker/docker-compose.yaml b/examples/getting-started/docker/docker-compose.yaml new file mode 100644 index 0000000000..ec2bb7ac3c --- /dev/null +++ b/examples/getting-started/docker/docker-compose.yaml @@ -0,0 +1,18 @@ +services: + autoinstrument: + image: grafana/beyla:latest + privileged: true + environment: + OTEL_EXPORTER_OTLP_ENDPOINT: "http://host.docker.internal:4317" + # OTEL_EXPORTER_OTLP_HEADERS: "x-tracetest-token:" + BEYLA_OPEN_PORT: "8080" # Beyla will autoinstrument services on these ports + BEYLA_TRACE_PRINTER: "text" + BEYLA_BPF_TRACK_REQUEST_HEADERS: "true" + extra_hosts: + - "host.docker.internal:host-gateway" + + app: + pid: service:autoinstrument # Add this line for Beyla to know what to instrument + image: adnanrahic/hello-world-nodejs + ports: + - 8080:8080 diff --git a/examples/quick-start-nodejs/Dockerfile b/examples/quick-start-nodejs/Dockerfile index 4d40dc62ad..9009e37ac7 100644 --- a/examples/quick-start-nodejs/Dockerfile +++ b/examples/quick-start-nodejs/Dockerfile @@ -4,4 +4,4 @@ COPY package*.json ./ RUN npm install COPY . . EXPOSE 8080 -CMD [ "npm", "run", "with-grpc-tracer" ] +CMD [ "npm", "start" ] diff --git a/examples/quick-start-nodejs/docker-compose.yaml b/examples/quick-start-nodejs/docker-compose.yaml index a5d37c2ee3..c5a1350571 100644 --- a/examples/quick-start-nodejs/docker-compose.yaml +++ b/examples/quick-start-nodejs/docker-compose.yaml @@ -1,7 +1,7 @@ -version: '3' +version: "3" services: app: - image: quick-start-nodejs + image: adnanrahic/hello-world-nodejs extra_hosts: - "host.docker.internal:host-gateway" build: . @@ -28,7 +28,7 @@ services: # Get the required information here: https://app.tracetest.io/retrieve-token - TRACETEST_API_KEY=${TRACETEST_TOKEN} - TRACETEST_ENVIRONMENT_ID=${TRACETEST_ENVIRONMENT_ID} - + tracetest-apply: build: dockerfile: Dockerfile.tracetest @@ -64,4 +64,3 @@ services: depends_on: tracetest-apply: condition: service_completed_successfully - diff --git a/examples/quick-start-nodejs/package.json b/examples/quick-start-nodejs/package.json index 658ddafd16..1b76ee1f96 100644 --- a/examples/quick-start-nodejs/package.json +++ b/examples/quick-start-nodejs/package.json @@ -6,7 +6,8 @@ "scripts": { "with-grpc-tracer-and-env": "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:4317 node -r ./tracing.otel.grpc.js app.js", "with-grpc-tracer": "node -r ./tracing.otel.grpc.js app.js", - "with-http-tracer": "node -r ./tracing.otel.http.js app.js" + "with-http-tracer": "node -r ./tracing.otel.http.js app.js", + "start": "node app.js" }, "keywords": [], "author": "",