diff --git a/content/en/docs/instrumentation/net/getting-started.md b/content/en/docs/instrumentation/net/getting-started.md index 82a86a78f632..37eadeabc2ca 100644 --- a/content/en/docs/instrumentation/net/getting-started.md +++ b/content/en/docs/instrumentation/net/getting-started.md @@ -46,6 +46,8 @@ code: ```csharp using System.Globalization; +using Microsoft.AspNetCore.Mvc; + var builder = WebApplication.CreateBuilder(args); var app = builder.Build(); @@ -65,6 +67,11 @@ string HandleRollDice([FromServices]ILogger logger, string? player) return result.ToString(CultureInfo.InvariantCulture); } +int RollDice() +{ + return Random.Shared.Next(1, 7); +} + app.MapGet("/rolldice/{player?}", HandleRollDice); app.Run(); @@ -114,7 +121,21 @@ that will generate the telemetry, and set them up. 2. Setup the OpenTelemetry code + In Program.cs, replace the following lines: + + ```csharp + var builder = WebApplication.CreateBuilder(args); + var app = builder.Build(); + ``` + + With: + ```csharp + using OpenTelemetry.Logs; + using OpenTelemetry.Metrics; + using OpenTelemetry.Resources; + using OpenTelemetry.Trace; + var builder = WebApplication.CreateBuilder(args); const string serviceName = "roll-dice";