Worked Examples
Apply service observability — Sustainable Catalyst Platform Core
Platform Core provides request tracing, operational metrics, service-level monitoring, and deployment diagnostics to support distributed research operations. This guide covers collecting and interpreting those signals while protecting credentials, sensitive research records, and the distinction between operational health and scientific validity.
Application: Sustainable Catalyst Platform Core
Component: Service Observability & Production Operations
Documentation status: Source-reviewed; deployed verification pending
Reviewed source commit: 59b8444365525a58fd4f6a7e29a20d712769e1a2
Estimated reading time: 17–20 minutes
Service observability gives operators a bounded, privacy-conscious view of request failures, service latency, SLOs, and deployment activity. The core requirement is to attribute failures without disclosing research records or secrets while keeping diagnostics separate from evidence authority.
1. Goal — apply observable, privacy-conscious service diagnostics
Capture request latency, status classes, correlation IDs, health conditions, service-level objectives (SLOs), and deployment markers so operators can investigate distributed failures without converting telemetry into scientific evidence. The acceptance criterion is a failure can be attributed across permitted service boundaries without collecting credentials or private research content.
This procedure is source-reviewed against Platform Core commit 59b8444365525a58fd4f6a7e29a20d712769e1a2. It describes implemented routes and source-defined behavior; live staging, production configuration, actual retention execution, and independent security review remain unverified.
2. Requirements — scope, permission, and release evidence
- Authorized, disposable staging or an approved incident-review environment; never insert fabricated monitoring data into production.
- Pinned Platform Core source revision and service image/package digest; verify the deployed revision independently before treating these procedures as production instructions.
- A known service owner and permissible research/organizational scope; a clear distinction between public aggregate status, internal diagnostics, and operator-only writes.
- Approved redaction rules for path parameters, labels, log sinks, retention, and access to traces; an independently verified off-host recovery path for persistent storage.
- Python 3.10+ only if running the optional local synthetic checker. No external provider or production credential is needed for that checker.
3. Architecture — separate four observable layers
| Layer | Implemented responsibility | What it does not establish |
|---|---|---|
| HTTP request tracer | RequestTraceMiddleware emits X-Request-ID, X-SC-Core-Version, and Server-Timing; records bounded request telemetry on a best-effort basis. |
An end-to-end distributed trace with verified spans for every downstream service. |
| Persisted observability control plane | observability_metric_samples, service_level_objectives, and production_deployment_markers hold samples, policies, and release markers. |
A managed external monitoring platform or proof every request was sampled. |
| Gateway and runtime health | Gateway health discovers downstream version mismatches, degraded statuses and timeouts; Core exposes operational readiness independently. | Scientific quality, model validity, or correctness of downstream results. |
| Runtime drift contract v3.97.0 | Versioned schemas for health observations, explicit drift baselines, signals, audit traces, and reference snapshots. | A continuously deployed collector; reference validation is not live drift monitoring. |
The observability and runtime-drift contracts are related but distinct. The v3.97.0 reference bundle includes diagnostic examples, not an assertion that providers or detectors are running. See v2.18.0 operations specification and v3.97.0 runtime contract.
4. Actual routes — select the correct diagnostic surface
| Method / route | Access guard in source | Diagnostic output |
|---|---|---|
GET /v1/observability/readiness |
require_read |
Enabled flags, migration 0021, metric/SLO counts, latest deployment summary. |
GET /v1/observability/metrics/summary |
require_read |
Aggregate sample count, availability, 5xx error rate, p95 latency for one service/window. |
GET /v1/observability/slos/evaluate |
require_read |
Evaluated SLO state: met, breached or insufficient_data. |
POST /v1/observability/metrics |
require_write |
Operator-supplied metric; no automatic proof labels are harmless. |
POST /v1/observability/slos |
require_write |
Create service/indicator/target/window policy. |
POST /v1/observability/deployments |
require_write |
Record a release/deployment-state marker. |
GET /v1/observability/deployments |
require_write |
Operator-facing deployment history. |
POST /v1/observability/retention/compact |
require_write |
Delete expired metric samples; a destructive operator action. |
GET /api/v1/observability/status |
Public credential with data:read and enabled flag |
Aggregate-only operational projection. |
GET /v1/gateway/health |
require_write |
Downstream service status and version-prefix comparisons. |
GET /v1/runtime-observability/contract |
No explicit dependency in inspected route | Reference contract metadata, not live runtime telemetry. |
Access nuance: require_read checks the public_reads setting rather than establishing a human operator identity. Treat internal diagnostic routes as a separate access-review surface; enforce access at the deployment/network boundary until verified. require_write expects X-SC-API-Key when configured and fails closed for writes in production without a configured key. Do not assume that a UI menu or documented “internal” label grants or restricts access.
5. Procedure — establish a trustworthy baseline before changes
- Pin the tested repository commit, image digest, environment, timestamp, and permitted probe target.
- Record whether
SC_CORE_OBSERVABILITY_CONTROL_PLANE_ENABLED,SC_CORE_OBSERVABILITY_REQUEST_METRICS_ENABLED, andSC_CORE_OBSERVABILITY_PUBLIC_STATUS_ENABLEDare enabled; these source defaults aretrue, not proof of deployed settings. - Confirm migration
0021is applied, database persistence is healthy, and the telemetry retention policy has an operator-approved duration. - Before sampling, decide whether routes include personal IDs or sensitive project identifiers; if so, adjust instrumentation/redaction at the trusted ingress or code level.
- Establish a comparison baseline for a bounded 60-minute window; record whether the sample count is adequate before interpreting an SLO state.
# Read-only example for an explicitly authorized local/staging instance.
# Set CORE_BASE to the approved endpoint; never embed an API key in this script.
CORE_BASE="http://127.0.0.1:8000"
curl --fail-with-body --silent --show-error "$CORE_BASE/v1/observability/readiness"
curl --fail-with-body --silent --show-error "$CORE_BASE/v1/observability/metrics/summary?service=platform-core&window_minutes=60"
curl --fail-with-body --silent --show-error "$CORE_BASE/v1/observability/slos/evaluate?service=platform-core"
These are read-only examples. Depending on deployed network policy and public_reads, they may be inaccessible. A failed authorized probe is evidence of that configuration, not authorization to bypass it.
6. Procedure — propagate and reconcile request correlation IDs
The tracer accepts a well-formed X-Request-ID (characters A–Z, a–z, digits, period, underscore, colon, hyphen; up to 64 characters), otherwise generates a UUID-like identifier. It returns a request ID, Core-version header, and a Server-Timing duration. The gateway forwards a correlation identifier to allowed downstream requests, but actual end-to-end propagation must be checked across each component.
# On disposable staging, capture headers only; do not print credentials.
curl --silent --show-error --dump-header - --output /dev/null --header "X-Request-ID: synthetic-trace-01" "$CORE_BASE/health"
# Compare X-Request-ID, X-SC-Core-Version and Server-Timing.
# Confirm downstream logs carry the same safe correlation ID.
Do not use request IDs as tenant authorization, event idempotency keys, or evidence provenance on their own. A correlation ID is a diagnostic locator, not a principal or a scientific data identifier.
7. Procedure — understand request-metric fields and limits
Automatic instrumentation writes an http_request_duration_ms sample containing the service name, request method, request path without query string, HTTP status and class, duration, internal request ID, labels, and observation timestamp. The source uses one database row per successfully recorded request; collection is best-effort, not guaranteed. A recorder exception is logged and does not fail the client request.
Because the current code captures the raw path rather than a parameterized route template, an object identifier embedded in /projects/{project_id} can be retained even if its query string is omitted. Protect and minimize path parameters and metric labels. The generic POST /v1/observability/metrics accepts caller-supplied labels and does not visibly apply secret-key redaction in its service function.
Source: request tracer, metric recorder, and persisted schema.
8. Procedure — calculate availability, 5xx rate, and nearest-rank p95
The v2.18.0 implementation defines availability from HTTP 5xx responses only, rather than all non-2xx responses. It computes p95 as the nearest-ranked sorted latency (rank ceil(0.95 × n)). Responses such as 401, 403, and 429 remain important separate security/quota signals but are not counted as Core availability failures by this implementation.
For n samples and f HTTP 5xx responses: availability = 100 × (n − f) / n; error rate = 100 × f / n. Both values and p95 are undefined when the window has no samples.
# Synthetic example; values are not measured Platform Core traffic.
from math import ceil
statuses = [200, 200, 429, 200, 200, 503, 200]
latencies_ms = [28, 42, 33, 57, 110, 900, 95]
n = len(statuses)
failures = sum(code >= 500 for code in statuses)
availability = round(100 * (n - failures) / n, 4)
error_rate = round(100 * failures / n, 4)
ordered = sorted(latencies_ms)
p95 = ordered[ceil(n * 0.95) - 1]
print(n, failures, availability, error_rate, p95)
# 7 1 85.7143 14.2857 900
This small dataset breaches the illustrative 99% availability SLO but satisfies the 1,000 ms p95 latency target. The code and included fixture reproduce these figures. They do not establish actual service performance.
9. Procedure — evaluate SLOs without inferring missing data
The seeded operational policy in the reviewed v2.18.0 document uses availability ≥ 99% and p95 latency ≤ 1,000 ms over 60 minutes, with at least five samples. The implementation reports met, breached, or insufficient_data. A 100% rate calculated from a single synthetic request is not a reliable 60-minute availability claim.
{
"service": "platform-core",
"name": "availability-60m",
"indicator": "availability_percent",
"target": 99.0,
"comparison": ">=",
"window_minutes": 60,
"minimum_samples": 5,
"metadata": {"purpose": "synthetic-staging-policy-example"},
"enabled": true
}
This is the expected JSON shape for POST /v1/observability/slos. Create a policy only on an approved disposable staging instance using authorized service credentials, and never repeatedly POST a policy with the same service/name: the source rejects duplicate SLO names. Only a read-only operator inspection is needed to use this article.
10. Procedure — compare public aggregates with internal details
When enabled, GET /api/v1/observability/status requires a public API credential containing data:read. Its data projection includes release, status, aggregate sample count, availability, error rate, p95, limited SLO states, and latest deployment release/state. It does not include raw metric samples, labels, principals or operator metadata. The outer response still legitimately includes its own request ID as correlation metadata.
The source returns status=ready when the observability plane is enabled; that flag is not an assertion that the entire platform or an external provider is healthy. Public status can be disabled by configuration and should then return 404. Verify both authorized and unauthorized public requests under the actual deployment rules.
11. Procedure — differentiate upstream health from Core health
The gateway measures health for configured downstream services and may label a service version_mismatch when its reported version does not match the configured expected prefix. It also distinguishes degraded, unreported, and failed upstream conditions. Do not collapse those into “Core failed,” and do not infer that a successful Core readiness probe proves Lab, Workbench, or Site Intelligence is healthy.
Use the authorized GET /v1/gateway/health for the service inventory and compare it with per-service health and release receipts. Source: gateway health/version checks and gateway integration boundaries.
12. Procedure — distinguish runtime-drift schemas from live alerting
The v3.97.0 contract declares runtime health, contract health, explicit baseline values, drift observations, provenance-gap signals, stale-evidence signals, alerts, traces, and immutable supersedable snapshots. Its /v1/runtime-observability/contract, /reference, and validation routes expose reference/validation behavior. No database migration is declared for this contract release.
A successful POST /v1/runtime-observability/validate-drift confirms contract validation of a supplied object; it is not evidence that an active detector measured a real anomaly. Drift and stale-data signals prompt investigation and revalidation, not automatic rejection or promotion of research claims.
13. Procedure — record deployments and link incidents responsibly
The persisted deployment marker accepts started, deployed, failed, rollback, or rolled_back, with release, environment, commit, actor, and metadata. This is an operator-written record, not a cryptographic deployment attestation. Independently cross-check the deployment manifest, image digest, host/service state, and backup/recovery evidence.
Incidents and change-control records are separate governed operational objects; automated rollback is not performed by the v2.19.0 incident contract. Use sanitized correlation IDs and release evidence to support an incident without including user records or service tokens in public tickets. See incident/change-control documentation.
14. Privacy and access boundary — what must never enter telemetry
| Data or field | Observed source treatment | Operator requirement |
|---|---|---|
| Query parameters | The request tracer passes request.url.path, excluding the query string, to the metric recorder. |
Still confirm reverse proxies and upstream logs do not store sensitive query strings. |
| Paths and object IDs | The raw request path is persisted internally; path parameters may expose record IDs. | Prefer parameterized route templates or allowlisted normalization in a reviewed code change; do not dump raw rows in public issues. |
| Request IDs | Stored with metric samples internally and returned to requesting clients for correlation. | Use opaque, nonsecret IDs; restrict metric-table access. |
| Metric labels | Generic metric creation persists supplied labels; no general secret-sanitizer is visible in this function. |
Allowlist label keys; reject token, email, patient, document, and research-content values. |
| Public status | Aggregate projection excludes raw samples, labels, detailed deployment metadata. | Test response body, wrapper metadata, caches and authorization boundary. |
| Runtime reference examples | Static fixture and schema contract; not a stream of deployed observations. | Never label examples as measured incidents. |
Operational note: Permission barriers around internal observability endpoints must be validated at the network/gateway layer; the source-level require_read dependency is not a principal-level entitlement check.
15. Retention and diagnostic minimization
The source defaults to SC_CORE_OBSERVABILITY_RETENTION_HOURS=720 (30 days) and provides a guarded POST /v1/observability/retention/compact operation deleting metric samples older than that duration. This endpoint is a mutation and should only run under documented retention approval, backup/recovery conditions, and staging or production change control.
A retention setting alone does not prove scheduled compaction is running. Verify actual scheduler invocation, timestamps, and post-compaction row counts on authorized staging. Do not use metrics deletion to erase incident evidence outside an approved retention policy.
16. Symptoms — service observability appears incomplete
| Symptom | Likely category | First check |
|---|---|---|
| No samples despite responsive API | Disabled instrumentation, DB write failure, insufficient traffic | Enabled flags, recorder exception logs, metric count and request IDs. |
| Dashboard reports 100% uptime with few requests | Sparse samples, 4xx exclusion, wrong service/window | Sample count, status-class distribution, SLO minimum samples. |
| Downstream unavailable but Core ready | Gateway or upstream-specific failure | Gateway health, upstream version, health timeout, correlation ID. |
| Public status contains detailed records | Disclosure projection or intermediary cache | Response body including nested fields, cache policy, raw log access. |
| Unexpected 401/403/404 | Credential, scope, or feature flag | data:read, public status flag, and actual route guard. |
| Too many metrics/large logs | Missing compaction, high cardinality | Retention jobs, path shape, labels, and table growth. |
| Drift validation passes but no real alert | Contract validation confused with active detection | Runtime collector configuration and real observation receipts. |
17. Cause — classify the root failure
Separate instrumentation failure (sampling, DB persistence, exception), interpretation failure (wrong denominator, sparse SLO window, 4xx treatment), correlation failure (lost IDs or environment mismatch), access failure (internal/public scope exposure), and upstream failure (version mismatch, timeouts, degraded service). Record the cause only after a reproducible read-only observation or isolated test.
A 5xx response means a request failed at the HTTP layer, not that its scientific result was invalid. Likewise, a high p95 does not identify which upstream component caused the delay without additional trace evidence.
18. Troubleshooting — safe diagnostic order
- Preserve timestamp, source/build commit, status code, response request ID, affected route template (without private identifiers), and approved incident identifier.
- Check
/health,/v1/observability/readiness, feature settings, and migration0021; do not create test traffic on production to manufacture samples. - Query
/metrics/summaryand/slos/evaluatefor the same service/window. Ifno_samplesorinsufficient_data, stop drawing SLO conclusions. - For service-specific failure, compare gateway health, service image version and separate downstream logs through an authorized channel.
- For possible data leakage, stop affected public diagnostics at the verified release boundary and preserve private evidence for a security reviewer; avoid posting raw responses publicly.
- For persistence errors, verify storage failure and application response independently; a best-effort telemetry failure should not change the original response.
- For drift/provenance warnings, retain the last accepted research record and require deliberate scientific revalidation; never auto-rewrite evidence.
19. Resolution — bounded reversible actions
For a monitoring configuration mismatch, restore the approved prior configuration and compare feature flags and service versions. For retention problems, rehearse the documented compaction on a disposable clone before authorizing a destructive production action. For high-cardinality labels or path leakage, propose a code-level minimization fix, replay only synthetic probes, and retest non-disclosure. For health check failures, repair the affected downstream service rather than altering accepted research artifacts.
A deployment marker or rollback recommendation does not execute a rollback. Require independent backup verification, scoped deployment approval, post-release health checks, and a fresh comparison of response IDs and metrics.
20. Verification — source-aligned acceptance conditions
| Case | Acceptance criterion | Evidence required |
|---|---|---|
| V-01 | An authorized request returns an opaque correlation ID, Core version and timing. | Response headers and matched sanitized operator trace. |
| V-02 | Metric records exclude query strings; raw path IDs and labels reviewed for sensitivity. | Internal row inspection performed only in an approved staging clone. |
| V-03 | The original user request is not failed by a simulated metric-write exception. | Injected storage failure and unchanged HTTP result. |
| V-04 | Availability counts 5xx, not 401/403/429; p95 matches nearest-rank algorithm. | Bounded synthetic responses and expected aggregate. |
| V-05 | SLO states include insufficient_data with inadequate sample count. | Policy and sample-count fixture. |
| V-06 | Public status omits private samples and operator details and rejects unscoped clients. | Positive/negative anonymous and scoped probes. |
| V-07 | Gateway version mismatch and unavailable service remain distinguishable. | Controlled synthetic upstream plus gateway health record. |
| V-08 | Retention compaction deletes only age-qualified metric samples. | Before/after disposable-DB counts and recovery test. |
| V-09 | No telemetry/drift alert automatically changes a claim or evidence status. | Research record hash/state before and after diagnostic event. |
| V-10 | Actual deployment release/digest, off-host backup and rollback evidence are reviewed independently. | Timestamped and owner-approved release receipt. |
21. Offline synthetic evidence checker — reproduce calculations
The downloadable companion checker is stdlib-only Python and accepts only a synthetic evidence packet. It recalculates request counts, 5xx availability, error rate, nearest-rank p95, SLO states, public status projection, and checks for obvious credential leakage and unsupported verification claims.
cd sc-platform-core-service-observability
python3 check_observability_evidence.py synthetic-observability-packet.json --output verified-synthetic-result.json
python3 -m unittest -v test_observability_evidence.py
# No network calls, no production configuration, no credential input.
The fixture intentionally has seven requests, including one 503 and one 429. Its availability is 85.7143%, error rate 14.2857%, and p95 is 900 ms. A passing packet status is synthetic-evidence-consistent—it is not a claim that deployed observability works.
22. Operator evidence register and release gate
Before declaring deployment verification, attach an exact commit and image digest; the enabled settings and migration receipt; timestamped staging request/response headers; sample counts and SLO states; actual negative public-disclosure probes; storage-failure injection results; gateway version-mismatch test; retention-compaction rehearsal; and an approved rollback plan. Mark each requirement passed, failed, blocked, or not run. The companion acceptance_matrix.csv intentionally leaves live tests as NOT_RUN.
For production decisions, review the organization’s access and privacy policies separately from scientific acceptance. Metrics can support incident attribution and operational confidence, but cannot independently validate published results.
23. Scientific interpretation — diagnostics are not evidence authority
Operational signals are informative but epistemically limited: a healthy endpoint does not validate a model, a stale observation is not necessarily false, a breached SLO does not revoke scientific findings, and an unchanged data fingerprint does not establish reproducibility. Link diagnostic records to scientific work only through authorized provenance references and independently documented methods.
The v3.97.0 contract explicitly prevents drift, alert, and stale-evidence signals from silently changing research truth status. Preserve source data, analytical assumptions, uncertainty, provenance, and accountable review outside the operations metric plane.
24. Technical references — pinned source and contract boundaries
- RequestTraceMiddleware: correlation ID, timing, fail-open metrics and path logging
- Observability service: recording, aggregation, SLO evaluation, deployment markers, retention
- Observability router: internal/public API guards and projection
- SQLAlchemy models: persisted metrics, objectives, and deployment marker tables
- Settings: observability flags, defaults, retention and SLO targets
- Repository tests: no-query metrics, p95, SLOs, privacy and retention
- v2.18.0 observability design and privacy boundary
- Gateway service: upstream health, version checks, timeouts
- v3.97.0 runtime reference/validation endpoints
- v3.97.0 trace, audit, drift and snapshot schemas
- Runtime observability epistemic boundaries
- Incident/change-control operational separation
