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

feat: OTLP Exporter #1324

Merged
merged 27 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
bb0d00d
feat: deprecate jaeger enabled in favor or specifying tracing exporter
markphelps Feb 3, 2023
2d9b8ad
chore: update example config; cue/json schemas
markphelps Feb 3, 2023
5b754c8
feat: add zipkin support for traces
markphelps Feb 3, 2023
a8ca1d3
chore: add shutdown functionality
markphelps Feb 3, 2023
e1d8e0b
chore: switch to 'backend'
markphelps Feb 6, 2023
253adcc
Merge branch 'main' into deprecate-jaeger-enabled
markphelps Feb 6, 2023
dcd6d01
chore: missed a few renames
markphelps Feb 6, 2023
f57704f
chore: missed in deprecations.md
markphelps Feb 6, 2023
9f6efe8
chore: change log msg
markphelps Feb 6, 2023
b7fb210
chore: merge in upstream branch
markphelps Feb 6, 2023
913d4bd
chore: merge main
markphelps Feb 6, 2023
c4d87d2
chore: add cue/json schema
markphelps Feb 6, 2023
39b40ba
chore: update tracing example docker-compose
markphelps Feb 6, 2023
f9061ab
chore: use build for docker-compose for now until release
markphelps Feb 6, 2023
3de305d
chore: config tests
markphelps Feb 6, 2023
91ca180
chore: update README
markphelps Feb 6, 2023
5dd3738
feat: support otlp exporter
markphelps Feb 6, 2023
e8b834a
chore: merge main
markphelps Feb 7, 2023
055c203
chore: fix readme merge conflicts; rename back to exporter
markphelps Feb 7, 2023
b89df15
chore: fix tests
markphelps Feb 7, 2023
3b08295
chore: add readme; finish backend->exporter
markphelps Feb 7, 2023
1f2ea9b
chore: update tracing example readme
markphelps Feb 7, 2023
cf1993c
chore: update config schemas
markphelps Feb 7, 2023
da2689b
chore: update examples docker-compose files
markphelps Feb 7, 2023
a036dd3
Update config/flipt.schema.cue
markphelps Feb 8, 2023
12aad19
chore: respond to PR feedback
markphelps Feb 8, 2023
281e252
Merge branch 'main' into otlp
markphelps Feb 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DEPRECATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Description.

> since [UNRELEASED]()

Enabling OpenTelemetry tracing with the Jaeger expoerter via `tracing.jaeger` is deprecated in favor of setting the `tracing.backend` to `jaeger` and `tracing.enabled` to `true`.
Enabling OpenTelemetry tracing with the Jaeger expoerter via `tracing.jaeger` is deprecated in favor of setting the `tracing.exporter` to `jaeger` and `tracing.enabled` to `true`.

=== Before

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Flipt supports use cases such as:
- :rocket: **Speed** - Since Flipt is co-located with your existing services, you do not have to communicate across the internet which can add excessive latency and slow down your applications.
- :white_check_mark: **Simplicity** - Flipt is a single binary with no external dependencies by default.
- :thumbsup: **Compatibility** - REST, GRPC, MySQL, Postgres, CockroachDB, SQLite, Redis... Flipt supports it all.
- :eyes: **Observability** - Flipt integrates with [Prometheus](https://prometheus.io/) and [OpenTelemetry](https://opentelemetry.io/) to provide metrics and tracing. We support sending trace data to [Jaeger](https://www.jaegertracing.io/) and [Zipkin](https://zipkin.io/) backends.
- :eyes: **Observability** - Flipt integrates with [Prometheus](https://prometheus.io/) and [OpenTelemetry](https://opentelemetry.io/) to provide metrics and tracing. We support sending trace data to [Jaeger](https://www.jaegertracing.io/), [Zipkin](https://zipkin.io/), and [OpenTelemetry Protocol (OTLP)](https://opentelemetry.io/docs/reference/specification/protocol/) backends.

<br clear="both"/>

Expand Down
2 changes: 1 addition & 1 deletion config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

# tracing:
# enabled: false
# backend: jaeger
# exporter: jaeger
# jaeger:
# host: localhost
# port: 6831
Expand Down
7 changes: 6 additions & 1 deletion config/flipt.schema.cue
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ import "strings"

#tracing: {
enabled?: bool | *false
backend?: "jaeger" | "zipkin" | *"jaeger"
exporter?: "jaeger" | "zipkin" | "otlp" | *"jaeger"

// Jaeger
jaeger?: {
Expand All @@ -145,6 +145,11 @@ import "strings"
zipkin?: {
endpoint?: string | *"http://localhost:9411/api/v2/spans"
}

// OTLP
otlp?: {
endpoint?: string | *"localhost:4317"
}
}

#ui: enabled?: bool | *true
Expand Down
15 changes: 13 additions & 2 deletions config/flipt.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,9 @@
"type": "boolean",
"default": false
},
"backend": {
"exporter": {
"type": "string",
"enum": ["jaeger", "zipkin"],
"enum": ["jaeger", "zipkin", "otlp"],
"default": "jaeger"
},
"jaeger": {
Expand Down Expand Up @@ -474,6 +474,17 @@
}
},
"title": "Zipkin"
},
"otlp": {
"type": "object",
"additionalProperties": false,
"properties": {
"endpoint": {
"type": "string",
"default": "localhost:4317"
}
},
"title": "OTLP"
}
},
"title": "Tracing"
Expand Down
1 change: 1 addition & 0 deletions examples/authentication/dex/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ services:
- flipt_network
flipt:
image: flipt/flipt:latest
command: ["./flipt", "--force-migrate"]
ports:
- "8080:8080"
volumes:
Expand Down
1 change: 1 addition & 0 deletions examples/authentication/proxy/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ services:

flipt:
image: flipt/flipt:latest
command: ["./flipt", "--force-migrate"]
# Note: no ports are exposed publicly as Caddy acts as a reverse proxy,
# proxying all requests to 8080 to the Flipt container
depends_on:
Expand Down
2 changes: 1 addition & 1 deletion examples/cockroachdb/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
environment:
- FLIPT_DB_URL=cockroach://root@crdb:26257/defaultdb?sslmode=disable
- FLIPT_LOG_LEVEL=debug
command: ["./tmp/wait-for-it.sh", "crdb:26257", "--", "./flipt"]
command: ["./tmp/wait-for-it.sh", "crdb:26257", "--", "./flipt", "--force-migrate"]

networks:
flipt_network:
1 change: 1 addition & 0 deletions examples/images/opentelemetry.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/mysql/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
environment:
- FLIPT_DB_URL=mysql://mysql:password@mysql:3306/flipt
- FLIPT_LOG_LEVEL=debug
command: ["./tmp/wait-for-it.sh", "mysql:3306", "--", "./flipt"]
command: ["./tmp/wait-for-it.sh", "mysql:3306", "--", "./flipt", "--force-migrate"]

networks:
flipt_network:
5 changes: 3 additions & 2 deletions examples/openfeature/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
- "COLLECTOR_ZIPKIN_HTTP_PORT=9411"

flipt:
image: flipt/openfeature:latest
build: ../..
command: ["./flipt", "--force-migrate"]
depends_on:
- jaeger
Expand All @@ -22,7 +22,8 @@ services:
environment:
- "FLIPT_LOG_LEVEL=debug"
- "FLIPT_TELMETRY_ENABLED=false"
- "FLIPT_TRACING_JAEGER_ENABLED=true"
- "FLIPT_TRACING_ENABLED=true"
- "FLIPT_TRACING_EXPORTER=jaeger"
- "FLIPT_TRACING_JAEGER_HOST=jaeger"
volumes:
- "./flipt.db:/var/opt/flipt/flipt.db"
Expand Down
2 changes: 1 addition & 1 deletion examples/openfeature/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,6 @@ func main() {
log.Println("Flipt UI available at http://localhost:8080")
log.Println("Demo API available at http://localhost:8000/api")
log.Println("Jaeger UI available at http://localhost:16686")
log.Print("\n -> run 'curl http://localhost:8000/api/greeting?user=xyz'\n")
log.Print("\n -> run 'curl \"http://localhost:8000/api/greeting?user=xyz\"'\n")
log.Fatal(http.ListenAndServe(":8000", router))
}
2 changes: 1 addition & 1 deletion examples/postgres/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
environment:
- FLIPT_DB_URL=postgres://postgres:password@postgres:5432/flipt?sslmode=disable
- FLIPT_LOG_LEVEL=debug
command: ["./tmp/wait-for-it.sh", "postgres:5432", "--", "./flipt"]
command: ["./tmp/wait-for-it.sh", "postgres:5432", "--", "./flipt", "--force-migrate"]

networks:
flipt_network:
1 change: 1 addition & 0 deletions examples/prometheus/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ services:

flipt:
image: flipt/flipt:latest
command: ["./flipt", "--force-migrate"]
depends_on:
- prometheus
ports:
Expand Down
2 changes: 1 addition & 1 deletion examples/redis/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
- FLIPT_CACHE_REDIS_HOST=redis
- FLIPT_CACHE_REDIS_PORT=6379
- FLIPT_LOG_LEVEL=debug
command: ["./tmp/wait-for-it.sh", "redis:6379", "--", "./flipt"]
command: ["./tmp/wait-for-it.sh", "redis:6379", "--", "./flipt", "--force-migrate"]

networks:
flipt_network:
9 changes: 7 additions & 2 deletions examples/tracing/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# Tracing Examples

<p align="center">
<img src="../images/opentelemetry.svg" alt="OpenTelemetry" width=250 height=250 />
</p>

This directory contains examples of how to setup Flipt to export traces using the [OpenTelemetry](https://opentelemetry.io/) integration to configured backends.

For more information on how to setup and enable tracing, see the [Observability](https://www.flipt.io/docs/configuration/observability) documentation.

## Contents

* [Jaeger Backend](jaeger/README.md)
* [Zipkin Backend](zipkin/README.md)
* [OTLP Example](otlp/README.md)
* [Jaeger Example](jaeger/README.md)
* [Zipkin Example](zipkin/README.md)
3 changes: 2 additions & 1 deletion examples/tracing/jaeger/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ services:

flipt:
build: ../../..
command: ["./flipt", "--force-migrate"]
depends_on:
- jaeger
ports:
Expand All @@ -29,7 +30,7 @@ services:
environment:
- "FLIPT_LOG_LEVEL=debug"
- "FLIPT_TRACING_ENABLED=true"
- "FLIPT_TRACING_BACKEND=jaeger"
- "FLIPT_TRACING_EXPORTER=jaeger"
- "FLIPT_TRACING_JAEGER_HOST=jaeger"

networks:
Expand Down
34 changes: 34 additions & 0 deletions examples/tracing/otlp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# OTLP Example

This example shows how you can run Flipt with an [OpenTelemetry Protocol](https://opentelemetry.io/docs/reference/specification/protocol/) exporter which recieves, aggregates, and in-turn exports traces to both Jaeger and Zipken backends.

## Requirements

To run this example application you'll need:

* [Docker](https://docs.docker.com/install/)
* [docker-compose](https://docs.docker.com/compose/install/)

## Running the Example

1. Run `docker-compose up` from this directory
1. Open the Flipt UI (default: [http://localhost:8080](http://localhost:8080))
1. Create some sample data: Flags/Segments/etc. Perform a few evaluations in the Console.

### Jaeger UI

!['Jaeger Example'](../../images/jaeger.jpg)

1. Open the Jaeger UI (default: [http://localhost:16686](http://localhost:16686))
1. Select 'flipt' from the Service dropdown
1. Click 'Find Traces'
1. You should see a list of traces to explore

### Zipkin UI

!['Zipkin Example'](../../images/zipkin.png)

1. Open the Zipkin UI (default: [http://localhost:9411](http://localhost:9411))
1. Select `serviceName=flipt` from the search box
1. Click 'Run Query'
1. You should see a list of traces to explore
52 changes: 52 additions & 0 deletions examples/tracing/otlp/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
version: "3"

services:
jaeger:
image: jaegertracing/all-in-one:latest
ports:
- "16686:16686"
- "14268"
- "14250"
networks:
- flipt_network

zipkin:
image: openzipkin/zipkin:latest
ports:
- "9411:9411"
networks:
- flipt_network

otel:
image: otel/opentelemetry-collector:latest
command: ["--config=/etc/otel-collector-config.yaml"]
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
- "55679:55679" # zpages extension
depends_on:
- jaeger
- zipkin
networks:
- flipt_network

flipt:
build: ../../..
command: ["./flipt", "--force-migrate"]
depends_on:
- otel
ports:
- "8080:8080"
networks:
- flipt_network
environment:
- "FLIPT_LOG_LEVEL=debug"
- "FLIPT_TRACING_ENABLED=true"
- "FLIPT_TRACING_EXPORTER=otlp"
- "FLIPT_TRACING_OTLP_ENDPOINT=otel:4317"

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

exporters:
logging:

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

jaeger:
endpoint: jaeger:14250
tls:
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, zipkin, jaeger]
3 changes: 2 additions & 1 deletion examples/tracing/zipkin/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ services:

flipt:
build: ../../..
command: ["./flipt", "--force-migrate"]
depends_on:
- zipkin
ports:
Expand All @@ -19,7 +20,7 @@ services:
environment:
- "FLIPT_LOG_LEVEL=debug"
- "FLIPT_TRACING_ENABLED=true"
- "FLIPT_TRACING_BACKEND=zipkin"
- "FLIPT_TRACING_EXPORTER=zipkin"
- "FLIPT_TRACING_ZIPKIN_ENDPOINT=http://zipkin:9411/api/v2/spans"

networks:
Expand Down
6 changes: 5 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ require (
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.37.0
go.opentelemetry.io/otel v1.12.0
go.opentelemetry.io/otel/exporters/jaeger v1.12.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.12.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.12.0
go.opentelemetry.io/otel/exporters/prometheus v0.34.0
go.opentelemetry.io/otel/exporters/zipkin v1.12.0
go.opentelemetry.io/otel/metric v0.34.0
Expand All @@ -50,7 +52,7 @@ require (
golang.org/x/exp v0.0.0-20221012211006-4de253d81b95
golang.org/x/net v0.5.0
golang.org/x/sync v0.1.0
google.golang.org/genproto v0.0.0-20221227171554-f9683d7f8bef
google.golang.org/genproto v0.0.0-20230202175211-008b39050e57
google.golang.org/grpc v1.52.3
google.golang.org/protobuf v1.28.1
gopkg.in/segmentio/analytics-go.v3 v3.1.0
Expand Down Expand Up @@ -123,6 +125,8 @@ require (
github.com/vmihailenco/msgpack/v5 v5.3.4 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.12.0 // indirect
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/crypto v0.0.0-20221010152910-d6f0a8c073c2 // indirect
Expand Down
Loading