Skip to content

Commit

Permalink
feat: add otel collector and otlp support (#238)
Browse files Browse the repository at this point in the history
## This PR

- adds updated OpenTelemetry hooks
- add the OpenTelemetry collector to Docker Compose
- add Prometheus

Signed-off-by: Michael Beemer <[email protected]>
  • Loading branch information
beeme1mr authored Sep 19, 2023
1 parent 50d8688 commit 427ebd6
Show file tree
Hide file tree
Showing 16 changed files with 3,352 additions and 1,126 deletions.
2 changes: 1 addition & 1 deletion config/flagd/flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"blue": "0d507b",
"yellow": "d4ac0d"
},
"defaultVariant": "red",
"defaultVariant": "blue",
"targeting": {
"if": [
{
Expand Down
23 changes: 23 additions & 0 deletions config/otel/collector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
receivers:
otlp:
protocols:
grpc:
exporters:
prometheus:
endpoint: "0.0.0.0:8889"
jaeger:
endpoint: jaeger:14250
tls:
insecure: true
processors:
batch:
service:
pipelines:
traces:
receivers: [ otlp ]
processors: [ batch ]
exporters: [ jaeger ]
metrics:
receivers: [ otlp ]
processors: [ batch ]
exporters: [ prometheus ]
18 changes: 18 additions & 0 deletions config/prometheus/prometheus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
global:
scrape_interval: 5s # By default, scrape targets every 15 seconds.

# Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: "playground"

# Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: 5s

static_configs:
- targets: [ 'otel-collector:8889' ]
- targets: [ 'otel-collector:8888' ]
42 changes: 37 additions & 5 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ services:
image: ghcr.io/open-feature/playground-app:v0.11.0 # x-release-please-version
# build:
# dockerfile: ./packages/app/Dockerfile
# context: .
ports:
- '30000:30000'
command:
Expand All @@ -23,6 +24,7 @@ services:
- FIB_SERVICE_URL=http://fib-service:30001
- FIB_SERVICE_USER
- FIB_SERVICE_PASS
- ENABLED_SPAN_BASED_TRACES
# Provider values come from the .env
- NEW_WELCOME_MESSAGE
- FIB_ALGO
Expand All @@ -47,7 +49,8 @@ services:
fib-service:
image: ghcr.io/open-feature/playground-fib-service:v0.11.0 # x-release-please-version
# build:
# dockerfile: ./packages/fibonacci-service/Dockerfile
# dockerfile: ./packages/fibonacci-service/Dockerfile
# context: .
expose:
- '30001'
environment:
Expand All @@ -57,6 +60,7 @@ services:
- OTEL_SERVICE_NAME=fibonacci-service
- FIB_SERVICE_USER
- FIB_SERVICE_PASS
- ENABLED_SPAN_BASED_TRACES
# Provider values come from the .env
- NEW_WELCOME_MESSAGE
- FIB_ALGO
Expand All @@ -69,20 +73,48 @@ services:
- CLOUDBEES_APP_KEY

jaeger:
image: jaegertracing/all-in-one:1.46
image: jaegertracing/all-in-one:latest
expose:
- '6832/udp'
ports:
- '16686:16686'

otel-collector:
image: otel/opentelemetry-collector-contrib:latest
restart: always
command: [ "--config=/etc/otel-collector-config.yaml" ]
volumes:
- ./config/otel/collector.yaml:/etc/otel-collector-config.yaml
expose:
- "1888" # pprof extension
- "8888" # Prometheus metrics exposed by the collector
- "8889" # Prometheus exporter metrics
- "4317" # OTLP gRPC receiver
depends_on:
- jaeger
- prometheus

prometheus:
container_name: prometheus
image: prom/prometheus:latest
restart: always
volumes:
- ./config/prometheus/prometheus.yaml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"

flagd:
image: ghcr.io/open-feature/flagd:v0.5.4
image: ghcr.io/open-feature/flagd:v0.6.6
command:
- start
- --cors-origin
- '*'
- --uri
- file://etc/flagd/flags.json
- --sources
- '[{"uri":"etc/flagd/flags.json","provider":"file","selector":"etc/flagd/flags.json"}]'
- --metrics-exporter
- otel
- --otel-collector-uri
- otel-collector:4317
volumes:
- ./config/flagd/flags.json:/etc/flagd/flags.json
ports:
Expand Down
Loading

0 comments on commit 427ebd6

Please sign in to comment.