Skip to content

Example repo showing how to instrument a .NET 5.0 web api with OpenTelemetry.Net and send logs and traces to Grafana Cloud

Notifications You must be signed in to change notification settings

AngeloMSFerreira/tempo-otel-dotnet-example

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Instrumenting a web api with .Net and OpenTelemetry

This repo contains the sample code and files for the blog post here. It shows how to use the OpenTelemetry.NET libraries to capture traces for incoming http requests, and use the Grafana Agent to forward them Grafana Cloud Tempo.

Usage

  1. Edit agent.yaml and supply your Grafana Cloud user name and api keys for Tempo.
  2. Start the agent and the example app for the .NET framework you are interested in. docker-compose up dotnet6 agent
  3. Generate some requests curl http:https://localhost:5000/weather (this works for all examples)
  4. Browse to https://<your_stack>.grafana.net and explore the traces.
    1. Click on the Search tab and then Run query. By default it will show traces received in the last hour.
    2. Try looking up a trace by ID. Each example logs the message "Getting weather forecast traceID=<ID>". Copy and paste this ID into the TraceID tab and then Run query to view the specific trace.

About

Example repo showing how to instrument a .NET 5.0 web api with OpenTelemetry.Net and send logs and traces to Grafana Cloud

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%