Comments have been closed on this page. Please use AppMon & UEM Open Q & A forum for questions about this plugin.



C++ Code Instrumentor Utility



dynaTrace Version

3.x, 4.x


Chuck Miller (chuck.miller@dynatrace.com)


dynaTrace BSD


Not Supported


dynaTrace CPP Instrumentor Utility
CPP Sample to test Utility


This Utility automates the process of instrumenting your CPP Source Code Files by adding calls to the Agent Development Kit (ADK).

Adding dynaTrace Instrumentation

  1. select a directory where c++ (.cpp) files exist either directly or recursively.
  2. click instrument source files which does the following ...
    1. adds the #include <dynatrace_adk.h> at the top of the file
    2. adds DYNATRACE_INITIALIZE([&argc, &argv for std], [NULL, NULL for windows]); at the top of the main() or WinMain() method block and DYNATRACE_UNINITIALIZE(); to the first return.
    3. adds dynaTrace ADK calls to all methods within those files specifying the namespace as the API - for example

would have the following ADK code added at the top of the method body

Refining dT Instrumentation

  1. select a directory where instrumented c++ (.cpp) files exist either directly or recursively.
  2. create and select an XML report file from the methods dashlet with methods to be removed from the c++ source files OR use the copy/paste XML from the methods dashlet.
  3. click refine/uninstrument source files which searches all c++ files recursively for the methods in step 2 and removes the instrumentation.

Updates (April 22nd)

I made some modifications/improvements to the c++ instrumentor utility.

Please check my assumptions below. I think they are good, but other eyes are always helpful. I also added my cpp code test bed so you check my math if you like.

1. It now understands functions and main declarations that span multiple lines

So both of these types of function or main declarations would work

2. I added support for Windows main declarations. So …

Becomes …


  1. Function or main declarations that close (i.e. with semicolons) on the same line are not significant enough to instrument.
  2. Function or main declarations do not contain “<<” anywhere in their declaration.  If that is the case, they will not be instrumented.  Note: I have not seen any functions or mains that do in any codes samples I've looked at, but I'm not sure if this is impossible or just unlikely.
  3. It is reasonable to expect the namespace::methodname convention for function calls.
  4. It is reasonable to use the namespace as the API designation (i.e. the bit before the ::).
  5. No method parameters are captured by the ADK and therefore are not available for uninstrumentation selection.

Potential Improvements

  1. Logging.
  2. Uninitialize all returns in the main or winmain block. Right now I’m only uninitializing the first one.
  3. Determine if there is no instrumentation left in the file and remove include.
  4. Check if instrumentation is already there and prompt user accordingly.
  5. Command line interface for automation.
  6. Others???

Of course, I'm still not confident it will always work right in the broader c++ world. I only have our sample code to use as a guide. It seems to work well there.


  File Modified
ZIP Archive cppInstrumentationTest.zip Apr 22, 2011 by Andreas Grabner
ZIP Archive dynaTraceCCodeInstrumentor.zip Apr 22, 2011 by Andreas Grabner

  1. Anonymous (login to see details)

    I tried it today in one of the PoCs. However, it also added instrumentation macros in the struct section of the code. Is there anyway for it to ignore struct?

    1. Anonymous (login to see details)

      There's currently no switch for that option, however the source code is available and you're welcome to make that change.