* add staging ios app build script * feat(api): add OpenTelemetry LGTM stack for local observability Wire OTel traces, metrics, and logs through a collector to Tempo, Prometheus, and Loki, with custom LLM instrumentation, dev compose overlay, Grafana provisioning, env templates, and development.sh auto-start. * feat: expand observability, harden dev tooling, and fix expo staging UX Add business and LLM Prometheus metrics with Grafana dashboards, alerting, and a metrics verification script. Wire telemetry through adapters and core LLM paths, and document the local LGTM workflow. Fix development.sh for macOS bash 3.2, open Grafana and eval-web in Chrome, and repair eval-web auto-open (unbound EVAL_WEB_BROWSER_SCHEDULED). Merge internal-eval into the main dev script with improved compose handling. Require EXPO_PUBLIC_* at build time, improve iOS HTTP ATS for staging IPs, show memoir empty state instead of load errors when no chapters exist, and add jest env setup plus chapter list response normalization. * chore: enable Grafana Assistant Cursor plugin * fix: memoir empty state and repair withdrawn 0020_chapters_book_id stamp Show empty memoir UI when the chapter list succeeds with no items; treat auth/404 as non-fatal. Extend alembic revision repair so local dev DBs stamped with the removed 0020_chapters_book_id migration can roll back and upgrade to 0019. --------- Co-authored-by: Kevin <kevin@brighteng.org> Co-authored-by: Cursor <cursoragent@cursor.com>
65 lines
2.3 KiB
Python
65 lines
2.3 KiB
Python
"""Business telemetry helpers (no real Collector required)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
from opentelemetry import trace
|
|
|
|
from app.core.business_telemetry import business_span
|
|
from app.core.config import settings
|
|
|
|
|
|
class TestBusinessSpan:
|
|
def test_disabled_is_noop(self, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
monkeypatch.setattr(settings, "otel_enabled", False)
|
|
with business_span("memoir.phase1", user_id="u1") as span:
|
|
assert span == trace.INVALID_SPAN
|
|
|
|
def test_filters_high_cardinality_attrs(self, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
monkeypatch.setattr(settings, "otel_enabled", True)
|
|
from opentelemetry.sdk.trace import TracerProvider
|
|
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
|
|
from opentelemetry.sdk.trace.export.in_memory_span_exporter import (
|
|
InMemorySpanExporter,
|
|
)
|
|
|
|
exporter = InMemorySpanExporter()
|
|
provider = TracerProvider()
|
|
provider.add_span_processor(SimpleSpanProcessor(exporter))
|
|
monkeypatch.setattr(
|
|
"app.core.business_telemetry.get_tracer",
|
|
lambda _name: provider.get_tracer("test"),
|
|
)
|
|
|
|
with business_span(
|
|
"memoir.phase2",
|
|
user_id="user-123",
|
|
chapter_category="childhood",
|
|
):
|
|
pass
|
|
|
|
spans = exporter.get_finished_spans()
|
|
assert spans
|
|
attrs = dict(spans[0].attributes or {})
|
|
assert attrs.get("business.chapter_category") == "childhood"
|
|
assert "business.user_id" not in attrs
|
|
|
|
def test_enabled_yields_span(self, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
monkeypatch.setattr(settings, "otel_enabled", True)
|
|
from opentelemetry.sdk.trace import TracerProvider
|
|
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
|
|
from opentelemetry.sdk.trace.export.in_memory_span_exporter import (
|
|
InMemorySpanExporter,
|
|
)
|
|
|
|
exporter = InMemorySpanExporter()
|
|
provider = TracerProvider()
|
|
provider.add_span_processor(SimpleSpanProcessor(exporter))
|
|
monkeypatch.setattr(
|
|
"app.core.business_telemetry.get_tracer",
|
|
lambda _name: provider.get_tracer("test"),
|
|
)
|
|
|
|
with business_span("conversation.ws.process_turn") as span:
|
|
assert span.is_recording()
|