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

Add EnableGrpcAspNetCoreSupport option for ASP.NET Core instrumentation #1423

Merged
merged 6 commits into from
Oct 30, 2020

Conversation

alanwest
Copy link
Member

Fixes #1403.

Changes

Please provide a brief description of the changes here.

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

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

@alanwest alanwest requested a review from a team October 29, 2020 19:07
Copy link
Contributor

@eddynaka eddynaka left a comment

Choose a reason for hiding this comment

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

Thanks for adding the TODO due to the status!

}
else
{
Assert.NotNull(activity.GetTagValue(GrpcTagHelper.GrpcMethodTagName));
Copy link
Member

Choose a reason for hiding this comment

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

as these are added not by Otel Instrumentation, do we need to validate this?

Copy link
Member Author

Choose a reason for hiding this comment

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

My original thought was that since the instrumentation removes these tags when this option is enabled it made sense to me to validate that the instrumentation left them untouched when when the option is disabled.

@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
Copy link
Member Author

Choose a reason for hiding this comment

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

@JamesNK We're now targeting netstandard2.1 and conditionally compiling the gRPC functionality for this instrumentation. However, I did note that the Grpc.AspNetCore library targets netcoreapp3.0.
https://github.com/grpc/grpc-dotnet/blob/ef77760676ce19c279d5480bca68af3ea4d60e96/src/Grpc.AspNetCore/Grpc.AspNetCore.csproj#L8

Would it make more sense for us to target netcoreapp3.0 as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

netcoreapp3.0 supports netstandard2.1. It doesn't matter either way.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, thanks! That's what I figured, but just wanted to be sure.

@codecov
Copy link

codecov bot commented Oct 29, 2020

Codecov Report

Merging #1423 into master will decrease coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1423      +/-   ##
==========================================
- Coverage   81.28%   81.24%   -0.04%     
==========================================
  Files         227      227              
  Lines        6113     6117       +4     
==========================================
+ Hits         4969     4970       +1     
- Misses       1144     1147       +3     
Impacted Files Coverage Δ
...ion.AspNetCore/AspNetCoreInstrumentationOptions.cs 100.00% <100.00%> (ø)
...tation.AspNetCore/Implementation/HttpInListener.cs 84.67% <100.00%> (+0.37%) ⬆️
...emetry.Api/Internal/OpenTelemetryApiEventSource.cs 73.52% <0.00%> (-8.83%) ⬇️

@@ -289,6 +292,13 @@ private static string GetUri(HttpRequest request)
return builder.ToString();
}

private static void SetStatusFromHttpStatusCode(Activity activity, int statusCode)
Copy link
Member

Choose a reason for hiding this comment

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

Might be worth inlining SetStatusFromHttpStatusCode & TryGetGrpcMethod they are only called a couple of places.

Copy link
Member Author

Choose a reason for hiding this comment

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

I also applied inline attribute to AddGrpcAttributes. Still kind of trying to feel out when best to apply the inlining attribute. I guess it's technically a balance between code size and performance. Does your intuition usually guide you to apply it to methods with few callers?

Copy link
Member

Choose a reason for hiding this comment

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

I guess it's technically a balance between code size and performance.

Totally! I think for OpenTelemetry our mission is to have as little overhead on the hosting process as possible so I tend to lean towards performance over binary size. I kind of ask myself: Is this hot path? Is this method really just to keep the code clean? Is it called in only a couple of spots (or is it really tiny)? If the answer is yes to all of that, I usually add the inline hint.

@alanwest
Copy link
Member Author

So I know the why for why the W3C trace context integration tests are failing but do not yet have the answer for how to best solve it.

run: docker-compose --file=test/OpenTelemetry.Instrumentation.W3cTraceContext.Tests/docker-compose.yml --file=build/docker-compose.${{ matrix.version }}.yml --project-directory=. up --exit-code-from=tests --build

The test relies on building the OpenTelemetry.Instrumentation.AspNetCore project with both the 2.1 and 3.1 SDKs. Now that OpenTelemetry.Instrumentation.AspNetCore is cross-compiled to netstandard2.1 the 2.1 build fails... probably need to work over the docker-compose file a bit...

FROM mcr.microsoft.com/dotnet/core/sdk:${SDK_VERSION} AS build
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
Copy link
Member Author

Choose a reason for hiding this comment

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

@eddynaka Not sure I solved this in the best way. I hardcoded 3.1 SDK for the build stage and then left the final stage using the SDK_VERSION arg. Can you think of a better way to deal with this?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's the way. Since 2.1 only exists for adk 3.*, we will have to use that to build. The important part is the version below. So we are still testing for both.

@cijothomas cijothomas merged commit 7cd1961 into open-telemetry:master Oct 30, 2020
@alanwest alanwest deleted the alanwest/grpc-option branch November 4, 2020 20:00
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.

Add option to AspNetCore instrumentation to turn on/off grpc tag population
5 participants