Перенос решения ЛР 6 без изменений (src, migrations, student-tests, bench, infra, scripts, compose, Dockerfile, docs)

This commit is contained in:
Alexey Bodanyuk
2026-11-27 16:01:21 +03:00
parent 20afc2c790
commit 6435b6a1c5
111 changed files with 19604 additions and 0 deletions
+93
View File
@@ -0,0 +1,93 @@
# OpenTelemetry Collector (otel/opentelemetry-collector-contrib 0.165.0), lab 6.
#
# API x2 / relay / worker --OTLP/HTTP protobuf :4318--> [receiver otlp]
# -> memory_limiter -> batch -> exporters:
# traces -> Tempo (otlp_http/tempo, http://tempo:4318/v1/traces)
# metrics -> Prometheus (otlp_http/prometheus, http://prometheus:9090/api/v1/otlp/v1/metrics)
# logs -> Loki (otlp_http/loki, http://loki:3100/otlp/v1/logs)
#
# The Collector stores nothing for long: it receives, limits, batches and forwards. When a backend
# is down, each exporter keeps a BOUNDED queue (sending_queue) and retries for at most
# max_elapsed_time; then the data is dropped and counted (otelcol_exporter_send_failed_*,
# otelcol_exporter_enqueue_failed_*). memory_limiter refuses new data above its limit (the SDKs
# get a retryable error and drop after their own bounded queue) instead of growing until OOM.
# Its own metrics: Prometheus scrapes :8888 (otelcol_*). Only on the internal `telemetry` network.
#
# Traces pipeline variants (track 1, docs/TRACK1.md): this file keeps EVERY span; the overlay
# traces-tail.yaml (passed as a second --config, compose OTEL_COLLECTOR_TRACES) adds tail sampling.
extensions:
health_check:
endpoint: 0.0.0.0:13133
receivers:
otlp:
protocols:
http:
endpoint: 0.0.0.0:4318
max_request_body_size: 8388608 # 8 MiB per export request
processors:
# First in every pipeline. Container limit 512 MiB: soft limit = 400 - 80 = 320 MiB (start
# refusing + GC), hard limit 400 MiB (forced GC). The contrib binary alone is ~150 MiB RSS;
# 256 MiB of container memory left the limiter refusing data at idle. GOMEMLIMIT = 360 MiB.
memory_limiter:
check_interval: 1s
limit_mib: 400
spike_limit_mib: 80
# Fewer, larger requests to the backends; at most 2 s of delay.
batch:
send_batch_size: 1024
send_batch_max_size: 2048
timeout: 2s
exporters:
otlp_http/tempo:
endpoint: http://tempo:4318
timeout: 5s
sending_queue: &queue
enabled: true
num_consumers: 2
queue_size: 100 # batches (<= 2048 items each): bounded, in memory only
retry_on_failure: &retry
enabled: true
initial_interval: 1s
max_interval: 10s
max_elapsed_time: 60s # then the batch is dropped (counted), never retried forever
otlp_http/prometheus:
endpoint: http://prometheus:9090/api/v1/otlp
timeout: 5s
sending_queue: *queue
retry_on_failure: *retry
otlp_http/loki:
endpoint: http://loki:3100/otlp
timeout: 5s
sending_queue: *queue
retry_on_failure: *retry
service:
extensions: [health_check]
telemetry:
logs:
level: warn
metrics:
level: normal
readers:
- pull:
exporter:
prometheus:
host: 0.0.0.0
port: 8888
pipelines:
traces:
receivers: [otlp]
processors: [memory_limiter, batch]
exporters: [otlp_http/tempo]
metrics:
receivers: [otlp]
processors: [memory_limiter, batch]
exporters: [otlp_http/prometheus]
logs:
receivers: [otlp]
processors: [memory_limiter, batch]
exporters: [otlp_http/loki]
+6
View File
@@ -0,0 +1,6 @@
# Overlay for collector.yaml: keep every received span (no tail sampling). Selected by
# OTEL_COLLECTOR_TRACES=traces-all (compose). Lists are replaced, maps are merged by the Collector.
service:
pipelines:
traces:
processors: [memory_limiter, batch]
+39
View File
@@ -0,0 +1,39 @@
# Overlay for collector.yaml: TAIL sampling of traces (track 1 "balanced" configuration,
# docs/TRACK1.md). The decision is taken per trace after decision_wait, when its spans are in:
# keep ALL traces with an error span (status ERROR: HTTP 5xx, failed/retried job, S3/DB error),
# keep ALL slow traces (root to last span >= 250 ms),
# keep 10 % of the rest (probabilistic, by trace id: the same trace -> the same decision).
# Head sampling in the SDK (OTEL_TRACES_SAMPLER_ARG) decides at the first span and cannot know
# whether the request will fail or be slow; tail sampling can, at the price of buffering spans
# in the Collector (num_traces x spans) for decision_wait.
#
# A job is processed seconds after its upload: those spans may arrive after the upload trace was
# decided. decision_cache remembers the decision per trace id, so late spans of a kept trace are
# kept, and late spans of a dropped one are dropped (unless they are errors/slow by themselves:
# then they form a partial trace - a documented limit of the approach).
processors:
tail_sampling:
decision_wait: 5s
num_traces: 20000
expected_new_traces_per_sec: 200
decision_cache:
sampled_cache_size: 100000
non_sampled_cache_size: 100000
policies:
- name: errors
type: status_code
status_code:
status_codes: [ERROR]
- name: slow
type: latency
latency:
threshold_ms: 250
- name: baseline
type: probabilistic
probabilistic:
sampling_percentage: 10
service:
pipelines:
traces:
processors: [memory_limiter, tail_sampling, batch]