Skip to content

Commit

Permalink
polish
Browse files Browse the repository at this point in the history
  • Loading branch information
reyang committed May 21, 2024
1 parent 03ff09b commit d1ba294
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 4 additions & 6 deletions docs/metrics/exemplars/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class Program
{
private static readonly ActivitySource MyActivitySource = new("OpenTelemetry.Demo.Exemplar");
private static readonly Meter MyMeter = new("OpenTelemetry.Demo.Exemplar");
private static readonly Counter<long> MyFruitCounter = MyMeter.CreateCounter<long>("MyFruitCounter");
private static readonly Histogram<double> MyHistogram = MyMeter.CreateHistogram<double>("MyHistogram");

public static void Main()
{
Expand All @@ -32,6 +32,8 @@ public static void Main()
})
.Build();

var random = new Random();

Console.WriteLine("Press any key to exit");

while (!Console.KeyAvailable)
Expand All @@ -46,14 +48,10 @@ public static void Main()
child?.SetTag("key3", "value3");
child?.SetTag("key4", "value4");

MyFruitCounter.Add(1, new("name", "apple"), new("color", "red"));
MyFruitCounter.Add(1, new("name", "lemon"), new("color", "yellow"));
MyHistogram.Record(random.NextDouble() * 100, new("tag1", "value1"), new("tag2", "value2"));
}
}

MyFruitCounter.Add(2, new("name", "apple"), new("color", "green"));
MyFruitCounter.Add(4, new("name", "lemon"), new("color", "yellow"));

Thread.Sleep(300);
}

Expand Down
10 changes: 6 additions & 4 deletions docs/metrics/exemplars/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,11 @@ var meterProvider = Sdk.CreateMeterProviderBuilder()
## Use exemplars to navigate from metrics to traces

Open Grafana, select Explore, and select Prometheus as the source. Select the
metric named "MyFruitCounter_total", and plot the chart. Toggle on the
"Exemplars" option from the UI and hit refresh.
metric named `MyHistogram_bucket`, and plot the chart. Toggle on the "Exemplars"
option from the UI and hit refresh.

![Enable Exemplars](https://github.com/open-telemetry/opentelemetry-dotnet/assets/17327289/fc11fd4b-5601-4728-acdd-5129d75fbc04)
![Enable
Exemplars](https://github.com/open-telemetry/opentelemetry-dotnet/assets/17327289/3c2dab2f-7a0a-419f-88fe-b8010b4c69f8)
The Exemplars appear as special "diamond shaped dots" along with the metric
charts in the UI. Select any exemplar to see the exemplar data, which includes
Expand All @@ -140,7 +141,8 @@ context when the recording was done. The "trace_id" enables jumping to the
tracing backed (Jaeger in this case). Click on the "Query with Jaeger" button
next to the "trace_id" field to open the corresponding trace in Jaeger.

![Navigate to trace with exemplar](https://user-images.githubusercontent.com/16979322/218629999-1d1cd6ba-2385-4683-975a-d4797df8361a.png)
![Navigate to trace with
exemplar](https://github.com/open-telemetry/opentelemetry-dotnet/assets/17327289/56bb5297-f744-41f3-bc35-8596392b8673)
## Learn more

Expand Down

0 comments on commit d1ba294

Please sign in to comment.