ADR-0021 — Observability stack: Application Insights + Log Analytics + Azure Monitor Metrics, instrumented via OpenTelemetry
Context
Every ION service emits three telemetry streams — logs, metrics, and traces — plus audit records for user-attributable actions. ION needs one platform-wide answer to:
- Where does telemetry land (sink choice)?
- What client-side SDK / instrumentation library do services use?
- What is the log schema, log-level policy, and PII-redaction rule?
- What is the metrics schema (labels, cardinality budget)?
- How does distributed tracing propagate across HTTP → Service Bus → Temporal boundaries?
- What is the workspace topology — per-service, per-environment, or platform-wide?
- Where do audit logs live, and how are they distinguished from diagnostic logs?
- How is the correlation-ID discipline codified in ADR-0020 § 8 actually realised end-to-end?
V2 shipped with informal answers per Architecture- Logging Guidelines.md
and Architecture- Logging and Metrics Guidelines.md. Both include
concrete schemas (fields, labels), sampling settings, APIM trace types,
and SLI definitions. This ADR retrospectively codifies them and closes
gaps: distributed tracing across event/workflow boundaries, workspace
topology, audit-vs-diagnostic separation, and OpenTelemetry
instrumentation as the vendor-lock-in mitigation lever.
Forces / Drivers
- Requirement / Constraint: NFR-5 Availability 99.9 %; NFR-4 latency
visibility; correlation-ID discipline from
ADR-0020; Trilateral API
(§ 10) — all three legs (publish/subscribe/REST) must be traceable
with the same correlation identifier; SLI/SLO definitions in
Architecture- Logging and Metrics Guidelines.md; data-residency constraint on Swiss customer telemetry. - Principle(s) embodied: § 16 Observability at every layer (primary); § 21 Azure-native managed services first (Azure Monitor family = the sanctioned sink); § 20 Vendor lock-in mitigation (OpenTelemetry keeps code portable); § 19 Cost as design constraint (sampling, log minimisation, cardinality budget).
- WAF pillar optimized:
operational-excellence(primary — a uniform telemetry contract across services, one query surface, one correlation identifier);reliability(SLI/SLO measurement, incident-response evidence);security(audit trail, JWT-claim provenance in APIM traces).
Decision
Observability is realised on the Azure Monitor family as the sink, instrumented on the client side through the OpenTelemetry SDK, with a common schema for logs, metrics, traces, and audit records. Concretely:
1. Sinks
- Logs and traces → Azure Application Insights, which back onto an Azure Log Analytics workspace per environment (Alpha, Beta, Gamma, Prod). Application Insights is the ingestion + telemetry-shape surface; Log Analytics is the storage + query surface (KQL).
- Metrics → Azure Monitor Metrics (platform metrics from Azure
resources) plus Application Insights
customMetrics(application metrics emitted by service code). - Audit records → Log Analytics workspace, dedicated
IonAudit_CLcustom table, distinct from diagnostic-log tables. Audit records MUST NOT sample, MUST NOT redact, and have their own retention. - Data residency: workspace(s) are provisioned in Switzerland North matching the platform region (ADR-0007, ADR-0017).
2. Workspace topology
- One Application Insights instance per service, per environment. Rationale: independent sampling and cost controls per service; blast radius of a chatty service is bounded; per-service RBAC is possible.
- One shared Log Analytics workspace per environment as the backing store for all Application Insights instances. Rationale: single KQL query surface across services for cross-service traces and incident investigation; matches the Trilateral API observability contract.
- Audit table lives in the shared per-env workspace (not per-service) because audit records are consumed by SOC, compliance, and support — not by service teams.
- NOT to be confused with ADR-0031, which normalizes the V2 ADR3 proposal for one Ontinue/NewCO-owned Log Analytics workspace per customer. Its exact realization is not corroborated. This ADR instead governs shared ION platform observability workspaces per environment.
3. Instrumentation — OpenTelemetry SDK
- Services instrument with OpenTelemetry SDKs (OTel .NET, OTel Python) exporting to Application Insights via the Azure Monitor OpenTelemetry exporter.
- W3C
traceparentandtracestateare the wire-level trace-context format — carried on HTTP headers (per ADR-0020) and on CloudEvents extension attributes (per ADR-0005). - Rationale: OpenTelemetry is the § 20 lock-in mitigation lever — if Azure Monitor is ever swapped for another backend, exporter changes, not application code.
4. Log schema (structured JSON)
Diagnostic logs use structured JSON with the following required
fields (per Architecture- Logging and Metrics Guidelines.md
§ Debug/Diagnostic Logs):
| Field | Purpose |
|---|---|
timestamp | RFC 3339 UTC |
logLevel | Critical / Error / Warning / Information / Debug |
service | Service short-name |
application | Domain application (Incidents / Tickets / Assets / …) |
correlationId | UUID; same identifier walks HTTP → event → workflow |
requestId | UUID for branched/intermediate flows |
customerShort | Customer short-name (never customer PII in the field) |
userEmail | Present only when user context exists (audit-relevant flows) |
environment | alpha / beta / gamma / prod |
server | Instance identifier (Function App instance, pod, host) |
id | Resource identifier (incident id / ticket id / asset id) |
status | success / failure |
message | Human-readable message |
data | Structured payload (nested JSON) |
Log levels follow the standard hierarchy (Critical → Debug); default
production log level is Information; Debug and Trace are disabled
in prod. Health-check functions log at Warning to avoid drowning
signal.
5. Metrics schema
Metrics carry the label set from
Architecture- Logging and Metrics Guidelines.md § Metrics Structure:
timestamp, metricName, metricValue, environment, application,
component, customerShort, transactionId?, correlationId?,
incidentId?.
Cardinality budget: high-cardinality labels (correlationId,
incidentId, userEmail) are attached to logs and traces, not to
metrics. Metrics stay low-cardinality (env × application × component
× customerShort). Violations blow up Application Insights customMetrics
storage cost and are rejected at code-review time.
SLI catalogue (from § API/Business/Pipeline Metrics):
- Business: Time-to-create-ticket; Availability (Alya/Portal); Latency percentiles; Feature usage.
- Pipeline: Timeliness (Sentinel-to-processed delay); Completeness (incidents-successfully-ticketed / non-auto-closed incidents).
- API: Availability (1 - 5xx-rate); Latency percentiles; Throughput; Error rate.
6. Distributed tracing
- Every request/event/workflow-activity carries a
traceparent(W3C). APIM injects one if the caller doesn’t provide it (per ADR-0020 § 8). - HTTP boundary: APIM emits
ION Platform APIM Request/Responsetraces with the JWT claim fields (JwtTenantId,JwtUserId,JwtRoles, etc. — perArchitecture- Logging Guidelines.md§ APIM Traces). Non-JWT variants exist for webhooks. - Event boundary: CloudEvents envelope carries
traceparentas an extension attribute (per ADR-0005); publisher extracts current span context, subscriber restores it. - Workflow boundary: Temporal activities receive
traceparentfrom the workflow context (per ADR-0019); workflow-start captures it from the triggering command/event and propagates it to every activity.
7. Sampling
- Adaptive sampling in Application Insights, configured per-service
in
host.json(Functions) / SDK config (services). Baseline: cap at ~20 telemetry items/second per instance, excludingRequestsandExceptions— those are always retained. - Audit records never sample (§ 1).
Error/Criticallogs never sample.
8. Audit logs (distinct from diagnostic logs)
- Audit records follow the CloudEvents envelope (per
Architecture- Logging and Metrics Guidelines.md § Audit Logs), withtypelikecom.ontinue.audit.<resource>.<action>.v<n>. - Emitted by every service that performs a user-attributable action;
written to the
IonAudit_CLcustom table in the per-env Log Analytics workspace. - Never sampled. Never redacted (PII is expected — it’s the audit trail).
- Retention: separate policy from diagnostic logs (typically longer, driven by compliance).
9. PII / sensitive-data policy
- Diagnostic logs redact tokens, secrets, and full request/response
bodies by default.
userEmailallowed where present. - Customer-tenant data (entities, IPs from customer traffic) is logged only when necessary for debugging; treated as sensitive.
- Audit logs are the only place raw user identity + action is intentionally recorded end-to-end.
10. Health probes contract
- Every service exposes
HEAD /v1/healthcheck/liveness(per Internal API worked example, ADR-0020) at theWarninglog level (so probe traffic doesn’t drown signal). - Readiness probes are separate from liveness where the service runtime distinguishes them (AKS-hosted Temporal cluster, etc.).
Alternatives Considered
Sink
Option A — Azure Monitor family (App Insights + Log Analytics + Azure Monitor Metrics) (selected)
Option B — Self-hosted ELK / Grafana Loki / Prometheus / Tempo
Rejected — decisive: § 21 Azure-native managed services first. Reinforcing: would compound the § 21 exception ION already carries for Temporal (ADR-0019); every stateful cluster ION owns is a permanent operational tax.
Feature parity is not the question here — the operational cost of owning another stateful cluster (or four) is. Azure Monitor is sufficient for ION’s SLIs.
Option C — Datadog / New Relic / Splunk (third-party SaaS)
Rejected — decisive: § 21 — not an Azure-native managed service. Reinforcing: Swiss data-residency constraint on customer telemetry; cost at ION’s log/metric volume; exfiltration of tenant-attributable data to a third-party operator.
Option D — Split vendors (logs = X, metrics = Y, traces = Z)
Rejected — decisive: fragments the correlation-ID story. Reinforcing: tripled operational surface (auth, retention, RBAC, cost model per vendor).
The whole value of correlation-ID discipline is that one identifier walks all three telemetry streams; splitting the stream forces manual join across vendors.
Instrumentation
Option I1 — OpenTelemetry SDK exporting to Azure Monitor (selected)
Option I2 — Application Insights SDK directly (no OTel abstraction)
Rejected — decisive: § 20 vendor lock-in mitigation would be sacrificed with no offsetting gain. Reinforcing: OTel is now Microsoft’s recommended path for Azure Monitor instrumentation.
The Azure Monitor OTel exporter is first-class and stable; using OTel buys sink-portability at no cost.
Option I3 — Custom logging library (Ontinue-authored)
Rejected — decisive: reinventing the SDK ecosystem with no conformance target for consumers or third parties.
Workspace topology
Option W1 — Per-service App Insights + shared per-env Log Analytics (selected)
Option W2 — Single shared Application Insights instance per environment
Rejected — decisive: no per-service sampling / cost isolation — a single chatty service can consume the shared budget. Reinforcing: RBAC is coarser (harder to scope service-team access).
Option W3 — Per-service Log Analytics workspaces (fully isolated)
Rejected — decisive: cross-service KQL queries become cross-workspace joins — expensive and awkward for incident investigation, which is the primary consumer.
Option W4 — Reuse customer-tenant Log Analytics workspaces (per ADR3 V2)
Rejected — decisive: ADR3 governs customer data collection (Sentinel MDR data in customer tenants); mixing platform telemetry into those workspaces breaks tenancy boundary and confuses SOC KQL queries.
Distributed tracing
Option T1 — W3C traceparent everywhere (HTTP + CloudEvents + Temporal) (selected)
Option T2 — Correlation ID only, no distributed tracing
Rejected — decisive: correlation-ID discipline in ADR-0020 § 8 is undermined without span-level trace context. Reinforcing: latency attribution across services is impossible without spans.
Option T3 — Zipkin / Jaeger B3 propagation
Rejected — decisive: W3C traceparent is the standard the Azure Monitor SDK, APIM, and OpenTelemetry all speak natively. B3 would require translation shims at every boundary.
Sampling
Option S1 — Adaptive sampling with Errors/Requests retained (selected)
Option S2 — No sampling
Rejected — decisive: cost at ION’s log volume (~180K incidents/day × N events/incident × M log lines/event) is unsustainable.
Option S3 — Head-based fixed-rate sampling (drop N % up front)
Rejected — decisive: loses low-frequency error signal that is exactly what observability is for.
Audit logs
Option AU1 — Dedicated audit table, CloudEvents envelope, never sampled (selected)
Option AU2 — Mix audit records into diagnostic-log stream
Rejected — decisive: audit compliance requires distinct retention, sampling, and RBAC from diagnostic logs.
Option AU3 — Send audit records to an event-store aggregate
Deferred, not rejected. Sensible longer-term — audit is a natural event-sourcing use case. Retained for a future ADR; current V3 posture is the Log-Analytics audit table.
Rationale
Azure Monitor wins as the sink because § 21 rules alternatives out — the operational cost of self-hosting ELK/Loki/Prometheus is not justified by any feature gap ION has actually hit. Third-party SaaS loses on data residency and § 21.
OpenTelemetry as the instrumentation layer is § 20 in action — the same principle that keeps ION service code portable across substrates. The Azure Monitor OTel exporter is Microsoft’s own recommended path; the abstraction is essentially free.
The per-service-App-Insights + shared-workspace topology gives the right trade-off: independent sampling and cost controls per service, but a single KQL surface for cross-service investigation — the primary consumption pattern during incidents.
W3C traceparent is the only propagation format supported natively at every ION boundary (APIM, Azure Monitor SDK, OTel, and — via the CloudEvents extension — the Service Bus event backbone). Choosing it means zero translation shims.
Distinct audit logs are a compliance non-negotiable; mixing them into the diagnostic-log stream defeats retention, RBAC, and sampling policy alike.
Consequences
Positive
- One telemetry contract across every ION service — one correlation identifier, one query surface, one sampling policy.
- Cross-service incident investigation is a single KQL workspace, not a cross-vendor join.
- OpenTelemetry keeps ION code sink-portable (§ 20).
- Audit trail is compliance-ready by construction (never sampled, never redacted, retention-distinct).
- SLI/SLO measurement is uniformly available for every service.
Negative
- Application Insights cost grows with telemetry volume; sampling policy and cardinality budget must be enforced at code review, not discovered on the bill.
- OpenTelemetry SDK maturity varies by language; Python OTel exporter has known gaps that services must work around.
- Audit-log retention is a separate cost line from diagnostic logs; needs explicit governance.
- Instrumentation is a per-service tax; drift (missing correlation IDs, high-cardinality metrics) is a real risk without automated checks.
Neutral / follow-ups
- Publish
standards/observability-standards.mdcodifying the schema, log levels, sampling, and cardinality rules with worked KQL query examples. - Publish
patterns/audit-logs.md(already stubbed) with the CloudEvents audit envelope and theIonAudit_CLschema. - Automated PR checks for high-cardinality metric labels and missing-correlation-ID logs — follow-up.
- Revisit audit-as-event-store (Option AU3) when the Ticket/Incident event stores mature.
- Contract-test the OTel instrumentation against the log/metric schemas — follow-up standard.
WAF Pillar Impact
- Primary pillar:
operational-excellence— one uniform telemetry contract, one KQL query surface, one instrumentation library. - Secondary pillars:
reliability(SLI/SLO measurement, incident evidence, health probes);security(audit trail, JWT-claim provenance in APIM traces, tenant-attributable actions). Cost-optimization: sampling + cardinality budget keep Application Insights cost bounded, but this is a trade-off, not an optimization — full-fidelity telemetry is out of budget at ION scale. - Trade-offs: Sampling means some low-volume debug detail is intentionally dropped; the cardinality budget means some queries ION might want cannot be answered from metrics alone (must join to logs). ION accepts this because the alternative — unbounded telemetry cost — is worse.
Previous approach (V2)
V2 shipped with informal versions of most of this — structured JSON logs, correlation IDs, Application Insights per Function App, and the Log-Analytics-and-metrics guidelines that this ADR canonicalises. Gaps V2 left open, closed by this ADR:
- No codified distributed-tracing story across event/workflow boundaries (correlation ID existed; span propagation did not).
- No explicit workspace-topology decision (per-service AI + shared Log Analytics per env was practice; never named).
- Audit-vs-diagnostic log separation was inconsistent.
- OpenTelemetry adoption as the § 20 mitigation lever was not yet named.
References
references/Architecture- Logging Guidelines.md— log levels, Function App logging config, APIM trace types.references/Architecture- Logging and Metrics Guidelines.md— SLI/SLO definitions, log/metrics/audit schemas, APIM JWT trace fields.references/Architecture V2- ADR3 - Log Analytics Workspace design.md— customer-tenant workspace design (distinct concern from this ADR).- External: Azure Monitor OpenTelemetry exporter — https://learn.microsoft.com/en-us/azure/azure-monitor/app/opentelemetry-overview
- External: W3C Trace Context — https://www.w3.org/TR/trace-context/
- External: CloudEvents distributed-tracing extension — https://github.com/cloudevents/spec/blob/main/cloudevents/extensions/distributed-tracing.md
Related ADRs
- Depends on: ADR-0005
(CloudEvents extension carries
traceparent); ADR-0020 (correlation-ID discipline on the HTTP leg). - Depended on by: pending CI/CD Runway ADR (deployment observability hooks); pending Reporting Data Store ADR (dashboard freshness SLIs); pending per-service ADRs (SLI/SLO catalogues).
- Related: ADR-0008
(event backbone — trace propagation);
ADR-0014 (APIM emits the
APIM-trace records);
ADR-0019 (Temporal workflows
propagate
traceparentinto activities).