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

Http Instrumentation: Fix gRPC causing issues retrieving request & response objects #2698

Merged

Conversation

CodeBlanch
Copy link
Member

@CodeBlanch CodeBlanch commented Nov 29, 2021

Fixes #2652

Changes

  • If PropertyFetcher is given a different payload type than what was used during construction, it will now build an inner instance and defer to that. We could have also looked up the correct PropertyFetcher from some kind of dictionary (by payload type), but I went with this design to keep the common path (where only a single payload type is used) fast/lock-free.

TODOs

  • CHANGELOG.md updated for non-trivial changes
  • Unit test

@CodeBlanch CodeBlanch requested a review from a team November 29, 2021 07:22
@codecov
Copy link

codecov bot commented Nov 29, 2021

Codecov Report

Merging #2698 (c3386f4) into main (7fff1cb) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2698      +/-   ##
==========================================
+ Coverage   83.80%   83.81%   +0.01%     
==========================================
  Files         250      250              
  Lines        8828     8830       +2     
==========================================
+ Hits         7398     7401       +3     
+ Misses       1430     1429       -1     
Impacted Files Coverage Δ
...DiagnosticSourceInstrumentation/PropertyFetcher.cs 97.14% <100.00%> (+6.23%) ⬆️
...emetry.Api/Internal/OpenTelemetryApiEventSource.cs 79.41% <0.00%> (-2.95%) ⬇️

Comment on lines +62 to +63
Assert.True(fetch.TryFetch(new PayloadTypeB(), out propertyValue));
Assert.Equal("B", propertyValue);
Copy link
Member

Choose a reason for hiding this comment

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

Interesting, so if most of the fetches are against PayloadTypeB but the first invocation for a process is against PayloadTypeA there'll always be a fetch first assuming A and then another for B. Probably not a huge deal overhead-wise, but just explicitly calling it out.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ya if you look at the issue it looks like some kind of Azure Functions thing where it always does a gRPC call first. So for native HttpClient invocations in that environment, it is going to pay the penalty of a failed is check and then an extra virtual dispatch on each call. Very minor hit, but a hit nonetheless. Not much we can do about it. If we instead did a dictionary lookup, we would have to pay for a hash + lookup for all invocations even in cases where only one payload is ever used. So this seemed like the lesser evil. Kind of lame this gRPC path uses the same diagnostic source but with different payload types.

Copy link
Member

@alanwest alanwest left a comment

Choose a reason for hiding this comment

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

LGTM

@CodeBlanch CodeBlanch merged commit fd22347 into open-telemetry:main Dec 2, 2021
@CodeBlanch CodeBlanch deleted the grpc-http-propertyfetcher-bug branch December 2, 2021 18:28
@@ -2,6 +2,10 @@

## Unreleased

* Fixed an issue with `Filter` and `Enrich` callbacks not firing under certain
conditions when gRPC is used
([#2698](https://github.com/open-telemetry/opentelemetry-dotnet/issues/2698))
Copy link
Contributor

@mic-max mic-max Dec 13, 2021

Choose a reason for hiding this comment

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

I think you meant to link the PR not the issue
(#2698)

Copy link
Member Author

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Http filter / enrich delegates are not invoked when service makes Grpc requests
3 participants