-
Notifications
You must be signed in to change notification settings - Fork 93
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
ILogger
integration fix for net6
when WebApplicationBuilder
is used
#3003
ILogger
integration fix for net6
when WebApplicationBuilder
is used
#3003
Conversation
Looking into CI failure for |
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.
Took a quick pass, it lgtm at this time, will do a more detailed pass when it is not draft anymore.
src/OpenTelemetry.AutoInstrumentation/Logger/LogBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.AutoInstrumentation/Logger/LogBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.AutoInstrumentation/Logger/LogBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.AutoInstrumentation/Logger/LogBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
I ran smoke test when bytecode instrumentation was not enabled, and it still crashed. It seems to be connected to addition of new kind of test app, I think this could be fixed as a part of separate issue. For now, I skipped problematic scenario. |
src/OpenTelemetry.AutoInstrumentation/Logger/LogBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
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.
LGTM. I've left a few minor comments to address.
Why
Fixes #2994
What
Logs are exported multiple times for ASP.NET Core apps targeting
net6
whenWebApplicationBuilder
is used.In such scenario, integration is called on 2 related service collections:
WebApplicationServiceCollection
andServiceCollection
.Integration tries to detect if it was called before on given
IServiceCollection
instance, but it doesn't work in this case, as it is called onServiceCollection
instance before services are copied to it fromWebApplicationServiceCollection
instance (on which integration was called before). This results in same logs being exported 4 times (duplicated loggers with duplicated processors).Before #2975, integration was not being called if
builder.Services
was not ofServiceCollection
type. That caused an issue whenHostingStartupAssembly
was configured to enable the integration (and bytecode instrumentation was disabled) for apps targetingnet6
whenWebApplicationBuilder
was used.The fix checks if
HostingStartupAssembly
is configured, and doesn't run integration fornet6
whenWebApplicationBuilder
is used on host'sServiceCollection
instance (OpenTelemetryLogger
related services will be copied fromWebApplicationServiceCollection
instance, for which integration was called fromHostingStartupAssembly
).All of the problematic scenarios (one that didn't work before #2975 and two that are being fixed with the PR) are covered by tests added in this PR.
Note:
As tests are waiting fixed amount of time to verify logs were not exported multiple times, this adds some time to the CI.
@rajkumar-rangaraj PTAL
Tests
Included in PR.
Checklist
CHANGELOG.md
is updated.- [ ] Documentation is updated.