-
Notifications
You must be signed in to change notification settings - Fork 773
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
[Instrumentation.GrpNetClient, Instrumentation.SqlCliet] set ActivitySource.Version to NuGet package version #5498
Merged
CodeBlanch
merged 18 commits into
open-telemetry:main
from
Kielek:instrumentation-scope-version
Apr 9, 2024
Merged
Changes from 10 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
a71856c
Include SignalVersionHelper
Kielek a5ae3fc
Instrumentation.SqlClient
Kielek af3e76e
Instrumentation.GrpcNetClient
Kielek 6c21efd
Merge branch 'main' into instrumentation-scope-version
Kielek 5585b56
Merge branch 'main' into instrumentation-scope-version
Kielek 33d5521
SignalVersionHelper -> InstrumentationScopeHelper
Kielek 4294446
Add behavior description for version logic
Kielek 7d538b2
Merge branch 'main' into instrumentation-scope-version
Kielek 0e6b2ae
PR feedback
Kielek fa7bae9
PR feedback - optimisation
Kielek 0d8add2
Merge branch 'main' into instrumentation-scope-version
Kielek 9f5f5bf
PR feedback - change fetching version contract
Kielek 5d382f0
Remove reference to non-existing file
Kielek d8f9a1a
PR feedback unify taking version in SDK
Kielek 7b3104d
Adjust tests
Kielek 2e48de8
Merge branch 'main' into instrumentation-scope-version
vishweshbankwar 15a4721
Merge branch 'main' into instrumentation-scope-version
Kielek bd3b88b
Merge branch 'main' into instrumentation-scope-version
Kielek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using System.Reflection; | ||
|
||
namespace OpenTelemetry.Instrumentation; | ||
|
||
internal static class InstrumentationScopeHelper | ||
{ | ||
public static string GetPackageVersion<T>() | ||
{ | ||
// MinVer https://github.com/adamralph/minver?tab=readme-ov-file#version-numbers | ||
// together with Microsoft.SourceLink.GitHub https://github.com/dotnet/sourcelink | ||
// fills AssemblyInformationalVersionAttribute by | ||
// `{NuGetPackageVersion}+{CommitHash}`, e.g. `1.7.0-beta.1.86+33d5521a73e881ac59d4bf1213765270ec2422ff`. | ||
// For Scope version, value of AssemblyInformationalVersionAttribute without commit hash is returned. | ||
return typeof(T).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()!.InformationalVersion.Split(new[] { '+' }, 2)[0]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Kielek We have similar logic here:
opentelemetry-dotnet/src/OpenTelemetry/Sdk.cs
Lines 34 to 35 in 3f4c73a
opentelemetry-dotnet/src/OpenTelemetry/Sdk.cs
Line 114 in 3f4c73a
Also here but it seems a little different:
opentelemetry-dotnet/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptions.cs
Line 232 in 3f4c73a
This new helper class doesn't really have anything to do with instrumentation scopes. Could we perhaps rename it something like AssemblyVersionHelper and refactor the SDK version stuff (maybe OtlpExporter stuff too) so that everything is using the same code for versioning?
Doesn't have to be on this PR.
The API could also be an extension method. Something like...
In the current signature you pass a type to use to lookup the assembly. I don't think that is immediately obvious IMO passing the assembly to use is nicer/more explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the changes covered in 9f5f5bf and d8f9a1a.
I think that changes in OTLP exported, related to dropping hash commit, deservers CHANGELOG entry.
It will bring as a bit closer to recommendation, to put there just version, without any additional data such as commit hash.
I will create follow up PR, when this one will be merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Kielek - What will change with respect to OTLP exporter? Could you elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User agent. Now it contains haskcommit.
Before changes OTel-OTLP-Exporter-Dotnet/version+hashcommit
After-changes OTel-OTLP-Exporter-Dotnet/version