Skip to content

Commit

Permalink
feat: implement just cmds otel-stream, otel-stop, and otel-dev (#…
Browse files Browse the repository at this point in the history
…2040)

Part 1 of #2020

This PR enables local testing of otel metric changes/additions. To use:

In tab 1, run `just otel-stream`.

In tab 2, run `just otel-dev`. You can pass in any args you'd run `ftl
dev` with (e.g. `--recreate`). If you set `--log-level=DEBUG`, you
should see `OTEL is enabled, exporting to localhost:4317` in your
output. Any signals you trigger to log at this point should appear in
the streaming output of tab 1.

When you're done, kill the `dev` command and then run `just otel-stop`
in any tab other than tab 1.
  • Loading branch information
deniseli authored Jul 12, 2024
1 parent 3d59eb4 commit 238d5ce
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,28 @@ debug *args:
FTL_DEBUG=true just build ftl
dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec "{{RELEASE}}/ftl" -- dev {{args}} &
dlv_pid=$!
wait "$dlv_pid"
wait "$dlv_pid"

# Run otel collector in a docker container to stream local (i.e. from ftl dev) signals to
# the terminal tab where this is running. To start FTL, opepn another terminal tab and run
# `just otel-dev` with any args you would pass to `ftl dev`. To stop the otel stream, run
# `just otel-stop` in a third terminal tab.
grpcPort := `cat docker-compose.yml | grep "OTLP gRPC" | sed 's/:.*//' | sed -r 's/ +- //'`
otel-stream:
docker run \
-p {{grpcPort}}:{{grpcPort}} \
-p 55679:55679 \
otel/opentelemetry-collector:0.104.0

# Stop the docker container running otel.
otelContainerID := `docker ps -f ancestor=otel/opentelemetry-collector:0.104.0 | tail -1 | cut -d " " -f1`
otel-stop:
docker stop "{{otelContainerID}}"

# Run `ftl dev` with the given args after setting the necessary envar.
otel-dev *args:
#!/bin/bash

gprcPort=$(cat docker-compose.yml | grep "OTLP gRPC" | sed 's/:.*//' | sed -r 's/ +- //')
export OTEL_EXPORTER_OTLP_ENDPOINT="localhost:${gprcPort}"
ftl dev {{args}}

0 comments on commit 238d5ce

Please sign in to comment.