# Instrument any .NET Core application

**URL:** <https://discuss.elastic.co/t/instrument-any-net-core-application/207680>\
**Category:** APM\
**Tags:** dotnet\
**Created:** [November 13, 2019, 10:26am UTC](https://discuss.elastic.co/t/instrument-any-net-core-application/207680 "2019-11-13T10:26:44Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![cpiment](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cpiment/32/67350_2.png) [@cpiment](https://discuss.elastic.co/u/cpiment)\
**Post date:** [November 13, 2019, 10:26am UTC](https://discuss.elastic.co/t/instrument-any-net-core-application/207680/1 "2019-11-13T10:26:44Z")

</div>

I am having lots of trouble using a .NET Core application in my environment, and it would be great if I could "see" what it is doing using APM. That application is closed-source and I cannot modify it.

I have usually worked in Java environments where you can attach a Java agent to a living PID, or modify the startup options of the program to enable the agent. Is there any way to do something like that to a .NET Core application?

I have access to the .exe file, the "web.config" and the "appsettings.json", and can run commands in the machine where the app is running.

---

<div class="post-metadata">

**Author:** ![GregKalapos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gregkalapos/32/37205_2.png) [@GregKalapos](https://discuss.elastic.co/u/GregKalapos)\
**Post date:** [November 13, 2019, 10:40am UTC](https://discuss.elastic.co/t/instrument-any-net-core-application/207680/2 "2019-11-13T10:40:57Z")

</div>

Hi @cpiment

Unfortunately this is currently not yet possible, but we have an issue tracking progress for something that I think would solve your problem: [https://github.com/elastic/apm-agent-dotnet/issues/71](https://github.com/elastic/apm-agent-dotnet/issues/71)

We get this question a lot, and actually for .NET Core I think we can implement this quickly. We have not yet scheduled that issue for a specific release, but it's definitely worth following.

---

<div class="post-metadata">

**Author:** ![cpiment](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cpiment/32/67350_2.png) [@cpiment](https://discuss.elastic.co/u/cpiment)\
**Post date:** [November 13, 2019, 11:08am UTC](https://discuss.elastic.co/t/instrument-any-net-core-application/207680/3 "2019-11-13T11:08:41Z")

</div>

Hi @GregKalapos, and thanks for your prompt response 🙂

Before posting here I have been reading the Github issues, but I didn't found the one you linked, sorry about that!

Anyway, you reference there that it would be available from .NET Core 2.2, but it seems the app I'm trying to monitor has been created with version 2.1

"runtimeTarget": {  
"name": ".NETCoreApp,Version=v2.1/win-x64"  
}

Would that left that feature out for my application?

---

<div class="post-metadata">

**Author:** ![GregKalapos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gregkalapos/32/37205_2.png) [@GregKalapos](https://discuss.elastic.co/u/GregKalapos)\
**Post date:** [November 13, 2019, 11:25am UTC](https://discuss.elastic.co/t/instrument-any-net-core-application/207680/4 "2019-11-13T11:25:15Z")

</div>

> but I didn't found the one you linked, sorry about that!

No worries, the issue name wasn't that very descriptive anyway 🙂

> Would that left that feature out for my application?

The startup hooks probably won't work for you unfortunately as it seems.

The `IHostingStartup` exists already in 2.1, but that is I think [ASP.NET](http://ASP.NET) Core specific - so I guess that would not work with e.g. a console application. Is your app [ASP.NET](http://ASP.NET) Core? Creating an `IHostingStartup` is not a big deal, we can add it if that'd help you.

---

<div class="post-metadata">

**Author:** ![cpiment](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cpiment/32/67350_2.png) [@cpiment](https://discuss.elastic.co/u/cpiment)\
**Post date:** [November 13, 2019, 11:36am UTC](https://discuss.elastic.co/t/instrument-any-net-core-application/207680/5 "2019-11-13T11:36:54Z")

</div>

> [@GregKalapos](#):
>
> Is your app [ASP.NET](http://ASP.NET) Core?

I'm not sure about that. I have a file named 'appname'.deps.json that makes reference to

`"Microsoft.AspNetCore/2.1.3"`

and

`"Microsoft.AspNetCore.All/2.1.3"`

Does that mean it is an [ASP.NET](http://ASP.NET) Core application? As I mentioned before, I'm pretty new to Windows/ASP/.NET environments. If only this was Java... 😆

---

<div class="post-metadata">

**Author:** ![GregKalapos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gregkalapos/32/37205_2.png) [@GregKalapos](https://discuss.elastic.co/u/GregKalapos)\
**Post date:** [November 13, 2019, 11:43am UTC](https://discuss.elastic.co/t/instrument-any-net-core-application/207680/6 "2019-11-13T11:43:20Z")

</div>

I see 🙂

> "Microsoft.AspNetCore/2.1.3"

Yeah, that dependency is definitely the one that [ASP.NET](http://ASP.NET) Core uses.

Is this a web application? Or at least something that responds to HTTTP?

---

<div class="post-metadata">

**Author:** ![cpiment](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cpiment/32/67350_2.png) [@cpiment](https://discuss.elastic.co/u/cpiment)\
**Post date:** [November 13, 2019, 11:47am UTC](https://discuss.elastic.co/t/instrument-any-net-core-application/207680/7 "2019-11-13T11:47:42Z")

</div>

Is a standalone application, is not running inside an IIS, but the application is reached by other applications via HTTP requests, so yes, it responds to HTTP.

---

<div class="post-metadata">

**Author:** ![GregKalapos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gregkalapos/32/37205_2.png) [@GregKalapos](https://discuss.elastic.co/u/GregKalapos)\
**Post date:** [November 13, 2019, 12:53pm UTC](https://discuss.elastic.co/t/instrument-any-net-core-application/207680/8 "2019-11-13T12:53:16Z")

</div>

Ok, thanks. This sounds like an [ASP.NET](http://ASP.NET) Core app to me. [ASP.NET](http://ASP.NET) Core can run standalone, you don't necessarily need IIS for it.

So, I guess we are good here, I'll add a comment to the GitHub issue to make sure we also use `IHostingStartup` and that should cover your use case.

---

<div class="post-metadata">

**Author:** ![cpiment](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cpiment/32/67350_2.png) [@cpiment](https://discuss.elastic.co/u/cpiment)\
**Post date:** [November 13, 2019, 12:55pm UTC](https://discuss.elastic.co/t/instrument-any-net-core-application/207680/9 "2019-11-13T12:55:45Z")

</div>

Thanks @GregKalapos!

I'm already watching the issue, please reach me there if you want me to try/test/modify something or if you think I can contribute in any way. I will be pleased to help 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 4, 2019, 8:59am UTC](https://discuss.elastic.co/t/instrument-any-net-core-application/207680/10 "2019-12-04T08:59:49Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
