elsa-core/src/modules/Elsa.Diagnostics.OpenTelemetry
Sipke Schoorstra f969cd61e8
refactor(auth)!: retire the legacy permission constants and duplicate descriptor types (#7987)
* refactor(auth)!: retire the legacy permission constants and duplicate descriptors

Completes the cutover started in #7980. Seven `<Module>Permissions` classes
holding `verb:resource` strings are removed: AIPermissions, ConsoleLogs,
Dashboard, ExternalAuthentication, OpenTelemetry, Secrets and StructuredLogs.
AIPermissions was not in #7982's list, which was written before the cutover
finished; it is dead by the same measure as the rest.

Removed rather than marked obsolete, which #7982 asked to be an explicit
decision. Every string these classes held carries two colons, so it does not
parse under the new grammar and authorizes nothing. Keeping them obsolete
would leave code that compiles, still reads as a permission check, and
silently grants no access -- a warning that is easy to suppress in front of a
runtime failure that is invisible. A compile error names the call site and
can be fixed against the migration guide's mapping table. Classes their own
modules still reference, WorkflowPermissions and IdentityPermissions among
them, are untouched.

External Authentication's parallel descriptor system is collapsed onto the
core types: its own PermissionDescriptor record, its IPermissionDescriptorProvider
and IPermissionDescriptorRegistry, and DefaultPermissionDescriptorRegistry.

That was not only tidiness. The module's registry was fed exclusively by its
legacy names, so after the cutover every well-formed grant failed the
`unknown_permission_descriptor` check and the warning fired constantly for
correct configuration. The resolver now consults the core catalog, which is
keyed by resource and lists the verbs each accepts, and a wildcard is treated
as advertised because it names a pattern rather than a resource to look up.
The descriptor endpoint serves the core catalog too: choosing what an
external mapping may confer means choosing from everything Elsa declares.

The module contributes its resource descriptors explicitly rather than
relying on the host's assembly scan, for the same reason it registers
AddElsaAuthorization itself.

The two naming tests now pin the new resource name instead of the legacy
string. The convention worth holding was always that the module is called
'diagnostics/console-logs', not that a retired constant kept its old value.

Refs #7982

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(client): match the permission descriptor client model to the catalog

Moving the descriptor endpoint onto the core catalog changed its shape from a
single permission string to a resource plus the verbs that resource accepts,
and the Refit client model kept the old one. It still deserialized and still
compiled, handing callers a blank Name and no way to reach the verbs -- the
data went missing without anything failing.

The client model now mirrors the served descriptor, and a contract test
compares the two property sets so the next divergence is a test failure
rather than an empty field. NonCoreVerbs is excluded: the server derives it
from SupportedVerbs, so a client holding the verbs can compute it.

Found by review, not by the suites: nothing here throws.

Refs #7982

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-25 06:04:32 +02:00
..
Contracts [codex] Fix console log metadata and type resolution (#7542) 2026-05-30 22:52:01 +02:00
Endpoints/OpenTelemetry feat(auth)!: structured authorization model, phases 1-6 (#7980) 2026-08-24 23:44:55 +02:00
Extensions [codex] Fix console log metadata and type resolution (#7542) 2026-05-30 22:52:01 +02:00
Features [codex] Fix console log metadata and type resolution (#7542) 2026-05-30 22:52:01 +02:00
Ingestion [codex] Fix console log metadata and type resolution (#7542) 2026-05-30 22:52:01 +02:00
Models [codex] Fix console log metadata and type resolution (#7542) 2026-05-30 22:52:01 +02:00
Options [codex] Fix console log metadata and type resolution (#7542) 2026-05-30 22:52:01 +02:00
Permissions refactor(auth)!: retire the legacy permission constants and duplicate descriptor types (#7987) 2026-08-25 06:04:32 +02:00
Providers/InMemory [codex] Fix diagnostics live feed regressions (#7548) 2026-05-31 09:40:02 +02:00
RealTime feat(auth)!: structured authorization model, phases 1-6 (#7980) 2026-08-24 23:44:55 +02:00
Services [codex] Fix console log metadata and type resolution (#7542) 2026-05-30 22:52:01 +02:00
ShellFeatures Remove PackageManifestCategories and update feature categories to inline strings 2026-06-08 09:48:55 +02:00
AssemblyInfo.cs [codex] Fix console log metadata and type resolution (#7542) 2026-05-30 22:52:01 +02:00
Elsa.Diagnostics.OpenTelemetry.csproj [codex] Fix console log metadata and type resolution (#7542) 2026-05-30 22:52:01 +02:00
README.md [codex] Fix console log metadata and type resolution (#7542) 2026-05-30 22:52:01 +02:00

Elsa Diagnostics OpenTelemetry

Provides the OpenTelemetry diagnostics collector surface for Elsa hosts.

This module owns the Core-side OTEL contracts, HTTP/protobuf ingestion, bounded in-memory diagnostics store, feature registration, permissions, read APIs, live update hub, and collector metadata that Studio consumes.

Scope

Elsa.Diagnostics.OpenTelemetry is collector/read-side diagnostics infrastructure. It does not create workflow spans, mutate Activity.Current, export telemetry to vendors, or provide durable OpenTelemetry persistence. Workflow telemetry production remains owned by existing Elsa.Workflows ActivitySource and Meter instrumentation.

The historical Elsa.OpenTelemetry module from elsa-extensions is intentionally not ported into this feature. It is producer-side workflow tracing middleware, duplicates current Elsa.Workflows instrumentation, and mutates Activity.Current; this module is collector/read-side diagnostics infrastructure.

Routes

OTLP HTTP/protobuf ingestion is exposed under OpenTelemetryDiagnosticsOptions.HttpEndpointPath, which defaults to /elsa/otlp/v1:

  • POST /elsa/otlp/v1/traces
  • POST /elsa/otlp/v1/metrics
  • POST /elsa/otlp/v1/logs

Diagnostics read APIs are exposed through Elsa API endpoints:

  • POST /diagnostics/opentelemetry/resources/search
  • POST /diagnostics/opentelemetry/traces/search
  • GET /diagnostics/opentelemetry/traces/{traceId}
  • POST /diagnostics/opentelemetry/metrics/search
  • POST /diagnostics/opentelemetry/logs/search
  • GET /diagnostics/opentelemetry/storage
  • GET /diagnostics/opentelemetry/collector-configuration

Live updates are exposed through SignalR at OpenTelemetryDiagnosticsOptions.HubRoute, which defaults to /elsa/hubs/diagnostics/opentelemetry.

Security

All diagnostics read APIs require the OpenTelemetry diagnostics read permission. OTLP ingestion allows unauthenticated loopback traffic by default for local development only when no API key is configured. When OpenTelemetryDiagnosticsOptions.ApiKey is set, every sender must provide the configured API key header, including loopback senders.

Collector configuration returns endpoint and required-header names only. It never returns secret header values.

Storage

The default provider is bounded in-memory storage. Capacity options cover traces, spans, metric points, OTLP log records, and live subscriber queues. When a buffer exceeds capacity, the oldest item for that signal is dropped and diagnostics counters are incremented.