:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(apm): add services and endpoints tabs to application observability (#123546)
Daniel Visca0893738fca0f
diff --git a/posthog/test/repo_invariants/test_pagination_contract.py b/posthog/test/repo_invariants/test_pagination_contract.pyindex f9fbbd21ef26..9c14ccf69aaa 100644--- a/posthog/test/repo_invariants/test_pagination_contract.py+++ b/posthog/test/repo_invariants/test_pagination_contract.py@@ -30,6 +30,8 @@ EXISTING_CUSTOM_LIST_VIEWSETS = {"products.aeo.backend.presentation.views.AEOPromptViewSet",# Returns one bounded object (capped at SERVICES_LIMIT services), not a page of rows."products.apm.backend.presentation.views.ServicesHealthViewSet",+ # Returns one bounded object (capped at ENDPOINTS_LIMIT rows), not a page of rows.+ "products.apm.backend.presentation.views.EndpointsHealthViewSet","ee.api.billing.BillingViewset","ee.api.quota_limits.QuotaLimitsViewSet","products.subscriptions.backend.presentation.views.SubscriptionDeliveryViewSet",diff --git a/products/apm/backend/facade/api.py b/products/apm/backend/facade/api.pyindex 9b7effad2529..ea97f389b892 100644--- a/products/apm/backend/facade/api.py+++ b/products/apm/backend/facade/api.py@@ -44,9 +44,17 @@ from products.apm.backend.logic.anomaly_detection.types import (TrafficTier,VerdictType,)-from products.apm.backend.logic.health.contract import HealthRow, HealthStatus, ServiceHealth, rank_services, status_of+from products.apm.backend.logic.health.contract import (+ EndpointHealth,+ HealthRow,+ HealthStatus,+ ServiceHealth,+ rank_services,+ status_of,+)from products.apm.backend.logic.health.sources import (ServicesHealthResult,+ list_endpoints_health as _list_endpoints_health,list_services_health as _list_services_health,)@@ -56,10 +64,12 @@ if TYPE_CHECKING:from posthog.models import Team__all__ = [+ "EndpointHealth","HealthRow","HealthStatus","ServiceHealth","ServicesHealthResult",+ "list_endpoints_health","list_services_health","rank_services","status_of",@@ -101,3 +111,12 @@ def list_services_health(Pure contracts out: the presentation layer serializes `ServicesHealthResult` without touching logic."""return _list_services_health(team=team, date_from=date_from, date_to=date_to, environment=environment)+++def list_endpoints_health(+ *, team: "Team", date_from: "datetime", date_to: "datetime", environment: str, service: str | None = None+) -> list[EndpointHealth]:+ """One health row per (service, entry span name) in the environment and window, worst first."""+ return _list_endpoints_health(+ team=team, date_from=date_from, date_to=date_to, environment=environment, service=service+ )diff --git a/products/apm/backend/logic/health/contract.py b/products/apm/backend/logic/health/contract.pyindex 240c11fb6960..3bfafc1c59f5 100644--- a/products/apm/backend/logic/health/contract.py+++ b/products/apm/backend/logic/health/contract.py@@ -40,6 +40,17 @@ class ServiceHealth:sparkline: tuple[int, ...] = ()+@dataclass(frozen=True)+class EndpointHealth:+ """One entry span name in one service: a route, an RPC, a consumed message, or a job."""++ service_name: str+ endpoint: str+ environment: str+ health: HealthRow+ status: HealthStatus = HealthStatus.GOOD++def status_of(health: HealthRow) -> HealthStatus:rate = health.error_rate or 0.0if rate >= SERIOUS_ERROR_RATE:@@ -56,3 +67,17 @@ def rank_services(rows: list[ServiceHealth]) -> list[ServiceHealth]:scored,key=lambda row: (_STATUS_RANK[row.status], -(row.health.error_rate or 0.0), row.service_name),)+++def rank_endpoints(rows: list[EndpointHealth]) -> list[EndpointHealth]:+ """The same order as rank_services, with the endpoint name after the service name."""+ scored = [replace(row, status=status_of(row.health)) for row in rows]+ return sorted(+ scored,+ key=lambda row: (+ _STATUS_RANK[row.status],+ -(row.health.error_rate or 0.0),+ row.service_name,+ row.endpoint,+ ),+ )diff --git a/products/apm/backend/logic/health/sources.py b/products/apm/backend/logic/health/sources.pyindex 2e87366dcb25..68e5128caabb 100644--- a/products/apm/backend/logic/health/sources.py+++ b/products/apm/backend/logic/health/sources.py@@ -1,7 +1,7 @@"""Reads the health row for every service in a window from the spans table.-A service's request rate comes from its server spans. A service that emits no server spans, which-is every consumer and worker in practice, falls back to its root spans so it still gets a row.+A service's request rate comes from its entry spans: server spans and consumer spans. A service+that emits neither, such as a scheduled job, falls back to its root spans so it still gets a row.The environment is the first non-empty resource attribute in the resolution order below, with thecluster name as the last fallback and `default` when nothing is set."""@@ -17,10 +17,17 @@ from posthog.hogql.query import execute_hogql_queryfrom posthog.clickhouse.client.connection import Workloadfrom posthog.models import Team-from products.apm.backend.logic.health.contract import HealthRow, ServiceHealth, rank_services+from products.apm.backend.logic.health.contract import (+ EndpointHealth,+ HealthRow,+ ServiceHealth,+ rank_endpoints,+ rank_services,+)SPARKLINE_POINTS = 24SERVICES_LIMIT = 500+ENDPOINTS_LIMIT = 500DEFAULT_ENVIRONMENT = "default"ENVIRONMENT_ATTRIBUTES = (@@ -61,8 +68,8 @@ def _window_where(date_from: datetime, date_to: datetime) -> ast.Expr:def _services_query(date_from: datetime, date_to: datetime, environment: str) -> ast.SelectQuery:- # Server spans are the request count. Root spans are the fallback for services with none, so a- # consumer's client spans count once each rather than once per downstream call.+ # Server and consumer spans are the request count. Root spans are the fallback for services with+ # neither, so a job's client spans count once each rather than once per downstream call.## A team with more services than SERVICES_LIMIT needs the worst ones to survive the cutoff, so# the ranking (error rate, then error count, then name — the same order rank_services applies)@@ -72,11 +79,11 @@ def _services_query(date_from: datetime, date_to: datetime, environment: str) ->"""SELECTservice_name,- countIf(kind = 2) AS server_spans,- if(countIf(kind = 2) > 0, countIf(kind = 2), countIf(is_root_span)) AS span_count,- if(countIf(kind = 2) > 0, countIf(kind = 2 AND status_code = 2), countIf(is_root_span AND status_code = 2)) AS error_count,- if(countIf(kind = 2) > 0,- quantileIf(0.95)(duration_nano, kind = 2),+ countIf(kind IN (2, 5)) AS entry_spans,+ if(countIf(kind IN (2, 5)) > 0, countIf(kind IN (2, 5)), countIf(is_root_span)) AS span_count,+ if(countIf(kind IN (2, 5)) > 0, countIf(kind IN (2, 5) AND status_code = 2), countIf(is_root_span AND status_code = 2)) AS error_count,+ if(countIf(kind IN (2, 5)) > 0,+ quantileIf(0.95)(duration_nano, kind IN (2, 5)),quantileIf(0.95)(duration_nano, is_root_span)) / 1e6 AS p95_msFROM posthog.trace_spansWHERE {where} AND {env_expr} = {environment}@@ -96,6 +103,40 @@ def _services_query(date_from: datetime, date_to: datetime, environment: str) ->return query+def _endpoints_query(date_from: datetime, date_to: datetime, environment: str, service: str | None) -> ast.SelectQuery:+ # An endpoint is an entry span name: what a server or consumer span handles, or what a root span+ # starts (a job with no server spans). This is the entry definition the Tracing service health+ # view uses, so a worker's job shows up here the same way it gets a row on the services tab.+ query = parse_select(+ """+ SELECT+ service_name,+ name,+ count() AS span_count,+ countIf(status_code = 2) AS error_count,+ quantile(0.95)(duration_nano) / 1e6 AS p95_ms+ FROM posthog.trace_spans+ WHERE {where} AND {env_expr} = {environment} AND {service_where} AND (is_root_span OR kind IN (2, 5))+ GROUP BY service_name, name+ ORDER BY error_count / span_count DESC, error_count DESC, service_name, name+ LIMIT {limit}+ """,+ placeholders={+ "where": _window_where(date_from, date_to),+ "env_expr": environment_expr(),+ "environment": ast.Constant(value=environment),+ "service_where": (+ parse_expr("service_name = {service}", placeholders={"service": ast.Constant(value=service)})+ if service+ else ast.Constant(value=True)+ ),+ "limit": ast.Constant(value=ENDPOINTS_LIMIT),+ },+ )+ assert isinstance(query, ast.SelectQuery)+ return query++def _sparkline_query(date_from: datetime, date_to: datetime, environment: str) -> ast.SelectQuery:# One bucket per point across the window; the client draws the counts in order.query = parse_select(@@ -103,7 +144,7 @@ def _sparkline_query(date_from: datetime, date_to: datetime, environment: str) -SELECTservice_name,toInt(floor(dateDiff('second', {date_from}, timestamp) / {bucket_seconds})) AS bucket,- countIf(kind = 2) AS server_spans,+ countIf(kind IN (2, 5)) AS entry_spans,countIf(is_root_span) AS root_spansFROM posthog.trace_spansWHERE {where} AND {env_expr} = {environment}@@ -150,13 +191,13 @@ def list_services_health(seconds = max(1.0, (date_to - date_from).total_seconds())rows = _run(team, _services_query(date_from, date_to, environment))sparklines: dict[str, list[int]] = {}- has_server: dict[str, bool] = {row[0]: row[1] > 0 for row in rows} # row[1] is server_spans- for service_name, bucket, server_spans, root_spans in _run(team, _sparkline_query(date_from, date_to, environment)):+ has_entry: dict[str, bool] = {row[0]: row[1] > 0 for row in rows} # row[1] is entry_spans+ for service_name, bucket, entry_spans, root_spans in _run(team, _sparkline_query(date_from, date_to, environment)):points = sparklines.setdefault(service_name, [0] * SPARKLINE_POINTS)if 0 <= bucket < SPARKLINE_POINTS:- points[bucket] += server_spans if has_server.get(service_name) else root_spans+ points[bucket] += entry_spans if has_entry.get(service_name) else root_spansservices = []- for service_name, _server_spans, span_count, error_count, p95_ms in rows:+ for service_name, _entry_spans, span_count, error_count, p95_ms in rows:if not span_count:continuehealth = HealthRow(@@ -176,3 +217,27 @@ def list_services_health()environments = [row[0] for row in _run(team, _environments_query(date_from, date_to))]return ServicesHealthResult(services=rank_services(services), environments=environments)+++def list_endpoints_health(+ *, team: Team, date_from: datetime, date_to: datetime, environment: str, service: str | None = None+) -> list[EndpointHealth]:+ seconds = max(1.0, (date_to - date_from).total_seconds())+ endpoints = [+ EndpointHealth(+ service_name=service_name,+ endpoint=name,+ environment=environment,+ health=HealthRow(+ request_rate=span_count / seconds,+ error_rate=error_count / span_count,+ p95_ms=float(p95_ms) if p95_ms is not None else None,+ span_count=int(span_count),+ error_count=int(error_count),+ ),+ )+ for service_name, name, span_count, error_count, p95_ms in _run(+ team, _endpoints_query(date_from, date_to, environment, service)+ )+ ]+ return rank_endpoints(endpoints)diff --git a/products/apm/backend/presentation/serializers.py b/products/apm/backend/presentation/serializers.pyindex a1a312537dec..af9295ed4c61 100644--- a/products/apm/backend/presentation/serializers.py+++ b/products/apm/backend/presentation/serializers.py@@ -19,6 +19,12 @@ class ServicesHealthRequestSerializer(serializers.Serializer):)+class EndpointsHealthRequestSerializer(ServicesHealthRequestSerializer):+ service = serializers.CharField(+ required=False, allow_blank=False, max_length=400, help_text="Only list the endpoints of this service."+ )++class HealthRowSerializer(serializers.Serializer):request_rate = serializers.FloatField(allow_null=True, help_text="Requests per second over the window.")error_rate = serializers.FloatField(allow_null=True, help_text="Share of requests with an error status, 0 to 1.")@@ -44,3 +50,20 @@ class ServicesHealthResponseSerializer(serializers.Serializer):environment = serializers.CharField(help_text="The environment the rows were computed for.")date_from = serializers.DateTimeField(help_text="Start of the window used.")date_to = serializers.DateTimeField(help_text="End of the window used.")+++class EndpointHealthSerializer(serializers.Serializer):+ service_name = serializers.CharField(help_text="The service.name resource attribute.")+ endpoint = serializers.CharField(help_text="The entry span name, for example the HTTP route or the job name.")+ environment = serializers.CharField(help_text="The environment the row was computed for.")+ status = serializers.ChoiceField(choices=HealthStatus.choices, help_text="Health band from the error rate.")+ health = HealthRowSerializer(help_text="The health row every surface renders.")+++@extend_schema_serializer(many=False)+class EndpointsHealthResponseSerializer(serializers.Serializer):+ results = EndpointHealthSerializer(many=True, help_text="One row per service and endpoint, worst status first.")+ environment = serializers.CharField(help_text="The environment the rows were computed for.")+ service = serializers.CharField(allow_null=True, help_text="The service filter applied, if any.")+ date_from = serializers.DateTimeField(help_text="Start of the window used.")+ date_to = serializers.DateTimeField(help_text="End of the window used.")diff --git a/products/apm/backend/presentation/views.py b/products/apm/backend/presentation/views.pyindex 456e04c6db1f..133758a36943 100644--- a/products/apm/backend/presentation/views.py+++ b/products/apm/backend/presentation/views.py@@ -6,14 +6,14 @@ return serialized responses. No business logic here."""from dataclasses import asdict-from datetime import timedelta+from datetime import datetime, timedeltafrom typing import castfrom django.utils import timezonefrom drf_spectacular.utils import extend_schemafrom rest_framework import status, viewsets-from rest_framework.exceptions import PermissionDenied+from rest_framework.exceptions import PermissionDenied, ValidationErrorfrom rest_framework.request import Requestfrom rest_framework.response import Response@@ -21,10 +21,14 @@ from posthog.schema import ProductKeyfrom posthog.api.routing import TeamAndOrgViewSetMixinfrom posthog.clickhouse.query_tagging import Feature, tag_queries+from posthog.dataclasses import frozen+from posthog.models import Teamfrom posthog.models.user import User-from products.apm.backend.facade.api import is_apm_enabled, list_services_health+from products.apm.backend.facade.api import is_apm_enabled, list_endpoints_health, list_services_healthfrom products.apm.backend.presentation.serializers import (+ EndpointsHealthRequestSerializer,+ EndpointsHealthResponseSerializer,ServicesHealthRequestSerializer,ServicesHealthResponseSerializer,)@@ -34,6 +38,33 @@ MAX_WINDOW = timedelta(days=7)DEFAULT_ENVIRONMENT = "default"+def _check_flag(team: Team, user: User) -> None:+ email = None if user.anonymize_data else user.email+ if not is_apm_enabled(team.pk, distinct_id=str(user.distinct_id), email=email):+ raise PermissionDenied("Application observability is not enabled for this project.")+++@frozen+class HealthWindow:+ date_from: datetime+ date_to: datetime+ environment: str+++def _window(params: ServicesHealthRequestSerializer) -> HealthWindow:+ """The window and environment every APM health route reads, with the same defaults and cap."""+ params.is_valid(raise_exception=True)+ date_to = params.validated_data.get("date_to") or timezone.now()+ date_from = params.validated_data.get("date_from") or date_to - DEFAULT_WINDOW+ if date_from >= date_to or date_to - date_from > MAX_WINDOW:+ raise ValidationError("date_from must precede date_to by at most 7 days.")+ return HealthWindow(+ date_from=date_from,+ date_to=date_to,+ environment=params.validated_data.get("environment") or DEFAULT_ENVIRONMENT,+ )++class ServicesHealthViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):"""One health row per service in an environment and window, worst first.@@ -43,34 +74,52 @@ class ServicesHealthViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):scope_object = "tracing"- def _check_flag(self) -> None:- user = cast(User, self.request.user)- email = None if user.anonymize_data else user.email- if not is_apm_enabled(self.team.pk, distinct_id=str(user.distinct_id), email=email):- raise PermissionDenied("Application observability is not enabled for this project.")-@extend_schema(parameters=[ServicesHealthRequestSerializer], responses={200: ServicesHealthResponseSerializer})def list(self, request: Request, *args, **kwargs) -> Response:- self._check_flag()+ _check_flag(self.team, cast(User, request.user))tag_queries(product=ProductKey.TRACING, feature=Feature.QUERY)- params = ServicesHealthRequestSerializer(data=request.query_params)- params.is_valid(raise_exception=True)- date_to = params.validated_data.get("date_to") or timezone.now()- date_from = params.validated_data.get("date_from") or date_to - DEFAULT_WINDOW- if date_from >= date_to or date_to - date_from > MAX_WINDOW:- return Response(- {"detail": "date_from must precede date_to by at most 7 days."}, status=status.HTTP_400_BAD_REQUEST- )- environment = params.validated_data.get("environment") or DEFAULT_ENVIRONMENT-- result = list_services_health(team=self.team, date_from=date_from, date_to=date_to, environment=environment)+ window = _window(ServicesHealthRequestSerializer(data=request.query_params))++ result = list_services_health(+ team=self.team, date_from=window.date_from, date_to=window.date_to, environment=window.environment+ )payload = {"results": [{**asdict(row), "status": row.status.value, "sparkline": list(row.sparkline)} for row in result.services],"environments": result.environments,- "environment": environment,- "date_from": date_from,- "date_to": date_to,+ "environment": window.environment,+ "date_from": window.date_from,+ "date_to": window.date_to,}return Response(ServicesHealthResponseSerializer(payload).data, status=status.HTTP_200_OK)+++class EndpointsHealthViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):+ """One health row per service and entry span name, worst first. Same gate and window as services."""++ scope_object = "tracing"++ @extend_schema(parameters=[EndpointsHealthRequestSerializer], responses={200: EndpointsHealthResponseSerializer})+ def list(self, request: Request, *args, **kwargs) -> Response:+ _check_flag(self.team, cast(User, request.user))+ tag_queries(product=ProductKey.TRACING, feature=Feature.QUERY)+ params = EndpointsHealthRequestSerializer(data=request.query_params)+ window = _window(params)+ service = params.validated_data.get("service")++ rows = list_endpoints_health(+ team=self.team,+ date_from=window.date_from,+ date_to=window.date_to,+ environment=window.environment,+ service=service,+ )+ payload = {+ "results": [{**asdict(row), "status": row.status.value} for row in rows],+ "environment": window.environment,+ "service": service,+ "date_from": window.date_from,+ "date_to": window.date_to,+ }+ return Response(EndpointsHealthResponseSerializer(payload).data, status=status.HTTP_200_OK)diff --git a/products/apm/backend/routes.py b/products/apm/backend/routes.pyindex 72f8d698b34a..327d82a16583 100644--- a/products/apm/backend/routes.py+++ b/products/apm/backend/routes.py@@ -1,7 +1,8 @@from posthog.api.routing import RouterRegistry-from products.apm.backend.presentation.views import ServicesHealthViewSet+from products.apm.backend.presentation.views import EndpointsHealthViewSet, ServicesHealthViewSetdef register_routes(routers: RouterRegistry) -> None:routers.projects.register(r"apm/services", ServicesHealthViewSet, "project_apm_services", ["team_id"])+ routers.projects.register(r"apm/endpoints", EndpointsHealthViewSet, "project_apm_endpoints", ["team_id"])diff --git a/products/apm/backend/tests/span_fixtures.py b/products/apm/backend/tests/span_fixtures.pynew file mode 100644index 000000000000..0fda6c1b95cf--- /dev/null+++ b/products/apm/backend/tests/span_fixtures.py@@ -0,0 +1,79 @@+"""Shared ClickHouse fixtures for the APM API tests: a trace_spans table with is_root_span, and a span writer."""++import base64+import datetime as dt+from dataclasses import dataclass, field++from posthog.clickhouse.client import sync_execute+from posthog.clickhouse.traces.spans import TRACE_SPANS_DISTRIBUTED_TABLE_SQL, TRACE_SPANS_TABLE_SQL+++def b64(raw: bytes) -> str:+ return base64.b64encode(raw).decode("ascii")+++def recreate_trace_spans_tables() -> None:+ # is_root_span ships via a separate logs-cluster migration, not the Python DDL.+ sync_execute("DROP TABLE IF EXISTS trace_spans_distributed")+ sync_execute("DROP TABLE IF EXISTS trace_spans")+ sync_execute(TRACE_SPANS_TABLE_SQL())+ sync_execute(+ "ALTER TABLE trace_spans ADD COLUMN IF NOT EXISTS "+ "is_root_span Bool MATERIALIZED (replaceAll(trimRight(parent_span_id, '='), 'A', '')) = ''"+ )+ sync_execute(TRACE_SPANS_DISTRIBUTED_TABLE_SQL())+++def restore_trace_spans_tables() -> None:+ sync_execute("DROP TABLE IF EXISTS trace_spans_distributed")+ sync_execute("DROP TABLE IF EXISTS trace_spans")+ sync_execute(TRACE_SPANS_TABLE_SQL())+ sync_execute(TRACE_SPANS_DISTRIBUTED_TABLE_SQL())+++@dataclass(frozen=False)+class SpanWriter:+ """Builds span rows for one team and inserts them in one statement.++ `span()` returns the new span's id so a caller can hang children off it.+ """++ team_id: int+ base: dt.datetime+ uuid_prefix: str = "019e8772"+ rows: list[str] = field(default_factory=list)+ n: int = 0++ def span(+ self,+ service: str,+ *,+ name: str = "op",+ kind: int = 2,+ status_code: int = 0,+ ms: int = 10,+ env: str = "",+ trace: int | None = None,+ parent: str = "",+ ) -> str:+ self.n += 1+ span_id = b64(self.n.to_bytes(8, "big"))+ trace_id = b64((trace if trace is not None else self.n).to_bytes(16, "big"))+ start = self.base + dt.timedelta(seconds=self.n)+ end = start + dt.timedelta(milliseconds=ms)+ attrs = f"map('deployment.environment.name', '{env}')" if env else "map()"+ fmt = "%Y-%m-%d %H:%M:%S.%f"+ self.rows.append(+ f"('{self.uuid_prefix}-0000-0000-0000-{self.n:012d}', {self.team_id}, '{trace_id}', '{span_id}', "+ f"'{parent}', '{name}', {kind}, '{start.strftime(fmt)}', '{end.strftime(fmt)}', '{start.strftime(fmt)}', "+ f"{status_code}, '{service}', {attrs})"+ )+ return span_id++ def insert(self) -> None:+ sync_execute(+ "INSERT INTO trace_spans (uuid, team_id, trace_id, span_id, parent_span_id, name, kind, "+ "timestamp, end_time, observed_timestamp, status_code, service_name, resource_attributes) VALUES "+ + ",".join(self.rows)+ )+ self.rows.clear()diff --git a/products/apm/backend/tests/test_endpoints_api.py b/products/apm/backend/tests/test_endpoints_api.pynew file mode 100644index 000000000000..13c1c21ec186--- /dev/null+++ b/products/apm/backend/tests/test_endpoints_api.py@@ -0,0 +1,143 @@+import datetime as dt++from posthog.test.base import APIBaseTest, ClickhouseTestMixin+from unittest.mock import patch++from django.test import SimpleTestCase++from drf_spectacular.generators import SchemaGenerator++from products.apm.backend.tests.span_fixtures import SpanWriter, recreate_trace_spans_tables, restore_trace_spans_tables++DATE_FROM = "2026-06-02T07:00:00Z"+DATE_TO = "2026-06-02T09:00:00Z"+FLAG_PATCH = "products.apm.backend.presentation.views.is_apm_enabled"+URL = "/api/projects/{}/apm/endpoints/"+++class TestEndpointsHealthAPI(ClickhouseTestMixin, APIBaseTest):+ """One row per (service, entry span name), worst first, behind the product flag."""++ CLASS_DATA_LEVEL_SETUP = True++ @classmethod+ def tearDownClass(cls):+ restore_trace_spans_tables()+ super().tearDownClass()++ @classmethod+ def setUpTestData(cls):+ super().setUpTestData()+ recreate_trace_spans_tables()+ w = SpanWriter(team_id=cls.team.id, base=dt.datetime(2026, 6, 2, 8, 0, 0))++ # web GET /orders: 10 server spans, 1 error -> 10%, serious.+ for i in range(10):+ root = w.span("web", name="GET /orders", status_code=2 if i == 0 else 0, ms=50 + i, env="prod")+ # A client span inside web is an outgoing call, not an endpoint.+ w.span("web", name="GET api/stock", kind=3, status_code=2, env="prod", parent=root)+ # web GET /health: 5 server spans, healthy.+ for _ in range(5):+ w.span("web", name="GET /health", env="prod")+ # api POST /charge: a non-root server span is still an endpoint.+ for _ in range(4):+ w.span("api", name="POST /charge", env="prod", parent=root)+ # api internal span: kind 1 non-root is not an endpoint.+ w.span("api", name="db.query", kind=1, env="prod", parent=root)+ # queue consumer: kind 5 is an entry span.+ for i in range(2):+ w.span("queue", name="orders process", kind=5, status_code=2 if i == 0 else 0, env="prod", parent=root)+ # worker cron: a root client span is the entry of a job with no server spans.+ for _ in range(3):+ w.span("worker", name="cron.tick", kind=3, env="prod")+ # Another environment must not appear for prod.+ w.span("eu-only", name="GET /eu", env="staging")+ w.insert()++ def _list(self, **params) -> dict:+ query = {"date_from": DATE_FROM, "date_to": DATE_TO, "environment": "prod", **params}+ with patch(FLAG_PATCH, return_value=True):+ response = self.client.get(URL.format(self.team.id), query)+ self.assertEqual(response.status_code, 200, response.content)+ return response.json()++ def test_one_row_per_service_and_entry_span_worst_first(self) -> None:+ rows = [(r["service_name"], r["endpoint"]) for r in self._list()["results"]]+ self.assertEqual(+ rows,+ [+ ("queue", "orders process"),+ ("web", "GET /orders"),+ ("api", "POST /charge"),+ ("web", "GET /health"),+ ("worker", "cron.tick"),+ ],+ )++ def test_row_carries_the_health_contract(self) -> None:+ orders = next(r for r in self._list()["results"] if r["endpoint"] == "GET /orders")+ self.assertEqual(orders["status"], "serious")+ self.assertEqual(orders["environment"], "prod")+ self.assertEqual(orders["health"]["span_count"], 10)+ self.assertEqual(orders["health"]["error_count"], 1)+ self.assertAlmostEqual(orders["health"]["error_rate"], 0.1)+ self.assertAlmostEqual(orders["health"]["request_rate"], 10 / 7200, places=6)+ self.assertGreaterEqual(orders["health"]["p95_ms"], 50)++ def test_client_and_internal_child_spans_are_not_endpoints(self) -> None:+ endpoints = {r["endpoint"] for r in self._list()["results"]}+ self.assertNotIn("GET api/stock", endpoints)+ self.assertNotIn("db.query", endpoints)++ def test_service_filter(self) -> None:+ rows = self._list(service="web")["results"]+ self.assertEqual([r["endpoint"] for r in rows], ["GET /orders", "GET /health"])++ def test_environment_filter(self) -> None:+ self.assertNotIn("eu-only", {r["service_name"] for r in self._list()["results"]})+ staging = self._list(environment="staging")["results"]+ self.assertEqual([(r["service_name"], r["endpoint"]) for r in staging], [("eu-only", "GET /eu")])++ def test_rejects_a_window_over_seven_days(self) -> None:+ with patch(FLAG_PATCH, return_value=True):+ response = self.client.get(+ URL.format(self.team.id), {"date_from": "2026-05-01T00:00:00Z", "date_to": "2026-06-02T00:00:00Z"}+ )+ self.assertEqual(response.status_code, 400)++ def test_403_when_the_flag_is_off(self) -> None:+ with patch(FLAG_PATCH, return_value=False):+ response = self.client.get(URL.format(self.team.id))+ self.assertEqual(response.status_code, 403)++ def test_unauthenticated_is_rejected(self) -> None:+ self.client.logout()+ response = self.client.get(URL.format(self.team.id))+ self.assertEqual(response.status_code, 401)++ def test_other_team_sees_nothing(self) -> None:+ other = self.create_team_with_organization(organization=self.organization)+ with patch(FLAG_PATCH, return_value=True):+ response = self.client.get(+ URL.format(other.id), {"date_from": DATE_FROM, "date_to": DATE_TO, "environment": "prod"}+ )+ self.assertEqual(response.status_code, 200, response.content)+ self.assertEqual(response.json()["results"], [])++ def test_queries_are_tagged_for_the_request_path(self) -> None:+ with (+ patch(FLAG_PATCH, return_value=True),+ patch("products.apm.backend.presentation.views.tag_queries") as tag,+ ):+ self.client.get(URL.format(self.team.id))+ tag.assert_called_once()+ self.assertTrue(tag.call_args.kwargs.get("product"))+ self.assertTrue(tag.call_args.kwargs.get("feature"))+++class TestEndpointsHealthOpenApiSchema(SimpleTestCase):+ def test_list_response_schema_is_a_single_object_not_an_array(self) -> None:+ schema = SchemaGenerator().get_schema(request=None, public=True)+ operation = schema["paths"]["/api/projects/{project_id}/apm/endpoints/"]["get"]+ response_schema = operation["responses"]["200"]["content"]["application/json"]["schema"]+ self.assertNotEqual(response_schema.get("type"), "array")diff --git a/products/apm/backend/tests/test_services_health_api.py b/products/apm/backend/tests/test_services_health_api.pyindex 06bfaa3807c6..5acdb6d4b9d2 100644--- a/products/apm/backend/tests/test_services_health_api.py+++ b/products/apm/backend/tests/test_services_health_api.py@@ -12,6 +12,7 @@ from posthog.clickhouse.client import sync_executefrom posthog.clickhouse.traces.spans import TRACE_SPANS_DISTRIBUTED_TABLE_SQL, TRACE_SPANS_TABLE_SQLfrom products.apm.backend.logic.health.sources import SERVICES_LIMIT+from products.apm.backend.tests.span_fixtures import SpanWriterDATE_FROM = "2026-06-02T07:00:00Z"DATE_TO = "2026-06-02T09:00:00Z"@@ -162,6 +163,28 @@ class TestServicesHealthAPI(ClickhouseTestMixin, APIBaseTest):names = [r["service_name"] for r in data["results"]]self.assertIn("zzz-failing", names)+ def test_a_consumer_only_service_counts_its_consumer_spans_as_requests(self) -> None:+ # A queue worker's consumer spans have a remote parent, so they are neither server nor root spans.+ writer = SpanWriter(team_id=self.team.id, base=dt.datetime(2026, 6, 4, 8, 0, 0), uuid_prefix="019e8774")+ producer = writer.span("api", name="orders publish", kind=4, env="queues", trace=1)+ for i in range(4):+ writer.span(+ "orders-worker",+ name="orders process",+ kind=5,+ status_code=2 if i == 0 else 0,+ env="queues",+ trace=1,+ parent=producer,+ )+ writer.insert()++ data = self._list(date_from="2026-06-04T07:00:00Z", date_to="2026-06-04T09:00:00Z", environment="queues")+ worker = next(r for r in data["results"] if r["service_name"] == "orders-worker")+ self.assertEqual(worker["health"]["span_count"], 4)+ self.assertEqual(worker["health"]["error_count"], 1)+ self.assertEqual(sum(worker["sparkline"]), 4)+def test_defaults_to_the_last_hour_when_no_range_is_given(self) -> None:with patch(FLAG_PATCH, return_value=True):response = self.client.get(f"/api/projects/{self.team.id}/apm/services/")diff --git a/products/apm/frontend/ApplicationObservabilityScene.tsx b/products/apm/frontend/ApplicationObservabilityScene.tsxindex 2c9420249d87..99283be0a707 100644--- a/products/apm/frontend/ApplicationObservabilityScene.tsx+++ b/products/apm/frontend/ApplicationObservabilityScene.tsx@@ -1,157 +1,35 @@import { useActions, useValues } from 'kea'-import { LemonBanner, LemonSelect, LemonTable, LemonTableColumns, LemonTag, Link } from '@posthog/lemon-ui'+import { LemonSelect, LemonTabs } from '@posthog/lemon-ui'import { SceneExport } from 'scenes/sceneTypes'-import { urls } from 'scenes/urls'import { SceneContent } from '~/layout/scenes/components/SceneContent'import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'import {+ ApplicationObservabilityTab,TIME_RANGE_LABELS,TimeRange,applicationObservabilityLogic,- drillDownParams,} from './applicationObservabilityLogic'-import type { HealthStatusEnumApi, ServiceHealthApi } from './generated/api.schemas'+import { EndpointsTab } from './EndpointsTab'+import { ServicesTab } from './ServicesTab'export const scene: SceneExport = {component: ApplicationObservabilityScene,logic: applicationObservabilityLogic,}-const STATUS_LABEL: Record<HealthStatusEnumApi, string> = {- good: 'Healthy',- warning: 'Watch',- serious: 'Failing',- critical: 'Confirmed',-}--const STATUS_TAG: Record<HealthStatusEnumApi, 'success' | 'warning' | 'danger'> = {- good: 'success',- warning: 'warning',- serious: 'danger',- critical: 'danger',-}--export function formatRate(perSecond: number | null): string {- if (perSecond === null) {- return '—'- }- if (perSecond >= 1000) {- return `${(perSecond / 1000).toFixed(1)}k/s`- }- if (perSecond >= 10) {- return `${Math.round(perSecond)}/s`- }- if (perSecond >= 0.1) {- return `${perSecond.toFixed(1)}/s`- }- return `${(perSecond * 60).toFixed(1)}/min`-}--export function formatPercent(fraction: number | null): string {- if (fraction === null) {- return '—'- }- const pct = fraction * 100- return `${pct.toFixed(pct >= 10 ? 0 : pct >= 1 ? 1 : 2)}%`-}--export function formatMs(ms: number | null): string {- if (ms === null) {- return '—'- }- return ms >= 1000 ? `${(ms / 1000).toFixed(1)}s` : `${Math.round(ms)}ms`-}--function Sparkline({ values }: { values: number[] }): JSX.Element {- const width = 72- const height = 18- const max = Math.max(1, ...values)- const points = values- .map((value, index) => {- const x = (index / Math.max(1, values.length - 1)) * (width - 2) + 1- const y = height - 1 - (value / max) * (height - 2)- return `${x.toFixed(1)},${y.toFixed(1)}`- })- .join(' ')- return (- <svg width={width} height={height} viewBox={`0 0 ${width} ${height}`} aria-hidden="true" className="block">- <polyline points={points} fill="none" stroke="currentColor" strokeWidth={1.5} className="text-muted" />- </svg>- )-}-export function ApplicationObservabilityScene(): JSX.Element {- const {- services,- servicesHealthLoading,- hasLoadError,- environments,- resolvedEnvironment,- timeRange,- attentionCount,- } = useValues(applicationObservabilityLogic)- const { setEnvironment, setTimeRange } = useActions(applicationObservabilityLogic)-- const columns: LemonTableColumns<ServiceHealthApi> = [- {- title: 'Service',- key: 'service_name',- render: (_, row) => <span className="font-semibold">{row.service_name}</span>,- },- {- title: 'Status',- key: 'status',- render: (_, row) => <LemonTag type={STATUS_TAG[row.status]}>{STATUS_LABEL[row.status]}</LemonTag>,- },- {- title: 'Requests',- key: 'request_rate',- align: 'right',- render: (_, row) => <span className="font-mono">{formatRate(row.health.request_rate)}</span>,- },- {- title: 'Errors',- key: 'error_rate',- align: 'right',- render: (_, row) => <span className="font-mono">{formatPercent(row.health.error_rate)}</span>,- },- {- title: 'p95',- key: 'p95_ms',- align: 'right',- render: (_, row) => <span className="font-mono">{formatMs(row.health.p95_ms)}</span>,- },- {- title: 'Trend',- key: 'sparkline',- render: (_, row) => <Sparkline values={row.sparkline} />,- },- {- title: 'Open in',- key: 'links',- render: (_, row) => (- <span className="flex gap-2">- <Link to={`${urls.tracing()}?${drillDownParams(row.service_name, timeRange)}`}>Traces</Link>- <Link to={`${urls.logs()}?${drillDownParams(row.service_name, timeRange)}`}>Logs</Link>- </span>- ),- },- ]-- const attentionMessage =- attentionCount > 0- ? `${attentionCount} ${attentionCount === 1 ? 'service needs' : 'services need'} attention in ${resolvedEnvironment}`- : `All quiet in ${resolvedEnvironment}`+ const { environments, resolvedEnvironment, timeRange, tab } = useValues(applicationObservabilityLogic)+ const { setEnvironment, setTimeRange, setTab } = useActions(applicationObservabilityLogic)return (<SceneContent><SceneTitleSectionname="Application observability"- description="One row per service, worst first, from the spans you already send."+ description="Services, endpoints, and their health, from the spans you already send."resourceType={{ type: 'tracing' }}/><div className="flex flex-wrap items-center gap-2">@@ -177,29 +55,14 @@ export function ApplicationObservabilityScene(): JSX.Element {/><span className="text-muted text-xs">Refreshes every 5 minutes</span></div>- {hasLoadError ? (- <LemonBanner type="error">- {services.length > 0- ? `Couldn't refresh service health for ${resolvedEnvironment}. Showing the last successful results.`- : `Couldn't load service health for ${resolvedEnvironment}. Try again shortly.`}- </LemonBanner>- ) : (- !servicesHealthLoading &&- services.length > 0 && (- <LemonBanner type={attentionCount > 0 ? 'warning' : 'success'}>{attentionMessage}</LemonBanner>- )- )}- <LemonTable- columns={columns}- dataSource={services}- rowKey="service_name"- loading={servicesHealthLoading}- emptyState={- hasLoadError- ? "Couldn't load service health. Check your connection and try again."- : 'No spans in this environment and time range. Send traces to see services here.'- }- data-attr="apm-services-table"+ <LemonTabs<ApplicationObservabilityTab>+ activeKey={tab}+ onChange={setTab}+ tabs={[+ { key: 'services', label: 'Services', content: <ServicesTab /> },+ { key: 'endpoints', label: 'Endpoints', content: <EndpointsTab /> },+ ]}+ data-attr="apm-tabs"/></SceneContent>)diff --git a/products/apm/frontend/EndpointsTab.tsx b/products/apm/frontend/EndpointsTab.tsxnew file mode 100644index 000000000000..96e9f5a250fa--- /dev/null+++ b/products/apm/frontend/EndpointsTab.tsx@@ -0,0 +1,84 @@+import { useActions, useValues } from 'kea'++import { LemonBanner, LemonSelect, LemonTable, LemonTableColumns, Link } from '@posthog/lemon-ui'++import { urls } from 'scenes/urls'++import { applicationObservabilityLogic } from './applicationObservabilityLogic'+import type { EndpointHealthApi } from './generated/api.schemas'+import { healthColumns } from './healthColumns'+import { TelemetryLinks } from './TelemetryLinks'++export function EndpointsTab(): JSX.Element {+ const { endpoints, endpointsHealthLoading, endpointsLoadError, services, endpointsService, timeRange } =+ useValues(applicationObservabilityLogic)+ const { setEndpointsService } = useActions(applicationObservabilityLogic)++ const serviceNames = services.map((row) => row.service_name)+ if (endpointsService && !serviceNames.includes(endpointsService)) {+ serviceNames.push(endpointsService)+ }++ const columns: LemonTableColumns<EndpointHealthApi> = [+ {+ title: 'Endpoint',+ key: 'endpoint',+ render: (_, row) => (+ <Link+ to={urls.tracingOperation(row.service_name, row.endpoint, { date_from: timeRange, date_to: null })}+ className="font-semibold"+ data-attr="apm-endpoint-operation"+ >+ {row.endpoint}+ </Link>+ ),+ },+ {+ title: 'Service',+ key: 'service_name',+ render: (_, row) => row.service_name,+ },+ ...healthColumns<EndpointHealthApi>(),+ {+ title: 'Open in',+ key: 'links',+ render: (_, row) => (+ <span className="flex gap-2">+ <TelemetryLinks serviceName={row.service_name} timeRange={timeRange} />+ </span>+ ),+ },+ ]++ return (+ <div className="flex flex-col gap-2">+ <div className="flex flex-wrap items-center gap-2">+ <LemonSelect+ size="small"+ value={endpointsService}+ onChange={(value) => setEndpointsService(value)}+ options={[+ { value: null, label: 'All services' },+ ...serviceNames.map((name) => ({ value: name, label: name })),+ ]}+ data-attr="apm-endpoints-service"+ />+ </div>+ {endpointsLoadError && (+ <LemonBanner type="error">+ {endpoints.length > 0+ ? "Couldn't refresh endpoints. Showing the last successful results."+ : "Couldn't load endpoints. Try again shortly."}+ </LemonBanner>+ )}+ <LemonTable+ columns={columns}+ dataSource={endpoints}+ rowKey={(row) => `${row.service_name}\n${row.endpoint}`}+ loading={endpointsHealthLoading}+ emptyState="No endpoints in this environment and time range. Endpoints come from the requests, messages, and jobs your services handle."+ data-attr="apm-endpoints-table"+ />+ </div>+ )+}diff --git a/products/apm/frontend/HealthStatusTag.tsx b/products/apm/frontend/HealthStatusTag.tsxnew file mode 100644index 000000000000..8dd793c8fb46--- /dev/null+++ b/products/apm/frontend/HealthStatusTag.tsx@@ -0,0 +1,8 @@+import { LemonTag } from '@posthog/lemon-ui'++import type { HealthStatusEnumApi } from './generated/api.schemas'+import { STATUS_LABEL, STATUS_TAG } from './healthDisplay'++export function HealthStatusTag({ status }: { status: HealthStatusEnumApi }): JSX.Element {+ return <LemonTag type={STATUS_TAG[status]}>{STATUS_LABEL[status]}</LemonTag>+}diff --git a/products/apm/frontend/ServicesTab.tsx b/products/apm/frontend/ServicesTab.tsxnew file mode 100644index 000000000000..9cff78e2b57a--- /dev/null+++ b/products/apm/frontend/ServicesTab.tsx@@ -0,0 +1,75 @@+import { useActions, useValues } from 'kea'++import { LemonBanner, LemonTable, LemonTableColumns, Link } from '@posthog/lemon-ui'++import { applicationObservabilityLogic } from './applicationObservabilityLogic'+import type { ServiceHealthApi } from './generated/api.schemas'+import { healthColumns } from './healthColumns'+import { Sparkline } from './Sparkline'+import { TelemetryLinks } from './TelemetryLinks'++export function ServicesTab(): JSX.Element {+ const { services, servicesHealthLoading, hasLoadError, resolvedEnvironment, timeRange, attentionCount } =+ useValues(applicationObservabilityLogic)+ const { showServiceEndpoints } = useActions(applicationObservabilityLogic)++ const columns: LemonTableColumns<ServiceHealthApi> = [+ {+ title: 'Service',+ key: 'service_name',+ render: (_, row) => <span className="font-semibold">{row.service_name}</span>,+ },+ ...healthColumns<ServiceHealthApi>(),+ {+ title: 'Trend',+ key: 'sparkline',+ render: (_, row) => <Sparkline values={row.sparkline} />,+ },+ {+ title: 'Open in',+ key: 'links',+ render: (_, row) => (+ <span className="flex gap-2">+ <Link onClick={() => showServiceEndpoints(row.service_name)} data-attr="apm-service-endpoints">+ Endpoints+ </Link>+ <TelemetryLinks serviceName={row.service_name} timeRange={timeRange} />+ </span>+ ),+ },+ ]++ const attentionMessage =+ attentionCount > 0+ ? `${attentionCount} ${attentionCount === 1 ? 'service needs' : 'services need'} attention in ${resolvedEnvironment}`+ : `All quiet in ${resolvedEnvironment}`++ return (+ <div className="flex flex-col gap-2">+ {hasLoadError ? (+ <LemonBanner type="error">+ {services.length > 0+ ? `Couldn't refresh service health for ${resolvedEnvironment}. Showing the last successful results.`+ : `Couldn't load service health for ${resolvedEnvironment}. Try again shortly.`}+ </LemonBanner>+ ) : (+ !servicesHealthLoading &&+ services.length > 0 && (+ <LemonBanner type={attentionCount > 0 ? 'warning' : 'success'}>{attentionMessage}</LemonBanner>+ )+ )}+ <LemonTable+ columns={columns}+ dataSource={services}+ rowKey="service_name"+ loading={servicesHealthLoading}+ emptyState={+ hasLoadError+ ? "Couldn't load service health. Check your connection and try again."+ : 'No spans in this environment and time range. Send traces to see services here.'+ }+ data-attr="apm-services-table"+ />+ </div>+ )+}diff --git a/products/apm/frontend/Sparkline.tsx b/products/apm/frontend/Sparkline.tsxnew file mode 100644index 000000000000..a47c5bdeb5e9--- /dev/null+++ b/products/apm/frontend/Sparkline.tsx@@ -0,0 +1,17 @@+export function Sparkline({ values }: { values: number[] }): JSX.Element {+ const width = 72+ const height = 18+ const max = Math.max(1, ...values)+ const points = values+ .map((value, index) => {+ const x = (index / Math.max(1, values.length - 1)) * (width - 2) + 1+ const y = height - 1 - (value / max) * (height - 2)+ return `${x.toFixed(1)},${y.toFixed(1)}`+ })+ .join(' ')+ return (+ <svg width={width} height={height} viewBox={`0 0 ${width} ${height}`} aria-hidden="true" className="block">+ <polyline points={points} fill="none" stroke="currentColor" strokeWidth={1.5} className="text-muted" />+ </svg>+ )+}diff --git a/products/apm/frontend/TelemetryLinks.tsx b/products/apm/frontend/TelemetryLinks.tsxnew file mode 100644index 000000000000..97ba78aaec56--- /dev/null+++ b/products/apm/frontend/TelemetryLinks.tsx@@ -0,0 +1,14 @@+import { Link } from '@posthog/lemon-ui'++import { urls } from 'scenes/urls'++import { TimeRange, drillDownParams } from './applicationObservabilityLogic'++export function TelemetryLinks({ serviceName, timeRange }: { serviceName: string; timeRange: TimeRange }): JSX.Element {+ return (+ <>+ <Link to={`${urls.tracing()}?${drillDownParams(serviceName, timeRange)}`}>Traces</Link>+ <Link to={`${urls.logs()}?${drillDownParams(serviceName, timeRange)}`}>Logs</Link>+ </>+ )+}diff --git a/products/apm/frontend/applicationObservabilityLogic.test.ts b/products/apm/frontend/applicationObservabilityLogic.test.tsindex b159e6bf729a..9f858d7e4ad0 100644--- a/products/apm/frontend/applicationObservabilityLogic.test.ts+++ b/products/apm/frontend/applicationObservabilityLogic.test.ts@@ -11,7 +11,7 @@ import {applicationObservabilityLogic,drillDownParams,} from './applicationObservabilityLogic'-import type { ServicesHealthResponseApi } from './generated/api.schemas'+import type { EndpointsHealthResponseApi, ServicesHealthResponseApi } from './generated/api.schemas'const row = (service_name: string, status: 'good' | 'warning' | 'serious' | 'critical'): any => ({service_name,@@ -29,18 +29,40 @@ const RESPONSE: ServicesHealthResponseApi = {date_to: '2026-06-02T08:00:00Z',}+const ENDPOINTS_RESPONSE: EndpointsHealthResponseApi = {+ results: [+ {+ service_name: 'queue',+ endpoint: 'orders process',+ environment: 'prod',+ status: 'serious',+ health: { request_rate: 1, error_rate: 0.5, p95_ms: 10, span_count: 2, error_count: 1 },+ },+ ],+ environment: 'prod',+ service: null,+ date_from: '2026-06-02T07:00:00Z',+ date_to: '2026-06-02T08:00:00Z',+}+describe('applicationObservabilityLogic', () => {let logic: ReturnType<typeof applicationObservabilityLogic.build>let requests: string[]+ let endpointRequests: string[]beforeEach(async () => {requests = []+ endpointRequests = []useMocks({get: {'/api/projects/:team_id/apm/services/': ({ request }) => {requests.push(new URL(request.url).search)return [200, RESPONSE]},+ '/api/projects/:team_id/apm/endpoints/': ({ request }) => {+ endpointRequests.push(new URL(request.url).search)+ return [200, ENDPOINTS_RESPONSE]+ },},})initKeaTests()@@ -124,4 +146,56 @@ describe('applicationObservabilityLogic', () => {const params = new URLSearchParams(drillDownParams('checkout,v2', '-1h'))expect(parseTagsFilter(params.get('serviceNames'))).toEqual(['checkout,v2'])})++ describe('tabs', () => {+ it('opens on the services tab and does not load endpoints until that tab is open', async () => {+ await expectLogic(logic).toDispatchActions(['loadServicesHealthSuccess'])+ expect(logic.values.tab).toBe('services')+ expect(endpointRequests).toHaveLength(0)+ })++ it('ignores an unknown tab in the URL', async () => {+ router.actions.push(APPLICATION_OBSERVABILITY_PATH, { tab: 'toString' })+ await expectLogic(logic).toFinishAllListeners()+ expect(logic.values.tab).toBe('services')+ })++ it('loads endpoints for the environment and window when the endpoints tab opens from the URL', async () => {+ router.actions.push(APPLICATION_OBSERVABILITY_PATH, { tab: 'endpoints', environment: 'staging' })+ await expectLogic(logic).toDispatchActions(['loadEndpointsHealthSuccess'])+ expect(logic.values.tab).toBe('endpoints')+ expect(logic.values.endpoints).toHaveLength(1)+ expect(endpointRequests).toHaveLength(1)+ expect(endpointRequests[0]).toContain('environment=staging')+ expect(endpointRequests[0]).toContain('date_from=')+ expect(endpointRequests[0]).not.toContain('service=')+ })++ it('writes the tab to the URL and loads endpoints once', async () => {+ await expectLogic(logic).toDispatchActions(['loadServicesHealthSuccess'])+ logic.actions.setTab('endpoints')+ await expectLogic(logic).toDispatchActions(['loadEndpointsHealthSuccess'])+ expect(router.values.searchParams).toMatchObject({ tab: 'endpoints' })+ expect(endpointRequests).toHaveLength(1)++ logic.actions.setTab('services')+ expect(router.values.searchParams.tab).toBeUndefined()+ })++ it('shows the endpoints of one service from a services row', async () => {+ await expectLogic(logic).toDispatchActions(['loadServicesHealthSuccess'])+ const servicesRequestsBefore = requests.length+ logic.actions.showServiceEndpoints('web')+ await expectLogic(logic).toDispatchActions(['loadEndpointsHealthSuccess'])+ expect(router.values.searchParams).toMatchObject({ tab: 'endpoints', service: 'web' })+ expect(endpointRequests[endpointRequests.length - 1]).toContain('service=web')++ logic.actions.setEndpointsService(null)+ await expectLogic(logic).toDispatchActions(['loadEndpointsHealthSuccess'])+ expect(router.values.searchParams.service).toBeUndefined()+ expect(endpointRequests[endpointRequests.length - 1]).not.toContain('service=')+ // The service filter only narrows endpoints, so service health must not reload with it.+ expect(requests.length).toBe(servicesRequestsBefore)+ })+ })})diff --git a/products/apm/frontend/applicationObservabilityLogic.ts b/products/apm/frontend/applicationObservabilityLogic.tsindex bb94cb1ec9b1..2d02529871f1 100644--- a/products/apm/frontend/applicationObservabilityLogic.ts+++ b/products/apm/frontend/applicationObservabilityLogic.ts@@ -4,13 +4,22 @@ import { actionToUrl, urlToAction } from 'kea-router'import { teamLogic } from 'scenes/teamLogic'-import { apmServicesList } from './generated/api'-import type { ServiceHealthApi, ServicesHealthResponseApi } from './generated/api.schemas'+import { apmEndpointsList, apmServicesList } from './generated/api'+import type {+ EndpointHealthApi,+ EndpointsHealthResponseApi,+ ServiceHealthApi,+ ServicesHealthResponseApi,+} from './generated/api.schemas'export const APPLICATION_OBSERVABILITY_PATH = '/application-observability'export type TimeRange = '-1h' | '-6h' | '-24h' | '-7d'+export type ApplicationObservabilityTab = 'services' | 'endpoints'++export const TABS: ApplicationObservabilityTab[] = ['services', 'endpoints']+export const TIME_RANGE_LABELS: Record<TimeRange, string> = {'-1h': 'Last hour','-6h': 'Last 6 hours',@@ -36,6 +45,10 @@ export function drillDownParams(serviceName: string, timeRange: TimeRange): strireturn `serviceNames=${encodeURIComponent(serviceNames)}&dateRange=${encodeURIComponent(dateRange)}`}+function isTab(value: unknown): value is ApplicationObservabilityTab {+ return typeof value === 'string' && (TABS as string[]).includes(value)+}+function isTimeRange(value: unknown): value is TimeRange {// `in` also matches inherited keys like `toString`, so a `?range=toString` URL would pass.return typeof value === 'string' && Object.hasOwn(TIME_RANGE_LABELS, value)@@ -45,6 +58,11 @@ function isTimeRange(value: unknown): value is TimeRange {export interface applicationObservabilityLogicValues {currentTeamId: number | null // teamLogicattentionCount: number+ endpoints: EndpointHealthApi[]+ endpointsHealth: EndpointsHealthResponseApi | null+ endpointsHealthLoading: boolean+ endpointsLoadError: boolean+ endpointsService: string | nullenvironment: string | nullenvironments: string[]hasLoadError: boolean@@ -52,11 +70,27 @@ export interface applicationObservabilityLogicValues {services: ServiceHealthApi[]servicesHealth: ServicesHealthResponseApi | nullservicesHealthLoading: boolean+ tab: ApplicationObservabilityTabtimeRange: TimeRange}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface applicationObservabilityLogicActions {+ loadEndpointsHealth: (_: void) => void+ loadEndpointsHealthFailure: (+ error: string,+ errorObject?: any+ ) => {+ error: string+ errorObject?: any+ }+ loadEndpointsHealthSuccess: (+ endpointsHealth: EndpointsHealthResponseApi,+ payload?: void+ ) => {+ endpointsHealth: EndpointsHealthResponseApi+ payload?: void+ }loadServicesHealth: (_: void) => voidloadServicesHealthFailure: (error: string,@@ -72,15 +106,24 @@ export interface applicationObservabilityLogicActions {servicesHealth: ServicesHealthResponseApipayload?: void}- requestReload: () => {- value: true+ requestReload: (includeServices?: boolean) => {+ includeServices: boolean+ }+ setEndpointsService: (service: string | null) => {+ service: string | null}setEnvironment: (environment: string | null) => {environment: string | null}+ setTab: (tab: ApplicationObservabilityTab) => {+ tab: ApplicationObservabilityTab+ }setTimeRange: (timeRange: TimeRange) => {timeRange: TimeRange}+ showServiceEndpoints: (service: string) => {+ service: string+ }}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -89,6 +132,7 @@ export interface applicationObservabilityLogicMeta {services: (servicesHealth: ServicesHealthResponseApi | null) => ServiceHealthApi[]environments: (servicesHealth: ServicesHealthResponseApi | null) => string[]resolvedEnvironment: (environment: string | null, servicesHealth: ServicesHealthResponseApi | null) => string+ endpoints: (endpointsHealth: EndpointsHealthResponseApi | null) => EndpointHealthApi[]attentionCount: (services: ServiceHealthApi[]) => number}}@@ -107,13 +151,25 @@ export const applicationObservabilityLogic = kea<applicationObservabilityLogicTyactions({setEnvironment: (environment: string | null) => ({ environment }),setTimeRange: (timeRange: TimeRange) => ({ timeRange }),+ setTab: (tab: ApplicationObservabilityTab) => ({ tab }),+ setEndpointsService: (service: string | null) => ({ service }),+ showServiceEndpoints: (service: string) => ({ service }),// Internal: coalesces the picker actions and the initial URL sync into a single reload.- requestReload: true,+ // `includeServices` is false for changes that only affect the active tab's own data.+ requestReload: (includeServices: boolean = true) => ({ includeServices }),}),reducers({environment: [null as string | null, { setEnvironment: (_, { environment }) => environment }],timeRange: ['-1h' as TimeRange, { setTimeRange: (_, { timeRange }) => timeRange }],+ tab: [+ 'services' as ApplicationObservabilityTab,+ { setTab: (_, { tab }) => tab, showServiceEndpoints: () => 'endpoints' },+ ],+ endpointsService: [+ null as string | null,+ { setEndpointsService: (_, { service }) => service, showServiceEndpoints: (_, { service }) => service },+ ],// Tracks the *last* load's outcome so a refresh failure can be told apart from a// genuinely empty result, and from a healthy result that's gone stale.hasLoadError: [@@ -123,9 +179,33 @@ export const applicationObservabilityLogic = kea<applicationObservabilityLogicTyloadServicesHealthFailure: () => true,},],+ endpointsLoadError: [+ false,+ {+ loadEndpointsHealthSuccess: () => false,+ loadEndpointsHealthFailure: () => true,+ },+ ],}),loaders(({ values }) => ({+ endpointsHealth: [+ null as EndpointsHealthResponseApi | null,+ {+ loadEndpointsHealth: async (_: void, breakpoint): Promise<EndpointsHealthResponseApi> => {+ const dateTo = new Date()+ const dateFrom = new Date(dateTo.getTime() - TIME_RANGE_MS[values.timeRange])+ const response = await apmEndpointsList(String(values.currentTeamId), {+ date_from: dateFrom.toISOString(),+ date_to: dateTo.toISOString(),+ ...(values.environment ? { environment: values.environment } : {}),+ ...(values.endpointsService ? { service: values.endpointsService } : {}),+ })+ breakpoint()+ return response+ },+ },+ ],servicesHealth: [null as ServicesHealthResponseApi | null,{@@ -160,6 +240,10 @@ export const applicationObservabilityLogic = kea<applicationObservabilityLogicTy(environment: string | null, servicesHealth: ServicesHealthResponseApi | null): string =>environment ?? servicesHealth?.environment ?? 'default',],+ endpoints: [+ (s) => [s.endpointsHealth],+ (endpointsHealth: EndpointsHealthResponseApi | null): EndpointHealthApi[] => endpointsHealth?.results ?? [],+ ],attentionCount: [(s) => [s.services],(services: ServiceHealthApi[]): number =>@@ -174,9 +258,17 @@ export const applicationObservabilityLogic = kea<applicationObservabilityLogicTy{...(values.environment ? { environment: values.environment } : {}),...(values.timeRange !== '-1h' ? { range: values.timeRange } : {}),+ ...(values.tab !== 'services' ? { tab: values.tab } : {}),+ ...(values.endpointsService ? { service: values.endpointsService } : {}),},]- return { setEnvironment: toUrl, setTimeRange: toUrl }+ return {+ setEnvironment: toUrl,+ setTimeRange: toUrl,+ setTab: toUrl,+ setEndpointsService: toUrl,+ showServiceEndpoints: toUrl,+ }}),urlToAction(({ actions, values }) => ({@@ -186,6 +278,14 @@ export const applicationObservabilityLogic = kea<applicationObservabilityLogicTy[APPLICATION_OBSERVABILITY_PATH]: (_, searchParams) => {const environment = typeof searchParams.environment === 'string' ? searchParams.environment : nullconst range = isTimeRange(searchParams.range) ? searchParams.range : '-1h'+ const tab = isTab(searchParams.tab) ? searchParams.tab : 'services'+ const service = typeof searchParams.service === 'string' ? searchParams.service : null+ if (service !== values.endpointsService) {+ actions.setEndpointsService(service)+ }+ if (tab !== values.tab) {+ actions.setTab(tab)+ }if (environment !== values.environment) {actions.setEnvironment(environment)}@@ -195,15 +295,27 @@ export const applicationObservabilityLogic = kea<applicationObservabilityLogicTy},})),- listeners(({ actions, cache }) => ({+ listeners(({ actions, values, cache }) => ({setEnvironment: () => actions.requestReload(),setTimeRange: () => actions.requestReload(),+ setTab: () => actions.requestReload(false),+ setEndpointsService: () => actions.requestReload(false),+ showServiceEndpoints: () => actions.requestReload(false),// Debounced with a replaceable timer: several `requestReload` calls in the same tick// (e.g. the initial URL sync setting both the environment and the range at once, or that// sync landing in the same tick as the mount-time load) collapse into a single request.- requestReload: () => {+ requestReload: ({ includeServices }) => {+ cache.reloadServices = cache.reloadServices || includeServicescache.disposables.add(() => {- const timerId = setTimeout(() => actions.loadServicesHealth(), 0)+ const timerId = setTimeout(() => {+ if (cache.reloadServices) {+ cache.reloadServices = false+ actions.loadServicesHealth()+ }+ if (values.tab === 'endpoints') {+ actions.loadEndpointsHealth()+ }+ }, 0)return () => clearTimeout(timerId)}, 'reloadTimer')},@@ -212,7 +324,7 @@ export const applicationObservabilityLogic = kea<applicationObservabilityLogicTyafterMount(({ actions, cache }) => {actions.requestReload()cache.disposables.add(() => {- const handle = setInterval(() => actions.loadServicesHealth(), POLL_INTERVAL_MS)+ const handle = setInterval(() => actions.requestReload(), POLL_INTERVAL_MS)return () => clearInterval(handle)}, 'poll')}),diff --git a/products/apm/frontend/generated/api.schemas.ts b/products/apm/frontend/generated/api.schemas.tsindex fedde3e6b7a1..b51f88c9a697 100644--- a/products/apm/frontend/generated/api.schemas.ts+++ b/products/apm/frontend/generated/api.schemas.ts@@ -44,6 +44,40 @@ export interface HealthRowApi {error_count: number}+export interface EndpointHealthApi {+ /** The service.name resource attribute. */+ service_name: string+ /** The entry span name, for example the HTTP route or the job name. */+ endpoint: string+ /** The environment the row was computed for. */+ environment: string+ /** Health band from the error rate.+ *+ * * `good` - Good+ * * `warning` - Warning+ * * `serious` - Serious+ * * `critical` - Critical */+ status: HealthStatusEnumApi+ /** The health row every surface renders. */+ health: HealthRowApi+}++export interface EndpointsHealthResponseApi {+ /** One row per service and endpoint, worst status first. */+ results: EndpointHealthApi[]+ /** The environment the rows were computed for. */+ environment: string+ /**+ * The service filter applied, if any.+ * @nullable+ */+ service: string | null+ /** Start of the window used. */+ date_from: string+ /** End of the window used. */+ date_to: string+}+export interface ServiceHealthApi {/** The service.name resource attribute. */service_name: string@@ -75,6 +109,29 @@ export interface ServicesHealthResponseApi {date_to: string}+export type ApmEndpointsListParams = {+ /**+ * Start of the window, ISO 8601. Defaults to one hour before date_to.+ */+ date_from?: string+ /**+ * End of the window, ISO 8601. Defaults to now.+ */+ date_to?: string+ /**+ * Environment to list, as resolved from span resource attributes. Defaults to 'default'.+ * @minLength 1+ * @maxLength 200+ */+ environment?: string+ /**+ * Only list the endpoints of this service.+ * @minLength 1+ * @maxLength 400+ */+ service?: string+}+export type ApmServicesListParams = {/*** Start of the window, ISO 8601. Defaults to one hour before date_to.diff --git a/products/apm/frontend/generated/api.ts b/products/apm/frontend/generated/api.tsindex ad2ff9edb028..1598a2e0a5c3 100644--- a/products/apm/frontend/generated/api.ts+++ b/products/apm/frontend/generated/api.ts@@ -8,7 +8,42 @@ import { apiMutator } from '../../../../frontend/src/lib/api-orval-mutator'* PostHog API - generated* OpenAPI spec version: 1.0.0*/-import type { ApmServicesListParams, ServicesHealthResponseApi } from './api.schemas'+import type {+ ApmEndpointsListParams,+ ApmServicesListParams,+ EndpointsHealthResponseApi,+ ServicesHealthResponseApi,+} from './api.schemas'++export const getApmEndpointsListUrl = (projectId: string, params?: ApmEndpointsListParams) => {+ const normalizedParams = new URLSearchParams()++ Object.entries(params || {}).forEach(([key, value]) => {+ if (value !== undefined) {+ normalizedParams.append(key, value === null ? 'null' : String(value))+ }+ })++ const stringifiedParams = normalizedParams.toString()++ return stringifiedParams.length > 0+ ? `/api/projects/${projectId}/apm/endpoints/?${stringifiedParams}`+ : `/api/projects/${projectId}/apm/endpoints/`+}++/**+ * One health row per service and entry span name, worst first. Same gate and window as services.+ */+export const apmEndpointsList = async (+ projectId: string,+ params?: ApmEndpointsListParams,+ options?: RequestInit+): Promise<EndpointsHealthResponseApi> => {+ return apiMutator<EndpointsHealthResponseApi>(getApmEndpointsListUrl(projectId, params), {+ ...options,+ method: 'GET',+ })+}export const getApmServicesListUrl = (projectId: string, params?: ApmServicesListParams) => {const normalizedParams = new URLSearchParams()diff --git a/products/apm/frontend/generated/api.zod.schemas.ts b/products/apm/frontend/generated/api.zod.schemas.tsindex 2f5f16b752df..22be003ea0d6 100644--- a/products/apm/frontend/generated/api.zod.schemas.ts+++ b/products/apm/frontend/generated/api.zod.schemas.ts@@ -27,6 +27,66 @@ export const HealthRowApi = zod.object({export type HealthRowApi = zod.input<typeof HealthRowApi>export type HealthRowApiOutput = zod.output<typeof HealthRowApi>+export const EndpointHealthApi = zod.object({+ service_name: zod.string().describe('The service.name resource attribute.'),+ endpoint: zod.string().describe('The entry span name, for example the HTTP route or the job name.'),+ environment: zod.string().describe('The environment the row was computed for.'),+ status: zod+ .enum(['good', 'warning', 'serious', 'critical'])+ .describe('\* `good` - Good\n\* `warning` - Warning\n\* `serious` - Serious\n\* `critical` - Critical')+ .describe(+ 'Health band from the error rate.\n\n\* `good` - Good\n\* `warning` - Warning\n\* `serious` - Serious\n\* `critical` - Critical'+ ),+ health: zod+ .object({+ request_rate: zod.number().nullable().describe('Requests per second over the window.'),+ error_rate: zod.number().nullable().describe('Share of requests with an error status, 0 to 1.'),+ p95_ms: zod.number().nullable().describe('95th percentile request duration in milliseconds.'),+ span_count: zod.number().describe('Requests counted in the window.'),+ error_count: zod.number().describe('Requests with an error status in the window.'),+ })+ .describe('The health row every surface renders.'),+})++export type EndpointHealthApi = zod.input<typeof EndpointHealthApi>+export type EndpointHealthApiOutput = zod.output<typeof EndpointHealthApi>++export const EndpointsHealthResponseApi = zod.object({+ results: zod+ .array(+ zod.object({+ service_name: zod.string().describe('The service.name resource attribute.'),+ endpoint: zod.string().describe('The entry span name, for example the HTTP route or the job name.'),+ environment: zod.string().describe('The environment the row was computed for.'),+ status: zod+ .enum(['good', 'warning', 'serious', 'critical'])+ .describe(+ '\* `good` - Good\n\* `warning` - Warning\n\* `serious` - Serious\n\* `critical` - Critical'+ )+ .describe(+ 'Health band from the error rate.\n\n\* `good` - Good\n\* `warning` - Warning\n\* `serious` - Serious\n\* `critical` - Critical'+ ),+ health: zod+ .object({+ request_rate: zod.number().nullable().describe('Requests per second over the window.'),+ error_rate: zod.number().nullable().describe('Share of requests with an error status, 0 to 1.'),+ p95_ms: zod.number().nullable().describe('95th percentile request duration in milliseconds.'),+ span_count: zod.number().describe('Requests counted in the window.'),+ error_count: zod.number().describe('Requests with an error status in the window.'),+ })+ .describe('The health row every surface renders.'),+ })+ )+ .describe('One row per service and endpoint, worst status first.'),+ environment: zod.string().describe('The environment the rows were computed for.'),+ service: zod.string().nullable().describe('The service filter applied, if any.'),+ date_from: zod.iso.datetime({ offset: true }).describe('Start of the window used.'),+ date_to: zod.iso.datetime({ offset: true }).describe('End of the window used.'),+})++export type EndpointsHealthResponseApi = zod.input<typeof EndpointsHealthResponseApi>+export type EndpointsHealthResponseApiOutput = zod.output<typeof EndpointsHealthResponseApi>+export const ServiceHealthApi = zod.object({service_name: zod.string().describe('The service.name resource attribute.'),environment: zod.string().describe('The environment the row was computed for.'),diff --git a/products/apm/frontend/healthColumns.tsx b/products/apm/frontend/healthColumns.tsxnew file mode 100644index 000000000000..c7f5ce004c87--- /dev/null+++ b/products/apm/frontend/healthColumns.tsx@@ -0,0 +1,34 @@+import { LemonTableColumns } from '@posthog/lemon-ui'++import type { HealthRowApi, HealthStatusEnumApi } from './generated/api.schemas'+import { formatMs, formatPercent, formatRate } from './healthDisplay'+import { HealthStatusTag } from './HealthStatusTag'++/** Status, requests, errors, and p95: the columns every health table shows for a row. */+export function healthColumns<T extends { status: HealthStatusEnumApi; health: HealthRowApi }>(): LemonTableColumns<T> {+ return [+ {+ title: 'Status',+ key: 'status',+ render: (_, row) => <HealthStatusTag status={row.status} />,+ },+ {+ title: 'Requests',+ key: 'request_rate',+ align: 'right',+ render: (_, row) => <span className="font-mono">{formatRate(row.health.request_rate)}</span>,+ },+ {+ title: 'Errors',+ key: 'error_rate',+ align: 'right',+ render: (_, row) => <span className="font-mono">{formatPercent(row.health.error_rate)}</span>,+ },+ {+ title: 'p95',+ key: 'p95_ms',+ align: 'right',+ render: (_, row) => <span className="font-mono">{formatMs(row.health.p95_ms)}</span>,+ },+ ]+}diff --git a/products/apm/frontend/healthDisplay.ts b/products/apm/frontend/healthDisplay.tsnew file mode 100644index 000000000000..1670797ca5c8--- /dev/null+++ b/products/apm/frontend/healthDisplay.ts@@ -0,0 +1,46 @@+import type { HealthStatusEnumApi } from './generated/api.schemas'++export const STATUS_LABEL: Record<HealthStatusEnumApi, string> = {+ good: 'Healthy',+ warning: 'Watch',+ serious: 'Failing',+ critical: 'Confirmed',+}++export const STATUS_TAG: Record<HealthStatusEnumApi, 'success' | 'warning' | 'danger'> = {+ good: 'success',+ warning: 'warning',+ serious: 'danger',+ critical: 'danger',+}++export function formatRate(perSecond: number | null): string {+ if (perSecond === null) {+ return '—'+ }+ if (perSecond >= 1000) {+ return `${(perSecond / 1000).toFixed(1)}k/s`+ }+ if (perSecond >= 10) {+ return `${Math.round(perSecond)}/s`+ }+ if (perSecond >= 0.1) {+ return `${perSecond.toFixed(1)}/s`+ }+ return `${(perSecond * 60).toFixed(1)}/min`+}++export function formatPercent(fraction: number | null): string {+ if (fraction === null) {+ return '—'+ }+ const pct = fraction * 100+ return `${pct.toFixed(pct >= 10 ? 0 : pct >= 1 ? 1 : 2)}%`+}++export function formatMs(ms: number | null): string {+ if (ms === null) {+ return '—'+ }+ return ms >= 1000 ? `${(ms / 1000).toFixed(1)}s` : `${Math.round(ms)}ms`+}diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 11f04fbd54a7..a46413b052a1 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -42003,6 +42003,62 @@ export namespace Schemas {error_message: string;}+ /**+ * * `good` - Good+ * * `warning` - Warning+ * * `serious` - Serious+ * * `critical` - Critical+ */+ export type HealthStatusEnum = typeof HealthStatusEnum[keyof typeof HealthStatusEnum];+++ export const HealthStatusEnum = {+ Good: 'good',+ Warning: 'warning',+ Serious: 'serious',+ Critical: 'critical',+ } as const;++ export interface HealthRow {+ /**+ * Requests per second over the window.+ * @nullable+ */+ request_rate: number | null;+ /**+ * Share of requests with an error status, 0 to 1.+ * @nullable+ */+ error_rate: number | null;+ /**+ * 95th percentile request duration in milliseconds.+ * @nullable+ */+ p95_ms: number | null;+ /** Requests counted in the window. */+ span_count: number;+ /** Requests with an error status in the window. */+ error_count: number;+ }++ export interface EndpointHealth {+ /** The service.name resource attribute. */+ service_name: string;+ /** The entry span name, for example the HTTP route or the job name. */+ endpoint: string;+ /** The environment the row was computed for. */+ environment: string;+ /** Health band from the error rate.+ *+ * * `good` - Good+ * * `warning` - Warning+ * * `serious` - Serious+ * * `critical` - Critical */+ status: HealthStatusEnum;+ /** The health row every surface renders. */+ health: HealthRow;+ }+export interface EndpointLastExecutionTimesRequest {names: string[];}@@ -42347,6 +42403,22 @@ export namespace Schemas {readonly version_created_by: UserBasic | null;}+ export interface EndpointsHealthResponse {+ /** One row per service and endpoint, worst status first. */+ results: EndpointHealth[];+ /** The environment the rows were computed for. */+ environment: string;+ /**+ * The service filter applied, if any.+ * @nullable+ */+ service: string | null;+ /** Start of the window used. */+ date_from: string;+ /** End of the window used. */+ date_to: string;+ }+export type EndpointsUsageOverviewItemKey = typeof EndpointsUsageOverviewItemKey[keyof typeof EndpointsUsageOverviewItemKey];@@ -57928,44 +58000,6 @@ export namespace Schemas {snoozed: HealthIssueCounts;}- export interface HealthRow {- /**- * Requests per second over the window.- * @nullable- */- request_rate: number | null;- /**- * Share of requests with an error status, 0 to 1.- * @nullable- */- error_rate: number | null;- /**- * 95th percentile request duration in milliseconds.- * @nullable- */- p95_ms: number | null;- /** Requests counted in the window. */- span_count: number;- /** Requests with an error status in the window. */- error_count: number;- }-- /**- * * `good` - Good- * * `warning` - Warning- * * `serious` - Serious- * * `critical` - Critical- */- export type HealthStatusEnum = typeof HealthStatusEnum[keyof typeof HealthStatusEnum];--- export const HealthStatusEnum = {- Good: 'good',- Warning: 'warning',- Serious: 'serious',- Critical: 'critical',- } as const;-export interface HeatmapCapturePage {/** A page URL that currently sends heatmap data. */url: string;@@ -129125,6 +129159,29 @@ export namespace Schemas {offset?: number;};+ export type ApmEndpointsListParams = {+ /**+ * Start of the window, ISO 8601. Defaults to one hour before date_to.+ */+ date_from?: string;+ /**+ * End of the window, ISO 8601. Defaults to now.+ */+ date_to?: string;+ /**+ * Environment to list, as resolved from span resource attributes. Defaults to 'default'.+ * @minLength 1+ * @maxLength 200+ */+ environment?: string;+ /**+ * Only list the endpoints of this service.+ * @minLength 1+ * @maxLength 400+ */+ service?: string;+ };+export type ApmServicesListParams = {/*** Start of the window, ISO 8601. Defaults to one hour before date_to.