elastic / apm-agent-dotnet

https://www.elastic.co/guide/en/apm/agent/dotnet/current/index.html
Apache License 2.0
582 stars 209 forks source link

Elastic APM no data logging in .NET 4.6.1 project using Owin #2052

Closed user-cloudiq closed 1 year ago

user-cloudiq commented 1 year ago

I’m working on a .net 4.6.1 framework project which uses owin with a startup.cs file. I have my elastic config code written in a separate file with the server URL, Apikey and the service name defined. When running the project, I do see the service name appear on the ‘observability’ dash on the elastic site, but I don't see transactions, requests or any sort of data being fed in. On checking the elastic docs for 4.6.1 framework projects its basically couple of lines of code in the web.config file to include elastic credentials and add to the module section. But I don't have a web.config in my project. Is there a workaround or different setup for .net framework projects using Owin? Attached the project structure, config code snippet form my config class in common folder and from the settings.xml file. Each of the modules contain a program.cs file, what would be the recommended way to implement auto instrumented elastic setup for my setup.

apm config owin programcs project structure setting xml
gregkalapos commented 1 year ago

Hi @user-cloudiq ,

for OWIN, we don't have any auto-instrumentation. So the only way to make this work is to use the API of the agent and start traces for each incoming request - for that you can e.g. create an OWIN middleware which always starts a transaction. This part of the doc could be useful for that.