DB Span Stacktrace reporting wrong filename

I have also done profiler auto instrumentation for another asp .net core application targeting net6.0 .
NopCommerce
For this application I was getting correct filename in the span stacktrace.
Can you explain this behaviour?

So, in additional to what I wrote in the previous answer, the agent actually tries to find the .cs file if possible - so indeed, the agent has a "best effort" mechanism to figure out the original .cs file, if this fails, the agent just reports the assembly (which is the .dll file) that is executed during runtime.

For determining the .cs file the agent uses this method: StackFrame.GetFileName Method (System.Diagnostics) | Microsoft Learn

That can determine the .cs file when debugging symbols are present and currently set up. If that method returns null, the agent just reports .dll files as the file name.

You can see this logic here: https://github.com/elastic/apm-agent-dotnet/blob/main/src/Elastic.Apm/Helpers/StacktraceHelper.cs#L87

How does the agent determine to which source file the function belongs to?

You opened another entry as well, I just see: Custom Stacktrace for Transaction

Is this question related to that entry. That indeed seems to be a bug (not sure yet, I need to dig deeper).