Skip to content

feat(reporting-api): add subagent observability logging#302

Merged
willvelida merged 2 commits intomainfrom
feat/reporting-api-subagent-logging
Apr 20, 2026
Merged

feat(reporting-api): add subagent observability logging#302
willvelida merged 2 commits intomainfrom
feat/reporting-api-subagent-logging

Conversation

@willvelida
Copy link
Copy Markdown
Owner

Summary

Add custom OpenTelemetry ActivitySource trace spans, Copilot SDK subagent lifecycle event subscriptions, custom metrics, ILogger bridge for JSON-RPC diagnostics, and structured logging across the Reporting API's report generation pipeline, endpoints, and A2A agent.

Motivation

The Reporting.Api had zero custom ActivitySource spans, unused Copilot SDK subagent lifecycle events, no custom metrics, and gaps in endpoint/agent logging — making it difficult to understand how subagents collaborate during report generation.

Changes

New File

  • Telemetry/ReportingTelemetry.cs — Centralized ActivitySource and Meter with 5 instruments: ReportsGenerated, ReportsFailed, ReportDuration, SubagentDuration, ConcurrentJobs

Modified Files

  • Program.cs — Registered ReportingTelemetry.SourceName with .AddSource() and .AddMeter() in OpenTelemetry pipeline
  • Services/CopilotService.cs — Added Logger and LogLevel = "info" to CopilotClientOptions for JSON-RPC diagnostics; added code comment documenting TelemetryConfig limitation in sidecar/external server mode
  • Services/ReportGenerationService.cs — Added 4 ActivitySource spans (report.generate, copilot.session, report.artifact_scan, report.artifact_upload); expanded session.On() with SubagentStartedEvent, SubagentCompletedEvent, SubagentFailedEvent, AssistantUsageEvent subscriptions; added Stopwatch timing and metric recording
  • Endpoints/ReportEndpoints.cs — Added ILogger<Program> injection and structured logging to both GET endpoints
  • Agents/ReportGenerationAgent.cs — Added structured logging to HandleStatusPollAsync for A2A polling

Observability Improvements

Category Before After
Custom trace spans 0 4 (report.generate, copilot.session, report.artifact_scan, report.artifact_upload)
Subagent lifecycle events Not subscribed SubagentStarted, SubagentCompleted, SubagentFailed logged with timing/tokens
Custom metrics 0 5 instruments (2 counters, 2 histograms, 1 gauge)
SDK JSON-RPC diagnostics Not logged Routed to ILogger at Info level
Endpoint logging 0 log points 5 log points across 2 GET endpoints
A2A polling logging 0 log points 3 log points in HandleStatusPollAsync

Related

Validation

  • Build: 0 errors, 0 warnings
  • Unit tests: 194 passed, 0 failed
  • Integration tests: 22 passed, 0 failed
  • Line coverage: 69% (CI threshold: 60%)
  • No new NuGet dependencies
  • No infrastructure or configuration changes required

- add ReportingTelemetry with ActivitySource, Meter, and 5 instruments

- expand session.On() with SubagentStarted/Completed/Failed events

- add ActivitySource spans for report generation pipeline stages

- enable ILogger bridge for Copilot SDK JSON-RPC diagnostics

- add structured logging to ReportEndpoints and A2A polling

Signed-off-by: Will Velida <willvelida@hotmail.co.uk>
agent: github-copilot
model: Claude Opus 4.6
contribution: code-generation
Copilot AI review requested due to automatic review settings April 20, 2026 00:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class observability to Biotrackr.Reporting.Api’s report-generation pipeline by introducing a centralized telemetry surface (ActivitySource + Meter), wiring it into OpenTelemetry, and expanding structured logging around Copilot subagent execution, endpoints, and the A2A agent polling flow.

Changes:

  • Added ReportingTelemetry (ActivitySource + Meter) with counters/histograms/gauge for report/subagent execution.
  • Instrumented ReportGenerationService with custom spans, subagent lifecycle event logging, and metric recording.
  • Added structured logging to report endpoints and A2A polling; enabled Copilot SDK JSON-RPC diagnostics via ILogger.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
.../Telemetry/ReportingTelemetry.cs Introduces centralized OpenTelemetry ActivitySource/Meter and instruments.
.../Program.cs Registers the new source/meter with the OTel pipeline.
.../Services/CopilotService.cs Routes Copilot SDK diagnostics into ILogger and documents telemetry limitations in sidecar mode.
.../Services/ReportGenerationService.cs Adds spans, subagent event subscriptions, and records custom metrics during generation.
.../Endpoints/ReportEndpoints.cs Adds endpoint-level structured logs for report listing and job retrieval.
.../Agents/ReportGenerationAgent.cs Adds A2A polling/completion structured logs.

- use 'using var' for eventSubscription to prevent leak on exception

- fix AgentName/DisplayName mismatch in subagent log templates

- remove early return to ensure metrics recorded on all paths

- lower A2A poll logs from Information to Debug

Signed-off-by: Will Velida <willvelida@hotmail.co.uk>
agent: github-copilot
model: Claude Opus 4.6
contribution: code-generation
@github-actions
Copy link
Copy Markdown

Code Coverage

Package Line Rate Branch Rate Health
Biotrackr.Reporting.Api 70% 46%
Summary 70% (484 / 691) 46% (102 / 221)

Minimum allowed line rate is 60%

@willvelida willvelida merged commit d7c50f8 into main Apr 20, 2026
17 checks passed
@willvelida willvelida deleted the feat/reporting-api-subagent-logging branch April 20, 2026 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants