Skip to content
Open
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
13 changes: 13 additions & 0 deletions jdbc/ydb-token-app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM maven:3.9.11-eclipse-temurin-17 AS build
WORKDIR /workspace

COPY . .
RUN mvn -B -pl jdbc/ydb-token-app -am dependency:go-offline
RUN mvn -B -pl jdbc/ydb-token-app -am clean package org.springframework.boot:spring-boot-maven-plugin:repackage -DskipTests

FROM eclipse-temurin:17-jre
WORKDIR /app

COPY --from=build /workspace/jdbc/ydb-token-app/target/ydb-token-app-1.1.0-SNAPSHOT.jar /app/app.jar

ENTRYPOINT ["java", "-jar", "/app/app.jar"]
26 changes: 26 additions & 0 deletions jdbc/ydb-token-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,29 @@ The main parameters list:

All parameters can be passed directly when launching the application (in the format `--param_name=value`) or can be
preconfigured in an `application.properties` file saved next to the executable jar of the application.

### Local observability infrastructure

All Docker and observability-related configs are stored in `infra/` to keep the example sources clean:

- `infra/compose-e2e.yaml`
- `infra/application/application.properties`
- `infra/otel/otel-collector-config.yaml`
- `infra/prometheus/prometheus.yaml`
- `infra/tempo/tempo.yaml`
- `infra/grafana/...`
- `infra/ydb/...`

Run the full stack:

```bash
cd jdbc/ydb-token-app
docker compose -f infra/compose-e2e.yaml up -d
```

Run one-shot app commands in the same stack:

```bash
cd jdbc/ydb-token-app
docker compose -f infra/compose-e2e.yaml run --rm ydb-token-app clean init load run
```
7 changes: 7 additions & 0 deletions jdbc/ydb-token-app/infra/application/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
app.connection=grpc://ydb:2136/local
app.threadsCount=32
app.workload.duration=180
app.rpsLimit=-1
app.otel.enabled=true
app.otel.endpoint=http://otel-collector:4317
app.otel.serviceName=ydb-token-app
76 changes: 76 additions & 0 deletions jdbc/ydb-token-app/infra/compose-e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
services:
ydb-token-app:
build:
context: ../../..
dockerfile: jdbc/ydb-token-app/Dockerfile
depends_on:
ydb:
condition: service_healthy
otel-collector:
condition: service_started
command:
- "clean"
- "init"
- "load"
- "run"
volumes:
- ./application/application.properties:/app/config/application.properties:ro
restart: on-failure

ydb:
image: ydbplatform/local-ydb:trunk
platform: linux/amd64
command: [ "--config-path", "/ydb_config/ydb-config.yaml" ]
environment:
YDB_DEFAULT_LOG_LEVEL: NOTICE
GRPC_TLS_PORT: "2135"
GRPC_PORT: "2136"
MON_PORT: "8765"
YDB_USE_IN_MEMORY_PDISKS: "true"
ports:
- "2135:2135"
- "2136:2136"
- "8765:8765"
volumes:
- ./ydb:/ydb_config:ro

otel-collector:
image: otel/opentelemetry-collector-contrib:latest
command: [ "--config=/etc/otelcol/config.yaml" ]
depends_on: [ tempo ]
volumes:
- ./otel/otel-collector-config.yaml:/etc/otelcol/config.yaml:ro
ports:
- "4317:4317"
- "4318:4318"
- "9464:9464"
- "13133:13133"
- "55679:55679"

prometheus:
image: prom/prometheus:latest
volumes:
- ./prometheus/prometheus.yaml:/etc/prometheus/prometheus.yml:ro
ports:
- "9090:9090"
depends_on: [ otel-collector ]

tempo:
image: grafana/tempo:2.4.1
command: [ "-config.file=/etc/tempo.yaml" ]
volumes:
- ./tempo/tempo.yaml:/etc/tempo.yaml:ro
ports:
- "3200:3200"

grafana:
image: grafana/grafana:10.4.2
environment:
GF_AUTH_ANONYMOUS_ENABLED: "true"
GF_AUTH_ANONYMOUS_ORG_ROLE: "Admin"
volumes:
- ./grafana/provisioning:/etc/grafana/provisioning:ro
- ./grafana/dashboards:/var/lib/grafana/dashboards:ro
ports:
- "3000:3000"
depends_on: [ prometheus, tempo ]
3 changes: 3 additions & 0 deletions jdbc/ydb-token-app/infra/grafana/dashboards/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This folder is intentionally left empty.

Grafana is provisioned with Tempo + Prometheus datasources; use **Explore** to search traces.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: 1

providers:
- name: 'default'
orgId: 1
folder: ''
type: file
disableDeletion: true
editable: false
options:
path: /var/lib/grafana/dashboards
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: 1

datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true
editable: false

- name: Tempo
type: tempo
access: proxy
url: http://tempo:3200
editable: false
jsonData:
tracesToMetrics:
datasourceUid: Prometheus
serviceMap:
datasourceUid: Prometheus
44 changes: 44 additions & 0 deletions jdbc/ydb-token-app/infra/otel/otel-collector-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318

processors:
batch: { }

exporters:
prometheus:
endpoint: 0.0.0.0:9464
resource_to_telemetry_conversion:
enabled: true

otlp/tempo:
endpoint: tempo:4317
tls:
insecure: true

debug:
verbosity: detailed

extensions:
health_check:
endpoint: 0.0.0.0:13133

zpages:
endpoint: 0.0.0.0:55679

service:
extensions: [ health_check, zpages ]
pipelines:
metrics:
receivers: [ otlp ]
processors: [ batch ]
exporters: [ prometheus ]

traces:
receivers: [ otlp ]
processors: [ batch ]
exporters: [ otlp/tempo, debug ]
7 changes: 7 additions & 0 deletions jdbc/ydb-token-app/infra/prometheus/prometheus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
global:
scrape_interval: 5s

scrape_configs:
- job_name: otel-collector
static_configs:
- targets: ["otel-collector:9464"]
15 changes: 15 additions & 0 deletions jdbc/ydb-token-app/infra/tempo/tempo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
server:
http_listen_port: 3200

distributor:
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317

storage:
trace:
backend: local
local:
path: /tmp/tempo
28 changes: 28 additions & 0 deletions jdbc/ydb-token-app/infra/ydb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# YDB server-side tracing (OpenTelemetry)

This folder is used to keep a **custom YDB config** that enables server-side OpenTelemetry tracing.

## 1) Export the default config from a running container

If YDB is running as `ydb-local`:

```bash
docker cp ydb-local:/ydb_data/cluster/kikimr_configs/config.yaml ./infra/ydb/ydb-config.yaml
```

## 2) Enable OpenTelemetry exporter in the config

Edit `ydb-config.yaml` and add the contents of `otel-tracing-snippet.yaml` (usually as a top-level section).

Default OTLP endpoint (inside docker-compose network): `grpc://otel-collector:4317`
Default service name (so you can find it in Tempo/Grafana): `ydb`

## 3) Run with the overridden config

Restart YDB:

```bash
docker compose -f infra/compose-e2e.yaml up -d --force-recreate ydb
```

Now you should see additional server-side traces in Tempo/Grafana.
26 changes: 26 additions & 0 deletions jdbc/ydb-token-app/infra/ydb/otel-tracing-snippet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
tracing_config:
backend:
opentelemetry:
collector_url: grpc://otel-collector:4317
service_name: ydb
external_throttling:
- scope:
database: /local
max_traces_per_minute: 60
max_traces_burst: 3
# Highest tracing detail for *sampled* traces (YDB-generated trace-id).
# Note: requests with an external `traceparent` are traced at level 13 (Detailed) per YDB docs.
sampling:
- scope:
database: /local
fraction: 1
level: 15
max_traces_per_minute: 1000
max_traces_burst: 100
uploader:
max_exported_spans_per_second: 30
max_spans_in_batch: 100
max_bytes_in_batch: 10485760 # 10 MiB
max_export_requests_inflight: 3
max_batch_accumulation_milliseconds: 5000
span_export_timeout_seconds: 120
Loading
Loading