open-telemetry / opentelemetry-dotnet

The OpenTelemetry .NET Client
https://opentelemetry.io
Apache License 2.0
3.27k stars 769 forks source link

[Error] While setting up dev env #5890

Open Annosha opened 1 month ago

Annosha commented 1 month ago

Package

OpenTelemetry

Package Version

$(TargetFrameworksForLibrariesExtended) OpenTelemetry .NET SDK core-

Runtime Version

Microsoft.AspNetCore.App 9.0.0-rc.1.24452.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 9.0.0-rc.1.24431.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 9.0.0-rc.1.24452.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Description

I was setting up dev env on my local machine and followed the instructions in CONTRIBUTING.md. After cloning and running dotnet test on top level. I get following errors.

Note: I've changed touched the code yet. err3 errorTestRUN1 errorTestRUN2 TestRunReport

What am I missing?

Steps to Reproduce

Followed instructions here I forked and cloned the repo with required version of sdk "version": "9.0.100-rc.1.24452.12" and ran:dotnet test

Expected Result

Since I haven't made changes in the code the tests must pass without errors.

Actual Result

TestRunReport

Additional Context

No response

TimothyMothra commented 1 month ago

Looking at the screenshots, it looks like you might have multiple issues. I would recommend on focusing on running the tests in one project at a time so you can focus on specific issues.

I see one exception in your screenshot:

PrometheusCollectionManagerTests.EnterExitCollectTest ErrorMessage: System.InvalidOperationException: PrometheusExporter HttpListener could not be started. HttpListenerException: Failed to listen on prefix 'http://localhost:9464/metrics/' because it conflicts with an existing registration on the machine.

You would have to review if that endpoint is already in use on your machine. I've seen that when unit tests crash, test servers don't get cleaned up. If that's the case, the easiest thing would be to restart your dev machine to force close all processes. And then focus on running the tests in one project at a time.

TimothyMothra commented 1 month ago

It looks like you're working with multiple repos at once. I see in your error message: "OpenTelemetry.Instrumentation.Http". That's not THIS repo.

Let me stress that you should focus on one repo at a time until you can resolve all the issues.

Try this:

  1. create a new directory
  2. open a command line terminal and navigate to the new directory.
  3. clone only this repo via command line: git clone https://github.com/open-telemetry/opentelemetry-dotnet.git
  4. try to compile this repo: dotnet build .\opentelemetry-dotnet\OpenTelemetry.sln

This will either pass or fail. If this fails you should have a distinct list of issues to investigate.

Annosha commented 1 month ago

@TimothyMothra sorry about the confusion in above comment. The earlier issue still persists. I've checked the end points and they aren't in use on my system. I have also cloned a fresh repo to get a clean start. (Deleted all files from the system for prev one).

Note: Before installing the required version of .NET SDK which is 9.0.100-rc.1.24452.12 I installed a .NET SDK 8.0.403. But since the required version was .NET SDK 9.0.100-rc.1.24452.12 so I deleted the old one from system.

Now the dotnet test is still giving same errors. I'm going to copy some of the failed test logs:

 Please check the diagnostic logs for more information.
  OpenTelemetry.Tests test net8.0 failed with 1 error(s) (2.0s)
    C:\Users\Aman\Desktop\dotnet\opentelemetry-dotnet\test\OpenTelemetry.Tests\bin\Debug\net8.0\OpenTelemetry.Tests.dll : error TESTRUNABORT: Test Run Aborted.
You must install or update .NET to run this application.
App: C:\Users\Aman\Desktop\dotnet\opentelemetry-dotnet\test\OpenTelemetry.Exporter.Zipkin.Tests\bin\Debug\net8.0\testhost.exe
Architecture: x64
Framework: 'Microsoft.NETCore.App', version '8.0.0' (x64)
.NET location: C:\Program Files\dotnet
The following frameworks were found:
  9.0.0-rc.1.24431.7 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]`

. Please check the diagnostic logs for more information.
  OpenTelemetry.Exporter.Zipkin.Tests test net8.0 failed with 1 error(s) (2.2s)
    C:\Users\Aman\Desktop\dotnet\opentelemetry-dotnet\test\OpenTelemetry.Exporter.Zipkin.Tests\bin\Debug\net8.0\OpenTelemetry.Exporter.Zipkin.Tests.dll : error TESTRUNABORT: Test Run Aborted.`

. Please check the diagnostic logs for more information.
  OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests test net8.0 failed with 1 error(s) (0.9s)
    C:\Users\Aman\Desktop\dotnet\opentelemetry-dotnet\test\OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests\bin\Debug\net8.0\OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests.dll : error TESTRUNABORT: Test Run Aborted.`

   . Please check the diagnostic logs for more information.
  OpenTelemetry.Extensions.Hosting.Tests test net8.0 failed with 1 error(s) (0.8s)
    C:\Users\Aman\Desktop\dotnet\opentelemetry-dotnet\test\OpenTelemetry.Extensions.Hosting.Tests\bin\Debug\net8.0\OpenTelemetry.Extensions.Hosting.Tests.dll : error TESTRUNABORT: Test Run Aborted.`

   [xUnit.net 00:00:09.42]   Finished:    OpenTelemetry.Exporter.Prometheus.HttpListener.Tests
  OpenTelemetry.Exporter.Prometheus.HttpListener.Tests test net462 failed with 3 error(s) (11.6s)
    C:\Users\Aman\Desktop\dotnet\opentelemetry-dotnet\src\OpenTelemetry.Exporter.Prometheus.HttpListener\PrometheusHttpListenerMeterProviderBuilderExtensions.cs(95): error TESTERROR:
      OpenTelemetry.Exporter.Prometheus.Tests.PrometheusCollectionManagerTests.EnterExitCollectTest(scrapeResponseCacheD
      urationMilliseconds: 0, openMetricsRequested: True) (7ms): Error Message: System.InvalidOperationException : Prome
      theusExporter HttpListener could not be started.`

     . Please check the diagnostic logs for more information.
  OpenTelemetry.Api.Tests test net8.0 failed with 1 error(s) (0.6s)
    C:\Users\Aman\Desktop\dotnet\opentelemetry-dotnet\test\OpenTelemetry.Api.Tests\bin\Debug\net8.0\OpenTelemetry.Api.Tests.dll : error TESTRUNABORT: Test Run Aborted.`
 Similar errors. If the required version is  .NET SDK  9 then why does the test keeps referring to version 8? The command: 
`**dotnet --list-sdks**`

9.0.100-rc.1.24452.12 [C:\Program Files\dotnet\sdk]

dotnet --list-runtimes Microsoft.AspNetCore.App 9.0.0-rc.1.24452.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 9.0.0-rc.1.24431.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 9.0.0-rc.1.24452.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

What did I miss?

Annosha commented 1 month ago

@TimothyMothra do I need to install these dependencies explicitly individually to set up dev env?

OpenTelemetry OpenTelemetry.Extensions.Hosting OpenTelemetry.Api OpenTelemetry.Instrumentation.AspNetCore OpenTelemetry.Exporter.Console

Although it's not mention in CONTRIBUTING.md to install these dependencies in order to contribute to the project? What dependencies do I need to install to be able to setup dev env?

Note: As a beginner I apologize for asking silly questions. I'm a newbie trying to contribute to Otel.dotnet. Thank you.

cijothomas commented 1 month ago

Note: Before installing the required version of .NET SDK which is 9.0.100-rc.1.24452.12 I installed a .NET SDK 8.0.403. But since the required version was .NET SDK 9.0.100-rc.1.24452.12 so I deleted the old one from system.

Please keep the .NET 8.0 and see if it helps. (Looks like the contributing doc may need an update to call this out)

TimothyMothra commented 1 month ago

Hi @Annosha,

  1. in my previous response I asked you to run the dotnet build command: dotnet build .\opentelemetry-dotnet\OpenTelemetry.sln What was the result of this? I'm expecting this to identify all the missing prerequisites on your machine. You should ignore the dotnet test command until the dotnet build completes successfully.

  2. But since the required version was .NET SDK 9.0.100-rc.1.24452.12 so I deleted the old one from system.

    Our SDKs target multiple frameworks at once. To build these SDKS, each version of .NET will need to be installed simultaneously.

    For example: the most recent version of OpenTelemetry.Api is 1.10.0-beta.1 (link) On the Frameworks tag, we can see that this package targets "net8.0, net9.0, netstandard2.0, and net462".

  3. do I need to install these dependencies explicitly individually to set up dev env?

    • No, the OpenTelemetry, OpenTelemetry.API, OpenTelemetry.Extensions.Hosting, OpenTelemetry.Exporter.Console are all build in THIS repo. These are not dependencies.

    • OpenTelemetry.Instrumentation.AspNetCore is not a component of this repo and should not appear in any error logs.

Annosha commented 1 month ago

@TimothyMothra the build was successful with zero errors or warnings. buildsucces

Annosha commented 1 month ago

@cijothomas yes indeed I kept the .NET 8.0 eventually and that did solve some of errors. But the latest errors for dotnet testI posted above still persist.

Annosha commented 1 month ago

@rajkumar-rangaraj Do you have any suggestions or feedback on this issue?

Annosha commented 1 month ago

Here is the full log of build and dotnet test output

build&testLog.txt

Annosha commented 1 month ago

@TimothyMothra the opentelemetry-java also fails test on windows env. I had it confirmed from a maintainer and another contributor. The build for otel-java is successful too. Has anyone tried setting up otel-dotnet on windows env?

TimothyMothra commented 1 month ago

I use Windows. And our CI builds run on Windows.

I reviewed the text log. In summary:

I don't see any indication in the log what's causing these tests to abort.

The HttpListenerException is the same one I described earlier. Several of our tests set up a local web server to simulate transmitting or receiving data. My best guess is that one of these tests are failing to shut down its test server and that blocks any other test from setting up its own test server, causing that test to fail.

Next Steps

@Annosha, the good news is that the overall majority of your tests appear to be running successfully. You should consider yourself unblocked if you're ready to work on any contributions. You can depend on our CI to run all tests whenever you create a PR.

To clear this specific error, the easiest thing you can do would be to restart your machine.