Skip to content

Commit

Permalink
Add a Dockerfile that can build the collector along with an example. (#…
Browse files Browse the repository at this point in the history
…256)

This makes sure that go tooling isn't required to play with a binary built from master. It works particularly well with docker-compose, where you can set the build context to https://github.com/open-telemetry/opentelemetry-collector-contrib.git and always be testing integrations against master with a single command.

**Link to tracking Issue:** fixes #236 

**Testing:** 
docker build / docker run

**Documentation:** Added the docker build command to the README
  • Loading branch information
Anuraag Agrawal authored May 28, 2020
1 parent 9b27241 commit 46c109d
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ workflows:
filters:
tags:
only: /.*/
- build-examples-tracing:
requires:
- setup-and-lint
filters:
tags:
only: /.*/
- cross-compile:
requires:
- build
Expand Down Expand Up @@ -140,6 +146,16 @@ jobs:
root: ~/
paths: project/bin

build-examples-tracing:
docker:
- image: cimg/go:1.14
steps:
- attach_to_workspace
- setup_remote_docker
- run:
name: Build trace example
command: docker-compose -f examples/tracing/docker-compose.yml build

cross-compile:
executor: golang
parallelism: 4
Expand Down
2 changes: 1 addition & 1 deletion cmd/otelcontribcol/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ FROM scratch
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY otelcontribcol /
ENTRYPOINT ["/otelcontribcol"]
EXPOSE 55678 55679
EXPOSE 55680 55679
15 changes: 15 additions & 0 deletions examples/tracing/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM golang:1.14 AS build

WORKDIR /src
ADD . /src

RUN make otelcontribcol

FROM alpine:latest as certs
RUN apk --update add ca-certificates

FROM scratch
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=build /src/bin/otelcontribcol_linux_amd64 /otelcontribcol
ENTRYPOINT ["/otelcontribcol"]
EXPOSE 55680 55679
11 changes: 11 additions & 0 deletions examples/tracing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# OpenTelemetry Collector Demo

This demo is a sample app to build the collector and exercise its tracing functionality.

To build and run the demo, switch to this directory and run

`docker-compose up`

Hit `http://localhost:8081` in your browser or using something like cURL, and then open
up `http://localhost:9411` or `http://localhost:16686` to search for the traces in the
Zipkin or Jaeger UIs.
56 changes: 56 additions & 0 deletions examples/tracing/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
version: "3"
services:
# Jaeger
jaeger:
image: jaegertracing/all-in-one:latest
ports:
- "16686:16686"
- "14268"
- "14250"

#Zipkin
zipkin:
image: openzipkin/zipkin
container_name: zipkin
ports:
- 9411:9411

otel-collector:
build:
context: ../..
dockerfile: examples/tracing/Dockerfile
command: ["--config=/etc/otel-collector-config.yml"]
volumes:
- ./otel-collector-config.yml:/etc/otel-collector-config.yml
ports:
- "1888:1888" # pprof extension
- "8888:8888" # Prometheus metrics exposed by the collector
- "8889:8889" # Prometheus exporter metrics
- "13133:13133" # health_check extension
- "9411" # Zipkin receiver
- "55680:55679" # zpages extension
depends_on:
- jaeger
- zipkin

# Expose the frontend on http://localhost:8081
frontend:
image: openzipkin/example-sleuth-webmvc
command: Frontend
environment:
JAVA_OPTS: -Dspring.zipkin.baseUrl=http://otel-collector:9411
ports:
- 8081:8081
depends_on:
- otel-collector

# Expose the backend on http://localhost:9000
backend:
image: openzipkin/example-sleuth-webmvc
command: Backend
environment:
JAVA_OPTS: -Dspring.zipkin.baseUrl=http://otel-collector:9411
ports:
- 9000:9000
depends_on:
- otel-collector
34 changes: 34 additions & 0 deletions examples/tracing/otel-collector-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
receivers:
otlp:
endpoint: 0.0.0.0:55680
zipkin:
endpoint: 0.0.0.0:9411

exporters:
logging:

zipkin:
url: "http://zipkin:9411/api/v2/spans"
format: proto

jaeger_thrift:
url: "http://jaeger:14268/api/traces"

processors:
batch:
queued_retry:

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

service:
extensions: [pprof, zpages, health_check]
pipelines:
traces:
receivers: [otlp, zipkin]
exporters: [zipkin, jaeger_thrift, logging]
processors: [batch, queued_retry]

0 comments on commit 46c109d

Please sign in to comment.