[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-dotnet-configuring-opentelemetry-dotnet":3,"mdc--lxcs98-key":40,"related-org-dotnet-configuring-opentelemetry-dotnet":2370,"related-repo-dotnet-configuring-opentelemetry-dotnet":2534},{"slug":4,"name":4,"fn":5,"description":6,"org":7,"tags":11,"stars":28,"repoUrl":29,"updatedAt":30,"license":31,"forks":32,"topics":33,"repo":35,"sourceUrl":38,"mdContent":39},"configuring-opentelemetry-dotnet","configure OpenTelemetry for .NET applications","Configure OpenTelemetry distributed tracing, metrics, and logging in ASP.NET Core using the .NET OpenTelemetry SDK. Use when adding observability, setting up OTLP exporters, creating custom metrics\u002Fspans, or troubleshooting distributed trace correlation.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},"dotnet",".NET (Microsoft)","https:\u002F\u002Fpexgzepcugksgbtrxkhf.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Forg-logos\u002Fdotnet.png",[12,16,19,22,25],{"name":13,"slug":14,"type":15},"Observability","observability","tag",{"name":17,"slug":18,"type":15},".NET","net",{"name":20,"slug":21,"type":15},"OpenTelemetry","opentelemetry",{"name":23,"slug":24,"type":15},"Distributed Tracing","distributed-tracing",{"name":26,"slug":27,"type":15},"Metrics","metrics",4576,"https:\u002F\u002Fgithub.com\u002Fdotnet\u002Fskills","2026-07-12T08:23:17.436076","MIT",332,[34],"agent-skills",{"repoUrl":29,"stars":28,"forks":32,"topics":36,"description":37},[34],"Repository for skills to assist AI coding agents with .NET and C#","https:\u002F\u002Fgithub.com\u002Fdotnet\u002Fskills\u002Ftree\u002FHEAD\u002Fplugins\u002Fdotnet-aspnetcore\u002Fskills\u002Fconfiguring-opentelemetry-dotnet","---\nname: configuring-opentelemetry-dotnet\ndescription: Configure OpenTelemetry distributed tracing, metrics, and logging in ASP.NET Core using the .NET OpenTelemetry SDK. Use when adding observability, setting up OTLP exporters, creating custom metrics\u002Fspans, or troubleshooting distributed trace correlation.\nlicense: MIT\n---\n\n# Configuring OpenTelemetry in .NET\n\n## When to Use\n\n- Adding distributed tracing to an ASP.NET Core application\n- Setting up OpenTelemetry exporters (OTLP is the primary protocol; Jaeger accepts OTLP natively; Prometheus OTLP ingestion requires explicit opt-in)\n- Creating custom metrics or trace spans for business operations\n- Troubleshooting distributed trace context propagation across services\n\n## When Not to Use\n\n- The user wants application-level logging only (use ILogger, Serilog)\n- The user is using Application Insights SDK directly (different API)\n- The user needs APM with a commercial vendor's proprietary SDK\n\n## Inputs\n\n| Input | Required | Description |\n|-------|----------|-------------|\n| ASP.NET Core project | Yes | The application to instrument |\n| Observability backend | No | Where to export: OTLP collector, Aspire dashboard, Jaeger (accepts OTLP natively) |\n\n## Workflow\n\n### Step 1: Install the correct packages\n\n**There are many OpenTelemetry NuGet packages. Install exactly these:**\n\n```bash\n# Core SDK + ASP.NET Core instrumentation + logging integration\ndotnet add package OpenTelemetry.Extensions.Hosting\ndotnet add package OpenTelemetry.Instrumentation.AspNetCore\ndotnet add package OpenTelemetry.Instrumentation.Http\n\n# Exporter\ndotnet add package OpenTelemetry.Exporter.OpenTelemetryProtocol  # OTLP exporter for traces, metrics, AND logs\n\n# Optional — dev\u002Flocal debugging only (do NOT include in production deployments)\n# dotnet add package OpenTelemetry.Exporter.Console\n```\n\n**Do NOT install `OpenTelemetry` alone** — you need `OpenTelemetry.Extensions.Hosting` for proper DI integration.\n\n#### Optional: additional auto-instrumentation packages\n\nInstall only the packages that match the libraries your application uses:\n\n```bash\ndotnet add package OpenTelemetry.Instrumentation.SqlClient           # SQL Server queries\ndotnet add package OpenTelemetry.Instrumentation.EntityFrameworkCore  # EF Core\ndotnet add package OpenTelemetry.Instrumentation.GrpcNetClient       # gRPC calls\ndotnet add package OpenTelemetry.Instrumentation.Runtime             # GC, thread pool metrics\n```\n\n### Step 2: Configure all signals in Program.cs\n\n```csharp\nusing OpenTelemetry.Resources;\nusing OpenTelemetry.Trace;\nusing OpenTelemetry.Metrics;\nusing OpenTelemetry.Logs;\n\nvar builder = WebApplication.CreateBuilder(args);\n\nbuilder.Services.AddOpenTelemetry()\n    .ConfigureResource(resource => resource\n        .AddService(serviceName: builder.Environment.ApplicationName))\n    .WithTracing(tracing => tracing\n        .AddAspNetCoreInstrumentation(options =>\n        {\n            \u002F\u002F Filter out health check endpoints from traces\n            options.Filter = httpContext =>\n                !httpContext.Request.Path.StartsWithSegments(\"\u002Fhealthz\");\n        })\n        .AddHttpClientInstrumentation(options =>\n        {\n            options.RecordException = true;\n        })\n        \u002F\u002F Optional: add SQL instrumentation if using SqlClient directly\n        \u002F\u002F .AddSqlClientInstrumentation(options =>\n        \u002F\u002F {\n        \u002F\u002F     options.SetDbStatementForText = true;\n        \u002F\u002F     options.RecordException = true;\n        \u002F\u002F })\n        \u002F\u002F Custom activity sources (must match ActivitySource names in your code)\n        .AddSource(\"MyApp.Orders\")\n        .AddSource(\"MyApp.Payments\")\n        .AddSource(\"MyApp.Messaging\"))\n    .WithMetrics(metrics => metrics\n        .AddAspNetCoreInstrumentation()\n        .AddHttpClientInstrumentation()\n        \u002F\u002F Optional: .AddRuntimeInstrumentation() for GC and thread pool metrics\n        \u002F\u002F   (requires OpenTelemetry.Instrumentation.Runtime package)\n        \u002F\u002F Custom meters (must match Meter names in your code)\n        .AddMeter(\"MyApp.Metrics\"))\n    .WithLogging(logging =>\n    {\n        logging.IncludeScopes = true;\n        \u002F\u002F logging.IncludeFormattedMessage = true;  \u002F\u002F Enable if you need the formatted message string in log exports\n    })\n    \u002F\u002F Single OTLP exporter for all signals — reads OTEL_EXPORTER_OTLP_ENDPOINT\n    \u002F\u002F env var (defaults to http:\u002F\u002Flocalhost:4317). Override via environment variable\n    \u002F\u002F or appsettings.json configuration.\n    .UseOtlpExporter();\n```\n\n### Step 3: Understanding log–trace correlation\n\nThe `.WithLogging()` call in Step 2 integrates ILogger with OpenTelemetry:\n\n- Each log entry automatically includes TraceId and SpanId for correlation with traces\n- The service resource from `.ConfigureResource()` propagates to logs automatically\n- `UseOtlpExporter()` applies to logs alongside traces and metrics\n- No additional packages or separate `SetResourceBuilder` call needed\n\n### Step 4: Create custom spans (Activities) for business operations\n\n```csharp\nusing System.Diagnostics;\nusing Microsoft.Extensions.Logging;\n\npublic class OrderService\n{\n    \u002F\u002F Create an ActivitySource matching what you registered in Step 2\n    private static readonly ActivitySource ActivitySource = new(\"MyApp.Orders\");\n    private readonly ILogger\u003COrderService> _logger;\n\n    public OrderService(ILogger\u003COrderService> logger) => _logger = logger;\n\n    public async Task\u003COrder> ProcessOrderAsync(CreateOrderRequest request)\n    {\n        \u002F\u002F Start a new span\n        using var activity = ActivitySource.StartActivity(\"ProcessOrder\");\n\n        \u002F\u002F Add attributes (tags) to the span\n        activity?.SetTag(\"order.customer_id\", request.CustomerId);\n        activity?.SetTag(\"order.item_count\", request.Items.Count);\n\n        try\n        {\n            \u002F\u002F Child span for validation\n            using (var validationActivity = ActivitySource.StartActivity(\"ValidateOrder\"))\n            {\n                await ValidateOrderAsync(request);\n                validationActivity?.SetTag(\"validation.result\", \"passed\");\n            }\n\n            \u002F\u002F Child span for payment\n            using (var paymentActivity = ActivitySource.StartActivity(\"ProcessPayment\",\n                ActivityKind.Client))  \u002F\u002F Client = outgoing call\n            {\n                paymentActivity?.SetTag(\"payment.method\", request.PaymentMethod);\n                await ProcessPaymentAsync(request);\n            }\n\n            var order = new Order { Id = Guid.NewGuid(), CustomerId = request.CustomerId, Status = \"Completed\" };\n\n            activity?.SetTag(\"order.status\", \"completed\");\n            activity?.SetStatus(ActivityStatusCode.Ok);\n\n            return order;\n        }\n        catch (Exception ex)\n        {\n            activity?.SetStatus(ActivityStatusCode.Error, ex.Message);\n            \u002F\u002F Log via ILogger — OpenTelemetry captures this with trace correlation.\n            \u002F\u002F Prefer logging over activity.RecordException() as OTel is deprecating\n            \u002F\u002F span events for exception recording in favor of log-based exceptions.\n            _logger.LogError(ex, \"Order processing failed for customer {CustomerId}\", request.CustomerId);\n            throw;\n        }\n    }\n}\n```\n\n**Critical: `ActivitySource` name must match `AddSource(\"...\")` in configuration.** Unmatched sources are silently ignored — this is the #1 debugging issue.\n\n### Step 5: Create custom metrics\n\nUse `IMeterFactory` (injected via DI) to create meters — this ensures proper lifetime management and testability.\n\n```csharp\nusing System.Diagnostics;\nusing System.Diagnostics.Metrics;\n\npublic class OrderMetrics\n{\n    private readonly Counter\u003Clong> _ordersProcessed;\n    private readonly Histogram\u003Cdouble> _orderProcessingDuration;\n    private readonly UpDownCounter\u003Cint> _activeOrders;\n\n    public OrderMetrics(IMeterFactory meterFactory)\n    {\n        \u002F\u002F Meter name must match AddMeter(\"...\") in configuration\n        var meter = meterFactory.Create(\"MyApp.Metrics\");\n\n        \u002F\u002F Counter — use for things that only go up\n        _ordersProcessed = meter.CreateCounter\u003Clong>(\n            \"orders.processed\", \"orders\", \"Total orders successfully processed\");\n\n        \u002F\u002F Histogram — use for measuring distributions (latency, sizes)\n        _orderProcessingDuration = meter.CreateHistogram\u003Cdouble>(\n            \"orders.processing_duration\", \"ms\", \"Time to process an order\");\n\n        \u002F\u002F UpDownCounter — use for things that go up AND down\n        _activeOrders = meter.CreateUpDownCounter\u003Cint>(\n            \"orders.active\", \"orders\", \"Currently processing orders\");\n    }\n\n    public void RecordOrderProcessed(string region, double durationMs)\n    {\n        \u002F\u002F Tags enable dimensional filtering (by region, status, etc.)\n        var tags = new TagList\n        {\n            { \"region\", region },\n            { \"order.type\", \"standard\" }\n        };\n\n        _ordersProcessed.Add(1, tags);\n        _orderProcessingDuration.Record(durationMs, tags);\n    }\n}\n```\n\nRegister `OrderMetrics` in DI:\n\n```csharp\nbuilder.Services.AddSingleton\u003COrderMetrics>();\n```\n\n### Step 6: Configure context propagation for distributed scenarios\n\nTrace context propagation is automatic for HTTP calls when using `AddHttpClientInstrumentation()`. For non-HTTP scenarios:\n\n```csharp\nusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing OpenTelemetry.Context.Propagation;\n\n\u002F\u002F ActivitySource should be static — register via .AddSource(\"MyApp.Messaging\") in Step 2\nprivate static readonly ActivitySource MessageSource = new(\"MyApp.Messaging\");\n\n\u002F\u002F Manual context propagation (e.g., across message queues)\n\u002F\u002F On the SENDING side:\nvar propagator = Propagators.DefaultTextMapPropagator;\nvar activityContext = Activity.Current?.Context ?? default;\nvar context = new PropagationContext(activityContext, Baggage.Current);\nvar carrier = new Dictionary\u003Cstring, string>();\n\npropagator.Inject(context, carrier, (dict, key, value) => dict[key] = value);\n\u002F\u002F Send carrier dictionary as message headers\n\n\u002F\u002F On the RECEIVING side:\nvar parentContext = propagator.Extract(default, carrier,\n    (dict, key) => dict.TryGetValue(key, out var value) ? new[] { value } : Array.Empty\u003Cstring>());\n\nBaggage.Current = parentContext.Baggage;\nusing var activity = MessageSource.StartActivity(\"ProcessMessage\",\n    ActivityKind.Consumer,\n    parentContext.ActivityContext);  \u002F\u002F Links to parent trace!\n```\n\n## Validation\n\n- [ ] Traces appear in the observability backend (Jaeger, Aspire dashboard, etc.)\n- [ ] HTTP requests automatically create spans with correct verb, URL, status code\n- [ ] Custom `ActivitySource` names match `AddSource()` registrations\n- [ ] Custom `Meter` names match `AddMeter()` registrations\n- [ ] Logs include TraceId and SpanId for correlation\n- [ ] Health check endpoints are filtered from traces\n- [ ] Exception details appear on error spans\n\n## Common Pitfalls\n\n| Pitfall | Solution |\n|---------|----------|\n| `ActivitySource.StartActivity` returns null | Source name doesn't match any `AddSource()` — names must match exactly |\n| Traces not appearing in exporter | Check OTLP endpoint: gRPC uses port 4317, HTTP uses 4318 |\n| Missing HTTP client spans | Ensure `AddHttpClientInstrumentation()` is registered; it works for both `IHttpClientFactory`\u002FDI and `new HttpClient()` (use `IHttpClientFactory` for lifetime management) |\n| High cardinality tags | Don't use user IDs, request IDs, or UUIDs as metric tags — explodes storage |\n| OTLP gRPC vs HTTP mismatch | Default is gRPC (port 4317); if collector only accepts HTTP, set `OtlpExportProtocol.HttpProtobuf` |\n| `Meter` \u002F `ActivitySource` lifecycle | `ActivitySource` should be static; create `Meter` via `IMeterFactory` from DI (not `new Meter()`) for proper lifetime management and testability |\n",{"data":41,"body":42},{"name":4,"description":6,"license":31},{"type":43,"children":44},"root",[45,54,61,86,92,110,116,185,191,198,208,370,395,402,407,514,520,943,949,962,1007,1013,1453,1479,1485,1498,1810,1823,1837,1843,1856,2065,2071,2170,2176,2364],{"type":46,"tag":47,"props":48,"children":50},"element","h1",{"id":49},"configuring-opentelemetry-in-net",[51],{"type":52,"value":53},"text","Configuring OpenTelemetry in .NET",{"type":46,"tag":55,"props":56,"children":58},"h2",{"id":57},"when-to-use",[59],{"type":52,"value":60},"When to Use",{"type":46,"tag":62,"props":63,"children":64},"ul",{},[65,71,76,81],{"type":46,"tag":66,"props":67,"children":68},"li",{},[69],{"type":52,"value":70},"Adding distributed tracing to an ASP.NET Core application",{"type":46,"tag":66,"props":72,"children":73},{},[74],{"type":52,"value":75},"Setting up OpenTelemetry exporters (OTLP is the primary protocol; Jaeger accepts OTLP natively; Prometheus OTLP ingestion requires explicit opt-in)",{"type":46,"tag":66,"props":77,"children":78},{},[79],{"type":52,"value":80},"Creating custom metrics or trace spans for business operations",{"type":46,"tag":66,"props":82,"children":83},{},[84],{"type":52,"value":85},"Troubleshooting distributed trace context propagation across services",{"type":46,"tag":55,"props":87,"children":89},{"id":88},"when-not-to-use",[90],{"type":52,"value":91},"When Not to Use",{"type":46,"tag":62,"props":93,"children":94},{},[95,100,105],{"type":46,"tag":66,"props":96,"children":97},{},[98],{"type":52,"value":99},"The user wants application-level logging only (use ILogger, Serilog)",{"type":46,"tag":66,"props":101,"children":102},{},[103],{"type":52,"value":104},"The user is using Application Insights SDK directly (different API)",{"type":46,"tag":66,"props":106,"children":107},{},[108],{"type":52,"value":109},"The user needs APM with a commercial vendor's proprietary SDK",{"type":46,"tag":55,"props":111,"children":113},{"id":112},"inputs",[114],{"type":52,"value":115},"Inputs",{"type":46,"tag":117,"props":118,"children":119},"table",{},[120,144],{"type":46,"tag":121,"props":122,"children":123},"thead",{},[124],{"type":46,"tag":125,"props":126,"children":127},"tr",{},[128,134,139],{"type":46,"tag":129,"props":130,"children":131},"th",{},[132],{"type":52,"value":133},"Input",{"type":46,"tag":129,"props":135,"children":136},{},[137],{"type":52,"value":138},"Required",{"type":46,"tag":129,"props":140,"children":141},{},[142],{"type":52,"value":143},"Description",{"type":46,"tag":145,"props":146,"children":147},"tbody",{},[148,167],{"type":46,"tag":125,"props":149,"children":150},{},[151,157,162],{"type":46,"tag":152,"props":153,"children":154},"td",{},[155],{"type":52,"value":156},"ASP.NET Core project",{"type":46,"tag":152,"props":158,"children":159},{},[160],{"type":52,"value":161},"Yes",{"type":46,"tag":152,"props":163,"children":164},{},[165],{"type":52,"value":166},"The application to instrument",{"type":46,"tag":125,"props":168,"children":169},{},[170,175,180],{"type":46,"tag":152,"props":171,"children":172},{},[173],{"type":52,"value":174},"Observability backend",{"type":46,"tag":152,"props":176,"children":177},{},[178],{"type":52,"value":179},"No",{"type":46,"tag":152,"props":181,"children":182},{},[183],{"type":52,"value":184},"Where to export: OTLP collector, Aspire dashboard, Jaeger (accepts OTLP natively)",{"type":46,"tag":55,"props":186,"children":188},{"id":187},"workflow",[189],{"type":52,"value":190},"Workflow",{"type":46,"tag":192,"props":193,"children":195},"h3",{"id":194},"step-1-install-the-correct-packages",[196],{"type":52,"value":197},"Step 1: Install the correct packages",{"type":46,"tag":199,"props":200,"children":201},"p",{},[202],{"type":46,"tag":203,"props":204,"children":205},"strong",{},[206],{"type":52,"value":207},"There are many OpenTelemetry NuGet packages. Install exactly these:",{"type":46,"tag":209,"props":210,"children":215},"pre",{"className":211,"code":212,"language":213,"meta":214,"style":214},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","# Core SDK + ASP.NET Core instrumentation + logging integration\ndotnet add package OpenTelemetry.Extensions.Hosting\ndotnet add package OpenTelemetry.Instrumentation.AspNetCore\ndotnet add package OpenTelemetry.Instrumentation.Http\n\n# Exporter\ndotnet add package OpenTelemetry.Exporter.OpenTelemetryProtocol  # OTLP exporter for traces, metrics, AND logs\n\n# Optional — dev\u002Flocal debugging only (do NOT include in production deployments)\n# dotnet add package OpenTelemetry.Exporter.Console\n","bash","",[216],{"type":46,"tag":217,"props":218,"children":219},"code",{"__ignoreMap":214},[220,232,257,278,299,309,318,344,352,361],{"type":46,"tag":221,"props":222,"children":225},"span",{"class":223,"line":224},"line",1,[226],{"type":46,"tag":221,"props":227,"children":229},{"style":228},"--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic",[230],{"type":52,"value":231},"# Core SDK + ASP.NET Core instrumentation + logging integration\n",{"type":46,"tag":221,"props":233,"children":235},{"class":223,"line":234},2,[236,241,247,252],{"type":46,"tag":221,"props":237,"children":239},{"style":238},"--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B",[240],{"type":52,"value":8},{"type":46,"tag":221,"props":242,"children":244},{"style":243},"--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D",[245],{"type":52,"value":246}," add",{"type":46,"tag":221,"props":248,"children":249},{"style":243},[250],{"type":52,"value":251}," package",{"type":46,"tag":221,"props":253,"children":254},{"style":243},[255],{"type":52,"value":256}," OpenTelemetry.Extensions.Hosting\n",{"type":46,"tag":221,"props":258,"children":260},{"class":223,"line":259},3,[261,265,269,273],{"type":46,"tag":221,"props":262,"children":263},{"style":238},[264],{"type":52,"value":8},{"type":46,"tag":221,"props":266,"children":267},{"style":243},[268],{"type":52,"value":246},{"type":46,"tag":221,"props":270,"children":271},{"style":243},[272],{"type":52,"value":251},{"type":46,"tag":221,"props":274,"children":275},{"style":243},[276],{"type":52,"value":277}," OpenTelemetry.Instrumentation.AspNetCore\n",{"type":46,"tag":221,"props":279,"children":281},{"class":223,"line":280},4,[282,286,290,294],{"type":46,"tag":221,"props":283,"children":284},{"style":238},[285],{"type":52,"value":8},{"type":46,"tag":221,"props":287,"children":288},{"style":243},[289],{"type":52,"value":246},{"type":46,"tag":221,"props":291,"children":292},{"style":243},[293],{"type":52,"value":251},{"type":46,"tag":221,"props":295,"children":296},{"style":243},[297],{"type":52,"value":298}," OpenTelemetry.Instrumentation.Http\n",{"type":46,"tag":221,"props":300,"children":302},{"class":223,"line":301},5,[303],{"type":46,"tag":221,"props":304,"children":306},{"emptyLinePlaceholder":305},true,[307],{"type":52,"value":308},"\n",{"type":46,"tag":221,"props":310,"children":312},{"class":223,"line":311},6,[313],{"type":46,"tag":221,"props":314,"children":315},{"style":228},[316],{"type":52,"value":317},"# Exporter\n",{"type":46,"tag":221,"props":319,"children":321},{"class":223,"line":320},7,[322,326,330,334,339],{"type":46,"tag":221,"props":323,"children":324},{"style":238},[325],{"type":52,"value":8},{"type":46,"tag":221,"props":327,"children":328},{"style":243},[329],{"type":52,"value":246},{"type":46,"tag":221,"props":331,"children":332},{"style":243},[333],{"type":52,"value":251},{"type":46,"tag":221,"props":335,"children":336},{"style":243},[337],{"type":52,"value":338}," OpenTelemetry.Exporter.OpenTelemetryProtocol",{"type":46,"tag":221,"props":340,"children":341},{"style":228},[342],{"type":52,"value":343},"  # OTLP exporter for traces, metrics, AND logs\n",{"type":46,"tag":221,"props":345,"children":347},{"class":223,"line":346},8,[348],{"type":46,"tag":221,"props":349,"children":350},{"emptyLinePlaceholder":305},[351],{"type":52,"value":308},{"type":46,"tag":221,"props":353,"children":355},{"class":223,"line":354},9,[356],{"type":46,"tag":221,"props":357,"children":358},{"style":228},[359],{"type":52,"value":360},"# Optional — dev\u002Flocal debugging only (do NOT include in production deployments)\n",{"type":46,"tag":221,"props":362,"children":364},{"class":223,"line":363},10,[365],{"type":46,"tag":221,"props":366,"children":367},{"style":228},[368],{"type":52,"value":369},"# dotnet add package OpenTelemetry.Exporter.Console\n",{"type":46,"tag":199,"props":371,"children":372},{},[373,385,387,393],{"type":46,"tag":203,"props":374,"children":375},{},[376,378,383],{"type":52,"value":377},"Do NOT install ",{"type":46,"tag":217,"props":379,"children":381},{"className":380},[],[382],{"type":52,"value":20},{"type":52,"value":384}," alone",{"type":52,"value":386}," — you need ",{"type":46,"tag":217,"props":388,"children":390},{"className":389},[],[391],{"type":52,"value":392},"OpenTelemetry.Extensions.Hosting",{"type":52,"value":394}," for proper DI integration.",{"type":46,"tag":396,"props":397,"children":399},"h4",{"id":398},"optional-additional-auto-instrumentation-packages",[400],{"type":52,"value":401},"Optional: additional auto-instrumentation packages",{"type":46,"tag":199,"props":403,"children":404},{},[405],{"type":52,"value":406},"Install only the packages that match the libraries your application uses:",{"type":46,"tag":209,"props":408,"children":410},{"className":211,"code":409,"language":213,"meta":214,"style":214},"dotnet add package OpenTelemetry.Instrumentation.SqlClient           # SQL Server queries\ndotnet add package OpenTelemetry.Instrumentation.EntityFrameworkCore  # EF Core\ndotnet add package OpenTelemetry.Instrumentation.GrpcNetClient       # gRPC calls\ndotnet add package OpenTelemetry.Instrumentation.Runtime             # GC, thread pool metrics\n",[411],{"type":46,"tag":217,"props":412,"children":413},{"__ignoreMap":214},[414,439,464,489],{"type":46,"tag":221,"props":415,"children":416},{"class":223,"line":224},[417,421,425,429,434],{"type":46,"tag":221,"props":418,"children":419},{"style":238},[420],{"type":52,"value":8},{"type":46,"tag":221,"props":422,"children":423},{"style":243},[424],{"type":52,"value":246},{"type":46,"tag":221,"props":426,"children":427},{"style":243},[428],{"type":52,"value":251},{"type":46,"tag":221,"props":430,"children":431},{"style":243},[432],{"type":52,"value":433}," OpenTelemetry.Instrumentation.SqlClient",{"type":46,"tag":221,"props":435,"children":436},{"style":228},[437],{"type":52,"value":438},"           # SQL Server queries\n",{"type":46,"tag":221,"props":440,"children":441},{"class":223,"line":234},[442,446,450,454,459],{"type":46,"tag":221,"props":443,"children":444},{"style":238},[445],{"type":52,"value":8},{"type":46,"tag":221,"props":447,"children":448},{"style":243},[449],{"type":52,"value":246},{"type":46,"tag":221,"props":451,"children":452},{"style":243},[453],{"type":52,"value":251},{"type":46,"tag":221,"props":455,"children":456},{"style":243},[457],{"type":52,"value":458}," OpenTelemetry.Instrumentation.EntityFrameworkCore",{"type":46,"tag":221,"props":460,"children":461},{"style":228},[462],{"type":52,"value":463},"  # EF Core\n",{"type":46,"tag":221,"props":465,"children":466},{"class":223,"line":259},[467,471,475,479,484],{"type":46,"tag":221,"props":468,"children":469},{"style":238},[470],{"type":52,"value":8},{"type":46,"tag":221,"props":472,"children":473},{"style":243},[474],{"type":52,"value":246},{"type":46,"tag":221,"props":476,"children":477},{"style":243},[478],{"type":52,"value":251},{"type":46,"tag":221,"props":480,"children":481},{"style":243},[482],{"type":52,"value":483}," OpenTelemetry.Instrumentation.GrpcNetClient",{"type":46,"tag":221,"props":485,"children":486},{"style":228},[487],{"type":52,"value":488},"       # gRPC calls\n",{"type":46,"tag":221,"props":490,"children":491},{"class":223,"line":280},[492,496,500,504,509],{"type":46,"tag":221,"props":493,"children":494},{"style":238},[495],{"type":52,"value":8},{"type":46,"tag":221,"props":497,"children":498},{"style":243},[499],{"type":52,"value":246},{"type":46,"tag":221,"props":501,"children":502},{"style":243},[503],{"type":52,"value":251},{"type":46,"tag":221,"props":505,"children":506},{"style":243},[507],{"type":52,"value":508}," OpenTelemetry.Instrumentation.Runtime",{"type":46,"tag":221,"props":510,"children":511},{"style":228},[512],{"type":52,"value":513},"             # GC, thread pool metrics\n",{"type":46,"tag":192,"props":515,"children":517},{"id":516},"step-2-configure-all-signals-in-programcs",[518],{"type":52,"value":519},"Step 2: Configure all signals in Program.cs",{"type":46,"tag":209,"props":521,"children":525},{"className":522,"code":523,"language":524,"meta":214,"style":214},"language-csharp shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","using OpenTelemetry.Resources;\nusing OpenTelemetry.Trace;\nusing OpenTelemetry.Metrics;\nusing OpenTelemetry.Logs;\n\nvar builder = WebApplication.CreateBuilder(args);\n\nbuilder.Services.AddOpenTelemetry()\n    .ConfigureResource(resource => resource\n        .AddService(serviceName: builder.Environment.ApplicationName))\n    .WithTracing(tracing => tracing\n        .AddAspNetCoreInstrumentation(options =>\n        {\n            \u002F\u002F Filter out health check endpoints from traces\n            options.Filter = httpContext =>\n                !httpContext.Request.Path.StartsWithSegments(\"\u002Fhealthz\");\n        })\n        .AddHttpClientInstrumentation(options =>\n        {\n            options.RecordException = true;\n        })\n        \u002F\u002F Optional: add SQL instrumentation if using SqlClient directly\n        \u002F\u002F .AddSqlClientInstrumentation(options =>\n        \u002F\u002F {\n        \u002F\u002F     options.SetDbStatementForText = true;\n        \u002F\u002F     options.RecordException = true;\n        \u002F\u002F })\n        \u002F\u002F Custom activity sources (must match ActivitySource names in your code)\n        .AddSource(\"MyApp.Orders\")\n        .AddSource(\"MyApp.Payments\")\n        .AddSource(\"MyApp.Messaging\"))\n    .WithMetrics(metrics => metrics\n        .AddAspNetCoreInstrumentation()\n        .AddHttpClientInstrumentation()\n        \u002F\u002F Optional: .AddRuntimeInstrumentation() for GC and thread pool metrics\n        \u002F\u002F   (requires OpenTelemetry.Instrumentation.Runtime package)\n        \u002F\u002F Custom meters (must match Meter names in your code)\n        .AddMeter(\"MyApp.Metrics\"))\n    .WithLogging(logging =>\n    {\n        logging.IncludeScopes = true;\n        \u002F\u002F logging.IncludeFormattedMessage = true;  \u002F\u002F Enable if you need the formatted message string in log exports\n    })\n    \u002F\u002F Single OTLP exporter for all signals — reads OTEL_EXPORTER_OTLP_ENDPOINT\n    \u002F\u002F env var (defaults to http:\u002F\u002Flocalhost:4317). Override via environment variable\n    \u002F\u002F or appsettings.json configuration.\n    .UseOtlpExporter();\n","csharp",[526],{"type":46,"tag":217,"props":527,"children":528},{"__ignoreMap":214},[529,537,545,553,561,568,576,583,591,599,607,616,625,634,643,652,661,670,679,687,696,704,713,722,731,740,749,758,767,776,785,794,803,812,821,830,839,848,857,866,875,884,898,907,916,925,934],{"type":46,"tag":221,"props":530,"children":531},{"class":223,"line":224},[532],{"type":46,"tag":221,"props":533,"children":534},{},[535],{"type":52,"value":536},"using OpenTelemetry.Resources;\n",{"type":46,"tag":221,"props":538,"children":539},{"class":223,"line":234},[540],{"type":46,"tag":221,"props":541,"children":542},{},[543],{"type":52,"value":544},"using OpenTelemetry.Trace;\n",{"type":46,"tag":221,"props":546,"children":547},{"class":223,"line":259},[548],{"type":46,"tag":221,"props":549,"children":550},{},[551],{"type":52,"value":552},"using OpenTelemetry.Metrics;\n",{"type":46,"tag":221,"props":554,"children":555},{"class":223,"line":280},[556],{"type":46,"tag":221,"props":557,"children":558},{},[559],{"type":52,"value":560},"using OpenTelemetry.Logs;\n",{"type":46,"tag":221,"props":562,"children":563},{"class":223,"line":301},[564],{"type":46,"tag":221,"props":565,"children":566},{"emptyLinePlaceholder":305},[567],{"type":52,"value":308},{"type":46,"tag":221,"props":569,"children":570},{"class":223,"line":311},[571],{"type":46,"tag":221,"props":572,"children":573},{},[574],{"type":52,"value":575},"var builder = WebApplication.CreateBuilder(args);\n",{"type":46,"tag":221,"props":577,"children":578},{"class":223,"line":320},[579],{"type":46,"tag":221,"props":580,"children":581},{"emptyLinePlaceholder":305},[582],{"type":52,"value":308},{"type":46,"tag":221,"props":584,"children":585},{"class":223,"line":346},[586],{"type":46,"tag":221,"props":587,"children":588},{},[589],{"type":52,"value":590},"builder.Services.AddOpenTelemetry()\n",{"type":46,"tag":221,"props":592,"children":593},{"class":223,"line":354},[594],{"type":46,"tag":221,"props":595,"children":596},{},[597],{"type":52,"value":598},"    .ConfigureResource(resource => resource\n",{"type":46,"tag":221,"props":600,"children":601},{"class":223,"line":363},[602],{"type":46,"tag":221,"props":603,"children":604},{},[605],{"type":52,"value":606},"        .AddService(serviceName: builder.Environment.ApplicationName))\n",{"type":46,"tag":221,"props":608,"children":610},{"class":223,"line":609},11,[611],{"type":46,"tag":221,"props":612,"children":613},{},[614],{"type":52,"value":615},"    .WithTracing(tracing => tracing\n",{"type":46,"tag":221,"props":617,"children":619},{"class":223,"line":618},12,[620],{"type":46,"tag":221,"props":621,"children":622},{},[623],{"type":52,"value":624},"        .AddAspNetCoreInstrumentation(options =>\n",{"type":46,"tag":221,"props":626,"children":628},{"class":223,"line":627},13,[629],{"type":46,"tag":221,"props":630,"children":631},{},[632],{"type":52,"value":633},"        {\n",{"type":46,"tag":221,"props":635,"children":637},{"class":223,"line":636},14,[638],{"type":46,"tag":221,"props":639,"children":640},{},[641],{"type":52,"value":642},"            \u002F\u002F Filter out health check endpoints from traces\n",{"type":46,"tag":221,"props":644,"children":646},{"class":223,"line":645},15,[647],{"type":46,"tag":221,"props":648,"children":649},{},[650],{"type":52,"value":651},"            options.Filter = httpContext =>\n",{"type":46,"tag":221,"props":653,"children":655},{"class":223,"line":654},16,[656],{"type":46,"tag":221,"props":657,"children":658},{},[659],{"type":52,"value":660},"                !httpContext.Request.Path.StartsWithSegments(\"\u002Fhealthz\");\n",{"type":46,"tag":221,"props":662,"children":664},{"class":223,"line":663},17,[665],{"type":46,"tag":221,"props":666,"children":667},{},[668],{"type":52,"value":669},"        })\n",{"type":46,"tag":221,"props":671,"children":673},{"class":223,"line":672},18,[674],{"type":46,"tag":221,"props":675,"children":676},{},[677],{"type":52,"value":678},"        .AddHttpClientInstrumentation(options =>\n",{"type":46,"tag":221,"props":680,"children":682},{"class":223,"line":681},19,[683],{"type":46,"tag":221,"props":684,"children":685},{},[686],{"type":52,"value":633},{"type":46,"tag":221,"props":688,"children":690},{"class":223,"line":689},20,[691],{"type":46,"tag":221,"props":692,"children":693},{},[694],{"type":52,"value":695},"            options.RecordException = true;\n",{"type":46,"tag":221,"props":697,"children":699},{"class":223,"line":698},21,[700],{"type":46,"tag":221,"props":701,"children":702},{},[703],{"type":52,"value":669},{"type":46,"tag":221,"props":705,"children":707},{"class":223,"line":706},22,[708],{"type":46,"tag":221,"props":709,"children":710},{},[711],{"type":52,"value":712},"        \u002F\u002F Optional: add SQL instrumentation if using SqlClient directly\n",{"type":46,"tag":221,"props":714,"children":716},{"class":223,"line":715},23,[717],{"type":46,"tag":221,"props":718,"children":719},{},[720],{"type":52,"value":721},"        \u002F\u002F .AddSqlClientInstrumentation(options =>\n",{"type":46,"tag":221,"props":723,"children":725},{"class":223,"line":724},24,[726],{"type":46,"tag":221,"props":727,"children":728},{},[729],{"type":52,"value":730},"        \u002F\u002F {\n",{"type":46,"tag":221,"props":732,"children":734},{"class":223,"line":733},25,[735],{"type":46,"tag":221,"props":736,"children":737},{},[738],{"type":52,"value":739},"        \u002F\u002F     options.SetDbStatementForText = true;\n",{"type":46,"tag":221,"props":741,"children":743},{"class":223,"line":742},26,[744],{"type":46,"tag":221,"props":745,"children":746},{},[747],{"type":52,"value":748},"        \u002F\u002F     options.RecordException = true;\n",{"type":46,"tag":221,"props":750,"children":752},{"class":223,"line":751},27,[753],{"type":46,"tag":221,"props":754,"children":755},{},[756],{"type":52,"value":757},"        \u002F\u002F })\n",{"type":46,"tag":221,"props":759,"children":761},{"class":223,"line":760},28,[762],{"type":46,"tag":221,"props":763,"children":764},{},[765],{"type":52,"value":766},"        \u002F\u002F Custom activity sources (must match ActivitySource names in your code)\n",{"type":46,"tag":221,"props":768,"children":770},{"class":223,"line":769},29,[771],{"type":46,"tag":221,"props":772,"children":773},{},[774],{"type":52,"value":775},"        .AddSource(\"MyApp.Orders\")\n",{"type":46,"tag":221,"props":777,"children":779},{"class":223,"line":778},30,[780],{"type":46,"tag":221,"props":781,"children":782},{},[783],{"type":52,"value":784},"        .AddSource(\"MyApp.Payments\")\n",{"type":46,"tag":221,"props":786,"children":788},{"class":223,"line":787},31,[789],{"type":46,"tag":221,"props":790,"children":791},{},[792],{"type":52,"value":793},"        .AddSource(\"MyApp.Messaging\"))\n",{"type":46,"tag":221,"props":795,"children":797},{"class":223,"line":796},32,[798],{"type":46,"tag":221,"props":799,"children":800},{},[801],{"type":52,"value":802},"    .WithMetrics(metrics => metrics\n",{"type":46,"tag":221,"props":804,"children":806},{"class":223,"line":805},33,[807],{"type":46,"tag":221,"props":808,"children":809},{},[810],{"type":52,"value":811},"        .AddAspNetCoreInstrumentation()\n",{"type":46,"tag":221,"props":813,"children":815},{"class":223,"line":814},34,[816],{"type":46,"tag":221,"props":817,"children":818},{},[819],{"type":52,"value":820},"        .AddHttpClientInstrumentation()\n",{"type":46,"tag":221,"props":822,"children":824},{"class":223,"line":823},35,[825],{"type":46,"tag":221,"props":826,"children":827},{},[828],{"type":52,"value":829},"        \u002F\u002F Optional: .AddRuntimeInstrumentation() for GC and thread pool metrics\n",{"type":46,"tag":221,"props":831,"children":833},{"class":223,"line":832},36,[834],{"type":46,"tag":221,"props":835,"children":836},{},[837],{"type":52,"value":838},"        \u002F\u002F   (requires OpenTelemetry.Instrumentation.Runtime package)\n",{"type":46,"tag":221,"props":840,"children":842},{"class":223,"line":841},37,[843],{"type":46,"tag":221,"props":844,"children":845},{},[846],{"type":52,"value":847},"        \u002F\u002F Custom meters (must match Meter names in your code)\n",{"type":46,"tag":221,"props":849,"children":851},{"class":223,"line":850},38,[852],{"type":46,"tag":221,"props":853,"children":854},{},[855],{"type":52,"value":856},"        .AddMeter(\"MyApp.Metrics\"))\n",{"type":46,"tag":221,"props":858,"children":860},{"class":223,"line":859},39,[861],{"type":46,"tag":221,"props":862,"children":863},{},[864],{"type":52,"value":865},"    .WithLogging(logging =>\n",{"type":46,"tag":221,"props":867,"children":869},{"class":223,"line":868},40,[870],{"type":46,"tag":221,"props":871,"children":872},{},[873],{"type":52,"value":874},"    {\n",{"type":46,"tag":221,"props":876,"children":878},{"class":223,"line":877},41,[879],{"type":46,"tag":221,"props":880,"children":881},{},[882],{"type":52,"value":883},"        logging.IncludeScopes = true;\n",{"type":46,"tag":221,"props":885,"children":887},{"class":223,"line":886},42,[888,893],{"type":46,"tag":221,"props":889,"children":890},{},[891],{"type":52,"value":892},"        \u002F\u002F logging.IncludeFormattedMessage = true;",{"type":46,"tag":221,"props":894,"children":895},{},[896],{"type":52,"value":897},"  \u002F\u002F Enable if you need the formatted message string in log exports\n",{"type":46,"tag":221,"props":899,"children":901},{"class":223,"line":900},43,[902],{"type":46,"tag":221,"props":903,"children":904},{},[905],{"type":52,"value":906},"    })\n",{"type":46,"tag":221,"props":908,"children":910},{"class":223,"line":909},44,[911],{"type":46,"tag":221,"props":912,"children":913},{},[914],{"type":52,"value":915},"    \u002F\u002F Single OTLP exporter for all signals — reads OTEL_EXPORTER_OTLP_ENDPOINT\n",{"type":46,"tag":221,"props":917,"children":919},{"class":223,"line":918},45,[920],{"type":46,"tag":221,"props":921,"children":922},{},[923],{"type":52,"value":924},"    \u002F\u002F env var (defaults to http:\u002F\u002Flocalhost:4317). Override via environment variable\n",{"type":46,"tag":221,"props":926,"children":928},{"class":223,"line":927},46,[929],{"type":46,"tag":221,"props":930,"children":931},{},[932],{"type":52,"value":933},"    \u002F\u002F or appsettings.json configuration.\n",{"type":46,"tag":221,"props":935,"children":937},{"class":223,"line":936},47,[938],{"type":46,"tag":221,"props":939,"children":940},{},[941],{"type":52,"value":942},"    .UseOtlpExporter();\n",{"type":46,"tag":192,"props":944,"children":946},{"id":945},"step-3-understanding-logtrace-correlation",[947],{"type":52,"value":948},"Step 3: Understanding log–trace correlation",{"type":46,"tag":199,"props":950,"children":951},{},[952,954,960],{"type":52,"value":953},"The ",{"type":46,"tag":217,"props":955,"children":957},{"className":956},[],[958],{"type":52,"value":959},".WithLogging()",{"type":52,"value":961}," call in Step 2 integrates ILogger with OpenTelemetry:",{"type":46,"tag":62,"props":963,"children":964},{},[965,970,983,994],{"type":46,"tag":66,"props":966,"children":967},{},[968],{"type":52,"value":969},"Each log entry automatically includes TraceId and SpanId for correlation with traces",{"type":46,"tag":66,"props":971,"children":972},{},[973,975,981],{"type":52,"value":974},"The service resource from ",{"type":46,"tag":217,"props":976,"children":978},{"className":977},[],[979],{"type":52,"value":980},".ConfigureResource()",{"type":52,"value":982}," propagates to logs automatically",{"type":46,"tag":66,"props":984,"children":985},{},[986,992],{"type":46,"tag":217,"props":987,"children":989},{"className":988},[],[990],{"type":52,"value":991},"UseOtlpExporter()",{"type":52,"value":993}," applies to logs alongside traces and metrics",{"type":46,"tag":66,"props":995,"children":996},{},[997,999,1005],{"type":52,"value":998},"No additional packages or separate ",{"type":46,"tag":217,"props":1000,"children":1002},{"className":1001},[],[1003],{"type":52,"value":1004},"SetResourceBuilder",{"type":52,"value":1006}," call needed",{"type":46,"tag":192,"props":1008,"children":1010},{"id":1009},"step-4-create-custom-spans-activities-for-business-operations",[1011],{"type":52,"value":1012},"Step 4: Create custom spans (Activities) for business operations",{"type":46,"tag":209,"props":1014,"children":1016},{"className":522,"code":1015,"language":524,"meta":214,"style":214},"using System.Diagnostics;\nusing Microsoft.Extensions.Logging;\n\npublic class OrderService\n{\n    \u002F\u002F Create an ActivitySource matching what you registered in Step 2\n    private static readonly ActivitySource ActivitySource = new(\"MyApp.Orders\");\n    private readonly ILogger\u003COrderService> _logger;\n\n    public OrderService(ILogger\u003COrderService> logger) => _logger = logger;\n\n    public async Task\u003COrder> ProcessOrderAsync(CreateOrderRequest request)\n    {\n        \u002F\u002F Start a new span\n        using var activity = ActivitySource.StartActivity(\"ProcessOrder\");\n\n        \u002F\u002F Add attributes (tags) to the span\n        activity?.SetTag(\"order.customer_id\", request.CustomerId);\n        activity?.SetTag(\"order.item_count\", request.Items.Count);\n\n        try\n        {\n            \u002F\u002F Child span for validation\n            using (var validationActivity = ActivitySource.StartActivity(\"ValidateOrder\"))\n            {\n                await ValidateOrderAsync(request);\n                validationActivity?.SetTag(\"validation.result\", \"passed\");\n            }\n\n            \u002F\u002F Child span for payment\n            using (var paymentActivity = ActivitySource.StartActivity(\"ProcessPayment\",\n                ActivityKind.Client))  \u002F\u002F Client = outgoing call\n            {\n                paymentActivity?.SetTag(\"payment.method\", request.PaymentMethod);\n                await ProcessPaymentAsync(request);\n            }\n\n            var order = new Order { Id = Guid.NewGuid(), CustomerId = request.CustomerId, Status = \"Completed\" };\n\n            activity?.SetTag(\"order.status\", \"completed\");\n            activity?.SetStatus(ActivityStatusCode.Ok);\n\n            return order;\n        }\n        catch (Exception ex)\n        {\n            activity?.SetStatus(ActivityStatusCode.Error, ex.Message);\n            \u002F\u002F Log via ILogger — OpenTelemetry captures this with trace correlation.\n            \u002F\u002F Prefer logging over activity.RecordException() as OTel is deprecating\n            \u002F\u002F span events for exception recording in favor of log-based exceptions.\n            _logger.LogError(ex, \"Order processing failed for customer {CustomerId}\", request.CustomerId);\n            throw;\n        }\n    }\n}\n",[1017],{"type":46,"tag":217,"props":1018,"children":1019},{"__ignoreMap":214},[1020,1028,1036,1043,1051,1059,1067,1075,1083,1090,1098,1105,1113,1120,1128,1136,1143,1151,1159,1167,1174,1182,1189,1197,1205,1213,1221,1229,1237,1244,1252,1260,1268,1275,1283,1291,1298,1305,1313,1320,1328,1336,1343,1351,1359,1367,1374,1382,1391,1400,1409,1418,1427,1435,1444],{"type":46,"tag":221,"props":1021,"children":1022},{"class":223,"line":224},[1023],{"type":46,"tag":221,"props":1024,"children":1025},{},[1026],{"type":52,"value":1027},"using System.Diagnostics;\n",{"type":46,"tag":221,"props":1029,"children":1030},{"class":223,"line":234},[1031],{"type":46,"tag":221,"props":1032,"children":1033},{},[1034],{"type":52,"value":1035},"using Microsoft.Extensions.Logging;\n",{"type":46,"tag":221,"props":1037,"children":1038},{"class":223,"line":259},[1039],{"type":46,"tag":221,"props":1040,"children":1041},{"emptyLinePlaceholder":305},[1042],{"type":52,"value":308},{"type":46,"tag":221,"props":1044,"children":1045},{"class":223,"line":280},[1046],{"type":46,"tag":221,"props":1047,"children":1048},{},[1049],{"type":52,"value":1050},"public class OrderService\n",{"type":46,"tag":221,"props":1052,"children":1053},{"class":223,"line":301},[1054],{"type":46,"tag":221,"props":1055,"children":1056},{},[1057],{"type":52,"value":1058},"{\n",{"type":46,"tag":221,"props":1060,"children":1061},{"class":223,"line":311},[1062],{"type":46,"tag":221,"props":1063,"children":1064},{},[1065],{"type":52,"value":1066},"    \u002F\u002F Create an ActivitySource matching what you registered in Step 2\n",{"type":46,"tag":221,"props":1068,"children":1069},{"class":223,"line":320},[1070],{"type":46,"tag":221,"props":1071,"children":1072},{},[1073],{"type":52,"value":1074},"    private static readonly ActivitySource ActivitySource = new(\"MyApp.Orders\");\n",{"type":46,"tag":221,"props":1076,"children":1077},{"class":223,"line":346},[1078],{"type":46,"tag":221,"props":1079,"children":1080},{},[1081],{"type":52,"value":1082},"    private readonly ILogger\u003COrderService> _logger;\n",{"type":46,"tag":221,"props":1084,"children":1085},{"class":223,"line":354},[1086],{"type":46,"tag":221,"props":1087,"children":1088},{"emptyLinePlaceholder":305},[1089],{"type":52,"value":308},{"type":46,"tag":221,"props":1091,"children":1092},{"class":223,"line":363},[1093],{"type":46,"tag":221,"props":1094,"children":1095},{},[1096],{"type":52,"value":1097},"    public OrderService(ILogger\u003COrderService> logger) => _logger = logger;\n",{"type":46,"tag":221,"props":1099,"children":1100},{"class":223,"line":609},[1101],{"type":46,"tag":221,"props":1102,"children":1103},{"emptyLinePlaceholder":305},[1104],{"type":52,"value":308},{"type":46,"tag":221,"props":1106,"children":1107},{"class":223,"line":618},[1108],{"type":46,"tag":221,"props":1109,"children":1110},{},[1111],{"type":52,"value":1112},"    public async Task\u003COrder> ProcessOrderAsync(CreateOrderRequest request)\n",{"type":46,"tag":221,"props":1114,"children":1115},{"class":223,"line":627},[1116],{"type":46,"tag":221,"props":1117,"children":1118},{},[1119],{"type":52,"value":874},{"type":46,"tag":221,"props":1121,"children":1122},{"class":223,"line":636},[1123],{"type":46,"tag":221,"props":1124,"children":1125},{},[1126],{"type":52,"value":1127},"        \u002F\u002F Start a new span\n",{"type":46,"tag":221,"props":1129,"children":1130},{"class":223,"line":645},[1131],{"type":46,"tag":221,"props":1132,"children":1133},{},[1134],{"type":52,"value":1135},"        using var activity = ActivitySource.StartActivity(\"ProcessOrder\");\n",{"type":46,"tag":221,"props":1137,"children":1138},{"class":223,"line":654},[1139],{"type":46,"tag":221,"props":1140,"children":1141},{"emptyLinePlaceholder":305},[1142],{"type":52,"value":308},{"type":46,"tag":221,"props":1144,"children":1145},{"class":223,"line":663},[1146],{"type":46,"tag":221,"props":1147,"children":1148},{},[1149],{"type":52,"value":1150},"        \u002F\u002F Add attributes (tags) to the span\n",{"type":46,"tag":221,"props":1152,"children":1153},{"class":223,"line":672},[1154],{"type":46,"tag":221,"props":1155,"children":1156},{},[1157],{"type":52,"value":1158},"        activity?.SetTag(\"order.customer_id\", request.CustomerId);\n",{"type":46,"tag":221,"props":1160,"children":1161},{"class":223,"line":681},[1162],{"type":46,"tag":221,"props":1163,"children":1164},{},[1165],{"type":52,"value":1166},"        activity?.SetTag(\"order.item_count\", request.Items.Count);\n",{"type":46,"tag":221,"props":1168,"children":1169},{"class":223,"line":689},[1170],{"type":46,"tag":221,"props":1171,"children":1172},{"emptyLinePlaceholder":305},[1173],{"type":52,"value":308},{"type":46,"tag":221,"props":1175,"children":1176},{"class":223,"line":698},[1177],{"type":46,"tag":221,"props":1178,"children":1179},{},[1180],{"type":52,"value":1181},"        try\n",{"type":46,"tag":221,"props":1183,"children":1184},{"class":223,"line":706},[1185],{"type":46,"tag":221,"props":1186,"children":1187},{},[1188],{"type":52,"value":633},{"type":46,"tag":221,"props":1190,"children":1191},{"class":223,"line":715},[1192],{"type":46,"tag":221,"props":1193,"children":1194},{},[1195],{"type":52,"value":1196},"            \u002F\u002F Child span for validation\n",{"type":46,"tag":221,"props":1198,"children":1199},{"class":223,"line":724},[1200],{"type":46,"tag":221,"props":1201,"children":1202},{},[1203],{"type":52,"value":1204},"            using (var validationActivity = ActivitySource.StartActivity(\"ValidateOrder\"))\n",{"type":46,"tag":221,"props":1206,"children":1207},{"class":223,"line":733},[1208],{"type":46,"tag":221,"props":1209,"children":1210},{},[1211],{"type":52,"value":1212},"            {\n",{"type":46,"tag":221,"props":1214,"children":1215},{"class":223,"line":742},[1216],{"type":46,"tag":221,"props":1217,"children":1218},{},[1219],{"type":52,"value":1220},"                await ValidateOrderAsync(request);\n",{"type":46,"tag":221,"props":1222,"children":1223},{"class":223,"line":751},[1224],{"type":46,"tag":221,"props":1225,"children":1226},{},[1227],{"type":52,"value":1228},"                validationActivity?.SetTag(\"validation.result\", \"passed\");\n",{"type":46,"tag":221,"props":1230,"children":1231},{"class":223,"line":760},[1232],{"type":46,"tag":221,"props":1233,"children":1234},{},[1235],{"type":52,"value":1236},"            }\n",{"type":46,"tag":221,"props":1238,"children":1239},{"class":223,"line":769},[1240],{"type":46,"tag":221,"props":1241,"children":1242},{"emptyLinePlaceholder":305},[1243],{"type":52,"value":308},{"type":46,"tag":221,"props":1245,"children":1246},{"class":223,"line":778},[1247],{"type":46,"tag":221,"props":1248,"children":1249},{},[1250],{"type":52,"value":1251},"            \u002F\u002F Child span for payment\n",{"type":46,"tag":221,"props":1253,"children":1254},{"class":223,"line":787},[1255],{"type":46,"tag":221,"props":1256,"children":1257},{},[1258],{"type":52,"value":1259},"            using (var paymentActivity = ActivitySource.StartActivity(\"ProcessPayment\",\n",{"type":46,"tag":221,"props":1261,"children":1262},{"class":223,"line":796},[1263],{"type":46,"tag":221,"props":1264,"children":1265},{},[1266],{"type":52,"value":1267},"                ActivityKind.Client))  \u002F\u002F Client = outgoing call\n",{"type":46,"tag":221,"props":1269,"children":1270},{"class":223,"line":805},[1271],{"type":46,"tag":221,"props":1272,"children":1273},{},[1274],{"type":52,"value":1212},{"type":46,"tag":221,"props":1276,"children":1277},{"class":223,"line":814},[1278],{"type":46,"tag":221,"props":1279,"children":1280},{},[1281],{"type":52,"value":1282},"                paymentActivity?.SetTag(\"payment.method\", request.PaymentMethod);\n",{"type":46,"tag":221,"props":1284,"children":1285},{"class":223,"line":823},[1286],{"type":46,"tag":221,"props":1287,"children":1288},{},[1289],{"type":52,"value":1290},"                await ProcessPaymentAsync(request);\n",{"type":46,"tag":221,"props":1292,"children":1293},{"class":223,"line":832},[1294],{"type":46,"tag":221,"props":1295,"children":1296},{},[1297],{"type":52,"value":1236},{"type":46,"tag":221,"props":1299,"children":1300},{"class":223,"line":841},[1301],{"type":46,"tag":221,"props":1302,"children":1303},{"emptyLinePlaceholder":305},[1304],{"type":52,"value":308},{"type":46,"tag":221,"props":1306,"children":1307},{"class":223,"line":850},[1308],{"type":46,"tag":221,"props":1309,"children":1310},{},[1311],{"type":52,"value":1312},"            var order = new Order { Id = Guid.NewGuid(), CustomerId = request.CustomerId, Status = \"Completed\" };\n",{"type":46,"tag":221,"props":1314,"children":1315},{"class":223,"line":859},[1316],{"type":46,"tag":221,"props":1317,"children":1318},{"emptyLinePlaceholder":305},[1319],{"type":52,"value":308},{"type":46,"tag":221,"props":1321,"children":1322},{"class":223,"line":868},[1323],{"type":46,"tag":221,"props":1324,"children":1325},{},[1326],{"type":52,"value":1327},"            activity?.SetTag(\"order.status\", \"completed\");\n",{"type":46,"tag":221,"props":1329,"children":1330},{"class":223,"line":877},[1331],{"type":46,"tag":221,"props":1332,"children":1333},{},[1334],{"type":52,"value":1335},"            activity?.SetStatus(ActivityStatusCode.Ok);\n",{"type":46,"tag":221,"props":1337,"children":1338},{"class":223,"line":886},[1339],{"type":46,"tag":221,"props":1340,"children":1341},{"emptyLinePlaceholder":305},[1342],{"type":52,"value":308},{"type":46,"tag":221,"props":1344,"children":1345},{"class":223,"line":900},[1346],{"type":46,"tag":221,"props":1347,"children":1348},{},[1349],{"type":52,"value":1350},"            return order;\n",{"type":46,"tag":221,"props":1352,"children":1353},{"class":223,"line":909},[1354],{"type":46,"tag":221,"props":1355,"children":1356},{},[1357],{"type":52,"value":1358},"        }\n",{"type":46,"tag":221,"props":1360,"children":1361},{"class":223,"line":918},[1362],{"type":46,"tag":221,"props":1363,"children":1364},{},[1365],{"type":52,"value":1366},"        catch (Exception ex)\n",{"type":46,"tag":221,"props":1368,"children":1369},{"class":223,"line":927},[1370],{"type":46,"tag":221,"props":1371,"children":1372},{},[1373],{"type":52,"value":633},{"type":46,"tag":221,"props":1375,"children":1376},{"class":223,"line":936},[1377],{"type":46,"tag":221,"props":1378,"children":1379},{},[1380],{"type":52,"value":1381},"            activity?.SetStatus(ActivityStatusCode.Error, ex.Message);\n",{"type":46,"tag":221,"props":1383,"children":1385},{"class":223,"line":1384},48,[1386],{"type":46,"tag":221,"props":1387,"children":1388},{},[1389],{"type":52,"value":1390},"            \u002F\u002F Log via ILogger — OpenTelemetry captures this with trace correlation.\n",{"type":46,"tag":221,"props":1392,"children":1394},{"class":223,"line":1393},49,[1395],{"type":46,"tag":221,"props":1396,"children":1397},{},[1398],{"type":52,"value":1399},"            \u002F\u002F Prefer logging over activity.RecordException() as OTel is deprecating\n",{"type":46,"tag":221,"props":1401,"children":1403},{"class":223,"line":1402},50,[1404],{"type":46,"tag":221,"props":1405,"children":1406},{},[1407],{"type":52,"value":1408},"            \u002F\u002F span events for exception recording in favor of log-based exceptions.\n",{"type":46,"tag":221,"props":1410,"children":1412},{"class":223,"line":1411},51,[1413],{"type":46,"tag":221,"props":1414,"children":1415},{},[1416],{"type":52,"value":1417},"            _logger.LogError(ex, \"Order processing failed for customer {CustomerId}\", request.CustomerId);\n",{"type":46,"tag":221,"props":1419,"children":1421},{"class":223,"line":1420},52,[1422],{"type":46,"tag":221,"props":1423,"children":1424},{},[1425],{"type":52,"value":1426},"            throw;\n",{"type":46,"tag":221,"props":1428,"children":1430},{"class":223,"line":1429},53,[1431],{"type":46,"tag":221,"props":1432,"children":1433},{},[1434],{"type":52,"value":1358},{"type":46,"tag":221,"props":1436,"children":1438},{"class":223,"line":1437},54,[1439],{"type":46,"tag":221,"props":1440,"children":1441},{},[1442],{"type":52,"value":1443},"    }\n",{"type":46,"tag":221,"props":1445,"children":1447},{"class":223,"line":1446},55,[1448],{"type":46,"tag":221,"props":1449,"children":1450},{},[1451],{"type":52,"value":1452},"}\n",{"type":46,"tag":199,"props":1454,"children":1455},{},[1456,1477],{"type":46,"tag":203,"props":1457,"children":1458},{},[1459,1461,1467,1469,1475],{"type":52,"value":1460},"Critical: ",{"type":46,"tag":217,"props":1462,"children":1464},{"className":1463},[],[1465],{"type":52,"value":1466},"ActivitySource",{"type":52,"value":1468}," name must match ",{"type":46,"tag":217,"props":1470,"children":1472},{"className":1471},[],[1473],{"type":52,"value":1474},"AddSource(\"...\")",{"type":52,"value":1476}," in configuration.",{"type":52,"value":1478}," Unmatched sources are silently ignored — this is the #1 debugging issue.",{"type":46,"tag":192,"props":1480,"children":1482},{"id":1481},"step-5-create-custom-metrics",[1483],{"type":52,"value":1484},"Step 5: Create custom metrics",{"type":46,"tag":199,"props":1486,"children":1487},{},[1488,1490,1496],{"type":52,"value":1489},"Use ",{"type":46,"tag":217,"props":1491,"children":1493},{"className":1492},[],[1494],{"type":52,"value":1495},"IMeterFactory",{"type":52,"value":1497}," (injected via DI) to create meters — this ensures proper lifetime management and testability.",{"type":46,"tag":209,"props":1499,"children":1501},{"className":522,"code":1500,"language":524,"meta":214,"style":214},"using System.Diagnostics;\nusing System.Diagnostics.Metrics;\n\npublic class OrderMetrics\n{\n    private readonly Counter\u003Clong> _ordersProcessed;\n    private readonly Histogram\u003Cdouble> _orderProcessingDuration;\n    private readonly UpDownCounter\u003Cint> _activeOrders;\n\n    public OrderMetrics(IMeterFactory meterFactory)\n    {\n        \u002F\u002F Meter name must match AddMeter(\"...\") in configuration\n        var meter = meterFactory.Create(\"MyApp.Metrics\");\n\n        \u002F\u002F Counter — use for things that only go up\n        _ordersProcessed = meter.CreateCounter\u003Clong>(\n            \"orders.processed\", \"orders\", \"Total orders successfully processed\");\n\n        \u002F\u002F Histogram — use for measuring distributions (latency, sizes)\n        _orderProcessingDuration = meter.CreateHistogram\u003Cdouble>(\n            \"orders.processing_duration\", \"ms\", \"Time to process an order\");\n\n        \u002F\u002F UpDownCounter — use for things that go up AND down\n        _activeOrders = meter.CreateUpDownCounter\u003Cint>(\n            \"orders.active\", \"orders\", \"Currently processing orders\");\n    }\n\n    public void RecordOrderProcessed(string region, double durationMs)\n    {\n        \u002F\u002F Tags enable dimensional filtering (by region, status, etc.)\n        var tags = new TagList\n        {\n            { \"region\", region },\n            { \"order.type\", \"standard\" }\n        };\n\n        _ordersProcessed.Add(1, tags);\n        _orderProcessingDuration.Record(durationMs, tags);\n    }\n}\n",[1502],{"type":46,"tag":217,"props":1503,"children":1504},{"__ignoreMap":214},[1505,1512,1520,1527,1535,1542,1550,1558,1566,1573,1581,1588,1596,1604,1611,1619,1627,1635,1642,1650,1658,1666,1673,1681,1689,1697,1704,1711,1719,1726,1734,1742,1749,1757,1765,1773,1780,1788,1796,1803],{"type":46,"tag":221,"props":1506,"children":1507},{"class":223,"line":224},[1508],{"type":46,"tag":221,"props":1509,"children":1510},{},[1511],{"type":52,"value":1027},{"type":46,"tag":221,"props":1513,"children":1514},{"class":223,"line":234},[1515],{"type":46,"tag":221,"props":1516,"children":1517},{},[1518],{"type":52,"value":1519},"using System.Diagnostics.Metrics;\n",{"type":46,"tag":221,"props":1521,"children":1522},{"class":223,"line":259},[1523],{"type":46,"tag":221,"props":1524,"children":1525},{"emptyLinePlaceholder":305},[1526],{"type":52,"value":308},{"type":46,"tag":221,"props":1528,"children":1529},{"class":223,"line":280},[1530],{"type":46,"tag":221,"props":1531,"children":1532},{},[1533],{"type":52,"value":1534},"public class OrderMetrics\n",{"type":46,"tag":221,"props":1536,"children":1537},{"class":223,"line":301},[1538],{"type":46,"tag":221,"props":1539,"children":1540},{},[1541],{"type":52,"value":1058},{"type":46,"tag":221,"props":1543,"children":1544},{"class":223,"line":311},[1545],{"type":46,"tag":221,"props":1546,"children":1547},{},[1548],{"type":52,"value":1549},"    private readonly Counter\u003Clong> _ordersProcessed;\n",{"type":46,"tag":221,"props":1551,"children":1552},{"class":223,"line":320},[1553],{"type":46,"tag":221,"props":1554,"children":1555},{},[1556],{"type":52,"value":1557},"    private readonly Histogram\u003Cdouble> _orderProcessingDuration;\n",{"type":46,"tag":221,"props":1559,"children":1560},{"class":223,"line":346},[1561],{"type":46,"tag":221,"props":1562,"children":1563},{},[1564],{"type":52,"value":1565},"    private readonly UpDownCounter\u003Cint> _activeOrders;\n",{"type":46,"tag":221,"props":1567,"children":1568},{"class":223,"line":354},[1569],{"type":46,"tag":221,"props":1570,"children":1571},{"emptyLinePlaceholder":305},[1572],{"type":52,"value":308},{"type":46,"tag":221,"props":1574,"children":1575},{"class":223,"line":363},[1576],{"type":46,"tag":221,"props":1577,"children":1578},{},[1579],{"type":52,"value":1580},"    public OrderMetrics(IMeterFactory meterFactory)\n",{"type":46,"tag":221,"props":1582,"children":1583},{"class":223,"line":609},[1584],{"type":46,"tag":221,"props":1585,"children":1586},{},[1587],{"type":52,"value":874},{"type":46,"tag":221,"props":1589,"children":1590},{"class":223,"line":618},[1591],{"type":46,"tag":221,"props":1592,"children":1593},{},[1594],{"type":52,"value":1595},"        \u002F\u002F Meter name must match AddMeter(\"...\") in configuration\n",{"type":46,"tag":221,"props":1597,"children":1598},{"class":223,"line":627},[1599],{"type":46,"tag":221,"props":1600,"children":1601},{},[1602],{"type":52,"value":1603},"        var meter = meterFactory.Create(\"MyApp.Metrics\");\n",{"type":46,"tag":221,"props":1605,"children":1606},{"class":223,"line":636},[1607],{"type":46,"tag":221,"props":1608,"children":1609},{"emptyLinePlaceholder":305},[1610],{"type":52,"value":308},{"type":46,"tag":221,"props":1612,"children":1613},{"class":223,"line":645},[1614],{"type":46,"tag":221,"props":1615,"children":1616},{},[1617],{"type":52,"value":1618},"        \u002F\u002F Counter — use for things that only go up\n",{"type":46,"tag":221,"props":1620,"children":1621},{"class":223,"line":654},[1622],{"type":46,"tag":221,"props":1623,"children":1624},{},[1625],{"type":52,"value":1626},"        _ordersProcessed = meter.CreateCounter\u003Clong>(\n",{"type":46,"tag":221,"props":1628,"children":1629},{"class":223,"line":663},[1630],{"type":46,"tag":221,"props":1631,"children":1632},{},[1633],{"type":52,"value":1634},"            \"orders.processed\", \"orders\", \"Total orders successfully processed\");\n",{"type":46,"tag":221,"props":1636,"children":1637},{"class":223,"line":672},[1638],{"type":46,"tag":221,"props":1639,"children":1640},{"emptyLinePlaceholder":305},[1641],{"type":52,"value":308},{"type":46,"tag":221,"props":1643,"children":1644},{"class":223,"line":681},[1645],{"type":46,"tag":221,"props":1646,"children":1647},{},[1648],{"type":52,"value":1649},"        \u002F\u002F Histogram — use for measuring distributions (latency, sizes)\n",{"type":46,"tag":221,"props":1651,"children":1652},{"class":223,"line":689},[1653],{"type":46,"tag":221,"props":1654,"children":1655},{},[1656],{"type":52,"value":1657},"        _orderProcessingDuration = meter.CreateHistogram\u003Cdouble>(\n",{"type":46,"tag":221,"props":1659,"children":1660},{"class":223,"line":698},[1661],{"type":46,"tag":221,"props":1662,"children":1663},{},[1664],{"type":52,"value":1665},"            \"orders.processing_duration\", \"ms\", \"Time to process an order\");\n",{"type":46,"tag":221,"props":1667,"children":1668},{"class":223,"line":706},[1669],{"type":46,"tag":221,"props":1670,"children":1671},{"emptyLinePlaceholder":305},[1672],{"type":52,"value":308},{"type":46,"tag":221,"props":1674,"children":1675},{"class":223,"line":715},[1676],{"type":46,"tag":221,"props":1677,"children":1678},{},[1679],{"type":52,"value":1680},"        \u002F\u002F UpDownCounter — use for things that go up AND down\n",{"type":46,"tag":221,"props":1682,"children":1683},{"class":223,"line":724},[1684],{"type":46,"tag":221,"props":1685,"children":1686},{},[1687],{"type":52,"value":1688},"        _activeOrders = meter.CreateUpDownCounter\u003Cint>(\n",{"type":46,"tag":221,"props":1690,"children":1691},{"class":223,"line":733},[1692],{"type":46,"tag":221,"props":1693,"children":1694},{},[1695],{"type":52,"value":1696},"            \"orders.active\", \"orders\", \"Currently processing orders\");\n",{"type":46,"tag":221,"props":1698,"children":1699},{"class":223,"line":742},[1700],{"type":46,"tag":221,"props":1701,"children":1702},{},[1703],{"type":52,"value":1443},{"type":46,"tag":221,"props":1705,"children":1706},{"class":223,"line":751},[1707],{"type":46,"tag":221,"props":1708,"children":1709},{"emptyLinePlaceholder":305},[1710],{"type":52,"value":308},{"type":46,"tag":221,"props":1712,"children":1713},{"class":223,"line":760},[1714],{"type":46,"tag":221,"props":1715,"children":1716},{},[1717],{"type":52,"value":1718},"    public void RecordOrderProcessed(string region, double durationMs)\n",{"type":46,"tag":221,"props":1720,"children":1721},{"class":223,"line":769},[1722],{"type":46,"tag":221,"props":1723,"children":1724},{},[1725],{"type":52,"value":874},{"type":46,"tag":221,"props":1727,"children":1728},{"class":223,"line":778},[1729],{"type":46,"tag":221,"props":1730,"children":1731},{},[1732],{"type":52,"value":1733},"        \u002F\u002F Tags enable dimensional filtering (by region, status, etc.)\n",{"type":46,"tag":221,"props":1735,"children":1736},{"class":223,"line":787},[1737],{"type":46,"tag":221,"props":1738,"children":1739},{},[1740],{"type":52,"value":1741},"        var tags = new TagList\n",{"type":46,"tag":221,"props":1743,"children":1744},{"class":223,"line":796},[1745],{"type":46,"tag":221,"props":1746,"children":1747},{},[1748],{"type":52,"value":633},{"type":46,"tag":221,"props":1750,"children":1751},{"class":223,"line":805},[1752],{"type":46,"tag":221,"props":1753,"children":1754},{},[1755],{"type":52,"value":1756},"            { \"region\", region },\n",{"type":46,"tag":221,"props":1758,"children":1759},{"class":223,"line":814},[1760],{"type":46,"tag":221,"props":1761,"children":1762},{},[1763],{"type":52,"value":1764},"            { \"order.type\", \"standard\" }\n",{"type":46,"tag":221,"props":1766,"children":1767},{"class":223,"line":823},[1768],{"type":46,"tag":221,"props":1769,"children":1770},{},[1771],{"type":52,"value":1772},"        };\n",{"type":46,"tag":221,"props":1774,"children":1775},{"class":223,"line":832},[1776],{"type":46,"tag":221,"props":1777,"children":1778},{"emptyLinePlaceholder":305},[1779],{"type":52,"value":308},{"type":46,"tag":221,"props":1781,"children":1782},{"class":223,"line":841},[1783],{"type":46,"tag":221,"props":1784,"children":1785},{},[1786],{"type":52,"value":1787},"        _ordersProcessed.Add(1, tags);\n",{"type":46,"tag":221,"props":1789,"children":1790},{"class":223,"line":850},[1791],{"type":46,"tag":221,"props":1792,"children":1793},{},[1794],{"type":52,"value":1795},"        _orderProcessingDuration.Record(durationMs, tags);\n",{"type":46,"tag":221,"props":1797,"children":1798},{"class":223,"line":859},[1799],{"type":46,"tag":221,"props":1800,"children":1801},{},[1802],{"type":52,"value":1443},{"type":46,"tag":221,"props":1804,"children":1805},{"class":223,"line":868},[1806],{"type":46,"tag":221,"props":1807,"children":1808},{},[1809],{"type":52,"value":1452},{"type":46,"tag":199,"props":1811,"children":1812},{},[1813,1815,1821],{"type":52,"value":1814},"Register ",{"type":46,"tag":217,"props":1816,"children":1818},{"className":1817},[],[1819],{"type":52,"value":1820},"OrderMetrics",{"type":52,"value":1822}," in DI:",{"type":46,"tag":209,"props":1824,"children":1826},{"className":522,"code":1825,"language":524,"meta":214,"style":214},"builder.Services.AddSingleton\u003COrderMetrics>();\n",[1827],{"type":46,"tag":217,"props":1828,"children":1829},{"__ignoreMap":214},[1830],{"type":46,"tag":221,"props":1831,"children":1832},{"class":223,"line":224},[1833],{"type":46,"tag":221,"props":1834,"children":1835},{},[1836],{"type":52,"value":1825},{"type":46,"tag":192,"props":1838,"children":1840},{"id":1839},"step-6-configure-context-propagation-for-distributed-scenarios",[1841],{"type":52,"value":1842},"Step 6: Configure context propagation for distributed scenarios",{"type":46,"tag":199,"props":1844,"children":1845},{},[1846,1848,1854],{"type":52,"value":1847},"Trace context propagation is automatic for HTTP calls when using ",{"type":46,"tag":217,"props":1849,"children":1851},{"className":1850},[],[1852],{"type":52,"value":1853},"AddHttpClientInstrumentation()",{"type":52,"value":1855},". For non-HTTP scenarios:",{"type":46,"tag":209,"props":1857,"children":1859},{"className":522,"code":1858,"language":524,"meta":214,"style":214},"using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing OpenTelemetry.Context.Propagation;\n\n\u002F\u002F ActivitySource should be static — register via .AddSource(\"MyApp.Messaging\") in Step 2\nprivate static readonly ActivitySource MessageSource = new(\"MyApp.Messaging\");\n\n\u002F\u002F Manual context propagation (e.g., across message queues)\n\u002F\u002F On the SENDING side:\nvar propagator = Propagators.DefaultTextMapPropagator;\nvar activityContext = Activity.Current?.Context ?? default;\nvar context = new PropagationContext(activityContext, Baggage.Current);\nvar carrier = new Dictionary\u003Cstring, string>();\n\npropagator.Inject(context, carrier, (dict, key, value) => dict[key] = value);\n\u002F\u002F Send carrier dictionary as message headers\n\n\u002F\u002F On the RECEIVING side:\nvar parentContext = propagator.Extract(default, carrier,\n    (dict, key) => dict.TryGetValue(key, out var value) ? new[] { value } : Array.Empty\u003Cstring>());\n\nBaggage.Current = parentContext.Baggage;\nusing var activity = MessageSource.StartActivity(\"ProcessMessage\",\n    ActivityKind.Consumer,\n    parentContext.ActivityContext);  \u002F\u002F Links to parent trace!\n",[1860],{"type":46,"tag":217,"props":1861,"children":1862},{"__ignoreMap":214},[1863,1871,1879,1886,1894,1901,1909,1917,1924,1932,1940,1948,1956,1964,1972,1979,1987,1995,2002,2010,2018,2026,2033,2041,2049,2057],{"type":46,"tag":221,"props":1864,"children":1865},{"class":223,"line":224},[1866],{"type":46,"tag":221,"props":1867,"children":1868},{},[1869],{"type":52,"value":1870},"using System;\n",{"type":46,"tag":221,"props":1872,"children":1873},{"class":223,"line":234},[1874],{"type":46,"tag":221,"props":1875,"children":1876},{},[1877],{"type":52,"value":1878},"using System.Collections.Generic;\n",{"type":46,"tag":221,"props":1880,"children":1881},{"class":223,"line":259},[1882],{"type":46,"tag":221,"props":1883,"children":1884},{},[1885],{"type":52,"value":1027},{"type":46,"tag":221,"props":1887,"children":1888},{"class":223,"line":280},[1889],{"type":46,"tag":221,"props":1890,"children":1891},{},[1892],{"type":52,"value":1893},"using OpenTelemetry.Context.Propagation;\n",{"type":46,"tag":221,"props":1895,"children":1896},{"class":223,"line":301},[1897],{"type":46,"tag":221,"props":1898,"children":1899},{"emptyLinePlaceholder":305},[1900],{"type":52,"value":308},{"type":46,"tag":221,"props":1902,"children":1903},{"class":223,"line":311},[1904],{"type":46,"tag":221,"props":1905,"children":1906},{},[1907],{"type":52,"value":1908},"\u002F\u002F ActivitySource should be static — register via .AddSource(\"MyApp.Messaging\") in Step 2\n",{"type":46,"tag":221,"props":1910,"children":1911},{"class":223,"line":320},[1912],{"type":46,"tag":221,"props":1913,"children":1914},{},[1915],{"type":52,"value":1916},"private static readonly ActivitySource MessageSource = new(\"MyApp.Messaging\");\n",{"type":46,"tag":221,"props":1918,"children":1919},{"class":223,"line":346},[1920],{"type":46,"tag":221,"props":1921,"children":1922},{"emptyLinePlaceholder":305},[1923],{"type":52,"value":308},{"type":46,"tag":221,"props":1925,"children":1926},{"class":223,"line":354},[1927],{"type":46,"tag":221,"props":1928,"children":1929},{},[1930],{"type":52,"value":1931},"\u002F\u002F Manual context propagation (e.g., across message queues)\n",{"type":46,"tag":221,"props":1933,"children":1934},{"class":223,"line":363},[1935],{"type":46,"tag":221,"props":1936,"children":1937},{},[1938],{"type":52,"value":1939},"\u002F\u002F On the SENDING side:\n",{"type":46,"tag":221,"props":1941,"children":1942},{"class":223,"line":609},[1943],{"type":46,"tag":221,"props":1944,"children":1945},{},[1946],{"type":52,"value":1947},"var propagator = Propagators.DefaultTextMapPropagator;\n",{"type":46,"tag":221,"props":1949,"children":1950},{"class":223,"line":618},[1951],{"type":46,"tag":221,"props":1952,"children":1953},{},[1954],{"type":52,"value":1955},"var activityContext = Activity.Current?.Context ?? default;\n",{"type":46,"tag":221,"props":1957,"children":1958},{"class":223,"line":627},[1959],{"type":46,"tag":221,"props":1960,"children":1961},{},[1962],{"type":52,"value":1963},"var context = new PropagationContext(activityContext, Baggage.Current);\n",{"type":46,"tag":221,"props":1965,"children":1966},{"class":223,"line":636},[1967],{"type":46,"tag":221,"props":1968,"children":1969},{},[1970],{"type":52,"value":1971},"var carrier = new Dictionary\u003Cstring, string>();\n",{"type":46,"tag":221,"props":1973,"children":1974},{"class":223,"line":645},[1975],{"type":46,"tag":221,"props":1976,"children":1977},{"emptyLinePlaceholder":305},[1978],{"type":52,"value":308},{"type":46,"tag":221,"props":1980,"children":1981},{"class":223,"line":654},[1982],{"type":46,"tag":221,"props":1983,"children":1984},{},[1985],{"type":52,"value":1986},"propagator.Inject(context, carrier, (dict, key, value) => dict[key] = value);\n",{"type":46,"tag":221,"props":1988,"children":1989},{"class":223,"line":663},[1990],{"type":46,"tag":221,"props":1991,"children":1992},{},[1993],{"type":52,"value":1994},"\u002F\u002F Send carrier dictionary as message headers\n",{"type":46,"tag":221,"props":1996,"children":1997},{"class":223,"line":672},[1998],{"type":46,"tag":221,"props":1999,"children":2000},{"emptyLinePlaceholder":305},[2001],{"type":52,"value":308},{"type":46,"tag":221,"props":2003,"children":2004},{"class":223,"line":681},[2005],{"type":46,"tag":221,"props":2006,"children":2007},{},[2008],{"type":52,"value":2009},"\u002F\u002F On the RECEIVING side:\n",{"type":46,"tag":221,"props":2011,"children":2012},{"class":223,"line":689},[2013],{"type":46,"tag":221,"props":2014,"children":2015},{},[2016],{"type":52,"value":2017},"var parentContext = propagator.Extract(default, carrier,\n",{"type":46,"tag":221,"props":2019,"children":2020},{"class":223,"line":698},[2021],{"type":46,"tag":221,"props":2022,"children":2023},{},[2024],{"type":52,"value":2025},"    (dict, key) => dict.TryGetValue(key, out var value) ? new[] { value } : Array.Empty\u003Cstring>());\n",{"type":46,"tag":221,"props":2027,"children":2028},{"class":223,"line":706},[2029],{"type":46,"tag":221,"props":2030,"children":2031},{"emptyLinePlaceholder":305},[2032],{"type":52,"value":308},{"type":46,"tag":221,"props":2034,"children":2035},{"class":223,"line":715},[2036],{"type":46,"tag":221,"props":2037,"children":2038},{},[2039],{"type":52,"value":2040},"Baggage.Current = parentContext.Baggage;\n",{"type":46,"tag":221,"props":2042,"children":2043},{"class":223,"line":724},[2044],{"type":46,"tag":221,"props":2045,"children":2046},{},[2047],{"type":52,"value":2048},"using var activity = MessageSource.StartActivity(\"ProcessMessage\",\n",{"type":46,"tag":221,"props":2050,"children":2051},{"class":223,"line":733},[2052],{"type":46,"tag":221,"props":2053,"children":2054},{},[2055],{"type":52,"value":2056},"    ActivityKind.Consumer,\n",{"type":46,"tag":221,"props":2058,"children":2059},{"class":223,"line":742},[2060],{"type":46,"tag":221,"props":2061,"children":2062},{},[2063],{"type":52,"value":2064},"    parentContext.ActivityContext);  \u002F\u002F Links to parent trace!\n",{"type":46,"tag":55,"props":2066,"children":2068},{"id":2067},"validation",[2069],{"type":52,"value":2070},"Validation",{"type":46,"tag":62,"props":2072,"children":2075},{"className":2073},[2074],"contains-task-list",[2076,2088,2097,2121,2143,2152,2161],{"type":46,"tag":66,"props":2077,"children":2080},{"className":2078},[2079],"task-list-item",[2081,2086],{"type":46,"tag":2082,"props":2083,"children":2085},"input",{"disabled":305,"type":2084},"checkbox",[],{"type":52,"value":2087}," Traces appear in the observability backend (Jaeger, Aspire dashboard, etc.)",{"type":46,"tag":66,"props":2089,"children":2091},{"className":2090},[2079],[2092,2095],{"type":46,"tag":2082,"props":2093,"children":2094},{"disabled":305,"type":2084},[],{"type":52,"value":2096}," HTTP requests automatically create spans with correct verb, URL, status code",{"type":46,"tag":66,"props":2098,"children":2100},{"className":2099},[2079],[2101,2104,2106,2111,2113,2119],{"type":46,"tag":2082,"props":2102,"children":2103},{"disabled":305,"type":2084},[],{"type":52,"value":2105}," Custom ",{"type":46,"tag":217,"props":2107,"children":2109},{"className":2108},[],[2110],{"type":52,"value":1466},{"type":52,"value":2112}," names match ",{"type":46,"tag":217,"props":2114,"children":2116},{"className":2115},[],[2117],{"type":52,"value":2118},"AddSource()",{"type":52,"value":2120}," registrations",{"type":46,"tag":66,"props":2122,"children":2124},{"className":2123},[2079],[2125,2128,2129,2135,2136,2142],{"type":46,"tag":2082,"props":2126,"children":2127},{"disabled":305,"type":2084},[],{"type":52,"value":2105},{"type":46,"tag":217,"props":2130,"children":2132},{"className":2131},[],[2133],{"type":52,"value":2134},"Meter",{"type":52,"value":2112},{"type":46,"tag":217,"props":2137,"children":2139},{"className":2138},[],[2140],{"type":52,"value":2141},"AddMeter()",{"type":52,"value":2120},{"type":46,"tag":66,"props":2144,"children":2146},{"className":2145},[2079],[2147,2150],{"type":46,"tag":2082,"props":2148,"children":2149},{"disabled":305,"type":2084},[],{"type":52,"value":2151}," Logs include TraceId and SpanId for correlation",{"type":46,"tag":66,"props":2153,"children":2155},{"className":2154},[2079],[2156,2159],{"type":46,"tag":2082,"props":2157,"children":2158},{"disabled":305,"type":2084},[],{"type":52,"value":2160}," Health check endpoints are filtered from traces",{"type":46,"tag":66,"props":2162,"children":2164},{"className":2163},[2079],[2165,2168],{"type":46,"tag":2082,"props":2166,"children":2167},{"disabled":305,"type":2084},[],{"type":52,"value":2169}," Exception details appear on error spans",{"type":46,"tag":55,"props":2171,"children":2173},{"id":2172},"common-pitfalls",[2174],{"type":52,"value":2175},"Common Pitfalls",{"type":46,"tag":117,"props":2177,"children":2178},{},[2179,2195],{"type":46,"tag":121,"props":2180,"children":2181},{},[2182],{"type":46,"tag":125,"props":2183,"children":2184},{},[2185,2190],{"type":46,"tag":129,"props":2186,"children":2187},{},[2188],{"type":52,"value":2189},"Pitfall",{"type":46,"tag":129,"props":2191,"children":2192},{},[2193],{"type":52,"value":2194},"Solution",{"type":46,"tag":145,"props":2196,"children":2197},{},[2198,2224,2237,2280,2293,2312],{"type":46,"tag":125,"props":2199,"children":2200},{},[2201,2212],{"type":46,"tag":152,"props":2202,"children":2203},{},[2204,2210],{"type":46,"tag":217,"props":2205,"children":2207},{"className":2206},[],[2208],{"type":52,"value":2209},"ActivitySource.StartActivity",{"type":52,"value":2211}," returns null",{"type":46,"tag":152,"props":2213,"children":2214},{},[2215,2217,2222],{"type":52,"value":2216},"Source name doesn't match any ",{"type":46,"tag":217,"props":2218,"children":2220},{"className":2219},[],[2221],{"type":52,"value":2118},{"type":52,"value":2223}," — names must match exactly",{"type":46,"tag":125,"props":2225,"children":2226},{},[2227,2232],{"type":46,"tag":152,"props":2228,"children":2229},{},[2230],{"type":52,"value":2231},"Traces not appearing in exporter",{"type":46,"tag":152,"props":2233,"children":2234},{},[2235],{"type":52,"value":2236},"Check OTLP endpoint: gRPC uses port 4317, HTTP uses 4318",{"type":46,"tag":125,"props":2238,"children":2239},{},[2240,2245],{"type":46,"tag":152,"props":2241,"children":2242},{},[2243],{"type":52,"value":2244},"Missing HTTP client spans",{"type":46,"tag":152,"props":2246,"children":2247},{},[2248,2250,2255,2257,2263,2265,2271,2273,2278],{"type":52,"value":2249},"Ensure ",{"type":46,"tag":217,"props":2251,"children":2253},{"className":2252},[],[2254],{"type":52,"value":1853},{"type":52,"value":2256}," is registered; it works for both ",{"type":46,"tag":217,"props":2258,"children":2260},{"className":2259},[],[2261],{"type":52,"value":2262},"IHttpClientFactory",{"type":52,"value":2264},"\u002FDI and ",{"type":46,"tag":217,"props":2266,"children":2268},{"className":2267},[],[2269],{"type":52,"value":2270},"new HttpClient()",{"type":52,"value":2272}," (use ",{"type":46,"tag":217,"props":2274,"children":2276},{"className":2275},[],[2277],{"type":52,"value":2262},{"type":52,"value":2279}," for lifetime management)",{"type":46,"tag":125,"props":2281,"children":2282},{},[2283,2288],{"type":46,"tag":152,"props":2284,"children":2285},{},[2286],{"type":52,"value":2287},"High cardinality tags",{"type":46,"tag":152,"props":2289,"children":2290},{},[2291],{"type":52,"value":2292},"Don't use user IDs, request IDs, or UUIDs as metric tags — explodes storage",{"type":46,"tag":125,"props":2294,"children":2295},{},[2296,2301],{"type":46,"tag":152,"props":2297,"children":2298},{},[2299],{"type":52,"value":2300},"OTLP gRPC vs HTTP mismatch",{"type":46,"tag":152,"props":2302,"children":2303},{},[2304,2306],{"type":52,"value":2305},"Default is gRPC (port 4317); if collector only accepts HTTP, set ",{"type":46,"tag":217,"props":2307,"children":2309},{"className":2308},[],[2310],{"type":52,"value":2311},"OtlpExportProtocol.HttpProtobuf",{"type":46,"tag":125,"props":2313,"children":2314},{},[2315,2332],{"type":46,"tag":152,"props":2316,"children":2317},{},[2318,2323,2325,2330],{"type":46,"tag":217,"props":2319,"children":2321},{"className":2320},[],[2322],{"type":52,"value":2134},{"type":52,"value":2324}," \u002F ",{"type":46,"tag":217,"props":2326,"children":2328},{"className":2327},[],[2329],{"type":52,"value":1466},{"type":52,"value":2331}," lifecycle",{"type":46,"tag":152,"props":2333,"children":2334},{},[2335,2340,2342,2347,2349,2354,2356,2362],{"type":46,"tag":217,"props":2336,"children":2338},{"className":2337},[],[2339],{"type":52,"value":1466},{"type":52,"value":2341}," should be static; create ",{"type":46,"tag":217,"props":2343,"children":2345},{"className":2344},[],[2346],{"type":52,"value":2134},{"type":52,"value":2348}," via ",{"type":46,"tag":217,"props":2350,"children":2352},{"className":2351},[],[2353],{"type":52,"value":1495},{"type":52,"value":2355}," from DI (not ",{"type":46,"tag":217,"props":2357,"children":2359},{"className":2358},[],[2360],{"type":52,"value":2361},"new Meter()",{"type":52,"value":2363},") for proper lifetime management and testability",{"type":46,"tag":2365,"props":2366,"children":2367},"style",{},[2368],{"type":52,"value":2369},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"items":2371,"total":2533},[2372,2388,2403,2418,2434,2448,2467,2477,2489,2499,2512,2523],{"slug":2373,"name":2373,"fn":2374,"description":2375,"org":2376,"tags":2377,"stars":2385,"repoUrl":2386,"updatedAt":2387},"multithreaded-task-migration","migrate MSBuild tasks to multithreaded mode","Guide for migrating MSBuild tasks to multithreaded mode support, including compatibility red-team review. Use this when converting tasks to thread-safe versions, implementing IMultiThreadableTask, adding TaskEnvironment support, or auditing migrations for behavioral compatibility.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2378,2379,2382],{"name":17,"slug":18,"type":15},{"name":2380,"slug":2381,"type":15},"Engineering","engineering",{"name":2383,"slug":2384,"type":15},"Performance","performance",5535,"https:\u002F\u002Fgithub.com\u002Fdotnet\u002Fmsbuild","2026-07-22T05:37:33.965588",{"slug":2389,"name":2389,"fn":2390,"description":2391,"org":2392,"tags":2393,"stars":28,"repoUrl":29,"updatedAt":2402},"analyzing-dotnet-performance","analyze .NET code for performance anti-patterns","Scans .NET code for ~50 performance anti-patterns across async, memory, strings, collections, LINQ, regex, serialization, and I\u002FO with tiered severity classification. Use when analyzing .NET code for optimization opportunities, reviewing hot paths, or auditing allocation-heavy patterns.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2394,2395,2398,2401],{"name":17,"slug":18,"type":15},{"name":2396,"slug":2397,"type":15},"Code Analysis","code-analysis",{"name":2399,"slug":2400,"type":15},"Debugging","debugging",{"name":2383,"slug":2384,"type":15},"2026-07-12T08:23:25.400375",{"slug":2404,"name":2404,"fn":2405,"description":2406,"org":2407,"tags":2408,"stars":28,"repoUrl":29,"updatedAt":2417},"android-tombstone-symbolication","symbolicate .NET runtime frames in Android tombstones","Symbolicate the .NET runtime frames in an Android tombstone file. Extracts BuildIds and PC offsets from the native backtrace, downloads debug symbols from the Microsoft symbol server, and runs llvm-symbolizer to produce function names with source file and line numbers. USE FOR triaging a .NET MAUI or Mono Android app crash from a tombstone, resolving native backtrace frames in libmonosgen-2.0.so or libcoreclr.so to .NET runtime source code, or investigating SIGABRT, SIGSEGV, or other native signals originating from the .NET runtime on Android. DO NOT USE FOR pure Java\u002FKotlin crashes, managed .NET exceptions that are already captured in logcat, or iOS crash logs. INVOKES Symbolicate-Tombstone.ps1 script, llvm-symbolizer, Microsoft symbol server.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2409,2410,2413,2414],{"name":17,"slug":18,"type":15},{"name":2411,"slug":2412,"type":15},"Android","android",{"name":2399,"slug":2400,"type":15},{"name":2415,"slug":2416,"type":15},"Microsoft","microsoft","2026-07-12T08:23:21.595572",{"slug":2419,"name":2419,"fn":2420,"description":2421,"org":2422,"tags":2423,"stars":28,"repoUrl":29,"updatedAt":2433},"apple-crash-symbolication","symbolicate .NET runtime frames in crash logs","Symbolicate .NET runtime frames in Apple platform .ips crash logs (iOS, tvOS, Mac Catalyst, macOS). Extracts UUIDs and addresses from the native backtrace, locates dSYM debug symbols, and runs atos to produce function names with source file and line numbers. Automatically downloads .dwarf symbols from the Microsoft symbol server using Mach-O UUIDs. USE FOR triaging a .NET MAUI or Mono app crash from an .ips file on any Apple platform, resolving native backtrace frames in libcoreclr or libmonosgen-2.0 to .NET runtime source code, retrieving .ips crash logs from a connected iOS device or iPhone, or investigating EXC_CRASH, EXC_BAD_ACCESS, SIGABRT, or SIGSEGV originating from the .NET runtime. DO NOT USE FOR pure Swift\u002FObjective-C crashes with no .NET components, or Android tombstone files. INVOKES Symbolicate-Crash.ps1 script, atos, dwarfdump, idevicecrashreport.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2424,2425,2426,2429,2432],{"name":17,"slug":18,"type":15},{"name":2399,"slug":2400,"type":15},{"name":2427,"slug":2428,"type":15},"iOS","ios",{"name":2430,"slug":2431,"type":15},"macOS","macos",{"name":13,"slug":14,"type":15},"2026-07-12T08:23:20.369986",{"slug":2435,"name":2435,"fn":2436,"description":2437,"org":2438,"tags":2439,"stars":28,"repoUrl":29,"updatedAt":2447},"assertion-quality","evaluate assertion quality in test suites","Analyzes the variety and depth of assertions across test suites in any language. Use when the user asks to evaluate assertion quality, find shallow tests, identify assertion-free tests (no assertions or only trivial ones like Assert.IsNotNull \u002F toBeTruthy()), flag self-referential or tautological assertions, measure assertion diversity, or audit whether tests verify different facets of behavior. Polyglot: .NET, Python, TS\u002FJS, Java, Go, Ruby, Rust, Swift, Kotlin, PowerShell, C++. DO NOT USE FOR: writing new tests (use code-testing-agent \u002F writing-mstest-tests), mutation reasoning about whether tests would catch a bug (use test-gap-analysis), or a general severity-ranked anti-pattern audit (use test-anti-patterns), fixing or rewriting assertions, or writing, fixing, or modernizing MSTest tests, assertions, or attributes (use writing-mstest-tests).",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2440,2441,2444],{"name":2396,"slug":2397,"type":15},{"name":2442,"slug":2443,"type":15},"QA","qa",{"name":2445,"slug":2446,"type":15},"Testing","testing","2026-07-12T08:23:51.277743",{"slug":2449,"name":2449,"fn":2450,"description":2451,"org":2452,"tags":2453,"stars":28,"repoUrl":29,"updatedAt":2466},"author-component","create and review Blazor components","Create or review Blazor components (.razor files) with correct architecture. USE FOR: writing new Blazor components that do NOT involve JavaScript interop, implementing parameters and EventCallback, RenderFragment slots, component lifecycle (OnInitializedAsync, OnParametersSet), async patterns, IAsyncDisposable, CancellationToken, CSS isolation, code-behind. DO NOT USE FOR: creating new projects (use create-blazor-project), JavaScript interop or calling browser APIs from Blazor (use use-js-interop), forms and validation (use collect-user-input), prerendering issues (use support-prerendering), HTTP data fetching patterns (use fetch-and-send-data), coordinating state between unrelated components (use coordinate-components).\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2454,2455,2458,2460,2463],{"name":17,"slug":18,"type":15},{"name":2456,"slug":2457,"type":15},"Blazor","blazor",{"name":2459,"slug":524,"type":15},"C#",{"name":2461,"slug":2462,"type":15},"UI Components","ui-components",{"name":2464,"slug":2465,"type":15},"Web Development","web-development","2026-07-15T06:03:29.216359",{"slug":2468,"name":2468,"fn":2469,"description":2470,"org":2471,"tags":2472,"stars":28,"repoUrl":29,"updatedAt":2476},"binlog-failure-analysis","analyze MSBuild binary logs","Analyze MSBuild binary logs to diagnose build failures. USE FOR: build errors that are unclear from console output, diagnosing cascading failures across multi-project builds, tracing MSBuild target execution order, and generally any MSBuild build issues. Requires an existing .binlog file. DO NOT USE FOR: generating binlogs (use binlog-generation), non-MSBuild build systems.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2473,2474,2475],{"name":2396,"slug":2397,"type":15},{"name":2399,"slug":2400,"type":15},{"name":2415,"slug":2416,"type":15},"2026-07-12T08:21:34.637923",{"slug":2478,"name":2478,"fn":2479,"description":2480,"org":2481,"tags":2482,"stars":28,"repoUrl":29,"updatedAt":2488},"binlog-generation","generate MSBuild binary logs for diagnostics","Generate MSBuild binary logs (binlogs) for build diagnostics and analysis. USE FOR: adding \u002Fbl:{} to any dotnet build, test, pack, publish, or restore command to capture a full build execution trace, prerequisite for binlog-failure-analysis and build-perf-diagnostics skills, enabling post-build investigation of errors or performance. Requires MSBuild 17.8+ \u002F .NET 8 SDK+ for {} placeholder; PowerShell needs -bl:{{}}. DO NOT USE FOR: non-MSBuild build systems (npm, Maven, CMake), analyzing an existing binlog (use binlog-failure-analysis instead).",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2483,2486,2487],{"name":2484,"slug":2485,"type":15},"Build","build",{"name":2399,"slug":2400,"type":15},{"name":2380,"slug":2381,"type":15},"2026-07-19T05:38:19.340791",{"slug":2490,"name":2490,"fn":2491,"description":2492,"org":2493,"tags":2494,"stars":28,"repoUrl":29,"updatedAt":2498},"build-parallelism","optimize MSBuild build parallelism","Diagnose and fix under-parallelized MSBuild builds. USE WHEN a multi-project solution build is slower than expected, doesn't speed up when you add cores, pegs a single core while others idle, or you want to know why `-m` isn't helping. Note: `\u002Fmaxcpucount` default is 1 (sequential) — always pass `-m` for parallel builds. Covers finding the critical path (longest serial ProjectReference chain), graph build (`\u002Fgraph`), BuildInParallel, and solution filters (`.slnf`). DO NOT USE FOR: single-project builds, incremental issues (use incremental-build), compilation slowness inside one project (use build-perf-diagnostics), non-MSBuild build systems.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2495,2496,2497],{"name":17,"slug":18,"type":15},{"name":2380,"slug":2381,"type":15},{"name":2383,"slug":2384,"type":15},"2026-07-19T05:38:18.364937",{"slug":2500,"name":2500,"fn":2501,"description":2502,"org":2503,"tags":2504,"stars":28,"repoUrl":29,"updatedAt":2511},"build-perf-baseline","establish and optimize build performance baselines","Establish build performance baselines and apply systematic optimization techniques. USE FOR: diagnosing slow builds, establishing before\u002Fafter measurements (cold, warm, no-op scenarios), applying optimization strategies like MSBuild Server, static graph builds, artifacts output, and dependency graph trimming. Start here before diving into build-perf-diagnostics, incremental-build, or build-parallelism. DO NOT USE FOR: non-MSBuild build systems, detailed bottleneck analysis (use build-perf-diagnostics after baselining).",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2505,2506,2509,2510],{"name":2380,"slug":2381,"type":15},{"name":2507,"slug":2508,"type":15},"Monitoring","monitoring",{"name":2383,"slug":2384,"type":15},{"name":2445,"slug":2446,"type":15},"2026-07-12T08:21:35.865649",{"slug":2513,"name":2513,"fn":2514,"description":2515,"org":2516,"tags":2517,"stars":28,"repoUrl":29,"updatedAt":2522},"build-perf-diagnostics","diagnose MSBuild build performance bottlenecks","Diagnose MSBuild build performance bottlenecks using binary log analysis. USE FOR: identifying why builds are slow by analyzing binlog performance summaries, detecting ResolveAssemblyReference (RAR) taking >5s, Roslyn analyzers consuming >30% of Csc time, single targets dominating >50% of build time, node utilization below 80%, excessive Copy tasks, NuGet restore running every build. Covers timeline analysis, Target\u002FTask Performance Summary interpretation, and 7 common bottleneck categories. Use after build-perf-baseline has established measurements. DO NOT USE FOR: establishing initial baselines (use build-perf-baseline first), fixing incremental build issues (use incremental-build), parallelism tuning (use build-parallelism), non-MSBuild build systems.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2518,2519,2520,2521],{"name":17,"slug":18,"type":15},{"name":2399,"slug":2400,"type":15},{"name":2380,"slug":2381,"type":15},{"name":2383,"slug":2384,"type":15},"2026-07-12T08:21:40.961722",{"slug":2524,"name":2524,"fn":2525,"description":2526,"org":2527,"tags":2528,"stars":28,"repoUrl":29,"updatedAt":2532},"check-bin-obj-clash","detect MSBuild output path conflicts","Detects MSBuild projects with conflicting OutputPath or IntermediateOutputPath. USE FOR: builds failing with 'Cannot create a file when that file already exists', 'The process cannot access the file because it is being used by another process', intermittent build failures that succeed on retry, or missing\u002Foverwritten outputs in multi-project or multi-targeting builds where bin\u002Fobj (or project.assets.json) collide. Common causes: shared OutputPath, missing AppendTargetFrameworkToOutputPath, extra global properties (e.g. PublishReadyToRun), or SetTargetFramework on a ProjectReference to a single-targeting project. DO NOT USE FOR: file access errors unrelated to MSBuild (OS-level locking), single-project single-TFM builds, non-MSBuild build systems.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2529,2530,2531],{"name":2399,"slug":2400,"type":15},{"name":2380,"slug":2381,"type":15},{"name":2442,"slug":2443,"type":15},"2026-07-19T05:38:14.336279",144,{"items":2535,"total":2584},[2536,2543,2550,2558,2564,2572,2578],{"slug":2389,"name":2389,"fn":2390,"description":2391,"org":2537,"tags":2538,"stars":28,"repoUrl":29,"updatedAt":2402},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2539,2540,2541,2542],{"name":17,"slug":18,"type":15},{"name":2396,"slug":2397,"type":15},{"name":2399,"slug":2400,"type":15},{"name":2383,"slug":2384,"type":15},{"slug":2404,"name":2404,"fn":2405,"description":2406,"org":2544,"tags":2545,"stars":28,"repoUrl":29,"updatedAt":2417},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2546,2547,2548,2549],{"name":17,"slug":18,"type":15},{"name":2411,"slug":2412,"type":15},{"name":2399,"slug":2400,"type":15},{"name":2415,"slug":2416,"type":15},{"slug":2419,"name":2419,"fn":2420,"description":2421,"org":2551,"tags":2552,"stars":28,"repoUrl":29,"updatedAt":2433},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2553,2554,2555,2556,2557],{"name":17,"slug":18,"type":15},{"name":2399,"slug":2400,"type":15},{"name":2427,"slug":2428,"type":15},{"name":2430,"slug":2431,"type":15},{"name":13,"slug":14,"type":15},{"slug":2435,"name":2435,"fn":2436,"description":2437,"org":2559,"tags":2560,"stars":28,"repoUrl":29,"updatedAt":2447},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2561,2562,2563],{"name":2396,"slug":2397,"type":15},{"name":2442,"slug":2443,"type":15},{"name":2445,"slug":2446,"type":15},{"slug":2449,"name":2449,"fn":2450,"description":2451,"org":2565,"tags":2566,"stars":28,"repoUrl":29,"updatedAt":2466},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2567,2568,2569,2570,2571],{"name":17,"slug":18,"type":15},{"name":2456,"slug":2457,"type":15},{"name":2459,"slug":524,"type":15},{"name":2461,"slug":2462,"type":15},{"name":2464,"slug":2465,"type":15},{"slug":2468,"name":2468,"fn":2469,"description":2470,"org":2573,"tags":2574,"stars":28,"repoUrl":29,"updatedAt":2476},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2575,2576,2577],{"name":2396,"slug":2397,"type":15},{"name":2399,"slug":2400,"type":15},{"name":2415,"slug":2416,"type":15},{"slug":2478,"name":2478,"fn":2479,"description":2480,"org":2579,"tags":2580,"stars":28,"repoUrl":29,"updatedAt":2488},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[2581,2582,2583],{"name":2484,"slug":2485,"type":15},{"name":2399,"slug":2400,"type":15},{"name":2380,"slug":2381,"type":15},96]