Skip to content

Enable Application Insights instrumentation in csharp playground-server#10709

Open
JoshLove-msft wants to merge 1 commit into
microsoft:mainfrom
JoshLove-msft:joshlove-msft/playground-server-app-insights
Open

Enable Application Insights instrumentation in csharp playground-server#10709
JoshLove-msft wants to merge 1 commit into
microsoft:mainfrom
JoshLove-msft:joshlove-msft/playground-server-app-insights

Conversation

@JoshLove-msft
Copy link
Copy Markdown
Contributor

Summary

Wires Application Insights telemetry into packages/http-client-csharp/playground-server so we can observe the csharp-playground-server App Service in production.

Changes

  • Add Microsoft.ApplicationInsights.AspNetCore (3.1.1) package reference.
  • Register the SDK unconditionally in Program.cs. The connection string is read from the standard APPLICATIONINSIGHTS_CONNECTION_STRING env var (or the ApplicationInsights:ConnectionString config key); when neither is set the SDK is a no-op and startup logs Application Insights telemetry disabled..
  • Instrument the /generate endpoint with a PlaygroundGenerate custom event tagged with:
    • outcome — one of success, generator_failed, timeout, exception, invalid_json, invalid_content_type, missing_fields, generator_missing
    • generatorName, codeModelSizeBytes, exitCode, generatedFileCount, durationMs
  • Track a PlaygroundGenerateDurationMs metric per outcome and report unhandled exceptions via TrackException.

Auto-collected request/dependency telemetry from the AspNetCore SDK is also enabled for free.

Deployment

No pipeline changes required — the existing deploy step (az webapp config container set) just swaps the container image and leaves app settings alone. Telemetry only starts flowing once APPLICATIONINSIGHTS_CONNECTION_STRING is set on the csharp-playground-server App Service (one-time Azure config).

Adds Microsoft.ApplicationInsights.AspNetCore (3.1.1) and registers the SDK
in Program.cs. The connection string is read from the standard
APPLICATIONINSIGHTS_CONNECTION_STRING env var (or the equivalent config key);
telemetry is silently dropped when unset.

The /generate endpoint emits a PlaygroundGenerate custom event tagged with
outcome (success, generator_failed, timeout, exception, invalid_json,
invalid_content_type, missing_fields, generator_missing) plus generatorName,
codeModelSizeBytes, exitCode, generatedFileCount and durationMs. A
PlaygroundGenerateDurationMs metric is also tracked per outcome, and
unhandled exceptions are reported via TrackException.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label May 16, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 16, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-csharp@10709

commit: f6a30d2

@github-actions
Copy link
Copy Markdown
Contributor

No changes needing a change description found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants