using System.Diagnostics; namespace GB5Shared.Telemetry; /// /// Central registry of all instances used across the GB5 platform. /// Every feature area has its own named source so traces can be filtered and searched by domain /// (e.g. show only "GB5.Dapr.Publish" or "GB5.Database" spans in Jaeger / Zipkin). /// public static class GB5ActivitySources { private const string Prefix = "GB5"; private const string Version = "1.0"; /// FastEndpoints API handler spans — one per endpoint invocation. public static readonly ActivitySource Endpoints = new($"{Prefix}.Endpoints", Version); /// Dapr pub/sub outbound — publishing events to a topic. public static readonly ActivitySource DaprPublish = new($"{Prefix}.Dapr.Publish", Version); /// Dapr pub/sub inbound — consuming events from a topic subscription. public static readonly ActivitySource DaprSubscribe = new($"{Prefix}.Dapr.Subscribe", Version); /// Database query and command spans (Dapper / EF Core / raw SQL). public static readonly ActivitySource Database = new($"{Prefix}.Database", Version); /// Quartz scheduler job execution spans. public static readonly ActivitySource Scheduler = new($"{Prefix}.Scheduler", Version); /// IHostedService background processing spans. public static readonly ActivitySource Background = new($"{Prefix}.Background", Version); /// Dapr state-store cache read / write / delete spans. public static readonly ActivitySource Cache = new($"{Prefix}.Cache", Version); /// Named HTTP client outbound calls (ReportClient, sysjob, BatchExecution, webhooks). public static readonly ActivitySource HttpClient = new($"{Prefix}.HttpClient", Version); /// WIP (Work-in-Progress) approval dispatching and replay spans. public static readonly ActivitySource Wip = new($"{Prefix}.Wip", Version); /// Transactional outbox reliable-messaging spans. public static readonly ActivitySource Outbox = new($"{Prefix}.Outbox", Version); /// Email, SMS, Webhook, Report, and all other action handler spans. public static readonly ActivitySource ActionProcessor = new($"{Prefix}.ActionProcessor", Version); /// Qualifier pipeline spans — DB_ENRICH, validation, enrichment, derivation steps. public static readonly ActivitySource Qualifier = new($"{Prefix}.Qualifier", Version); /// /// Entity save pipeline spans — covers the full ExecuteSaveAsync flow in /// BaseEntityAppService: transaction, qualifier steps, persist, workflow, /// outbox write, and direct Dapr publish. /// public static readonly ActivitySource EntitySave = new($"{Prefix}.EntitySave", Version); /// /// Workflow action outcome spans — covers Approve (final), Reject, and Return outcome /// event publishing in WorkFlowBLL.WorkFlowActions: direct Dapr publish and /// outbox write for each workflow outcome so email/SMS actions can be configured via /// MACTION without additional code per entity type. /// public static readonly ActivitySource WorkflowAction = new($"{Prefix}.WorkflowAction", Version); /// /// Explicit BLL/service-layer processing section spans opened via . /// Use for complex processing pipelines where named child spans improve trace readability /// beyond what ILogger events alone provide — e.g. qualification steps, bulk operations, /// approval dispatch sub-flows. /// public static readonly ActivitySource Processing = new($"{Prefix}.Processing", Version); /// /// GOP AIExtract node calls to the external Enterprise AI engine — distinct from the /// generic source so AI-capability calls (classification gate /// outcome, target agent slug, engine executionId for cross-system correlation) are /// filterable on their own in a trace backend, same reasoning as /// and getting their own sources once they became real capabilities. /// public static readonly ActivitySource AICapability = new($"{Prefix}.AICapability", Version); /// /// All GB5 source names in a single array, used by AddGB5Telemetry to register /// every source with the OpenTelemetry TracerProvider in a single loop. /// internal static readonly string[] AllSourceNames = [ Endpoints.Name, DaprPublish.Name, DaprSubscribe.Name, Database.Name, Scheduler.Name, Background.Name, Cache.Name, HttpClient.Name, Wip.Name, Outbox.Name, ActionProcessor.Name, Qualifier.Name, EntitySave.Name, WorkflowAction.Name, Processing.Name, AICapability.Name, ]; }