| | | 1 | | using System.Diagnostics; |
| | | 2 | | |
| | | 3 | | namespace NexusLabs.Needlr.AgentFramework.Diagnostics; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// No-op <see cref="IPipelineMetrics"/> implementation. Registered as the DI |
| | | 7 | | /// default when the consumer has not configured <see cref="PipelineMetricsOptions"/> |
| | | 8 | | /// via <c>ConfigurePipelineMetrics</c> on the agent-framework syringe — pipeline |
| | | 9 | | /// observability is opt-in with zero overhead by default. Same posture as |
| | | 10 | | /// <see cref="IAgentMetrics"/> when no <see cref="AgentFrameworkMetricsOptions"/> |
| | | 11 | | /// is configured at the <c>IAgentMetrics</c> level today. |
| | | 12 | | /// </summary> |
| | | 13 | | /// <remarks> |
| | | 14 | | /// All <see cref="IPipelineMetrics"/> methods are no-ops. The exposed |
| | | 15 | | /// <see cref="ActivitySource"/> uses a unique source name with the suffix |
| | | 16 | | /// <c>".NoOp"</c> so that an unintentional listener attached to |
| | | 17 | | /// <c>"NexusLabs.Needlr.AgentFramework.Pipelines"</c> does not accidentally pick |
| | | 18 | | /// up no-op activities — listeners must explicitly opt into the <c>".NoOp"</c> |
| | | 19 | | /// source if they want to capture this no-op output (which they almost never do). |
| | | 20 | | /// </remarks> |
| | | 21 | | [DoNotAutoRegister] |
| | | 22 | | internal sealed class NoOpPipelineMetrics : IPipelineMetrics, IDisposable |
| | | 23 | | { |
| | 76 | 24 | | private readonly ActivitySource _activitySource = new("NexusLabs.Needlr.AgentFramework.Pipelines.NoOp"); |
| | | 25 | | |
| | 167 | 26 | | public ActivitySource ActivitySource => _activitySource; |
| | | 27 | | |
| | 69 | 28 | | public void RecordPipelineStarted(string pipelineName) { } |
| | | 29 | | |
| | 69 | 30 | | public void RecordPipelineCompleted(string pipelineName, bool succeeded, TimeSpan duration) { } |
| | | 31 | | |
| | 104 | 32 | | public void RecordStageCompleted(string pipelineName, IAgentStageResult stage, TimeSpan duration) { } |
| | | 33 | | |
| | 5 | 34 | | public void Dispose() => _activitySource.Dispose(); |
| | | 35 | | } |