-
Notifications
You must be signed in to change notification settings - Fork 5.1k
[AzureMonitorDistro] fix for LiveMetrics Dependencies #45103
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
TimothyMothra
merged 16 commits into
main
from
tilee/202407_fixLiveMetrics_manualDependency
Aug 23, 2024
Merged
Changes from 3 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
5f31c31
fix for LiveMetrics and manual Dependencies
066b875
changelog
211b03f
update all dependency mappings
0314a22
merge main and resolve conflicts
2397b4b
Merge branch 'main' into tilee/202407_fixLiveMetrics_manualDependency
01a1492
fix
8223c95
update tests
df8abd0
cleanup
9bdd0ae
cleanup
4576e2b
drop ActivityType
a49bffb
changelog
a98276d
merge main
c91efb6
update changelog
0f1a4c9
update mappings
ea48726
fix tests
84294ca
Merge branch 'main' into tilee/202407_fixLiveMetrics_manualDependency
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
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
66 changes: 66 additions & 0 deletions
66
...Monitor.OpenTelemetry.AspNetCore.Tests/LiveMetrics/DocumentTests/ManualDependencyTests.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,66 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Diagnostics; | ||
| using System.Linq; | ||
| using System.Net.Http; | ||
| using System.Threading.Tasks; | ||
| using Azure.Monitor.OpenTelemetry.AspNetCore.LiveMetrics.DataCollection; | ||
| using Azure.Monitor.OpenTelemetry.AspNetCore.Models; | ||
| using Microsoft.AspNetCore.Builder; | ||
| using OpenTelemetry; | ||
| using OpenTelemetry.Trace; | ||
| using Xunit; | ||
| using Xunit.Abstractions; | ||
|
|
||
| namespace Azure.Monitor.OpenTelemetry.AspNetCore.Tests.LiveMetrics.DocumentTests | ||
| { | ||
| public class ManualDependencyTests : DocumentTestBase | ||
| { | ||
| public ManualDependencyTests(ITestOutputHelper output) : base(output) | ||
| { | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData(ActivityStatusCode.Ok, true)] | ||
| [InlineData(ActivityStatusCode.Error, false)] | ||
| [InlineData(ActivityStatusCode.Unset, true)] | ||
| public void VerifyManualDependency(ActivityStatusCode activityStatusCode, bool expectedIsSuccess) | ||
| { | ||
| var exportedActivities = new List<Activity>(); | ||
|
|
||
| var testActivitySource = new ActivitySource("testSource"); | ||
|
|
||
| // SETUP | ||
| using var tracerProvider = Sdk.CreateTracerProviderBuilder() | ||
| .AddSource("testSource") | ||
| .AddInMemoryExporter(exportedActivities) | ||
| .Build(); | ||
|
|
||
| // ACT | ||
| using (var activity = testActivitySource.StartActivity("testActivity", ActivityKind.Internal)) | ||
| { | ||
| activity?.SetStatus(activityStatusCode); | ||
| } | ||
|
|
||
| WaitForActivityExport(exportedActivities); | ||
|
|
||
| // Assert | ||
| var dependencyActivity = exportedActivities.Last(); | ||
| PrintActivity(dependencyActivity); | ||
| var dependencyDocument = DocumentHelper.ConvertToDependencyDocument(dependencyActivity); | ||
|
|
||
| Assert.Null(dependencyDocument.CommandName); | ||
| Assert.Equal(DocumentType.RemoteDependency, dependencyDocument.DocumentType); | ||
| Assert.Equal("testActivity", dependencyDocument.Name); | ||
| Assert.Equal("testSource", dependencyDocument.Properties.Single(x => x.Key == "ActivitySource").Value); | ||
| Assert.Equal("Unknown", dependencyDocument.Properties.Single(x => x.Key == "ActivityType").Value); | ||
|
|
||
| //// The following "EXTENSION" properties are used to calculate metrics. These are not serialized. | ||
| Assert.Equal(dependencyActivity.Duration.TotalMilliseconds, dependencyDocument.Extension_Duration); | ||
| Assert.Equal(expectedIsSuccess, dependencyDocument.Extension_IsSuccess); | ||
| } | ||
| } | ||
| } |
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.