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

[Instrumentation.Http] Support for enrich and filter delegates for http client metric #4075

Conversation

aunikitin
Copy link

@aunikitin aunikitin commented Jan 11, 2023

Hello, I'd like to have an opportunity to enrich metrics with custom logic (for example uri templates of requested paths). Also I add opportunity to filter some requests because of TODO in MeterProviderBuilderExtensions
I tried to use existing HttpClientInstrumentationOptions but firstly, they have too mutch for metrics and secondly, because in the HttpHandlerMetricsDiagnosticListener we are not allowed to take tags from activity (because of uncontrolled source of filling), that's why delegates in settings don't fit .
Also I wrote some tests and did small refactoring in them (move trace tests in one file; split configuration tests from common, because they don't need running HttpListener).
If my changes are admissible, I will add description to CHANGELOG.md.

Probably it resolves issue

Changes

Please provide a brief description of the changes here.

For significant contributions please make sure you have completed the following items:

  • Appropriate CHANGELOG.md updated for non-trivial changes
  • Design discussion issue #
  • Changes in public API reviewed

@aunikitin aunikitin requested a review from a team January 11, 2023 19:10
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jan 11, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link
Member

@vishweshbankwar vishweshbankwar left a comment

Choose a reason for hiding this comment

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

@aunikitin Thanks for your PR. Could you please update the PR to only include changes related to enrich and filter options on metrics?. This will keep it small and easier to review. Any refactoring, renaming can be done separately.

@aunikitin
Copy link
Author

aunikitin commented Jan 15, 2023

@vishweshbankwar hello, you want me to rollback changes in tests (for example moving test AddHttpClientInstrumentationUsesOptionsApi to ProviderBuilderExtensionsTests without HttpListener and etc.) or only options renaming?

@aunikitin aunikitin force-pushed the enrich_filter_in_http_client_metrics branch 2 times, most recently from 4dbf5b9 to dcb5abf Compare January 15, 2023 08:23
@aunikitin aunikitin changed the title Support for enrich and filter delegates for http client metric [Instrumentation.Http] Support for enrich and filter delegates for http client metric Jan 17, 2023
Copy link
Member

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

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

See https://github.com/open-telemetry/opentelemetry-dotnet/pull/4075/files#r1073154671

Not yet ready to make new additions to instrumentation library as we do not have a metrics enrichment concept yet.

@aunikitin aunikitin requested review from cijothomas and vishweshbankwar and removed request for cijothomas and vishweshbankwar January 19, 2023 16:34
@aunikitin aunikitin force-pushed the enrich_filter_in_http_client_metrics branch from 2b54dd5 to 75b8411 Compare January 21, 2023 15:02
@cijothomas
Copy link
Member

@aunikitin Thanks for the PR. I have triggered CI checks and will review.
There is some pending discussions about potentially making stable releases of Instrumentation Libraries, and we'll need to evaluate all the public APIs at that time, and the Enrich/Filter will be re-evaluated at that time to make sure its in alignment with overall Metrics design. (See #3948 (comment) as well)

@aunikitin
Copy link
Author

@cijothomas okay, I'm waiting of your decision.
Can you restart CI? I faced with some issues under Windows, hope they're fixed

Signed-off-by: aunikitin <sanya_nikiti@mail.ru>
Signed-off-by: aunikitin <sanya_nikiti@mail.ru>
Signed-off-by: aunikitin <sanya_nikiti@mail.ru>
@aunikitin aunikitin force-pushed the enrich_filter_in_http_client_metrics branch from d5bdb44 to 4b587cf Compare January 23, 2023 07:56
Signed-off-by: aunikitin <sanya_nikiti@mail.ru>
{
tags.Add(new KeyValuePair<string, object>(SemanticConventions.AttributeNetPeerPort, request.RequestUri.Port));
}
this.EnrichWithHttpRequestMessage(ref tags, request);
Copy link
Member

Choose a reason for hiding this comment

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

same as above...this looks like response message and not request?

Copy link
Author

Choose a reason for hiding this comment

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

In meter, both request and response are used. Should I do the same? I agree that it's more convinient to have response, but it'll conflict with #4098

/// <param name="name">The name of the metric being enriched.</param>
/// <param name="requestMessage"><see cref="HttpRequestMessage"/>: the HttpRequestMessage object.</param>
/// <param name="tags"><see cref="TagList"/>: List of current tags. You can add additional tags to this list. </param>
public delegate void HttpRequestMessageEnrichmentFunc(string name, HttpRequestMessage requestMessage, ref TagList tags);
Copy link
Member

Choose a reason for hiding this comment

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

I think we need to pass in both request and response.
#4098
@cijothomas - FYI

Copy link
Author

Choose a reason for hiding this comment

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

I'll leave HttpResponse, if your changes appear earlier, I'll fix mine, and vice versa

@aunikitin aunikitin force-pushed the enrich_filter_in_http_client_metrics branch 2 times, most recently from ff8550b to ebb41ce Compare February 4, 2023 16:37
# Conflicts:
#	src/OpenTelemetry/CHANGELOG.md
#	src/OpenTelemetry/OpenTelemetry.csproj
Signed-off-by: Alex <sanya_nikiti@mail.ru>
@aunikitin aunikitin marked this pull request as draft February 8, 2023 10:58
@aunikitin aunikitin marked this pull request as ready for review February 12, 2023 21:07
@github-actions
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 the Stale Issues and pull requests which have been flagged for closing due to inactivity label Feb 20, 2023
@github-actions
Copy link
Contributor

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions bot closed this Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale Issues and pull requests which have been flagged for closing due to inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enrich support for HttpClientMetrics
7 participants