Instrument any .NET Core application

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.

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

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.

Hi @GregKalapos, and thanks for your prompt response :slight_smile:

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?

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

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

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 Core specific - so I guess that would not work with e.g. a console application. Is your app ASP.NET Core? Creating an IHostingStartup is not a big deal, we can add it if that'd help you.

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 Core application? As I mentioned before, I'm pretty new to Windows/ASP/.NET environments. If only this was Java... :laughing:

I see :slight_smile:

"Microsoft.AspNetCore/2.1.3"

Yeah, that dependency is definitely the one that ASP.NET Core uses.

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

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.

Ok, thanks. This sounds like an ASP.NET Core app to me. 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.

1 Like

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 :slight_smile:

1 Like

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