Custom Stacktrace for Transaction

Elasticsearch version: v8.1.2
APM Agent language and version: dotnet Agent v1.18.0
Hi,
I have a requirement for fetching details of every function calls happened during execution of one transaction. The way I am currently doing it is by making code changes in the agent source code. Inside End() function of Transaction.cs
source link.
And I understood that this function will be called at the end of a transaction, so thought its the best place to collect the stacktrace.

public void End()
{
            StackTrace stackTrace = new StackTrace(true);
            // external function call to filter out library function calls from stack frame 
            // and convert it into json to store in custom field of the transaction 
            String jsonString = ConvertStackTraceToJSON(stackTrace);
            this.Custom.Add("stacktrace", jsonString);
            ....
}

but the issue is I am only getting stacktrace of few function calls and missing lot of other functions in the code.
Is there a better way to capture details of every function call ocurred during the transaction, across all the active threads in the dotnet core application.

Update: I have tracked down the error to my custom code which was filtering out stackframe with namespace of System. Microsoft. But the span stacktrace reported for db query was reporting the filename wrongly:

{
                "exclude_from_grouping" : false,
                "filename" : """C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.32\System.Private.CoreLib.dll""",
                "classname" : "CourseLibrary.API.Services.CourseLibraryRepository",
                "line" : {
                  "number" : 0
                },
                "function" : "GetAuthors x 1",
                "module" : "CourseLibrary.API, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
 }

The GetAuthorx1 function is part of the my application code and not in the C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.32\System.Private.CoreLib.dll

The application being traced is using netcoreapp3.1

Issue: file name reported by the span stacktrace is wrong

Hi @AbhijithCV,

could you give us a minimal reproducer of this issue?

Hi @GregKalapos
I have given steps to reproduce the bug in DB span stacktrace wrong filename

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