• Log inStart now

On August 31, 2024, we're EOLing developer.newrelic.com. All relevant content has been migrated to docs.newrelic.com.

Set up your lab environment

5 min

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:

  1. Spin up your .NET application
  2. Send traffic to your app with a simple load generator
Step 1 of 3

Clone the lab repository:

bash
$
git clone https://github.com/newrelic-experimental/opentelemetry-dotnet-lab-materials
Step 2 of 3

Restore dependencies, build, and run the application:

bash
$
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:

bash
Determining projects to restore...
All projects are up-to-date for restore.
Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET
Copyright (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.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:01.42
Building...
info: Microsoft.Hosting.Lifetime[14]
Now listening on: https://localhost:7072
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: 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:

bash
$
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.

Step 3 of 3

In another terminal window, run the load generator:

bash
$
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.

Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.