lab
This procedure is part of a lab that teaches you how to instrument your application with OpenTelemetry. If you haven't already, check out the lab introduction.
Before you can walk through the lab proper, you need to set up your development environment. Here, you:
- Spin up your .NET application
- Send traffic to your app with a simple load generator
Clone the lab repository:
$git clone https://github.com/newrelic-experimental/opentelemetry-dotnet-lab-materials
Restore dependencies, build, and run the application:
$cd opentelemetry-dotnet-lab-materials$dotnet restore app$dotnet build app$dotnet run --project app
In the output, you see a url for your app:
Determining projects to restore... All projects are up-to-date for restore.Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NETCopyright (C) Microsoft Corporation. All rights reserved. Determining projects to restore... All projects are up-to-date for restore. opentelemetry-dotnet-lab-materials -> /workspace/opentelemetry-dotnet-lab-materials/app/bin/Debug/net6.0/opentelemetry-dotnet-lab-materials.dllBuild succeeded. 0 Warning(s) 0 Error(s)Time Elapsed 00:00:01.42Building...info: Microsoft.Hosting.Lifetime[14] Now listening on: https://localhost:7072info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down.info: Microsoft.Hosting.Lifetime[0] Hosting environment: Developmentinfo: Microsoft.Hosting.Lifetime[0] Content root path: /workspace/opentelemetry-dotnet-lab-materials/app/
The application has a single endpoint at /WeatherForcast
, which you can visit in your browser or with curl:
$curl -k https://localhost:7072/WeatherForecast[{"date":"2021-11-18T16:03:02.655159-05:00","temperatureC":38,"temperatureF":100,"summary":"Chilly"},{"date":"2021-11-19T16:03:02.655161-05:00","temperatureC":-3,"temperatureF":27,"summary":"Mild"},{"date":"2021-11-20T16:03:02.655162-05:00","temperatureC":-8,"temperatureF":18,"summary":"Hot"},{"date":"2021-11-21T16:03:02.655162-05:00","temperatureC":3,"temperatureF":37,"summary":"Cool"},{"date":"2021-11-22T16:03:02.655162-05:00","temperatureC":10,"temperatureF":49,"summary":"Warm"}]
Technical Detail
You use the -k
option to instruct curl to not verify the site's SSL certification. This is fine because you're making a request against localhost.
Leave this open so you can simulate requests against it.
In another terminal window, run the load generator:
$cd opentelemetry-dotnet-lab-materials/sim$pip install requests$python simulator.py
Now that you've got your application and load generator running, it's time to see what OpenTelemetry's all about.
lab
This procedure is part of a lab that teaches you how to instrument your application with OpenTelemetry. Now that you've set up your environment, instrument your application.