Skip to content

Commit

Permalink
review updates
Browse files Browse the repository at this point in the history
  • Loading branch information
martinjt committed Oct 23, 2023
1 parent 3bcba8e commit 51c7558
Showing 1 changed file with 35 additions and 41 deletions.
76 changes: 35 additions & 41 deletions content/en/docs/instrumentation/net/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ Ensure that you have the following installed locally:

The following example uses a basic
[Minimal API with ASP.NET Core](https://learn.microsoft.com/aspnet/core/tutorials/min-web-api)
application. If you are not using ASP.NET Core, that's OK — you can still use
OpenTelemetry .NET Automatic Instrumentation.
application.

For more elaborate examples, see
[examples](/docs/instrumentation/net/examples/).
Expand Down Expand Up @@ -106,22 +105,27 @@ dotnet add package OpenTelemetry.Instrumentation.AspNetCore --prerelease
dotnet add package OpenTelemetry.Exporter.Console
```

2. Setup the packages
2. Setup the OpenTelemetry code

```csharp
var builder = WebApplication.CreateBuilder(args);

const string serviceName = "roll-dice";

builder.Logging.AddOpenTelemetry(options =>
{
options.AddConsoleExporter();
options
.SetResourceBuilder(
ResourceBuilder.CreateDefault()
.AddService(serviceName))
.AddConsoleExporter();
});

builder.Services.AddOpenTelemetry()
.ConfigureResource(rb => rb.AddService("roll-dice"))
.WithTracing(tpb => tpb
.ConfigureResource(resource => resource.AddService(serviceName))
.WithTracing(tracing => tracing
.AddAspNetCoreInstrumentation()
.AddConsoleExporter())
.WithMetrics(mpb => mpb
.WithMetrics(metrics => metrics
.AddAspNetCoreInstrumentation()
.AddConsoleExporter());

Expand Down Expand Up @@ -151,49 +155,49 @@ that looks something like this (output is line-wrapped for readability):
<summary>Traces and Logs</summary>

```log
LogRecord.Timestamp: 2023-08-14T06:44:53.9279186Z
LogRecord.TraceId: 3961d22b5f90bf7662ad4933318743fe
LogRecord.SpanId: 93d5fcea422ff0ac
ogRecord.Timestamp: 2023-10-23T12:13:30.2704325Z
LogRecord.TraceId: 324333ec3bbca04ba7f4be4bf3618cb1
LogRecord.SpanId: e7d3814e31e504eb
LogRecord.TraceFlags: Recorded
LogRecord.CategoryName: simple-dotnet
LogRecord.LogLevel: Information
LogRecord.StateValues (Key:Value):
LogRecord.CategoryName: Program
LogRecord.Severity: Info
LogRecord.SeverityText: Information
LogRecord.Body: Anonymous player is rolling the dice: {result}
LogRecord.Attributes (Key:Value):
result: 1
OriginalFormat (a.k.a Body): Anonymous player is rolling the dice: {result}
Resource associated with LogRecord:
service.name: simple-dotnet
telemetry.auto.version: 0.7.0
service.name: roll-dice
service.instance.id: f20134f3-293f-4cb2-ace3-724b5571ca9a
telemetry.sdk.name: opentelemetry
telemetry.sdk.language: dotnet
telemetry.sdk.version: 1.4.0.802
telemetry.sdk.version: 1.6.0
info: simple-dotnet[0]
Anonymous player is rolling the dice: 1
Activity.TraceId: 3961d22b5f90bf7662ad4933318743fe
Activity.SpanId: 93d5fcea422ff0ac
Activity.TraceId: 324333ec3bbca04ba7f4be4bf3618cb1
Activity.SpanId: e7d3814e31e504eb
Activity.TraceFlags: Recorded
Activity.ActivitySourceName: OpenTelemetry.Instrumentation.AspNetCore
Activity.ActivitySourceName: Microsoft.AspNetCore
Activity.DisplayName: /rolldice
Activity.Kind: Server
Activity.StartTime: 2023-08-14T06:44:53.9278162Z
Activity.Duration: 00:00:00.0049754
Activity.StartTime: 2023-10-23T12:13:30.2163005Z
Activity.Duration: 00:00:00.0585187
Activity.Tags:
net.host.name: localhost
net.host.port: 8080
net.host.name: 127.0.0.1
net.host.port: 5197
http.method: GET
http.scheme: http
http.target: /rolldice
http.url: http://localhost:8080/rolldice
http.url: http://127.0.0.1:5197/rolldice
http.flavor: 1.1
http.user_agent: curl/8.0.1
http.user_agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36 Edg/118.0.2088.61

Check warning on line 193 in content/en/docs/instrumentation/net/getting-started.md

View workflow job for this annotation

GitHub Actions / SPELLING check

Unknown word (KHTML)
http.status_code: 200
Resource associated with Activity:
service.name: simple-dotnet
telemetry.auto.version: 0.7.0
service.name: roll-dice
service.instance.id: 36bfe322-51b8-4976-90fc-9186376d6ad0
telemetry.sdk.name: opentelemetry
telemetry.sdk.language: dotnet
telemetry.sdk.version: 1.4.0.802
telemetry.sdk.version: 1.6.0
```

</details>
Expand All @@ -205,16 +209,6 @@ collected (sample excerpt shown):
<summary>Metrics</summary>

```log
Export process.runtime.dotnet.gc.collections.count, Number of garbage collections that have occurred since process start., Meter: OpenTelemetry.Instrumentation.Runtime/1.1.0.2
(2023-08-14T06:12:05.8500776Z, 2023-08-14T06:12:23.7750288Z] generation: gen2 LongSum
Value: 2
(2023-08-14T06:12:05.8500776Z, 2023-08-14T06:12:23.7750288Z] generation: gen1 LongSum
Value: 2
(2023-08-14T06:12:05.8500776Z, 2023-08-14T06:12:23.7750288Z] generation: gen0 LongSum
Value: 6
...
Export http.client.duration, Measures the duration of outbound HTTP requests., Unit: ms, Meter: OpenTelemetry.Instrumentation.Http/1.0.0.0
(2023-08-14T06:12:06.2661140Z, 2023-08-14T06:12:23.7750388Z] http.flavor: 1.1 http.method: POST http.scheme: https http.status_code: 200 net.peer.name: dc.services.visualstudio.com Histogram
Value: Sum: 1330.4766000000002 Count: 5 Min: 50.0333 Max: 465.7936
Expand Down

0 comments on commit 51c7558

Please sign in to comment.