Quick Question for the more experienced.
I`am trying to capture function Arguments in C/C++ Code deep within the Function because the Argument is a complex Type of some sort: Hence i did:
stuff |
void func_call (ComplexType fooArg) { #ifdef DYNATRACE DYNATRACE_API("STUFF"); DYNATRACE_ENTER_CAPTURE(); #endif code code more code #ifdef DYNATRACE DYNATRACE_CAPTURE_INT64(long_var); #endif more code even more code some more code return foo; } |
I couldnt find if that is property Syntax because the Native ADK Docs only specify catching Arguments in the DYNATRACE_ENTER_CAPTURE call itself.
In fact i was able to capture said long_var but in gets recorded as return Value not as argument like if i had used DYNATRACE_EXIT_RETURN_INT64.
Has anyone experienced anything similar or is there a known Bug or Misbehavoir related to this?
Thanks for any Info upfront.
Answer by Christian S. ·
hi Christian,
reason for this is simple: argument & return value capturing are based on the same mechanism, the only difference is that arguments are sent with the method enter event and return values with the method exit event. implication of this is that arguments can only be captured at the start of a method and return values (obviously) only at the end of a method.
so in your case the method enter event is already sent at DYNATRACE_ENTER_CAPTURE(), so the captured long_var is sent with the next event, which is the method exit in your case and so it's treated as the return value here.
this is the reason why you should only capture arguments & return values immediately before sending enter/exit events. and that's also why we introduced those macros which capture arguments/return values together with DYNATRACE_ENTER/_EXIT.
bottom line: you can capture the long_var out of this ComplexType as argument, if you extract and capture it before DYNATRACE_ENTER. but the current behavior is as intended.
hope this helps,
Christian
Answer by Christian S. ·
Hi Christian,
that explains it. Too bad that i cant capture (in this particular case) anything useful from the Methods Entry Point directly as the Argument is a pointer to a XML Document which, in subsequent code, gets deconstructed. So placing the DYNATRACE_ENTER_CAPTURE deeper within the code at the Point where i have extracted the relevant Node Information would loose the Tracing Informations regarding the deconstruction of the XML.
Thanks for the explanation and enlightnment.
Answer by Bernhard L. ·
You may consider putting another DYNATRACE_ENTER_CAPTURE into your code after parsing the XML input. So you won't lose the trace (i.e. the timing information of the method itself) and have the arguments as "dummy" call inside the actual method call:
void func_call (ComplexType fooArg) { DYNATRACE_API("STUFF"); DYNATRACE_ENTER(); code code more code { // IMPORTANT: note the additional block here DYNATRACE_ENTER_CAPTURE( DYNATRACE_CAPTURE_INT64(long_var); ); more code even more code some more code // leave internal 'dummy' call - put the EXIT *before* leaving the block DYNATRACE_EXIT(); } // leave the actual call DYNATRACE_EXIT(); }
The "inner" call will have the same method name, but will have the captured arguments. In the PurePath tree view it will appear as:
(M) func_call()
+ (M) func_call(long) <arg value> ...
Best regards,
Bernhard
Learn how Dynatrace Real User Monitoring automatically detects errors that impact your end users caused by erroneous 3rd party or CDNs.
December 12, 4:00 pm CET / 10:00 am ET
Register here
Learn how Dynatrace Real User Monitoring automatically detects errors that impact your end users caused by erroneous 3rd party or CDNs.
December 12, 4:00 pm CET / 10:00 am ET
Register here
Learn how Dynatrace Real User Monitoring automatically detects errors that impact your end users caused by erroneous 3rd party or CDNs.
December 12, 4:00 pm CET / 10:00 am ET
Register here
Learn how Dynatrace Real User Monitoring automatically detects errors that impact your end users caused by erroneous 3rd party or CDNs.
December 12, 4:00 pm CET / 10:00 am ET
Register here