Skip to content

Commit

Permalink
consolidate basic-otlp* examples docker-compose setups (#802)
Browse files Browse the repository at this point in the history
* consolidate basic-otlp* docker-compose setups

* just copy the docker-compose setup

* Update examples/basic-otlp/Dockerfile

* fix: bump the MSRV to 1.59

Co-authored-by: Zhongyang Wu <zhongyang.wu@outlook.com>
  • Loading branch information
guswynn and TommyCpp authored Jun 9, 2022
1 parent 1f84f4a commit 7c3a489
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.55.0
toolchain: 1.59.0
override: true
- name: Run tests
run: cargo --version &&
Expand Down
3 changes: 2 additions & 1 deletion examples/basic-otlp-http/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
* Run the application locally, to run as a docker container you have to change the relative paths from the `Cargo.toml`
* The Collector then sends the data to the appropriate backend, in this case JAEGER

This demo uses `docker-compose` and by default runs against the `otel/opentelemetry-collector-dev:latest` image.
This demo uses `docker-compose` and by default runs against the `otel/opentelemetry-collector-dev:latest` image,
and uses `http` as the transport.

```shell
docker-compose up
Expand Down
2 changes: 1 addition & 1 deletion examples/basic-otlp-http/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:
ports:
- "1888:1888" # pprof extension
- "13133:13133" # health_check extension
- "4317" # OTLP gRPC receiver
- "4317:4317" # OTLP gRPC receiver
- "4318:4318" # OTLP HTTP receiver
- "55670:55679" # zpages extension
depends_on:
Expand Down
6 changes: 6 additions & 0 deletions examples/basic-otlp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM rust:1.51
COPY . /usr/src/basic-otlp/
WORKDIR /usr/src/basic-otlp/
RUN cargo build --release
RUN cargo install --path .
CMD ["/usr/local/cargo/bin/basic-otlp"]
31 changes: 30 additions & 1 deletion examples/basic-otlp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,33 @@ This example shows basic span and metric usage, and exports to the [OpenTelemetr

## Usage

### `docker-compose`

By default runs against the `otel/opentelemetry-collector-dev:latest` image, and uses the `tonic`'s
`grpc` example as the transport.

```shell
docker-compose up
or
docker-compose up -d
```

In another terminal run the application `cargo run`

Use the browser to see the trace:
- Jaeger at http://0.0.0.0:16686

Tear it down:

```shell
docker-compose down
```

### Manual

If you don't want to use `docker-compose`, you can manually run the `otel/opentelemetry-collector` container
and inspect the logs to see traces being transferred.

```shell
# Run `opentelemetry-collector`
$ docker run -p4317:4317 otel/opentelemetry-collector:latest
Expand Down Expand Up @@ -90,4 +117,6 @@ Data point attributes:
StartTimestamp: 2021-11-19 04:07:46.29555 +0000 UTC
Timestamp: 2021-11-19 04:08:36.297279 +0000 UTC
Value: 1.000000
```
```


37 changes: 37 additions & 0 deletions examples/basic-otlp/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
version: "2"
services:

# Jaeger
jaeger-all-in-one:
image: jaegertracing/all-in-one:latest
ports:
- "16686:16686"
- "14268"
- "14250"

# Collector
otel-collector:
image: otel/opentelemetry-collector:latest
command: ["--config=/etc/otel-collector-config.yaml", "${OTELCOL_ARGS}"]
volumes:
- ./otel-collector-config.yaml:/etc/otel-collector-config.yaml
ports:
- "1888:1888" # pprof extension
- "13133:13133" # health_check extension
- "4317:4317" # OTLP gRPC receiver
- "4318:4318" # OTLP HTTP receiver
- "55670:55679" # zpages extension
depends_on:
- jaeger-all-in-one


# metrics-rust:
# build:
# dockerfile: $PWD/Dockerfile
# context: ./basic-otlp-http
# environment:
# - OTLP_TONIC_ENDPOINT=otel-collector:4317
# depends_on:
# - otel-collector


35 changes: 35 additions & 0 deletions examples/basic-otlp/otel-collector-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
receivers:
otlp:
protocols:
http:
grpc:

exporters:
logging:
loglevel: debug

jaeger:
endpoint: jaeger-all-in-one:14250
insecure: true

processors:
batch:

extensions:
health_check:
pprof:
endpoint: :1888
zpages:
endpoint: :55679

service:
extensions: [pprof, zpages, health_check]
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [logging, jaeger]
metrics:
receivers: [otlp]
processors: [batch]
exporters: [logging]

0 comments on commit 7c3a489

Please sign in to comment.