What the telemetry is for
OpenTelemetry is the vendor-neutral standard for traces, metrics and logs. The platform's software emits one trace per work item, such as a report draft or a rights response, and links the steps of a case by a case identifier, so an operator can answer three questions: is it fast and available, is it correct and safe, and what does it cost. Gate, match and deletion events are recorded alongside, without faces. Telemetry carries identifiers, outcomes and measurements. It never carries images, templates, member names or report text (ADR-010). The edge appliances keep their own security-grade logs.
Traces
Spans for each step of an item, parent and child, from intake to the record. One trace identifier follows the item across services and the gateway.
Metrics
Counters and histograms for item latency, gate decisions, match outcomes, tokens, cost and guardrail blocks. Cheap to store and good for alerts.
Events
Business events with a name and properties: consent given, gate decision, match proposed, confirmed or rejected, consent withdrawn, template deleted, register reconciled.
Correlation
The W3C trace context header travels from intake through the AI (artificial intelligence) gateway and the retail gateway, so their logs join the same trace.
The shape of a trace
| Span | Kind | Key attributes |
|---|---|---|
| report.item | Server (root) | store.id (hashed), stage, outcome |
| airs.scan.input, airs.scan.output, airs.scan.tool_args | Client | airs.profile, airs.action, airs.detections (names only) |
| gateway.llm_call | Client | gen_ai.request.model (alias), gen_ai.usage.input_tokens, gen_ai.usage.output_tokens, gateway.cost_usd, gateway.fallback_used |
| retrieval.search | Client | knowledge.index, filter.jurisdiction, results.count, top.score |
| policy.check | Internal | policy.rule, policy.decision |
| tool.call | Client | tool.name, tool.outcome, tool.signed |
What must never be in telemetry
| Data | Rule | How |
|---|---|---|
| Images, frames and templates | Never | Not an attribute. They do not leave the edge or the vault |
| Member names, references and contact details | Never in clear | Dropped by the collector before export |
| Raw match scores | Never | Only a score band is emitted; the raw score is dropped |
| Store identifiers | Hashed | Keyed hash, so queries can group by store without exposing it |
| Blocked content | Never | Record the detection names and the verdict only |
| Counts, timings, versions and outcomes | Allowed | Needed for privacy proof, safety and performance analysis |
Instrumenting the service
A sketch in Python with the OpenTelemetry SDK (Software Development Kit) and the Azure Monitor distribution, which sends to Application Insights. The root span is a server span so it appears as a request; child spans appear as dependencies; business events are logged with a custom event name. Check the current package and attribute names before you build.
import logging, os
from opentelemetry import trace, metrics
from opentelemetry.trace import SpanKind
from azure.monitor.opentelemetry import configure_azure_monitor
configure_azure_monitor(connection_string=os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"])
tracer = trace.get_tracer("retail.platform")
meter = metrics.get_meter("retail.platform")
item_ms = meter.create_histogram("rf.item.duration", unit="ms")
blocks = meter.create_counter("rf.guardrail.blocks")
log = logging.getLogger("rf.events")
def draft_report_item(facts, store):
with tracer.start_as_current_span("report.item", kind=SpanKind.SERVER) as item:
item.set_attributes({"store.id": hash_id(store), "stage": "documentation"})
with tracer.start_as_current_span("airs.scan.input") as sp:
verdict = scan(prompt=json.dumps(facts), store=store, model="rf-fast")
sp.set_attributes({"airs.profile": "privacy-docs-prod", "airs.action": verdict["action"]})
if verdict["action"] != "allow":
blocks.add(1, {"detection": detection_name(verdict), "stage": "input"})
log.warning("guardrail block", extra={"microsoft.custom_event.name": "guardrail.block",
"store.id": hash_id(store), "airs.detection": detection_name(verdict)})
return document_manually(facts, reason="blocked")
with tracer.start_as_current_span("gateway.llm_call") as llm:
draft, usage = draft_privacy_report(facts)
llm.set_attributes({"gen_ai.request.model": "rf-fast", "gen_ai.usage.input_tokens": usage.input,
"gen_ai.usage.output_tokens": usage.output, "gateway.cost_usd": usage.cost})
...
log.info("report signed", extra={"microsoft.custom_event.name": "report.signed", "store.id": hash_id(store),
"edits": edit_count, "minutes_to_sign": minutes})
item_ms.record(elapsed_ms(item), {"stage": "documentation"})A collector in the middle
An OpenTelemetry Collector receives telemetry from the service and the gateway, removes or hashes sensitive attributes, keeps every error, block and gate incident, samples the rest, and sends it to Azure Monitor for operations and to the lakehouse for long-term analysis.
receivers:
otlp:
protocols: { grpc: {}, http: {} }
processors:
attributes/privacy:
actions:
- { key: report.text, action: delete }
- { key: member.ref, action: delete }
- { key: face.score, action: delete } # only a banded score is allowed through
- { key: store.key, action: hash }
tail_sampling:
decision_wait: 10s
policies:
- { name: keep-errors, type: status_code, status_code: { status_codes: [ERROR] } }
- { name: keep-blocks, type: string_attribute, string_attribute: { key: airs.action, values: [block] } }
- { name: keep-gate, type: string_attribute, string_attribute: { key: gate.incident, values: ["true"] } }
- { name: sample-rest, type: probabilistic, probabilistic: { sampling_percentage: 10 } }
batch: {}
exporters:
azuremonitor:
connection_string: ${env:APPLICATIONINSIGHTS_CONNECTION_STRING}
otlphttp/lakehouse:
endpoint: ${env:LAKEHOUSE_OTLP_ENDPOINT}
service:
pipelines:
traces: { receivers: [otlp], processors: [attributes/privacy, tail_sampling, batch], exporters: [azuremonitor, otlphttp/lakehouse] }
metrics: { receivers: [otlp], processors: [batch], exporters: [azuremonitor] }
logs: { receivers: [otlp], processors: [attributes/privacy, batch], exporters: [azuremonitor, otlphttp/lakehouse] }KQL queries operators use
These queries use the workspace-based Application Insights tables in Log Analytics: AppRequests for the root span, AppDependencies for child spans, AppEvents for business events and AppMetrics for metrics. Custom attributes appear in the Properties column. Table and column names can differ with your setup, so adjust them to your workspace. The same Kusto Query Language also runs in Azure Data Explorer if you export telemetry there.
Documentation latency by stage
Median and 95th percentile processing time per stage, hourly, for the last day.
AppRequests
| where TimeGenerated > ago(1d) and Name == "report.item"
| extend stage = tostring(Properties["stage"])
| summarize items = count(), p50 = percentile(DurationMs, 50), p95 = percentile(DurationMs, 95)
by stage, bin(TimeGenerated, 1h)
| order by TimeGenerated desc, stage ascReports or responses sent without a signature (must be zero)
Finds any report or response sent with no approval or content hash. Any row is an incident.
AppEvents
| where Name in ("report.filed", "response.sent")
| extend signer = tostring(Properties["approved_by"]), hash = tostring(Properties["content_hash"])
| where isempty(signer) or isempty(hash)
| project TimeGenerated, store = tostring(Properties["store.id"]), OperationIdTemplates without an active consent (must be zero)
Orphan templates found by the nightly reconciliation, by day. Any row is an incident.
AppEvents
| where TimeGenerated > ago(30d) and Name == "register.reconciled"
| extend orphans = toint(Properties["orphan_count"]), pending = toint(Properties["pending_delete"])
| summarize orphans = sum(orphans), pending_delete = sum(pending), runs = count() by day = bin(TimeGenerated, 1d)
| order by day descWithdrawals not completed within 24 hours (must be zero)
Withdrawals whose deletion event is older than the limit and not yet reconciled.
let withdrawn = AppEvents | where Name == "consent.withdrawn"
| project consent = tostring(Properties["consent.id"]), t0 = TimeGenerated;
let deleted = AppEvents | where Name == "template.deleted"
| project consent = tostring(Properties["consent.id"]), t1 = TimeGenerated;
withdrawn
| join kind=leftouter deleted on consent
| where isnull(t1) and t0 < ago(24h)
| project consent, withdrawn_at = t0Privacy gate decisions by zone
How often the gate allowed matching or discarded a frame, by zone type, to spot a misconfigured zone.
AppEvents
| where TimeGenerated > ago(7d) and Name == "gate.decision"
| extend decision = tostring(Properties["decision"]), zone_type = tostring(Properties["zone_type"])
| summarize decisions = count() by decision, zone_type, bin(TimeGenerated, 1h)
| order by TimeGenerated desc, decisions descMatch proposals and confirmations, by store
Proposals shown, confirmed and rejected, a measure of accuracy in use and of trust.
AppEvents
| where TimeGenerated > ago(30d) and Name in ("match.proposed", "match.confirmed", "match.rejected")
| extend store = tostring(Properties["store.id"])
| summarize proposed = countif(Name == "match.proposed"), confirmed = countif(Name == "match.confirmed"), rejected = countif(Name == "match.rejected") by store
| extend confirm_pct = round(100.0 * confirmed / proposed, 1), reject_pct = round(100.0 * rejected / proposed, 1)
| order by reject_pct descGuardrail blocks by detection
How often each Prisma AIRS detection fired, by hour, to spot an attack or a noisy rule.
AppEvents
| where TimeGenerated > ago(7d) and Name == "guardrail.block"
| extend detection = tostring(Properties["airs.detection"])
| summarize blocks = count(), stores = dcount(tostring(Properties["store.id"]))
by detection, bin(TimeGenerated, 1h)
| order by TimeGenerated desc, blocks descTokens and cost by model alias
Spend and token use per alias and per day, from gateway metadata.
AppDependencies
| where TimeGenerated > ago(14d) and Name == "gateway.llm_call"
| extend model = tostring(Properties["gen_ai.request.model"]),
tin = toint(Properties["gen_ai.usage.input_tokens"]),
tout = toint(Properties["gen_ai.usage.output_tokens"]),
cost = todouble(Properties["gateway.cost_usd"])
| summarize calls = count(), input_tokens = sum(tin), output_tokens = sum(tout), cost_usd = round(sum(cost), 2)
by model, day = bin(TimeGenerated, 1d)
| order by day desc, cost_usd descEdge devices with a failed self-check
Stores whose edge appliance failed its privacy self-check or has not reported, an early sign of a gate fault.
AppEvents
| where TimeGenerated > ago(2d) and Name == "edge.selfcheck"
| extend device = tostring(Properties["device_id"]), result = tostring(Properties["result"])
| summarize last_seen = max(TimeGenerated), last_result = arg_max(TimeGenerated, result) by device
| where last_result != "pass" or last_seen < ago(30m)
| project device, last_seen, resultAlert: block rate spike
Compares the hourly block rate with its normal pattern and returns hours that are anomalously high. Use it as an alert query.
let items = AppRequests | where Name == "report.item"
| make-series items = count() default = 0 on TimeGenerated from ago(14d) to now() step 1h;
let blocked = AppEvents | where Name == "guardrail.block"
| make-series blocked = count() default = 0 on TimeGenerated from ago(14d) to now() step 1h;
items
| join kind=inner (blocked) on $left.TimeGenerated == $right.TimeGenerated
| project TimeGenerated, rate = series_divide(blocked, items)
| extend (flag, score, baseline) = series_decompose_anomalies(rate, 2.5)
| mv-expand TimeGenerated to typeof(datetime), rate to typeof(double), flag to typeof(int), score to typeof(double)
| where flag == 1 and TimeGenerated > ago(3h)Service-level objectives and alerts
| Objective | Signal | Target | Alert |
|---|---|---|---|
| Fast drafts | report.item p95 | Under 30 seconds | p95 over target for 15 minutes |
| Available | Share of items not ending in error | At least 99.5% | Below target for 10 minutes |
| Approved sending | Reports or responses sent without approval | Zero | Any occurrence, page the on-call |
| Consent has teeth | Orphan templates | Zero | Any occurrence, page the on-call and the privacy officer |
| Deletion on time | Withdrawals older than 24 hours without deletion | Zero | Any occurrence, page the on-call |
| Gate healthy | Edge devices failing self-check or silent | Zero | Any device for 30 minutes |
| Scans on all traffic | Model calls with a scan span | 100% | Any unscanned model call |
| Attacks visible | Block rate versus baseline | Within normal range | Anomaly flagged for 1 hour |
| Cost under control | Cost per enrolled member, daily | Within budget | Over 120% of the 7-day average |
Dashboards
Operations
Item latency and errors by stage, step breakdown, tool health and gateway fallbacks.
Privacy and assurance
Gate decisions, orphans, deletion times, match outcomes and error rates by group.
Security
Blocks by detection, anomalies, scan coverage, device self-checks and unapproved sends.
Cost
Tokens and cost by model and stage, cost per enrolled member and budget burn.
Build this for your business
This example is speculative and not a recommendation to deploy, but the same pattern, consent first, a deterministic privacy gate, a governed gateway, runtime security, advisory-only AI and measured fairness, fits any service that handles sensitive personal data. We can scope a pilot on your own systems.
Book a discovery call