Difficulties with integration of Elastic.Apm to .Net Core console apps
See original GitHub issueIs your feature request related to a problem? Please describe. In the era of microservices a lot of services are creating as simple .Net Core console apps: message handlers, batch jobs.
From monitoring perspective it would be nice to monitor such applications with Elastic APM, however, it’s unable to achieve it right now: Elastic.Apm.AspNetCore
cannot be used due to integration is performed with IApplicationBuilder
, which is available only in Asp .Net Core applications. The issue can be solved by manual configuration of Elastic.Apm agent except of reading configuration values from appsettings.json
due to MicrosoftExtensionsConfig
is internal class.
Describe the solution you’d like
As a short term solution MicrosoftExtensionsConfig
can be mark as public, but it seems as a workaround. In addition, manual setup is still needed.
As a long term solution, it would be nice to add additonal extension method on IHostBuilder
, which is introduced in .Net Core 2.1 and became as default builder for console and http-based applications in .Net Core 3.0.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:12
- Comments:12 (8 by maintainers)
Top GitHub Comments
@connorads, you can track a progress in #537. Only yesterday I returned to such a thing and started to polish code. As for workaround, yes I have it for our current services. It’s very simple:
AspNetCoreLogger
,AbstractConfigurationWithEnvFallbackReader
andMicrosoftExtensionsConfig
into your code.IApmLogger
,IConfigurationReader
andAgentComponents
into dependency injection container:So, I know, it’s not very beautiful. Also, with agent update, this code can be broken and need to be updated due to some parts marked as internal classes and can be changed. However, right now it’s only one possible way for me to use it with proper logger and configuration reader setup.
I think this is done - #537 implements it - thanks for the work @vhatsura. There are some related issues still open and probably there will be some follow up PRs on the topic, but overall the use-case is already covered and merged.
If something important is missing please check if there is already an issue for that and if not, feel free to either comment here.