-
Notifications
You must be signed in to change notification settings - Fork 2
VCST-4717: Update App Insights module, use System.Diagnostics.Activity instead of App Insights directly #70
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
Open
ksavosteev
wants to merge
5
commits into
dev
Choose a base branch
from
feat/VCST-4717
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e28b11e
feat: switch to Activityi telemetry
ksavosteev 614fd6f
Merge branch 'dev' into feat/VCST-4717
ksavosteev 8a0cd22
fix: change csproj (local dep)
ksavosteev 37f42b5
feat: update dependency
ksavosteev c845be8
feat: update platform dependency
ksavosteev 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
40 changes: 17 additions & 23 deletions
40
src/VirtoCommerce.Xapi.Core/Infrastructure/IgnorePlainCoreXapiGraphQLTelemetryProcessor.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 |
|---|---|---|
| @@ -1,31 +1,25 @@ | ||
| using Microsoft.ApplicationInsights.Channel; | ||
| using Microsoft.ApplicationInsights.DataContracts; | ||
| using Microsoft.ApplicationInsights.Extensibility; | ||
| using System.Diagnostics; | ||
| using OpenTelemetry; | ||
| using VirtoCommerce.Platform.Core.Common; | ||
|
|
||
| namespace VirtoCommerce.Xapi.Core.Infrastructure | ||
| { | ||
| /// <summary> | ||
| /// AppInsights telemetry processor that skips default Graphql queries | ||
| /// </summary> | ||
| public class IgnorePlainCoreXapiGraphQLTelemetryProcessor : ITelemetryProcessor | ||
| { | ||
| private ITelemetryProcessor Next { get; set; } | ||
|
|
||
| public IgnorePlainCoreXapiGraphQLTelemetryProcessor(ITelemetryProcessor next) | ||
| { | ||
| Next = next; | ||
| } | ||
| namespace VirtoCommerce.ApplicationInsights.Data.Telemetry; | ||
|
|
||
| public void Process(ITelemetry item) | ||
| /// <summary> | ||
| /// OpenTelemetry processor that suppresses activities whose urls match GraphQL related path but | ||
| /// <c>graphql.type</c> tag is empty meaning this activity was not generated by GraphQLHttpMiddlewareWithLogs. | ||
| /// Clearing the <see cref="ActivityTraceFlags.Recorded"/> flag prevents the activity | ||
| /// from being exported to Application Insights. | ||
| /// </summary> | ||
| public class IgnorePlainCoreXapiGraphQLTelemetryProcessor : BaseProcessor<Activity> | ||
| { | ||
| public override void OnEnd(Activity activity) | ||
| { | ||
| var urlPath = activity?.GetTagItem("url.path")?.ToString(); | ||
| var graphQlTag = activity?.GetTagItem("graphql.type"); | ||
| if (urlPath != null && urlPath.ContainsIgnoreCase("/graphql") && graphQlTag == null) | ||
| { | ||
| // skip plain "POST /graphql" (without operation name) requests to reduce AppInsights telemetry flood | ||
| if (item is RequestTelemetry request && request.Name?.EqualsIgnoreCase("POST /graphql") == true) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| Next.Process(item); | ||
| activity.ActivityTraceFlags &= ~ActivityTraceFlags.Recorded; | ||
| } | ||
| } | ||
| } |
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
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
Oops, something went wrong.
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.
Missing leading slash in
url.pathtag valueMedium Severity
The
url.pathtag is set tographql/{OperationName}without a leading/. The OpenTelemetry semantic convention definesurl.pathas the RFC 3986 URI path component, which for HTTP requests always starts with/. This non-standard value will appear incorrectly in Application Insights dashboards and may break alerts or queries that expect paths starting with/. The value likely needs to be$"/graphql/{request.OperationName}".Reviewed by Cursor Bugbot for commit e28b11e. Configure here.