elsa-core/specs/008-diagnostics-otel/tasks.md
Sipke Schoorstra 842cf7c162
[codex] Fix console log metadata and type resolution (#7542)
* Avoid null endpoint DTO metadata in tests

* Enforce console logs hub read permission

* Remove unused console logs hub import

* Support mapped endpoint metadata in auth tests

* Reduce console log capture throughput impact

* Address Copilot console logs review

* Refactor task scheduling to support tenant-level background work and enhance logging functionality.

* Introduce ConsoleStreamHook for stdout/stderr tee and enhance logging validation. Adjust test cases and startup warnings for distributed lock provider usage.

* Refactor console logging pipeline with capture optimization and new ConsoleLogsHost; update tests accordingly.

* Add Ansi SGR parser for console logs and associated unit tests

* Remove ANSI color renderings and parsers; integrate ConsoleLogScopeAccessor for improved logging context with workflow instance ID support.

* Address console logs code quality feedback

* Address PR review feedback

* Preserve console logs extension points

* Stabilize console logs host lifecycle

* Address final automated review comments

* Tighten console log capture shutdown

* Address console log review feedback

* Address follow-up review feedback

* Cover final review feedback

* Avoid recursive console provider initialization

* Guard console host lease shutdown

* Preserve console log scope and provider lifetime

* Correlate console log scope fallback

* Tighten console scope correlation

* Expose host services during provider construction

* Redact ANSI-normalized console lines

* Add OpenTelemetry diagnostics backend foundation

* Add OTLP HTTP ingestion parsing

* Document OpenTelemetry diagnostics setup

* Enforce OpenTelemetry hub permissions

* Remove `ConsoleCaptureTee` and related services and tests

* Add OpenTelemetry HTTP ingestion integration test

* Use pipeline contributors for console log context

* Update CShells package versions to 0.0.24-preview.132

* Add OpenTelemetry ingestion security tests

* Add OpenTelemetry API authorization tests

* Filter live console logs by workflow instance

* Add OpenTelemetry hub tests

* Add OpenTelemetry gRPC metadata hook

* Assert OpenTelemetry workflow tags survive ingestion

* Mark OpenTelemetry core build verified

* Enhance console logging with activity execution metadata and extend test coverage.

* Address console logs stream consumption comment

* Wire OpenTelemetry diagnostics into core sample

* Address Core diagnostics review feedback

* Address Core Copilot follow-up feedback

* Add OpenTelemetry metric instrument names

* Address Core Copilot provider feedback

* Address Core Copilot diagnostics follow-up

* Address Core Copilot live feed feedback

* Address Core Copilot store feedback

* Integrate OpenTelemetry for logging, tracing, and metrics in ModularServer and update launch settings and docker-compose configuration.

* Refactor to replace `ConsoleLogStream.Core` with `ConsoleLogStreaming.Core` across codebase and update `ConsoleStreamHook` installation.

* Add diagnostics OpenTelemetry backend

* Fix OpenTelemetry live hub subscription

* Fix modular OpenTelemetry exporter endpoints

* Add CShells logging configuration in appsettings.json

* Remove obsolete unit tests and helper classes

* Restore default activity exception handling

* Simplify type serialization and alias management

This commit refactors the internal type serialization and alias management system to reduce boilerplate, improve robustness, and simplify the developer experience:

-   Removed numerous explicit `ExpressionOptions` type alias registrations across various modules.
-   Updated `TypeJsonConverter` and polymorphic serialization to reliably handle types using assembly-qualified names when a short alias is not explicitly registered.
-   Streamlined `ExcludeFromHashConverter` to strictly adhere to `ExcludeFromHashAttribute` for hash calculations, removing complex `JsonIgnoreCondition` logic.
-   Eliminated several helper classes (`WorkflowJsonTypeResolver`, `WorkflowTypeValidator`, `IWorkflowTypeRegistry`, `WorkflowFactoryDictionary`, `JavaScriptExceptionTypeAliasRegistrar`, `WorkflowRuntimeTypeAliasRegistrar`) and their associated unit tests, simplifying the codebase.

Additionally, this commit introduces a comprehensive markdown document (`product-website-feature-source.md`) outlining Elsa's core features, Studio capabilities, extension ecosystem, and architectural selling points, intended as source material for the product website.

* Refine type serialization for improved robustness and alias handling

This commit further enhances the type serialization and deserialization mechanisms:

*   Centralizes type resolution and alias management through `IWellKnownTypeRegistry` and `WorkflowJsonTypeResolver`.
*   Prioritizes registered type aliases when serializing type metadata in `PolymorphicObjectConverter`, resulting in more concise JSON output.
*   Enhances deserialization in `PolymorphicObjectConverter` and `VariableMapper` to gracefully handle unknown or non-instantiable types, providing fallbacks and logging warnings.
*   Simplifies `TypeJsonConverter` by delegating complex type resolution logic to the `WorkflowJsonTypeResolver`.
*   Adds `JsonArray` to the well-known type aliases for direct recognition.

* Fix console logs packaging and workflow type resolution

* Fix console log metadata and type resolution

* Address Copilot review feedback

* Enhance type resolution, improve console log handling, and update tests

- Streamlined `WorkflowDictionaryExtensions` for better workflow registration validation.
- Refined `ConsoleLogsAuthorizationTests` with the new `SetJsonRequest` helper to improve test requests handling.
- Updated `OrderDefinition` to ignore JSON serialization for `KeySelector`.
- Enhanced `WorkflowRuntimeFeature` for improved workflow registration and type alias configuration.
- Added tests to ensure `ConsoleLogProvider` metadata filtration in various scenarios.
- Improved type serialization logic in `WorkflowJsonTypeResolver`.
- Updated README to fix references related to diagnostics.
- Optimized `ExcludeFromHashConverter` for property serialization conditions.
- Modified `TriggerIndexer` for streamlined trigger management.
- Tested payload checks in `PublishEventTests`.
- Adjusted `Endpoint` in `ConsoleLogs` for automatic JSON request handling.
- Ensured registration of workflow type aliases in `WorkflowsFeature`.

* Restore CLR workflow registration compatibility

* Align JSON island serialization fixtures

* Add Console Logs Services and Enhance Endpoint Handling

- Introduced `ActivityExecutionsEndpointTests` to validate route exposure.
- Added `ConsoleLogCaptureHostedService` for console log streaming.
- Implemented `ConsoleStreamJsonConverter` for JSON conversion of console streams.
- Developed `ElsaConsoleLogRecentBuffer` to handle recent log buffering.
- Updated `ConsoleLogsAuthorizationTests` with new test cases for stream filter mapping.
- Consolidated console log provider dependencies and registration, including recent buffering.
- Enhanced `ElsaConsoleLogProvider` to use recent buffer for filtering.
- Adjusted `Program.cs` for streamlined logging service setup.

* Enhance type resolution and test coverage; streamline console log integration

- Added `ConsoleStreamHook` for streamlined log streaming.
- Updated `WorkflowJsonTypeResolverTests` to improve type resolution and test new scenarios.
- Simplified type resolution by removing trusted assembly checks.

* Fix CI smoke and package restore failures

* Fix Docker smoke image project paths

* Fix Docker Python runtime packages

* Fix Docker CA smoke teardown

* Refresh Elsa roadmap

* Implement background processors and mediation coordination

- Added `BackgroundCommandProcessor`, `BackgroundJobProcessor`, and `BackgroundNotificationProcessor` classes for handling commands, jobs, and notifications, respectively.
- Introduced `MediatorBackgroundProcessingCoordinator` to coordinate the execution of all background processors.
- Implemented `MediatorBackgroundTask` for wrapping `MediatorBackgroundProcessingCoordinator` in `BackgroundTask`.
- Added unit tests for `MediatorBackgroundTask` to ensure proper start and stop behavior.
- Refactored `BackgroundCommandSenderHostedService` to utilize `BackgroundCommandProcessor`.
- Introduced 'elsa-roadmap-refresh' skill configuration for roadmap updates.

* Address workflow type resolution review feedback

* Address follow-up review feedback

* Restore recent console logs execute path

* Address Copilot follow-up review

* Decouple workflow JSON aliases from expressions

* Fix workflow management unit test setup

* Fix console logs recent endpoint handler shape

* Respect workflow JSON strict type aliases

* Remove unused console log contracts reference

* Address Copilot review feedback

* Address Copilot follow-up comments

* Synchronize ring buffer dropped count

* Address background processor strategy replay
2026-05-30 22:52:01 +02:00

10 KiB

Tasks: Diagnostics OpenTelemetry

Input: Design documents from /specs/008-diagnostics-otel/
Prerequisites: plan.md, spec.md, research.md, data-model.md, contracts/, quickstart.md

Tests: Required for ingestion, normalization, redaction, bounded storage, permissions, live updates, collector configuration, and workflow export-to-collector timing.

Phase 1: Setup

  • T001 Create Core project skeleton at src/modules/Elsa.Diagnostics.OpenTelemetry/Elsa.Diagnostics.OpenTelemetry.csproj
  • T002 Create unit test project at test/unit/Elsa.Diagnostics.OpenTelemetry.UnitTests/Elsa.Diagnostics.OpenTelemetry.UnitTests.csproj
  • T003 Create integration test project at test/integration/Elsa.Diagnostics.OpenTelemetry.IntegrationTests/Elsa.Diagnostics.OpenTelemetry.IntegrationTests.csproj
  • T004 Add project and test projects to Elsa.sln
  • T005 [P] Add initial module README at src/modules/Elsa.Diagnostics.OpenTelemetry/README.md

Phase 2: Foundational

  • T006 Create telemetry resource/span/trace/metric/log/storage models in src/modules/Elsa.Diagnostics.OpenTelemetry/Models
  • T007 Create filter/result DTOs for resources, traces, metrics, logs, and collector configuration in src/modules/Elsa.Diagnostics.OpenTelemetry/Models
  • T008 Create provider, store, live feed, ingestor, redactor, and source registry contracts in src/modules/Elsa.Diagnostics.OpenTelemetry/Contracts
  • T009 Create options in src/modules/Elsa.Diagnostics.OpenTelemetry/Options/OpenTelemetryDiagnosticsOptions.cs with configurable capacity defaults, ingestion security, and live subscriber queue settings
  • T010 Create permission constants in src/modules/Elsa.Diagnostics.OpenTelemetry/Permissions/OpenTelemetryPermissions.cs
  • T011 Create feature and shell feature in src/modules/Elsa.Diagnostics.OpenTelemetry/Features/OpenTelemetryFeature.cs and src/modules/Elsa.Diagnostics.OpenTelemetry/ShellFeatures/OpenTelemetryFeature.cs
  • T012 Create DI and endpoint mapping extensions in src/modules/Elsa.Diagnostics.OpenTelemetry/Extensions
  • T013 Add README note that historical Elsa.OpenTelemetry producer middleware is not ported in v1 in src/modules/Elsa.Diagnostics.OpenTelemetry/README.md

Phase 3: User Story 1 - Collect OpenTelemetry from Elsa services (Priority: P1) MVP

Goal: Receive OTLP payloads, normalize, redact, store bounded telemetry, and expose basic diagnostics queries.

Independent Test: Ingest OTLP traces/metrics/logs and run an Elsa workflow export-to-collector integration test.

  • T014 [P] [US1] Add OTLP trace normalization tests in test/unit/Elsa.Diagnostics.OpenTelemetry.UnitTests/Ingestion/OtlpTraceNormalizerTests.cs
  • T015 [P] [US1] Add OTLP metric normalization tests in test/unit/Elsa.Diagnostics.OpenTelemetry.UnitTests/Ingestion/OtlpMetricNormalizerTests.cs
  • T016 [P] [US1] Add OTLP log normalization tests in test/unit/Elsa.Diagnostics.OpenTelemetry.UnitTests/Ingestion/OtlpLogNormalizerTests.cs
  • T017 [P] [US1] Add redaction tests in test/unit/Elsa.Diagnostics.OpenTelemetry.UnitTests/Services/OpenTelemetryRedactorTests.cs
  • T018 [P] [US1] Add bounded store/drop-count tests for default capacities, drop-oldest overflow, and deterministic query limits in test/unit/Elsa.Diagnostics.OpenTelemetry.UnitTests/Providers/InMemoryOpenTelemetryStoreTests.cs
  • T019 [P] [US1] Add HTTP/protobuf ingestion and workflow export-to-collector timing tests that assert existing Elsa.Workflows tags are preserved in test/integration/Elsa.Diagnostics.OpenTelemetry.IntegrationTests/OtlpHttpIngestionTests.cs
  • T020 [US1] Implement HTTP/protobuf request parsing in src/modules/Elsa.Diagnostics.OpenTelemetry/Ingestion/HttpProtobuf
  • T021 [US1] Implement shared OTLP normalization services in src/modules/Elsa.Diagnostics.OpenTelemetry/Ingestion
  • T022 [US1] Implement redactor in src/modules/Elsa.Diagnostics.OpenTelemetry/Services/OpenTelemetryRedactor.cs
  • T023 [US1] Implement source registry in src/modules/Elsa.Diagnostics.OpenTelemetry/Services/OpenTelemetrySourceRegistry.cs
  • T024 [US1] Implement bounded in-memory store in src/modules/Elsa.Diagnostics.OpenTelemetry/Providers/InMemory/InMemoryOpenTelemetryStore.cs
  • T025 [US1] Implement provider facade in src/modules/Elsa.Diagnostics.OpenTelemetry/Services/DefaultOpenTelemetryProvider.cs
  • T026 [US1] Implement HTTP/protobuf endpoint mapping in src/modules/Elsa.Diagnostics.OpenTelemetry/Extensions/EndpointRouteBuilderExtensions.cs

Phase 4: User Story 2 - Serve Trace Investigation APIs (Priority: P1)

Goal: Provide authenticated trace search/detail APIs and live updates.

Independent Test: Query traces by service/resource/trace/workflow/status/time and retrieve ordered span detail.

  • T027 [P] [US2] Add trace search/detail provider tests in test/unit/Elsa.Diagnostics.OpenTelemetry.UnitTests/Providers/OpenTelemetryTraceQueryTests.cs
  • T028 [P] [US2] Add API authorization tests in test/integration/Elsa.Diagnostics.OpenTelemetry.IntegrationTests/OpenTelemetryAuthorizationTests.cs
  • T029 [P] [US2] Add SignalR hub tests for authorization, filter updates, per-subscriber queue overflow, drop-oldest behavior, and dropped-update diagnostics in test/integration/Elsa.Diagnostics.OpenTelemetry.IntegrationTests/OpenTelemetryHubTests.cs
  • T030 [US2] Implement trace search and trace detail query logic in src/modules/Elsa.Diagnostics.OpenTelemetry/Providers/InMemory/InMemoryOpenTelemetryStore.cs
  • T031 [US2] Implement resource search endpoint in src/modules/Elsa.Diagnostics.OpenTelemetry/Endpoints/OpenTelemetry/Resources/Endpoint.cs
  • T032 [US2] Implement trace search and detail endpoints in src/modules/Elsa.Diagnostics.OpenTelemetry/Endpoints/OpenTelemetry/Traces/Endpoint.cs and src/modules/Elsa.Diagnostics.OpenTelemetry/Endpoints/OpenTelemetry/Trace/Endpoint.cs
  • T033 [US2] Implement live feed in src/modules/Elsa.Diagnostics.OpenTelemetry/Providers/InMemory/InMemoryOpenTelemetryLiveFeed.cs
  • T034 [US2] Implement SignalR hub in src/modules/Elsa.Diagnostics.OpenTelemetry/RealTime/OpenTelemetryHub.cs

Phase 5: User Story 3 - Serve Metrics and OTLP Logs (Priority: P2)

Goal: Provide bounded metric and OTLP log search APIs with overflow diagnostics.

Independent Test: Ingest metrics/logs, query by filters, and verify dropped counts.

  • T035 [P] [US3] Add metric query tests in test/unit/Elsa.Diagnostics.OpenTelemetry.UnitTests/Providers/OpenTelemetryMetricQueryTests.cs
  • T036 [P] [US3] Add OTLP log query tests in test/unit/Elsa.Diagnostics.OpenTelemetry.UnitTests/Providers/OtlpLogQueryTests.cs
  • T037 [US3] Implement metric instrument and point query support in src/modules/Elsa.Diagnostics.OpenTelemetry/Providers/InMemory/InMemoryOpenTelemetryStore.cs
  • T038 [US3] Implement OTLP log query support in src/modules/Elsa.Diagnostics.OpenTelemetry/Providers/InMemory/InMemoryOpenTelemetryStore.cs
  • T039 [US3] Implement metrics endpoint in src/modules/Elsa.Diagnostics.OpenTelemetry/Endpoints/OpenTelemetry/Metrics/Endpoint.cs
  • T040 [US3] Implement OTLP logs endpoint in src/modules/Elsa.Diagnostics.OpenTelemetry/Endpoints/OpenTelemetry/Logs/Endpoint.cs
  • T041 [US3] Implement storage diagnostics endpoint in src/modules/Elsa.Diagnostics.OpenTelemetry/Endpoints/OpenTelemetry/Storage/Endpoint.cs

Phase 6: User Story 4 - Expose Collector Configuration and Secure Ingestion (Priority: P3)

Goal: Provide collector configuration metadata and protect non-loopback ingestion.

Independent Test: Query configuration and verify API key enforcement.

  • T042 [P] [US4] Add collector configuration tests in test/unit/Elsa.Diagnostics.OpenTelemetry.UnitTests/Services/CollectorConfigurationTests.cs
  • T043 [P] [US4] Add ingestion security tests for loopback-only no-key development, non-loopback request rejection without API key, and non-secret collector metadata in test/integration/Elsa.Diagnostics.OpenTelemetry.IntegrationTests/OtlpIngestionSecurityTests.cs
  • T044 [US4] Implement collector configuration provider in src/modules/Elsa.Diagnostics.OpenTelemetry/Services/CollectorConfigurationProvider.cs
  • T045 [US4] Implement collector configuration endpoint in src/modules/Elsa.Diagnostics.OpenTelemetry/Endpoints/OpenTelemetry/CollectorConfiguration/Endpoint.cs
  • T046 [US4] Implement API key header validation in src/modules/Elsa.Diagnostics.OpenTelemetry/Ingestion
  • T047 [US4] Add option-gated gRPC wrappers and disabled metadata handling in src/modules/Elsa.Diagnostics.OpenTelemetry/Ingestion/Grpc
  • T048 [US4] Update workflow OpenTelemetry docs in doc/wiki/opentelemetry-workflows.md

Phase 7: Polish and Verification

  • T049 [P] Update module README with routes, permissions, security, scope boundaries, and historical extension decision in src/modules/Elsa.Diagnostics.OpenTelemetry/README.md
  • T050 [P] Verify no production code references historical producer middleware by running rg "Elsa.OpenTelemetry|UseWorkflowExecutionTracing|UseActivityExecutionTracing" src test
  • T051 Run dotnet test test/unit/Elsa.Diagnostics.OpenTelemetry.UnitTests/Elsa.Diagnostics.OpenTelemetry.UnitTests.csproj
  • T052 Run dotnet test test/integration/Elsa.Diagnostics.OpenTelemetry.IntegrationTests/Elsa.Diagnostics.OpenTelemetry.IntegrationTests.csproj
  • T053 Run dotnet build Elsa.sln

Dependencies

  • Phase 1 precedes all work.
  • Phase 2 blocks all user stories.
  • US1 is the MVP backend collector slice.
  • US2 can begin after Phase 2 with seeded store data; full validation depends on US1.
  • US3 depends on US1 storage and normalization.
  • US4 depends on endpoint mapping from US1.

Notes

  • Keep Studio UI tasks in elsa-studio/specs/008-diagnostics-otel/tasks.md.
  • Do not port historical Elsa.OpenTelemetry middleware in this feature.
  • Durable OTEL persistence and vendor exporters are out of scope.