Fix all baseline code-review findings across the six shared libraries
Resolves the 35 findings from the 2026-06-01 baseline (commit 26ba1c7),
test-first for every behavioral change. +51 tests (331 -> 382 passing, 0 failed).
- Telemetry-001 (HIGH): RedactionEnricher now honours property removal, so a
redactor that drops a key actually scrubs the secret from the event.
- Auth: LDAP validator ValidateOnStart; API-key verify no longer fails on a
best-effort MarkUsed write or a corrupt scopes column (fail-closed); LDAP cert
validation hook; KeyPrefix persistence aligned; README algorithm corrected.
- Health: Akka checks return Degraded (not throw) when the cluster isn't up yet;
GrpcDependencyHealthCheck catch-all; null 'description' rendered; composite
endpoint builder; XML docs shipped.
- Audit: CompositeAuditWriter no longer re-throws OperationCanceledException;
TruncatingAuditRedactor over-redact scrubs Target + safe negative max; options
record; XML docs shipped.
- Configuration: TryAddEnumerable idempotent registration; consistent port
quoting; strict invariant port parsing; XML docs + README packaged.
- Theme: mobile toggle is now CSS-only (no Bootstrap JS); token/CSS hygiene;
XML docs on the public parameter surface.
Shared-contract/spec docs updated where the code was the source of truth
(observability service.instance.id, MapZbMetrics, redactor reach). All changes
additive/back-compatible at v0.1.0. code-reviews bookkeeping follows separately.
This commit is contained in:
@@ -124,17 +124,32 @@ public static class ZbTelemetryExtensions
|
||||
/// Used internally by AddZbTelemetry. Exposed for tests and custom pipelines.
|
||||
public static class ZbResource
|
||||
{
|
||||
/// Deterministic, process-stable service instance identifier, formatted as
|
||||
/// "MachineName:ProcessId". Populates OTel Resource service.instance.id on every signal
|
||||
/// (metrics, traces, logs). The OTel SDK's random-GUID default is disabled in favour of this
|
||||
/// value so all signals from one process share one restart-stable instance id, enabling
|
||||
/// cross-signal correlation. Always present (not optional).
|
||||
public static string InstanceId { get; }
|
||||
|
||||
/// Returns a ResourceBuilder pre-populated with service.name, service.namespace,
|
||||
/// service.version, site.id, node.role, and host.name (always Environment.MachineName).
|
||||
/// Attributes with null values are omitted from the Resource.
|
||||
/// service.version, service.instance.id (always — see InstanceId), site.id, node.role, and
|
||||
/// host.name (always Environment.MachineName). Attributes with null/empty values are omitted.
|
||||
public static ResourceBuilder Build(ZbTelemetryOptions options);
|
||||
|
||||
/// The single source of truth for the shared Resource attribute set. Both the OTel SDK
|
||||
/// metrics/traces pipeline and the Serilog OTLP log sink derive their attributes from this one
|
||||
/// map, so logs cannot drift from metrics/traces. service.name/namespace/instance.id/host.name
|
||||
/// are always present; service.version/site.id/node.role are included only when the option is
|
||||
/// non-null/non-empty.
|
||||
public static IReadOnlyDictionary<string, object> BuildAttributes(ZbTelemetryOptions options);
|
||||
}
|
||||
|
||||
/// Endpoint extension for mounting the Prometheus /metrics scrape endpoint.
|
||||
public static class ZbMetricsEndpointExtensions
|
||||
{
|
||||
/// Mounts the Prometheus /metrics endpoint.
|
||||
/// Only valid when ZbTelemetryOptions.Exporter = ZbExporter.Prometheus (or both).
|
||||
/// Mounts the Prometheus /metrics endpoint. Valid under ANY ZbTelemetryOptions.Exporter value:
|
||||
/// AddZbTelemetry always wires the Prometheus exporter, and OTLP (ZbExporter.Otlp) is only an
|
||||
/// additive overlay — so /metrics serves scrape data even when Exporter = ZbExporter.Otlp.
|
||||
/// Call after app.UseRouting().
|
||||
public static IEndpointConventionBuilder MapZbMetrics(
|
||||
this IEndpointRouteBuilder endpoints);
|
||||
|
||||
@@ -104,6 +104,7 @@ joinable in any OTel-compatible backend.
|
||||
| `service.name` | string | Yes | Short lower-case app id: `otopcua`, `mxgateway`, `scadabridge` |
|
||||
| `service.namespace` | string | Yes | Always `"ZB.MOM.WW"` — do not override |
|
||||
| `service.version` | string | Recommended | Populate from `AssemblyInformationalVersion`; absent is better than wrong |
|
||||
| `service.instance.id` | string | Auto | Always `ZbResource.InstanceId` = deterministic `MachineName:ProcessId`. The OTel SDK random-GUID default is disabled so every signal from one process shares one restart-stable instance id (cross-signal correlation); never override |
|
||||
| `site.id` | string | Recommended | Physical or logical site identifier; omit for single-site deployments |
|
||||
| `node.role` | string | Recommended | Node function: `"central"`, `"site"`, `"hub"`, `"standalone"` |
|
||||
| `host.name` | string | Auto | Always `Environment.MachineName`; never override |
|
||||
|
||||
@@ -68,6 +68,7 @@ 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.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"` |
|
||||
| `host.name` | _(auto)_ | Always populated from `Environment.MachineName` |
|
||||
|
||||
Reference in New Issue
Block a user