Bound Tempo blocks and complete telemetry diagnostics

This commit is contained in:
Самохвалов Андрей Ремович
2026-10-02 17:06:13 +03:00
parent 43bcde73de
commit f1963e5f19
5 changed files with 36 additions and 10 deletions
+1
View File
@@ -34,6 +34,7 @@ services:
tempo:
image: grafana/tempo:2.9.5
mem_limit: 768m
command: ["-config.file=/etc/tempo/config.yaml"]
volumes:
- ./infra/tempo/config.yaml:/etc/tempo/config.yaml:ro
+18 -4
View File
@@ -94,7 +94,7 @@
"targets": [
{
"refId": "A",
"expr": "sum(rate(messenger_http_requests_total{status_class=\"5xx\",route!~\"/health/.*\"}[1m])) / clamp_min(sum(rate(messenger_http_requests_total{route!~\"/health/.*\"}[1m])),0.001)",
"expr": "(sum(rate(messenger_http_requests_total{status_class=\"5xx\",route!~\"/health/.*\"}[1m])) or vector(0)) / clamp_min(sum(rate(messenger_http_requests_total{route!~\"/health/.*\"}[1m])),0.001)",
"legendFormat": "series 1"
}
],
@@ -519,17 +519,17 @@
},
{
"refId": "B",
"expr": "sum(rate(otelcol_exporter_send_failed_metric_points_total[1m]))",
"expr": "sum(rate(otelcol_exporter_send_failed_metric_points[1m]))",
"legendFormat": "series 2"
},
{
"refId": "C",
"expr": "sum(rate(otelcol_exporter_send_failed_log_records_total[1m]))",
"expr": "sum(rate(otelcol_exporter_send_failed_log_records[1m]))",
"legendFormat": "series 3"
},
{
"refId": "D",
"expr": "sum(rate(otelcol_exporter_send_failed_spans_total[1m]))",
"expr": "sum(rate(otelcol_exporter_send_failed_spans[1m]))",
"legendFormat": "series 4"
}
],
@@ -587,6 +587,20 @@
"x": 0,
"y": 56
}
},
{
"id": 16,
"type": "timeseries",
"title": "HTTP 4xx RPS (client responses)",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"targets": [{
"refId": "A",
"expr": "sum(rate(messenger_http_requests_total{status_class=\"4xx\",route!~\"/health/.*\"}[1m])) or vector(0)",
"legendFormat": "4xx"
}],
"fieldConfig": {"defaults": {"unit": "reqps", "min": 0}, "overrides": []},
"options": {"legend": {"displayMode": "list", "placement": "bottom"}},
"gridPos": {"h": 8, "w": 12, "x": 12, "y": 56}
}
]
}
+5
View File
@@ -8,6 +8,11 @@ distributor:
grpc:
endpoint: 0.0.0.0:4317
ingester:
max_block_bytes: 5000000
max_block_duration: 1m
concurrent_flushes: 1
storage:
trace:
backend: local
+1 -1
View File
@@ -14,7 +14,7 @@ QUERIES = {
"http_5xx_ratio_30s": 'sum(rate(messenger_http_requests_total{status_class="5xx",route!~"/health/.*"}[30s])) / clamp_min(sum(rate(messenger_http_requests_total{route!~"/health/.*"}[30s])),0.001)',
"queue_oldest_seconds": 'max(messenger_queue_oldest_age_seconds{queue_name="attachments.process"})',
"ready_slow_ratio_30s": '(sum(rate(messenger_attachments_ready_duration_seconds_count[30s])) - sum(rate(messenger_attachments_ready_duration_seconds_bucket{le="5"}[30s]))) / clamp_min(sum(rate(messenger_attachments_ready_duration_seconds_count[30s])),0.001)',
"collector_failed_spans": 'sum(otelcol_exporter_send_failed_spans_total)',
"collector_failed_spans": 'sum(otelcol_exporter_send_failed_spans)',
}
+11 -5
View File
@@ -14,6 +14,8 @@ import psycopg
from argon2 import PasswordHasher
from argon2.exceptions import InvalidHashError, VerificationError
from fastapi import HTTPException
from opentelemetry import trace
from opentelemetry.trace import Status, StatusCode
from psycopg.errors import UniqueViolation
from psycopg_pool import PoolTimeout
@@ -21,6 +23,7 @@ from . import db
from .auth import BASIC_CHALLENGE, BEARER_CHALLENGE, token_hash, unauthorized
password_hasher = PasswordHasher()
tracer = trace.get_tracer(__name__)
def timestamp(value: datetime) -> str:
@@ -53,11 +56,14 @@ def decode_cursor(cursor: str | None, resource: str) -> tuple[datetime, UUID] |
@contextmanager
def connection():
try:
with db.pool().connection() as conn:
yield conn
except (psycopg.Error, PoolTimeout, OSError):
raise HTTPException(503) from None
with tracer.start_as_current_span("db.store", record_exception=False, set_status_on_exception=False) as span:
span.set_attribute("db.system.name", "postgresql")
try:
with db.pool().connection() as conn:
yield conn
except (psycopg.Error, PoolTimeout, OSError):
span.set_status(Status(StatusCode.ERROR))
raise HTTPException(503) from None
def user_view(row: dict) -> dict: