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: open telemetry traces setup #1009

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 1 addition & 7 deletions .github/workflows/container-smoke-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,8 @@ jobs:
with:
fetch-depth: 0

- name: Install requirements
run: make install-dev

- name: Resolve Karapace version
run: |
source ./venv/bin/activate
KARAPACE_VERSION=$(python -c "from karapace import version; print(version.__version__)")
echo KARAPACE_VERSION=$KARAPACE_VERSION >> $GITHUB_ENV
run: echo KARAPACE_VERSION="$(git describe --tags | cut -d '-' -f -2 | sed 's/-/.dev/g')" >> $GITHUB_ENV

- run: echo "RUNNER_UID=$(id -u)" >> $GITHUB_ENV
- run: echo "RUNNER_GID=$(id -g)" >> $GITHUB_ENV
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Need fetch-depth 0 to fetch tags, see https://github.com/actions/checkout/issues/701
with:
fetch-depth: 0

- uses: actions/setup-python@v5
with:
cache: pip
python-version: '3.12'

- name: Install requirements
run: make install-dev

- name: Resolve Karapace version
run: |
source ./venv/bin/activate
KARAPACE_VERSION=$(python -c "from karapace import version; print(version.__version__)")
echo KARAPACE_VERSION=$KARAPACE_VERSION >> $GITHUB_ENV
run: echo KARAPACE_VERSION="$(git describe --tags | cut -d '-' -f -2 | sed 's/-/.dev/g')" >> $GITHUB_ENV

- run: echo "RUNNER_UID=$(id -u)" >> $GITHUB_ENV
- run: echo "RUNNER_GID=$(id -g)" >> $GITHUB_ENV
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ jobs:
--showlocals
steps:
- uses: actions/checkout@v4
# Need fetch-depth 0 to fetch tags, see https://github.com/actions/checkout/issues/701
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
Expand All @@ -40,14 +43,8 @@ jobs:
with:
go-version: '1.21.0'

- name: Install requirements
run: make install-dev

- name: Resolve Karapace version
run: |
source ./venv/bin/activate
KARAPACE_VERSION=$(python -c "from karapace import version; print(version.__version__)")
echo KARAPACE_VERSION=$KARAPACE_VERSION >> $GITHUB_ENV
run: echo KARAPACE_VERSION="$(git describe --tags | cut -d '-' -f -2 | sed 's/-/.dev/g')" >> $GITHUB_ENV

- run: echo "RUNNER_UID=$(id -u)" >> $GITHUB_ENV
- run: echo "RUNNER_GID=$(id -g)" >> $GITHUB_ENV
Expand Down
87 changes: 57 additions & 30 deletions container/compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
---
version: '3'
services:
zookeeper:
image: confluentinc/cp-zookeeper:latest
Expand Down Expand Up @@ -67,6 +65,7 @@ services:
- schema_registry
depends_on:
- kafka
- opentelemetry-collector
ports:
- 8081:8081
environment:
Expand All @@ -85,6 +84,13 @@ services:
KARAPACE_STATSD_PORT: 8125
KARAPACE_KAFKA_SCHEMA_READER_STRICT_MODE: false
KARAPACE_KAFKA_RETRIABLE_ERRORS_SILENCED: true
KARAPACE_TAGS__APP: karapace-schema-registry
KARAPACE_TELEMETRY__OTEL_ENDPOINT_URL: http://opentelemetry-collector:4317
KARAPACE_TELEMETRY__RESOURCE_SERVICE_NAME: karapace-schema-registry
KARAPACE_TELEMETRY__RESOURCE_SERVICE_INSTANCE_ID: sr1
KARAPACE_TELEMETRY__RESOURCE_TELEMETRY_SDK_NAME: opentelemetry
KARAPACE_TELEMETRY__RESOURCE_TELEMETRY_SDK_LANGUAGE: python
KARAPACE_TELEMETRY__RESOURCE_TELEMETRY_SDK_VERSION: 1.27.0

karapace-rest-proxy:
image: ghcr.io/aiven-open/karapace:develop
Expand Down Expand Up @@ -133,44 +139,65 @@ services:
- karapace-schema-registry
- karapace-rest-proxy
volumes:
- ../tests:/opt/karapace/tests
- ../pytest.ini:/opt/karapace/pytest.ini
- ../mypy.ini:/opt/karapace/mypy.ini
- ../.flake8:/opt/karapace/.flake8
- ../.isort.cfg:/opt/karapace/.isort.cfg
- ../.pre-commit-config.yaml:/opt/karapace/.pre-commit-config.yaml
- ../.pylintrc:/opt/karapace/.pylintrc
- ../.coveragerc:/opt/karapace/.coveragerc
- ../.coverage.3.10:/opt/karapace/coverage/.coverage.3.10
- ../.coverage.3.11:/opt/karapace/coverage/.coverage.3.11
- ../.coverage.3.12:/opt/karapace/coverage/.coverage.3.12
- ../tests:/opt/karapace/tests
- ../pytest.ini:/opt/karapace/pytest.ini
- ../mypy.ini:/opt/karapace/mypy.ini
- ../.flake8:/opt/karapace/.flake8
- ../.isort.cfg:/opt/karapace/.isort.cfg
- ../.pre-commit-config.yaml:/opt/karapace/.pre-commit-config.yaml
- ../.pylintrc:/opt/karapace/.pylintrc
- ../.coveragerc:/opt/karapace/.coveragerc
- ../.coverage.3.10:/opt/karapace/coverage/.coverage.3.10
- ../.coverage.3.11:/opt/karapace/coverage/.coverage.3.11
- ../.coverage.3.12:/opt/karapace/coverage/.coverage.3.12
environment:
- COVERAGE_FILE
- COVERAGE_RCFILE=/opt/karapace/.coveragerc

prometheus:
image: prom/prometheus
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- ./prometheus/rules.yml:/etc/prometheus/rules.yml
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- ./prometheus/rules.yml:/etc/prometheus/rules.yml
depends_on:
- karapace-schema-registry
- karapace-rest-proxy
- opentelemetry-collector
ports:
- 9090:9090

grafana:
image: grafana/grafana
environment:
GF_SECURITY_ADMIN_USER: karapace
GF_SECURITY_ADMIN_PASSWORD: karapace
GF_PATHS_PROVISIONING: /grafana/provisioning
ports:
- 3000:3000
volumes:
- ./grafana/dashboards:/grafana/dashboards
- ./grafana/provisioning:/grafana/provisioning
image: grafana/grafana
environment:
GF_SECURITY_ADMIN_USER: karapace
GF_SECURITY_ADMIN_PASSWORD: karapace
GF_PATHS_PROVISIONING: /grafana/provisioning
ports:
- 3000:3000
volumes:
- ./grafana/dashboards:/grafana/dashboards
- ./grafana/provisioning:/grafana/provisioning

statsd-exporter:
image: prom/statsd-exporter
command: "--statsd.listen-udp=:8125 --web.listen-address=:9102"
ports:
- 9102:9102
- 8125:8125/udp
image: prom/statsd-exporter
command: --statsd.listen-udp=:8125 --web.listen-address=:9102
ports:
- 9102:9102
- 8125:8125/udp

opentelemetry-collector:
image: otel/opentelemetry-collector-contrib:latest
command: --config=/etc/collector-config.yaml
volumes:
- ./opentelemetry/collector-config.yaml:/etc/collector-config.yaml
ports: # 4317=OTLP-gRPC-receiver | 8888=prom-collector-metrics | 8889=prom-exporter-metrics
- 4317:4317
- 8888:8888
- 8889:8889

jaeger:
image: jaegertracing/all-in-one:latest
ports: # 6831=agent | 16686=UI | 14268=spans | 4317=metrics (not exposing, clashes with opentelemetry-collector)
- 6831:6831/udp
- 16686:16686
- 14268:14268
29 changes: 29 additions & 0 deletions container/opentelemetry/collector-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
receivers:
otlp:
protocols:
grpc:
endpoint: opentelemetry-collector:4317

processors:

extensions:
health_check: {}

exporters:
otlp:
endpoint: jaeger:4317
tls:
insecure: true
otlphttp/prometheus:
endpoint: prometheus:9090/api/v1/otlp
tls:
insecure: true

service:
pipelines:
traces:
receivers: [otlp]
exporters: [otlp]
metrics:
receivers: [otlp]
exporters: [otlphttp/prometheus]
5 changes: 5 additions & 0 deletions container/prometheus/prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ scrape_configs:
static_configs:
- targets:
- statsd-exporter:9102

- job_name: opentelemetry-collector
static_configs:
- targets:
- opentelemetry-collector:8888
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ warn_no_return = True
warn_unreachable = True
strict_equality = True

[mypy-schema_registry.schema_registry_apis]
[mypy-schema_registry.controller]
ignore_errors = True

[mypy-karapace.compatibility.jsonschema.checks]
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ dependencies = [
"zstandard",
"prometheus-client == 0.20.0",
"yarl == 1.12.1",
"opentelemetry-api == 1.28.2",
"opentelemetry-sdk == 1.28.2",
"opentelemetry-instrumentation-fastapi == 0.49b2",
"opentelemetry-api == 1.27.0",
"opentelemetry-sdk == 1.27.0",
"opentelemetry-exporter-otlp == 1.27.0",
"dependency-injector == 4.43.0",

# Patched dependencies
Expand Down
Loading
Loading