Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix user_event test cases #2368

Conversation

xiang17
Copy link
Contributor

@xiang17 xiang17 commented Dec 7, 2024

Fixes #2326.

Added back tests which were failing on Linux after bumping .NET SDK to 9.0.100. I'm not able to reproduce the failures locally. Not sure why they were failing before.

Fixes #
Design discussion issue #

Changes

Please provide a brief description of the changes here.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

…'m not able to reproduce the failures locally. Not sure why they were failing before.
@github-actions github-actions bot added the comp:exporter.geneva Things related to OpenTelemetry.Exporter.Geneva label Dec 7, 2024
Copy link

codecov bot commented Dec 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.97%. Comparing base (71655ce) to head (e21483f).
Report is 642 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2368      +/-   ##
==========================================
- Coverage   73.91%   67.97%   -5.95%     
==========================================
  Files         267      361      +94     
  Lines        9615    13324    +3709     
==========================================
+ Hits         7107     9057    +1950     
- Misses       2508     4267    +1759     
Flag Coverage Δ
unittests-Contrib.Shared.Tests 85.07% <ø> (?)
unittests-Exporter.Geneva 47.44% <ø> (?)
unittests-Exporter.InfluxDB 93.92% <ø> (?)
unittests-Exporter.Instana 74.86% <ø> (?)
unittests-Exporter.OneCollector 94.57% <ø> (?)
unittests-Exporter.Stackdriver 79.26% <ø> (?)
unittests-Extensions 89.53% <ø> (?)
unittests-Extensions.Enrichment 100.00% <ø> (?)
unittests-Instrumentation.AWS 84.63% <ø> (?)
unittests-Instrumentation.AspNetCore 80.45% <ø> (?)
unittests-Instrumentation.ConfluentKafka 14.51% <ø> (?)
unittests-Instrumentation.ElasticsearchClient 80.12% <ø> (?)
unittests-Instrumentation.EntityFrameworkCore 57.06% <ø> (?)
unittests-Instrumentation.EventCounters 76.36% <ø> (?)
unittests-Instrumentation.GrpcCore 91.42% <ø> (?)
unittests-Instrumentation.GrpcNetClient 79.61% <ø> (?)
unittests-Instrumentation.Hangfire 93.58% <ø> (?)
unittests-Instrumentation.Http 62.18% <ø> (?)
unittests-Instrumentation.Process 100.00% <ø> (?)
unittests-Instrumentation.Quartz 78.76% <ø> (?)
unittests-Instrumentation.Runtime 100.00% <ø> (?)
unittests-Instrumentation.SqlClient 91.69% <ø> (?)
unittests-Instrumentation.StackExchangeRedis 68.26% <ø> (?)
unittests-Instrumentation.Wcf 49.55% <ø> (?)
unittests-PersistentStorage 64.88% <ø> (?)
unittests-Resources.AWS 78.57% <ø> (?)
unittests-Resources.Azure 85.03% <ø> (?)
unittests-Resources.Container 67.34% <ø> (?)
unittests-Resources.Gcp 71.15% <ø> (?)
unittests-Resources.Host 69.91% <ø> (?)
unittests-Resources.OperatingSystem 76.19% <ø> (?)
unittests-Resources.Process 100.00% <ø> (?)
unittests-Resources.ProcessRuntime 78.26% <ø> (?)
unittests-Sampler.AWS 88.12% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 386 files with indirect coverage changes

@github-actions github-actions bot added the infra Infra work - CI/CD, code coverage, linters label Dec 7, 2024
…est:

Requested SDK version: 9.0.100
global.json file: /home/runner/work/opentelemetry-dotnet-contrib/opentelemetry-dotnet-contrib/global.json

Installed SDKs:

Install the [9.0.100] .NET SDK or update [/home/runner/work/opentelemetry-dotnet-contrib/opentelemetry-dotnet-contrib/global.json] to match an installed SDK.
@@ -104,6 +104,8 @@ jobs:
with:
project-name: Component[OpenTelemetry.Exporter.Geneva]
code-cov-name: Exporter.Geneva
os-list: '[ "ubuntu-24.04" ]' # Note: This may be switched to latest once ubuntu-latest has a kernel version >= 6.8.0-1014-azure
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xiang17 Just some context for you. From what I could tell, user_events were added to the kernel. But early versions seemed to have an issue where user space couldn't register the tracepoint as was intended. That was later fixed. So you need a kernel with user_events enabled AND the permissions fix for it all to work correctly.

How it should work is the reader process (think agent/collector) needs sudo/admin. But the writer process (app emitting telemetry) shouldn't need anything special.

Copy link
Contributor Author

@xiang17 xiang17 Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the context. I simply restored your code back which worked in your PR.

I removed your code because I read it wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, simply adding back didn't work. The failure symptom is that the SDK is missing even though a correct SDK (9.0.101) is installed during setup dotnet step and dotnet restore & build steps were working:

  sudo -E dotnet test ./build/Projects/Component.proj --collect:"Code Coverage" --results-directory:TestResults --framework net9.0 --configuration Release --no-restore --no-build --logger:"console;verbosity=detailed" --filter "CategoryName=Geneva:user_events:metrics" -- RunConfiguration.DisableAppDomain=true && sudo chmod a+rw ./TestResults
  shell: /usr/bin/bash -e {0}
  env:
    BUILD_COMPONENT: OpenTelemetry.Exporter.Geneva
    DOTNET_ROOT: /usr/share/dotnet
The command could not be loaded, possibly because:
  * You intended to execute a .NET application:
      The application 'test' does not exist.
  * You intended to execute a .NET SDK command:
      A compatible .NET SDK was not found.

Requested SDK version: 9.0.100
global.json file: /home/runner/work/opentelemetry-dotnet-contrib/opentelemetry-dotnet-contrib/global.json

Installed SDKs:

Install the [9.0.100] .NET SDK or update [/home/runner/work/opentelemetry-dotnet-contrib/opentelemetry-dotnet-contrib/global.json] to match an installed SDK.

Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found
8.0.110 [/usr/lib/dotnet/sdk]
Error: Process completed with exit code 145.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I even changed the global.json version to 9.0.101 in case the installed 9.0.101 does not satisfy the global.json's request for 9.0.100, however it still couldn't find the SDK:

  sudo -E dotnet test ./build/Projects/Component.proj --collect:"Code Coverage" --results-directory:TestResults --framework net9.0 --configuration Release --no-restore --no-build --logger:"console;verbosity=detailed" --filter "CategoryName=Geneva:user_events:metrics" -- RunConfiguration.DisableAppDomain=true && sudo chmod a+rw ./TestResults
  shell: /usr/bin/bash -e {0}
  env:
    BUILD_COMPONENT: OpenTelemetry.Exporter.Geneva
    DOTNET_ROOT: /usr/share/dotnet
The command could not be loaded, possibly because:
  * You intended to execute a .NET application:
      The application 'test' does not exist.
  * You intended to execute a .NET SDK command:
      A compatible .NET SDK was not found.

Requested SDK version: 9.0.101
global.json file: /home/runner/work/opentelemetry-dotnet-contrib/opentelemetry-dotnet-contrib/global.json

Installed SDKs:

8.0.110 [/usr/lib/dotnet/sdk]
Install the [9.0.101] .NET SDK or update [/home/runner/work/opentelemetry-dotnet-contrib/opentelemetry-dotnet-contrib/global.json] to match an installed SDK.

Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found
Error: Process completed with exit code 145.

@Kielek
Copy link
Contributor

Kielek commented Dec 10, 2024

Potential problem to investigate with the build pipeline. The dotnet is installed for the local user. Then two first steps are executed in the same context. Last part requires elevated privileges (sudo). I suppose that there can be a problem with visibility of newly installed dotnet.
image

Potential workaround is to add /usr/share/dotnet to the PATH, but I have not tested it.

I have not tested this, just blind shot based on differences in output.

@github-actions github-actions bot requested a review from CodeBlanch December 10, 2024 18:54
@xiang17
Copy link
Contributor Author

xiang17 commented Dec 10, 2024

Potential problem to investigate with the build pipeline. The dotnet is installed for the local user. Then two first steps are executed in the same context. Last part requires elevated privileges (sudo). I suppose that there can be a problem with visibility of newly installed dotnet. image

Potential workaround is to add /usr/share/dotnet to the PATH, but I have not tested it.

I have not tested this, just blind shot based on differences in output.

Thanks! I did some tests and found that sudo mode is what broke it. However, this test needs to be run in admin mode. The '-E' arg is supposed to preserve the environment. And it worked before in Blanch's PR https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/2219/files.

I poked the environment variables and tried manually adding /usr/share/dotnet to the PATH:
dotnet --info && echo $PATH && sudo echo $PATH && sudo -E echo $PATH && export PATH=/usr/share/dotnet:$PATH && echo $PATH && sudo -E dotnet test ./build/Projects/Component.proj ...

All the echo outputs are expected, but the dotnet test would still fail:

/usr/share/dotnet:/snap/bin:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
/usr/share/dotnet:/snap/bin:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
/usr/share/dotnet:/snap/bin:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
/usr/share/dotnet:/usr/share/dotnet:/snap/bin:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
The command could not be loaded, possibly because:
  * You intended to execute a .NET application:
      The application 'test' does not exist.
  * You intended to execute a .NET SDK command:
      A compatible .NET SDK was not found.

Requested SDK version: 9.0.101
global.json file: /home/runner/work/opentelemetry-dotnet-contrib/opentelemetry-dotnet-contrib/global.json

Installed SDKs:

Install the [9.0.101] .NET SDK or update [/home/runner/work/opentelemetry-dotnet-contrib/opentelemetry-dotnet-contrib/global.json] to match an installed SDK.

Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found
8.0.110 [/usr/lib/dotnet/sdk]

Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Dec 18, 2024
Copy link
Contributor

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions bot closed this Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:exporter.geneva Things related to OpenTelemetry.Exporter.Geneva infra Infra work - CI/CD, code coverage, linters Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Exporter.Geneva] Fix user event unit tests failures on .NET 9
3 participants