Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

otel: simple OTEL collector/Jaeger/Aspire stack for testing purposes #47733

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions hack/otel/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: moby-otel

services:

jaeger:
image: jaegertracing/all-in-one:latest
ports:
- 16686:16686

aspire-dashboard:
image: mcr.microsoft.com/dotnet/nightly/aspire-dashboard
ports:
- 18888:18888
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering if we should use 127.0.0.1 for these; just in case someone runs this without considering that mapping the port will default to the public interface. @akerouanton any thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's generally better to bind 127.0.0.1 to not expose services needlessly on the LAN. But personnally, I'm using this stack to have a single collector on my home network and send Engine traces from all my machines to it. I'm okay binding these to 0.0.0.0 and let contributors figure out what's the most appropriate for their situation.

environment:
DOTNET_DASHBOARD_UNSECURED_ALLOW_ANONYMOUS: 'true'

otelcol:
image: otel/opentelemetry-collector:latest
restart: always
depends_on:
- jaeger
- aspire-dashboard
ports:
- 4318:4318 # default otlp http port
volumes:
# Mount the otelcol.yml config file
- ./otelcol.yaml:/etc/otelcol/config.yaml
21 changes: 21 additions & 0 deletions hack/otel/otelcol.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Receive signals over gRPC and HTTP
# moby currently uses http
receivers:
otlp:
protocols:
grpc:
http:

exporters:
otlp/jaeger:
endpoint: jaeger:4317
tls::insecure: true
otlp/aspire:
endpoint: aspire-dashboard:18889
tls::insecure: true

service:
pipelines:
traces:
receivers: [otlp]
exporters: [otlp/jaeger, otlp/aspire]
28 changes: 28 additions & 0 deletions hack/otel/usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Sample stack for testing OTEL functionality with moby

To easily test the OTEL functionality present in moby, you can spin up a small demo compose stack that includes:
- an OTEL collector container;
- a Jaeger container to visualize traces;
- an alternative Aspire Dashboard container to visualize traces;

The OTEL collector is configured to export Traces to both the Jaeger and Aspire containers.

The `hack/otel` directory contains the compose file with the services configured, along with a basic configuration file for the OTEL collector.

## How can I use it?

1) Export the env var used to override the OTLP endpoint:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit; should this be a actual markdown numbered list?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmh good question, I thought it looked a bit better but I guess it depends on the markdown renderer used. No hard feelings here, if it's "more correct" to do otherwise i'll change this

`export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318` (if running in a devcontainer or in other ways, you might have to change how you pass this env var to the daemon);
2) Start the moby engine you want to get traces from (make sure it gets the env var declared above);
3) Start the otel compose stack by running `docker compose up -d` in the `hack/otel/` directory;
4) Make some calls to the engine using the Docker CLI to send some traces to the endpoint;
5) Browse Jaeger at `http://localhost:16686` or the Aspire Dashboard at `http://localhost:18888/traces`;
6) To see some traces from the engine, select `dockerd` in the top left dropdown

> **Note**: The precise steps may vary based on how you're working on the codebase (buiding a binary and executing natively, running/debugging in a devcontainer, etc... )

## Cleanup?

Simply run `docker compose down` in the `hack/otel/` directory.

You can also run `unset OTEL_EXPORTER_OTLP_ENDPOINT` to get rid of the OTLP env var from your environment