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

[repo/Runtime] Prepare to .NET9 #2281

Merged
merged 10 commits into from
Nov 4, 2024
Merged

Conversation

Kielek
Copy link
Contributor

@Kielek Kielek commented Oct 31, 2024

Changes

Follow up #2251

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)

@Kielek Kielek requested a review from a team as a code owner October 31, 2024 13:23
@github-actions github-actions bot added the comp:instrumentation.runtime Things related to OpenTelemetry.Instrumentation.Runtime label Oct 31, 2024
Copy link

codecov bot commented Oct 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.02%. Comparing base (71655ce) to head (fac6d9c).
Report is 576 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #2281       +/-   ##
===========================================
+ Coverage   73.91%   98.02%   +24.11%     
===========================================
  Files         267        2      -265     
  Lines        9615      152     -9463     
===========================================
- Hits         7107      149     -6958     
+ Misses       2508        3     -2505     
Flag Coverage Δ
unittests-Instrumentation.Runtime 98.02% <100.00%> (?)

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

Files with missing lines Coverage Δ
...elemetry.Instrumentation.Runtime/RuntimeMetrics.cs 97.93% <100.00%> (-2.07%) ⬇️

... and 263 files with indirect coverage changes

Comment on lines +196 to +202
#pragma warning disable SA1313
/// <summary>
/// Initializes a new instance of the <see cref="RuntimeMetrics"/> class.
/// </summary>
/// <param name="options">The options to define the metrics.</param>
public RuntimeMetrics(RuntimeInstrumentationOptions options)
/// <param name="_1">The options to define the metrics.</param>
public RuntimeMetrics(RuntimeInstrumentationOptions _1)
#pragma warning restore SA1313
Copy link
Member

Choose a reason for hiding this comment

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

A bit odd. Why not just remove the parameter?

-public RuntimeMetrics(RuntimeInstrumentationOptions _1)
+public RuntimeMetrics()

Could make the whole class static. But need some way to make sure it is bootstrapped.

Like instead of...

        var instrumentation = new RuntimeMetrics(options);
        builder.AddMeter(RuntimeMetrics.MeterInstance.Name);
        return builder.AddInstrumentation(() => instrumentation);

Do something like...

        GC.KeepAlive(RuntimeMetrics.SomethingAccessibleToTriggetStaticCtor)
        return builder.AddMeter(RuntimeMetrics.MeterInstance.Name);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created #2289

The problem is with public contract if extension method. We need to keep this as the package is released as stable. Then we need to suppress warning there. I am not against, but lets do it seprately

    public static MeterProviderBuilder AddRuntimeInstrumentation(
        this MeterProviderBuilder builder,
        Action<RuntimeInstrumentationOptions>? configure)

Copy link
Member

@CodeBlanch CodeBlanch left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -24,14 +24,16 @@ internal sealed class RuntimeMetrics
#endif
private const int NumberOfGenerations = 3;

private static readonly string[] GenNames = new string[] { "gen0", "gen1", "gen2", "loh", "poh" };
private static readonly string[] GenNames = ["gen0", "gen1", "gen2", "loh", "poh"];
#if NET
Copy link
Contributor

@xiang17 xiang17 Oct 31, 2024

Choose a reason for hiding this comment

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

Is this #if NET added by some automation tool?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, it was manual modification. isGcInfoAvailable was marked as unused on some target frameworks. I manually modified it.

@Kielek Kielek merged commit c732609 into open-telemetry:main Nov 4, 2024
56 checks passed
@Kielek Kielek deleted the net9prep-runtime branch November 4, 2024 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:instrumentation.runtime Things related to OpenTelemetry.Instrumentation.Runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants