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

Fix DiagnosticSource + Disposable issues + service name doc #75

Merged
merged 11 commits into from
Jan 23, 2019
Merged

Fix DiagnosticSource + Disposable issues + service name doc #75

merged 11 commits into from
Jan 23, 2019

Conversation

gregkalapos
Copy link
Contributor

@gregkalapos gregkalapos commented Jan 22, 2019

  • Added service name doc

  • Some refactorings:

The ApmMiddlewareExtension automatically subscribes to EFCore and HttpClient events. Additionally, the Elastic.Apm.AspNetCore now references the Elastic.Apm.EntityFrameworkCore project.
With this, registering the agent in ASP.NET Core became simpler: app.UseElasticApm(Configuration);
This was the old code:
`app.UseElasticApm(Configuration, new HttpDiagnosticsSubscriber(), new EfCoreDiagnosticsSubscriber());

Update:
Added Elastic.Apm.All project that references every other agent project and contains an ApmMiddlewareExtension that automatically subscribes to HttpClient and EFCore events. This way in typical ASP.NET Core apps (ASP.NET Core + EF Core) that reference Microsoft.AspNetCore.All users can just reference our Elastic.Apm.All package and enable the agent with all its features (including EF Core and HttpClient monitoring) with app.UseElasticApm(Configuration);. In other cases (e.g. ASP.NET Core without EF Core, or even no ASP.NET Core) the other packages can be referenced individually to avoid unnecessary dependencies. In those scenarios the diagnostic listeners must be enabled manually.

  1. Moved TransactionContainer into AgentComponents. With that TransactionContainer.Transactions became Agent.TransactionContainer, which we can reset in tests.

  2. Fix for Bug: Unsubscribing from DiagnosticSource events does not work #72.

  3. As a consequence of fixing Bug: Unsubscribing from DiagnosticSource events does not work #72 the ApmAgent also became Disposable. With this in tests we can dispose the agent.

  • Tests

In order to make the API more simple we autosubscribe to outgoing HTTP calls and EFCore calls.

Also added 2 tests to test non-ASP.NET Core scenarios + HttpDiagnosticsSubscriber registration.
With this unit tests can dispose the agent, which automatically unsubscribes from all diagnosticsource events.
@codecov-io
Copy link

codecov-io commented Jan 22, 2019

Codecov Report

Merging #75 into master will increase coverage by 0.8%.
The diff coverage is 77.61%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master      #75     +/-   ##
=========================================
+ Coverage   80.53%   81.33%   +0.8%     
=========================================
  Files          34       35      +1     
  Lines         904      943     +39     
  Branches      115      119      +4     
=========================================
+ Hits          728      767     +39     
+ Misses        131      129      -2     
- Partials       45       47      +2
Impacted Files Coverage Δ
src/Elastic.Apm/Logging/ConsoleLogger.cs 66.66% <ø> (ø) ⬆️
src/Elastic.Apm/Model/Payload/Service.cs 73.68% <ø> (ø) ⬆️
.../Elastic.Apm/Config/AbstractConfigurationReader.cs 64.28% <ø> (ø) ⬆️
...Apm.AspNetCore/Config/MicrosoftExtensionsConfig.cs 74.28% <ø> (ø) ⬆️
src/Elastic.Apm.All/ApmMiddlewareExtension.cs 0% <0%> (ø)
...DiagnosticListener/AspNetCoreDiagnosticListener.cs 69.23% <0%> (-5.77%) ⬇️
src/Elastic.Apm/ApmAgentExtensions.cs 86.95% <100%> (+41.95%) ⬆️
src/Elastic.Apm/TransactionContainer.cs 100% <100%> (ø) ⬆️
...EntityFrameworkCore/EfCoreDiagnosticsSubscriber.cs 100% <100%> (ø) ⬆️
src/Elastic.Apm/Api/Tracer.cs 96.58% <100%> (ø) ⬆️
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cf97872...59e5c3a. Read the comment docs.

@gregkalapos
Copy link
Contributor Author

Just for reference: the coverage report is probably wrong. @kuisathaverat is on it...

@gregkalapos
Copy link
Contributor Author

@bmorelli25 docs/configuration.asciidoc has a new section. Could you please take a look?

@gregkalapos gregkalapos changed the title Docs and clean up Fix DiagnosticSource + Disposable issues + service name doc Jan 22, 2019
Also removed IDisposable from the Listeners
Copy link
Member

@bmorelli25 bmorelli25 left a comment

Choose a reason for hiding this comment

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

See comment below. Everything else is 👍

docs/configuration.asciidoc Outdated Show resolved Hide resolved
Elastic.Apm.All has a reference to all other agent projects and it contains convenient methods to activate the agent very easily and enable each agent component.
@gregkalapos gregkalapos merged commit 1bf59e3 into elastic:master Jan 23, 2019
@gregkalapos gregkalapos deleted the DocsAndCleanUp branch January 23, 2019 10:49
@gregkalapos gregkalapos self-assigned this Jan 24, 2019
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.

None yet

5 participants