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] Small cleanup/simplification #6048

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

pentp
Copy link

@pentp pentp commented Jan 6, 2025

Some basic cleanup and simplification.

@pentp pentp requested a review from a team as a code owner January 6, 2025 09:58
Copy link

linux-foundation-easycla bot commented Jan 6, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@github-actions github-actions bot added pkg:OpenTelemetry.Api.ProviderBuilderExtensions Issues related to OpenTelemetry.Api.ProviderBuilderExtensions NuGet package pkg:OpenTelemetry.Api Issues related to OpenTelemetry.Api NuGet package pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package pkg:OpenTelemetry.Extensions.Hosting Issues related to OpenTelemetry.Extensions.Hosting NuGet package pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package labels Jan 6, 2025
@CodeBlanch
Copy link
Member

@pentp There's some stuff on here I would be happy to merge. Like adding readonly or simplifying lambdas, etc. There's other stuff I think we need to look at more closely like switching from Interlocked to Volatile. Would you be willing to split up this PR?

@CodeBlanch CodeBlanch changed the title Small metrics handling optimizations/cleanup [repo] Small cleanup/simplification Jan 8, 2025
@@ -404,7 +404,10 @@ static void InnerTest()
getTracerThread.Join();
}

Assert.Empty(tracers);
foreach (var kvp in tracers)
Copy link
Member

Choose a reason for hiding this comment

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

@pentp Can you explain why this test is changing? For simple cleanup/simplification work I would expect all the tests to pass as they did before so this worries me a bit 😄

Copy link
Author

@pentp pentp Jan 9, 2025

Choose a reason for hiding this comment

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

It's changing because I removed the ConcurrentDictionary.Clear() call here.

It's unnecessary from a functional perspective (the dictionary isn't used in any way after the class field is nulled out) and somewhat expensive - it takes all the locks and allocates new backing arrays which can be potentially quite large: https://source.dot.net/#System.Collections.Concurrent/System/Collections/Concurrent/ConcurrentDictionary.cs,108c257ef528517e

Copy link
Author

Choose a reason for hiding this comment

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

Should I restore the Clear() call?

Copy link
Contributor

This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or pushing will instruct the bot to automatically remove the label. This bot runs once per day.

@github-actions github-actions bot added Stale Issues and pull requests which have been flagged for closing due to inactivity and removed Stale Issues and pull requests which have been flagged for closing due to inactivity labels Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:OpenTelemetry.Api.ProviderBuilderExtensions Issues related to OpenTelemetry.Api.ProviderBuilderExtensions NuGet package pkg:OpenTelemetry.Api Issues related to OpenTelemetry.Api NuGet package pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package pkg:OpenTelemetry.Extensions.Hosting Issues related to OpenTelemetry.Extensions.Hosting NuGet package pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants