See CLRIE in Azure
The CLR stands for the Common Language Runtime. It is the runtime for Microsoft's .NET framework and provides execution support for programs written in managed .NET languages such as C#, C++ CLI, F#, and VB.Net. Compiling code written in a managed language results in bytecode called the Common Intermediate Language (CIL). The CIL is platform and processor independent and it is up to the CLR to Just-In-Time (JIT) compile the CIL into machine code in order to be executed. The CIL and the CLR together make up the Common Language Infrastructure (CLI).
In addition to the CLR which supports the full .NET Framework, Microsoft has also released CoreCLR to support .NET Core libraries.
The CLR exposes a profiling API which reports events and messages of what is happening during the execution of a managed process or application (such as what methods are JIT compiled or if a class is loaded). The problem is that only one profiler can interact with the CLR Profiler APIs at a time. The CLR Instrumentation Engine was written to address this by acting as a host and inverse multiplexes the APIs for multiple profiler clients.
See the MSDN Profiling Overview for more details about profilers in general.
See the Design Notes for in-depth details of the CLR Instrumentation Engine.
Since the CLR Instrumentation Engine is meant to be shared, it is available as an x86 & x64 MSI/MSM installer on Windows desktop. The installer sets up Instrumentation Engine with the following folder structure:
%ProgramFiles%|%ProgramFiles(x86)%
Microsoft Instrumentation Engine
<CLRIE Version>
Instrumentation64|32
<dlls>
Proxy
<Proxy Version>
proxy.dll
We recommend setting the COR_PROFILER variables to the profiler proxy whenever applicable.
When a managed process starts execution, it must first load the CLR. Once the CLR is initialized, it then checks environment variables to see if a Profiler should be loaded.
See Environment Variables for more details on configuring your environment.
The Instrumentation Engine supports both x86 and x64 configurations.
- MicrosoftInstrumentationEngine_x86.dll
- MicrosoftInstrumentationEngine_x64.dll
See CLRIE in Azure for details about leveraging CLRIE on supported Azure platforms and products.
A simple example of an InstrumentationMethod can be found in NaglerInstrumentationMethod.cpp.
See Configuration for more details
The RawProfilerHook allows one additional profiler that has not yet on-boarded to the ClrInstrumentationEngine to work with the Instrumentation Methods.
The profiler callbacks will first iterate through each Instrumentation Method in priority order. Then the resultant IL is given to the ICorProfiler profiler listening on the RawProfilerHook.
In order to use the RawProfilerHook, you must modify these environment variables for the ICorProfiler profiler:
Variable Name | RawProfilerHook Variable Name |
---|---|
CORECLR/COR_PROFILER | MicrosoftInstrumentationEngine_RawProfilerHook |
CORECLR/COR_PROFILER_PATH_32/64 | MicrosoftInstrumentationEngine_RawProfilerHookPath_32/64 |
See Environment Variables for more details.