docs(observability): Telemetry 0.3.0 published, adopted by all four apps, logs over OTLP proven (#55)

Evidence doc gains the #55 section (root cause of no logs, 0.3.0 contents + SHA256,
per-app commits, collector output per app: service.version, site.id, node.role and
log records on OtOpcUa, HistorianGateway, ScadaBridge Site and MxAccessGateway).
GAPS, current-state, SPEC, the Telemetry CLAUDE.md and the index row updated;
infra/otel-collector gains otelidentity.py (Resource per signal + log samples).

Claude-Session: https://claude.ai/code/session_01GT67ACmpMR7b9LGRPLijMi
This commit is contained in:
Joseph Doherty
2026-11-12 21:28:50 -05:00
parent 2011c8d6b9
commit f05ce80269
10 changed files with 247 additions and 27 deletions
@@ -165,9 +165,143 @@ HistorianGateway (`ZB.MOM.WW.HistorianGateway` meter + source) and MxAccessGatew
- **ScadaBridge#133:** OTLP from the Central role is not yet proven.
- **scadaproj#54:** collector on the wonder tiers.
## Telemetry 0.2.1: not published
## Telemetry 0.2.1: not published (superseded — shipped inside 0.3.0, see below)
No finding needed a library change. The fixes and gaps above are all on the app side. `0.2.1`'s
scheme-less-endpoint rejection is a startup-breaking behaviour change. Publishing it would also
need a consumer pin-bump plan, and this run shows no consumer is exposed to that typo. It stays
built-but-unpublished until a pin bump wants it.
---
# Resource identity + logs over OTLP — scadaproj#55 (2026-11-12, same day)
Closes the three #55 gaps found above: no `service.version` anywhere, no `site.id`/`node.role` on OtOpcUa,
MxAccessGateway and HistorianGateway, and no logs over OTLP from any app.
## Root cause of "no logs"
`ZbSerilogConfig.ApplyOpenTelemetryExport` adds the `WriteTo.OpenTelemetry` sink only when the options
passed **to `AddZbSerilog`** say `Exporter=Otlp`. Every app filled those options with the service name alone
and set the exporter only on `AddZbTelemetry`, a separate options object the Serilog package never saw. The
sink condition could therefore never be true.
## Library: `ZB.MOM.WW.Telemetry(.Serilog)` 0.3.0 — published
scadaproj `main` `b34049b` + `334c82c`. Feed SHA256 (feed download = local pack):
| Package | SHA256 |
|---|---|
| `ZB.MOM.WW.Telemetry.0.3.0.nupkg` | `a61492383bc854f6108f20da6ec55a16b2e0bf6121cd7ca13c86a951cb29f5e2` |
| `ZB.MOM.WW.Telemetry.Serilog.0.3.0.nupkg` | `04675cead32e2fb2c2cfbe88cdb4b7895b4b1601c53ba379b6215f53c731478c` |
- **`service.version`**: `ServiceVersion = null` (the default) now means the entry assembly's
`AssemblyInformationalVersion` (the git SHA the apps stamp), falling back to its assembly version. Set a
value to override it; `""` omits the attribute.
- **`ResourceAttributes`**: extra Resource attributes on all three signals. The first-class keys
(`service.*`, `host.name`, `site.id`, `node.role`) are reserved and rejected at startup.
- **`ApplyConfiguration(section)`**: reads `Exporter`, `OtlpEndpoint`, `ServiceVersion`, `SiteId`, `NodeRole`,
`ExportLogs`, `ResourceAttributes:<key>` from an app's own `<App>:Telemetry` section. Absent keys keep the
code defaults, so the four hand-written exporter parsers are gone.
- **Logs follow `AddZbTelemetry`**: `AddZbTelemetry` registers its options in DI. `AddZbSerilog` resolves them
inside its `AddSerilog` callback (so call order does not matter), and when its own options do not select
OTLP, the OTLP log sink uses that registration's endpoint and Resource. `ExportLogs = false` keeps logs
local. Levels and the configuration-driven sinks are unchanged.
- **0.2.1 shipped in the same release.** It holds the P3 review fixes: redaction after `ConfigureLogger`,
dictionary-key collisions, and the stricter endpoint check (`collector:4317` without a scheme now fails at
startup when `Exporter=Otlp`). It is a minor bump because it adds API and changes behaviour. No checked-in
config in any of the four repos sets an OTLP endpoint. The check is a no-op unless `Exporter=Otlp`, and no
wonder tier has a collector yet (#54), so no deployed box can trip it.
- **Tests**: 42 → **77** in Release (Telemetry 38, Serilog 39). They include a loopback OTLP/gRPC receiver on
Kestrel that proves a log record arrives with `service.version`/`site.id`/`node.role`/an extra attribute, an
`ExportLogs=false` case with a metrics positive control, and a Prometheus case.
Mutation checks, each caught by the named tests:
- Drop the DI lookup → the e2e log test fails.
- Drop the version default → the pipeline-Resource and e2e tests fail.
- Drop `ResourceAttributes` → 2 attribute tests and the e2e test fail.
- Ignore `ExportLogs` → the decision test and the e2e test fail.
- Disable the reserved-key check → 7 theory cases fail.
- Drop `ApplyConfiguration`'s attribute or `SiteId` read → its test fails.
## Apps (all pushed to their default branch; no wonder-box deploys)
| App | Commit | Pin | Identity wiring |
|---|---|---|---|
| OtOpcUa | `master` `412da27c` | 0.1.0 → 0.3.0 | `site.id` = the application Cluster id (the `cluster-<ClusterId>` role suffix; omitted on a legacy node); `node.role` = the plain roles, sorted (`admin,driver`); Program passes its `EffectiveRoles`. |
| MxAccessGateway | `main` `d9d9ff48` | 0.1.0 → 0.3.0 (csproj) | `node.role=standalone` (one gateway per box); `site.id` from `MxGateway:Telemetry:SiteId` (there is no node identity in its config, so it is omitted unless set). |
| HistorianGateway | `main` `ae1dbcc` | 0.1.0 → 0.3.0 (csproj) | Same as mxgw, under the root-level `Telemetry:` section. |
| ScadaBridge | `main` `a633005f` | 0.2.0 → 0.3.0 | Unchanged `site.id`/`node.role`. The new `ScadaBridgeTelemetryConfig` fills both `AddZbTelemetry` and the pre-host `AddZbSerilog` logger. The logger is built on its own container with no `AddZbTelemetry` to follow, so the exporter is passed to it explicitly. |
Tests: OtOpcUa Host.Tests 288/288 + Host.IntegrationTests 325/327 (2 skipped); mxgw MxGateway.Tests 1446/1452
(6 skipped); HistorianGateway 1414 + 206 + 186 passed; ScadaBridge Host.Tests 699/699. Each app gained identity
tests (OtOpcUa `ObservabilityResourceIdentityTests`, HG `GatewayTracingTests`, ScadaBridge
`ScadaBridgeTelemetryConfigTests`).
## What arrived (collector, [`otelidentity.py`](../../infra/otel-collector/otelidentity.py), one process each)
All runs: `Exporter=Otlp`, `OtlpEndpoint=http://10.100.0.35:4317`, `OTEL_METRIC_EXPORT_INTERVAL=10000`.
**OtOpcUa** — local Release host, fused `admin,driver,cluster-OTEL55` single node. Its own Akka mesh on
`localhost:14053`. Throwaway ConfigDb `OtOpcUaOtel55` on the docker-dev SQL: EF-migrated, one
`ServerCluster` `OTEL55` + one `ClusterNode`, gRPC mesh/telemetry keys of its own. The DB was **dropped
afterwards**. Activity: one `POST /api/deployments` (202) plus health/metrics GETs.
```
RESOURCE resourceMetrics {"service.name": "otopcua", "service.version": "1.0.0+412da27c5fb7e440e4a75d4f8e82e0e5b9832411", "service.instance.id": "Josephs-MacBook-Pro:67675", "site.id": "OTEL55", "node.role": "admin,driver", "host.name": "Josephs-MacBook-Pro"}
RESOURCE resourceSpans {... identical ...}
RESOURCE resourceLogs {... identical ...}
COUNTS {'metric points': 427, 'spans': 29, 'log records': 73} SEVERITY {'Information': 61, 'Warning': 12}
LOG {"severity": "Information", "body": "OtOpcUa.Host starting with roles=[admin,driver,cluster-OTEL55] (admin=True, driver=True) source=Configured"}
LOG {"severity": "Information", "body": "HTTP POST /telemetry.v1.TelemetryStreamService/Subscribe responded 200 in 29942.6698 ms", "traceId": "f5f90813adac357cdce4c165ab9e1468"}
```
The `otopcua.deploy.apply` and `otopcua.opcua.address_space_rebuild` spans arrived again.
**HistorianGateway** — local Release host, `Development`, HTTP `:15220` / gRPC `:15221`, scratch SQLite stores,
`Telemetry__SiteId=otel-probe-55`. Activity: `HistorianStatus/Probe` + health GETs.
```
RESOURCE resourceMetrics {"service.name": "historian-gateway", "service.version": "1.0.0+ae1dbccc201aeebbe030c407870879a7985002db", "service.instance.id": "Josephs-MacBook-Pro:72641", "site.id": "otel-probe-55", "node.role": "standalone", "host.name": "Josephs-MacBook-Pro"}
RESOURCE resourceSpans {... identical ...}
RESOURCE resourceLogs {... identical ...}
COUNTS {'metric points': 184, 'spans': 12, 'log records': 29} SEVERITY {'Information': 25, 'Warning': 2, 'Error': 2}
LOG {"severity": "Information", "body": "Request starting HTTP/1.1 GET http://localhost:15220/health/ready - null null", "traceId": "8eca56a689d61f710bdbdaad32879a6b"}
```
**ScadaBridge (Site)** — local Release **Site** host, own site id `otel-probe-55`, own 1-node mesh (`localhost:18082`),
scratch LocalDb/audit/secrets, metrics listener `:18084`, central endpoint deliberately unreachable.
```
RESOURCE resourceMetrics {"service.name": "scadabridge", "service.version": "1.0.0+a633005f4f826e662d09fa47359bced17ccd6acf", "service.instance.id": "Josephs-MacBook-Pro:69217", "site.id": "otel-probe-55", "node.role": "Site", "host.name": "Josephs-MacBook-Pro"}
RESOURCE resourceSpans {... identical ...}
RESOURCE resourceLogs {... identical ...}
COUNTS {'metric points': 290, 'spans': 30, 'log records': 78} SEVERITY {'Information': 66, 'Warning': 10, 'Error': 2}
LOG {"severity": "Information", "body": "Starting ScadaBridge host as Site on localhost"}
LOG {"severity": "Information", "body": "Request starting HTTP/1.1 GET http://localhost:18084/health/ready - null null", "traceId": "0e976e6c0b8d7d3d0aaf85a99f5fbe21"}
```
The first line, `Starting ScadaBridge host …`, is written to the static logger before any web host exists, so
the explicit exporter path on the pre-host logger works. **Central not run:** the rig was in use by the
ScadaBridge#132 failover drills (`sb132-p` / `sb132-probe` running, centrals recreated 3–6 minutes earlier), so
ScadaBridge#133 stays open.
**MxAccessGateway** — Release `main` `54aa61a0`, published framework-dependent win-x64 from the Mac. (It was
pushed as `d9d9ff48` after rebasing over one docs-only commit.) Run as a scratch copy at `C:\otel55\mxgw` on
windev, on `:15120`/`:15130`, under `Staging` + `DisableLogin`, with alarms off, scratch auth/secrets/snapshot
stores and a throwaway pepper. `Worker:ExecutablePath` pointed at the non-existent
`C:\otel55\OtelProbeNoWorker.exe`. It was launched through `Win32_Process.Create`, because a process started
from the ssh session dies with it. `MxGateway__Telemetry__SiteId=otel-probe-55`.
```
RESOURCE resourceMetrics {"service.name": "mxgateway", "service.version": "0.1.2+54aa61a0", "service.instance.id": "DESKTOP-6JL3KKO:23580", "site.id": "otel-probe-55", "node.role": "standalone", "host.name": "DESKTOP-6JL3KKO"}
RESOURCE resourceSpans {... identical ...}
RESOURCE resourceLogs {... identical ...}
COUNTS {'metric points': 454, 'spans': 37, 'log records': 21} SEVERITY {'Warning': 3, 'Information': 6, 'Error': 12}
LOG {"severity": "Information", "body": "Gateway alarm monitor disabled (MxGateway:Alarms:Enabled is false)."}
LOG {"severity": "Error", "body": "Health check worker-executable with status Unhealthy completed after 4.6339ms with message 'Worker executable ...", "traceId": "b76b4059dd4f33c88e556ec5ef2e4083"}
```
The live `MxAccessGw` service stayed `Running` with `:5130/health/ready` = 200 throughout. Its gateway PID
(9148) and worker PIDs (`14700,22108`) were unchanged before and after. The scratch copy and `C:\otel55` were
deleted.
On every app, log records carry `traceId` when written inside a request, so logs join their spans in the
backend. The Resource is byte-identical across the three signals of each process.
+12 -3
View File
@@ -29,6 +29,14 @@ reach the shared `ZB.MOM.WW.Telemetry` library. Status legend: ⛔ gap · 🟡 p
> from OtOpcUa, HistorianGateway, ScadaBridge (Site) and MxAccessGateway. One defect fixed: OtOpcUa's
> Galaxy driver meter/source were missing from the allowlists (lmxopcua#892). Evidence:
> [`2026-11-12-otlp-end-to-end-evidence.md`](2026-11-12-otlp-end-to-end-evidence.md).
>
> **✅ RESOURCE IDENTITY + LOGS OVER OTLP — 2026-11-12 (#55, closed).** Telemetry(.Serilog) **`0.3.0`**
> (published; ships the 0.2.1 review fixes): `service.version` defaults from the entry assembly's
> informational version (the git SHA), `ResourceAttributes` + `ApplyConfiguration(<App>:Telemetry)`, and the
> Serilog OTLP log sink follows `AddZbTelemetry`'s exporter. All four apps pin `0.3.0` and report
> `service.version`, `site.id` and `node.role` (OtOpcUa: Cluster id / plain roles; mxgw + HG: `standalone`
> + configurable `SiteId`; ScadaBridge unchanged) and send logs — proven at the collector for OtOpcUa,
> HistorianGateway, ScadaBridge (Site) and MxAccessGateway. Central role still → ScadaBridge#133.
## Divergence vs spec
@@ -267,7 +275,8 @@ behaviour-preserving except the intentional, no-consumer-yet metric-shape change
ScadaBridge#133). See [`2026-11-12-otlp-end-to-end-evidence.md`](2026-11-12-otlp-end-to-end-evidence.md).
- **No collector on the wonder tiers** (DEV vd03, QA vq03/vq04) — every deployed box is still
Prometheus-only. → #54
- **Resource identity + logs-over-OTLP gaps** found by #13: `service.version` absent on all four apps;
`site.id`/`node.role` absent on OtOpcUa, MxAccessGateway, HistorianGateway; no app passes the exporter
settings to `AddZbSerilog`, so logs never travel over OTLP. → #55
- ~~**Resource identity + logs-over-OTLP gaps** found by #13~~ — **DONE 2026-11-12 (#55)**: Telemetry
`0.3.0`; all four apps report `service.version` / `site.id` / `node.role` and export logs over OTLP
(OtOpcUa `412da27c`, ScadaBridge `a633005f`, MxAccessGateway `d9d9ff48`, HistorianGateway `ae1dbcc`). See the
#55 section of [`2026-11-12-otlp-end-to-end-evidence.md`](2026-11-12-otlp-end-to-end-evidence.md).
- **Further ScadaBridge instruments** beyond the first 4 are additive future work (not blocking). → ScadaBridge#81
@@ -5,6 +5,12 @@
> OTLP export of **metrics and traces** is proven end to end (scratch copy of the deployed windev build; the
> `mxgateway.*` gauges and ASP.NET Core spans arrived). The gateway still has no `ActivitySource` of its own.
> Evidence: [`2026-11-12-otlp-end-to-end-evidence.md`](../../2026-11-12-otlp-end-to-end-evidence.md).
>
> **2026-11-12 update (scadaproj#55):** closed on `main` `d9d9ff48` (Telemetry `0.3.0`). The Resource now
> carries `service.version` (entry-assembly informational version, e.g. `0.1.2+54aa61a0`), `node.role=standalone`
> (one gateway per box; `MxGateway:Telemetry:NodeRole` overrides) and `site.id` from
> `MxGateway:Telemetry:SiteId` (no natural value in the gateway's config, so it is omitted unless set).
> `MxGateway:Telemetry:Exporter=Otlp` now also sends the Serilog logs (proven: 21 log records).
Repo: `~/Desktop/MxAccessGateway`. Stack: .NET 10 gateway (x64) + .NET 4.8 worker (**x86**);
solution `src/MxGateway.sln`. Telemetry code is concentrated in
@@ -7,6 +7,13 @@
> Galaxy driver's `galaxy.*` spans and `galaxy.events.*` counters were missing from the allowlists; fixed in
> lmxopcua#892 (`master` `db86b996`). Still absent from the Resource: `service.version`, `site.id`, `node.role`
> (scadaproj#55). Evidence: [`2026-11-12-otlp-end-to-end-evidence.md`](../../2026-11-12-otlp-end-to-end-evidence.md).
>
> **2026-11-12 update (scadaproj#55):** closed on `master` `412da27c` (Telemetry `0.3.0`). The Resource now
> carries `service.version` (entry-assembly informational version, e.g. `1.0.0+412da27c…`), `site.id` = the
> node's application Cluster id (suffix of its `cluster-<ClusterId>` role; omitted on a legacy node) and
> `node.role` = its plain roles (`admin`, `driver`, `admin,driver`). `OtOpcUa:Telemetry:SiteId` / `:NodeRole` /
> `:ServiceVersion` / `:ResourceAttributes:*` override them. `OtOpcUa:Telemetry:Exporter=Otlp` now also sends
> the Serilog logs to the collector (proven: 73 log records with the same Resource).
Repo: `~/Desktop/OtOpcUa`. Stack: .NET 10, Akka.NET, OPC UA; solution `ZB.MOM.WW.OtOpcUa.slnx`.
Telemetry code lives in two places: `src/Server/ZB.MOM.WW.OtOpcUa.Host/Observability/` (host-side
@@ -5,6 +5,12 @@
> end to end for a **Site** node (6 `scadabridge.*` instruments, `localdb.oplog.depth`, gRPC-client spans,
> with `site.id`/`node.role` on the Resource); the Central role is not yet proven (ScadaBridge#133).
> Evidence: [`2026-11-12-otlp-end-to-end-evidence.md`](../../2026-11-12-otlp-end-to-end-evidence.md).
>
> **2026-11-12 update (scadaproj#55):** closed on `main` `a633005f` (Telemetry `0.3.0`). `service.version` now
> on the Resource (entry-assembly informational version); `site.id`/`node.role` unchanged.
> `ScadaBridgeTelemetryConfig` fills both the `AddZbTelemetry` registration and the pre-host `AddZbSerilog`
> logger, so `ScadaBridge:Telemetry:Exporter=Otlp` also sends logs (proven on a Site node: 78 log records,
> including the pre-host startup line). Central still → ScadaBridge#133.
Repo: `~/Desktop/ScadaBridge`. Stack: .NET 10, Akka.NET, Docker; solution
`ZB.MOM.WW.ScadaBridge.slnx`. The telemetry posture is split across a dangling OTel package ref
+3 -2
View File
@@ -67,10 +67,11 @@ The OTel `Resource` attached to all three signals is built from `ZbTelemetryOpti
|---|---|---|
| `service.name` | `ServiceName` | Required. Lower-case short identifier (`otopcua`, `mxgateway`, `scadabridge`) |
| `service.namespace` | `ServiceNamespace` | Default `"ZB.MOM.WW"` — constant across the fleet |
| `service.version` | `ServiceVersion` | Optional; recommend populating from `AssemblyInformationalVersion` |
| `service.version` | `ServiceVersion` | Defaults (Telemetry 0.3.0+) to the entry assembly's `AssemblyInformationalVersion` — the git SHA every family app stamps; set a value to override, `""` to omit |
| `service.instance.id` | _(auto)_ | Always populated from `ZbResource.InstanceId` — a deterministic `MachineName:ProcessId`. The OTel SDK's random-GUID default is disabled so every signal from the same process carries an identical, restart-stable instance id for cross-signal correlation |
| `site.id` | `SiteId` | Optional; identifies the physical/logical site |
| `node.role` | `NodeRole` | Optional; e.g. `"central"`, `"site"`, `"hub"` |
| `node.role` | `NodeRole` | Optional; e.g. `"central"`, `"site"`, `"hub"`, `"standalone"` |
| _(any other)_ | `ResourceAttributes` | Optional extra attributes (0.3.0+); the keys above are reserved |
| `host.name` | _(auto)_ | Always populated from `Environment.MachineName` |
The same `SiteId` and `NodeRole` values are passed to the Serilog enrichers (§4) so a