-
Notifications
You must be signed in to change notification settings - Fork 125
Add DiagnosticSource version check rule #2411
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
Merged
pjanotti
merged 17 commits into
open-telemetry:main
from
xiang17:xiang17/DiagnosticSourceDllVersionCheck
Apr 12, 2023
Merged
Changes from 10 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
a0912af
Add DiagnosticSource version check rule
xiang17 204f9b7
rename variable
xiang17 65f4f03
Get version using `Assembly.GetAssembly(diagnosticSourceType).GetCust…
xiang17 4c672eb
Merge branch 'main' into xiang17/DiagnosticSourceDllVersionCheck
xiang17 95691ff
Add unit test
xiang17 f9fefe4
Revert "Add unit test"
xiang17 3ee1f63
Add unit test
xiang17 6a3162a
Updated unit tests
xiang17 893c25c
Log warning for unexpected exception in DLL evaluation
xiang17 855df28
Merge branch 'main' into xiang17/DiagnosticSourceDllVersionCheck
xiang17 11b4319
Merge branch 'main' into xiang17/DiagnosticSourceDllVersionCheck
xiang17 123b094
Include testing for logging information
xiang17 65c6d2f
Add a comment on why AssemblyFileVersion is used for comparing versions
xiang17 5832d82
Use `MemberData` instead of `InlineData`
xiang17 5c1c538
PR feedbacks
xiang17 3584f3f
Merge branch 'main' into xiang17/DiagnosticSourceDllVersionCheck
pjanotti 0212816
Merge branch 'main' into xiang17/DiagnosticSourceDllVersionCheck
pjanotti 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 hidden or 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
54 changes: 54 additions & 0 deletions
54
test/OpenTelemetry.AutoInstrumentation.StartupHook.Tests/DiagnosticSourceRuleTests.cs
This file contains hidden or 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,54 @@ | ||
| // <copyright file="DiagnosticSourceRuleTests.cs" company="OpenTelemetry Authors"> | ||
| // Copyright The OpenTelemetry Authors | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| // </copyright> | ||
|
|
||
| using OpenTelemetry.AutoInstrumentation.RulesEngine; | ||
| using Xunit; | ||
|
|
||
| namespace OpenTelemetry.AutoInstrumentation.StartupHook.Tests; | ||
| public class DiagnosticSourceRuleTests | ||
| { | ||
| [Theory] | ||
| [InlineData("6.0.0.0", "7.0.0.0", false)] | ||
| [InlineData("8.0.0.0", "7.0.0.0", true)] | ||
| [InlineData("7.0.0.0", "7.0.0.0", true)] | ||
| public void DiagnosticSourceVersion(string appVersion, string autoInstrumentationVersion, bool result) | ||
| { | ||
| var rule = new TestableDiagnosticSourceRule(appVersion, autoInstrumentationVersion); | ||
| Assert.Equal(rule.Evaluate(), result); | ||
| } | ||
| } | ||
|
|
||
| internal class TestableDiagnosticSourceRule : DiagnosticSourceRule | ||
| { | ||
| private readonly string appVersion; | ||
| private readonly string autoInstrumentationVersion; | ||
|
|
||
| public TestableDiagnosticSourceRule(string appVersion, string autoInstrumentationVersion) | ||
| { | ||
| this.appVersion = appVersion; | ||
| this.autoInstrumentationVersion = autoInstrumentationVersion; | ||
| } | ||
|
|
||
| protected override Version? GetVersionFromApp() | ||
| { | ||
| return new Version(appVersion); | ||
| } | ||
|
|
||
| protected override Version? GetVersionFromAutoInstrumentation() | ||
| { | ||
| return new Version(autoInstrumentationVersion); | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.