Concrete class with all processing logic to generate RDD data from the calls backs received from Profiler instrumentation for SQL.
 public void TestInitialize()
 {
     this.configuration = new TelemetryConfiguration();
     this.sendItems = new List<ITelemetry>();
     this.configuration.TelemetryChannel = new StubTelemetryChannel { OnSend = item => this.sendItems.Add(item) };
     this.configuration.InstrumentationKey = Guid.NewGuid().ToString();
     this.sqlProcessingProfiler = new ProfilerSqlProcessing(this.configuration, null, new ObjectInstanceBasedOperationHolder());
     this.ex = new Exception();
 }
Exemple #2
0
 public void TestInitialize()
 {
     this.configuration = new TelemetryConfiguration();
     this.sendItems     = new List <ITelemetry>();
     this.configuration.TelemetryChannel = new StubTelemetryChannel {
         OnSend = item => this.sendItems.Add(item)
     };
     this.configuration.InstrumentationKey = Guid.NewGuid().ToString();
     this.sqlProcessingProfiler            = new ProfilerSqlProcessing(this.configuration, null, new ObjectInstanceBasedOperationHolder());
 }
Exemple #3
0
        internal static void DecorateProfilerForSql(ref ProfilerSqlProcessing sqlCallbacks)
        {
            //// ___ ExecuteNonQuery ___ ////

            // Decorates Sql BeginExecuteNonQuery, 0 params (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteNonQuery",
                sqlCallbacks.OnBeginForOneParameter,
                null,
                null,
                isStatic: false);

            // Decorates Sql BeginExecuteNonQuery(AsyncCallback, Object), 2 params (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteNonQuery",
                sqlCallbacks.OnBeginForThreeParameters,
                null,
                null,
                isStatic: false);

            // Decorates Sql EndExecuteNonQuery, 1 param (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.EndExecuteNonQuery",
                null,
                sqlCallbacks.OnEndForTwoParameters,
                sqlCallbacks.OnExceptionForTwoParameters,
                isStatic: false);

            // Decorate Sql ExecuteNonQuery, 0 param (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.ExecuteNonQuery",
                sqlCallbacks.OnBeginForOneParameter,
                sqlCallbacks.OnEndForOneParameter,
                sqlCallbacks.OnExceptionForOneParameter,
                isStatic: false);

            // Decorate Sql ExecuteNonQueryAsync(CancellationToken)
            // TODO - abaranch 10/6/16 - Only latest instrumentation engine supports Tasks so we need to uncomment this code and add funcs when StatusMonitor is out
            // + Decorate in the same way ExecuteReader, ExecuteXmlReader and ExecuteScalar and remove 2 decorations below
            ////Functions.Decorate(
            ////    "System.Data",
            ////    "System.Data.dll",
            ////    "System.Data.SqlClient.SqlCommand.ExecuteNonQueryAsync",
            ////    sqlCallbacks.OnBeginForTwoParameter,
            ////    null,
            ////    null,
            ////    isStatic: false);
            //// Instead of Decorating public methods we have to use private one that may change signature from one framework to the other:

            // Read comment above. Decorate BeginExecuteNonQueryAsync, 2 param (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteNonQueryAsync",
                sqlCallbacks.OnBeginForThreeParameters,
                null,
                null,
                isStatic: false);

            // Read comment above. Decorate EndExecuteNonQueryAsync, 1 param (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.EndExecuteNonQueryAsync",
                null,
                sqlCallbacks.OnEndForTwoParameters,
                sqlCallbacks.OnExceptionForTwoParameters,
                isStatic: false);

            //// ___ ExecuteReader ___ ////

            // Decorates Sql BeginExecuteReader, 0 param (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteReader",
                sqlCallbacks.OnBeginForOneParameter,
                null,
                null,
                isStatic: false);

            // Decorates Sql BeginExecuteReader(CommandBehavior), 1 param (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteReader",
                sqlCallbacks.OnBeginForTwoParameters,
                null,
                null,
                isStatic: false);

            // Decorates Sql BeginExecuteReader(AsyncCallback, Object), 2 param (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteReader",
                sqlCallbacks.OnBeginForThreeParameters,
                null,
                null,
                isStatic: false);

            // Decorates Sql BeginExecuteReader(AsyncCallback, Object, CommandBehavior), 3 params (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteReader",
                sqlCallbacks.OnBeginForFourParameters,
                null,
                null,
                isStatic: false);

            // Decorates Sql EndExecuteReader, 1 param (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.EndExecuteReader",
                null,
                sqlCallbacks.OnEndForTwoParameters,
                sqlCallbacks.OnExceptionForTwoParameters,
                isStatic: false);

            // Decorate Sql ExecuteReader, 0 params(+this) (we instrument 2 overloads of ExecuteReader because there are cases when methods get inlined or tail call optimized)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.ExecuteReader",
                sqlCallbacks.OnBeginForOneParameter,
                sqlCallbacks.OnEndForOneParameter,
                sqlCallbacks.OnExceptionForOneParameter,
                isStatic: false);

            // Decorate Sql ExecuteReader(CommandBehavior), 2 params(+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.ExecuteReader",
                sqlCallbacks.OnBeginForThreeParameters,
                sqlCallbacks.OnEndForThreeParameters,
                sqlCallbacks.OnExceptionForThreeParameters,
                isStatic: false);

            // Should be replaced with public method when InstrumentationEngine supports Tasks.
            // Decorate BeginExecuteReaderAsync, 3 param (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteReaderAsync",
                sqlCallbacks.OnBeginForFourParameters,
                null,
                null,
                isStatic: false);

            // Should be replaced with public method when InstrumentationEngine supports Tasks.
            // Decorate EndExecuteReaderAsync, 1 param (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.EndExecuteReaderAsync",
                null,
                sqlCallbacks.OnEndForTwoParameters,
                sqlCallbacks.OnExceptionForTwoParameters,
                isStatic: false);

            //// ___ ExecuteScalar ___ ////

            // Decorate Sql ExecuteScalar, 0 params(+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.ExecuteScalar",
                sqlCallbacks.OnBeginForOneParameter,
                sqlCallbacks.OnEndForOneParameter,
                sqlCallbacks.OnExceptionForOneParameter,
                isStatic: false);

            //// ___ ExecuteXmlReader ___ ////

            // Decorates Sql BeginExecuteXmlReader, 0 params(+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteXmlReader",
                sqlCallbacks.OnBeginForOneParameter,
                null,
                null,
                isStatic: false);

            // Decorates Sql BeginExecuteXmlReader(AsyncCallback, Object), 2 params(+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteXmlReader",
                sqlCallbacks.OnBeginForThreeParameters,
                null,
                null,
                isStatic: false);

            // Decorates Sql EndExecuteXmlReader(IAsyncResult), 1 param(+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.EndExecuteXmlReader",
                null,
                sqlCallbacks.OnEndForTwoParameters,
                sqlCallbacks.OnExceptionForTwoParameters,
                isStatic: false);

            // Decorate Sql ExecuteXmlReader, 0 params(+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.ExecuteXmlReader",
                sqlCallbacks.OnBeginForOneParameter,
                sqlCallbacks.OnEndForOneParameter,
                sqlCallbacks.OnExceptionForOneParameter,
                isStatic: false);

            // Should be replaced with public method when InstrumentationEngine supports Tasks.
            // Decorate BeginExecuteXmlReaderAsync, 2 param (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteXmlReaderAsync",
                sqlCallbacks.OnBeginForThreeParameters,
                null,
                null,
                isStatic: false);

            // Should be replaced with public method when InstrumentationEngine supports Tasks.
            // Decorate EndExecuteXmlReaderAsync, 1 param (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.EndExecuteXmlReaderAsync",
                null,
                sqlCallbacks.OnEndForTwoParameters,
                sqlCallbacks.OnExceptionForTwoParameters,
                isStatic: false);
        }
        internal virtual void InitializeForRuntimeProfiler()
        {
            // initialize instrumentation extension
            var extensionBaseDirectory = string.IsNullOrWhiteSpace(AppDomain.CurrentDomain.RelativeSearchPath)
                ? AppDomain.CurrentDomain.BaseDirectory
                : AppDomain.CurrentDomain.RelativeSearchPath;

            DependencyCollectorEventSource.Log.RemoteDependencyModuleInformation("extesionBaseDirectrory is " + extensionBaseDirectory);
            Decorator.InitializeExtension(extensionBaseDirectory);

            // obtain agent version
            var agentVersion = Decorator.GetAgentVersion();
            DependencyCollectorEventSource.Log.RemoteDependencyModuleInformation("AgentVersion is " + agentVersion);

            this.httpProcessing = new ProfilerHttpProcessing(this.telemetryConfiguration, agentVersion, DependencyTableStore.Instance.WebRequestConditionalHolder, this.SetComponentCorrelationHttpHeaders, this.ExcludeComponentCorrelationHttpHeadersOnDomains);
            this.sqlProcessing = new ProfilerSqlProcessing(this.telemetryConfiguration, agentVersion, DependencyTableStore.Instance.SqlRequestConditionalHolder);

            ProfilerRuntimeInstrumentation.DecorateProfilerForHttp(ref this.httpProcessing);
            ProfilerRuntimeInstrumentation.DecorateProfilerForSql(ref this.sqlProcessing);
        }
        internal static void DecorateProfilerForSql(ref ProfilerSqlProcessing sqlCallbacks)
        {
            // Decorate Sql ExecuteNonQuery
            Decorator.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.ExecuteNonQuery",
                0,
                sqlCallbacks.OnBeginForSync,
                sqlCallbacks.OnEndForSync,
                sqlCallbacks.OnExceptionForSync);
           
            // Decorate Sql ExecuteReader
            Decorator.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.ExecuteReader",
                2,
                sqlCallbacks.OnBeginForExecuteReader,
                sqlCallbacks.OnEndForExecuteReader,
                sqlCallbacks.OnExceptionForExecuteReader);

            // Decorate Sql ExecuteReader (we instrument 2 overloads of ExecuteReader because there are cases when methods get inlined or tail call optimized)
            Decorator.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.ExecuteReader",
                0,
                sqlCallbacks.OnBeginForSync,
                sqlCallbacks.OnEndForSync,
                sqlCallbacks.OnExceptionForSync);

            // Decorate Sql ExecuteScalar
            Decorator.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.ExecuteScalar",
                0,
                sqlCallbacks.OnBeginForSync,
                sqlCallbacks.OnEndForSync,
                sqlCallbacks.OnExceptionForSync);

            // Decorate Sql ExecuteXmlReader
            Decorator.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.ExecuteXmlReader",
                0,
                sqlCallbacks.OnBeginForSync,
                sqlCallbacks.OnEndForSync,
                sqlCallbacks.OnExceptionForSync); 

            // Decorates Sql BeginExecuteNonQueryInternal
            Decorator.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteNonQueryInternal",
                4,
                sqlCallbacks.OnBeginForBeginExecuteNonQueryInternal,
                null,
                null);

            // Decorates Sql EndExecuteNonQueryInternal
            Decorator.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.EndExecuteNonQueryInternal",
                1,
                null,
                sqlCallbacks.OnEndForSqlAsync,
                sqlCallbacks.OnExceptionForSqlAsync);
            
            // Decorates Sql BeginExecuteReaderInternal
            Decorator.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteReaderInternal",
                5,
                sqlCallbacks.OnBeginForBeginExecuteReaderInternal,
                null,
                null);

            // Decorates Sql EndExecuteReaderInternal
            Decorator.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.EndExecuteReaderInternal",
                1,
                null,
                sqlCallbacks.OnEndForSqlAsync,
                sqlCallbacks.OnExceptionForSqlAsync);           

            // Decorates Sql BeginExecuteXmlReaderInternal
            Decorator.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteXmlReaderInternal",
                4,
                sqlCallbacks.OnBeginForBeginExecuteXmlReaderInternal,
                null,
                null);

            // Decorates Sql EndExecuteXmlReaderInternal
            Decorator.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.EndExecuteXmlReaderInternal",
                1,
                null,
                sqlCallbacks.OnEndForSqlAsync,
                sqlCallbacks.OnExceptionForSqlAsync);
        }
        internal static void DecorateProfilerForSql(ref ProfilerSqlProcessing sqlCallbacks)
        {
            //// ___ ExecuteNonQuery ___ ////

            // Decorates Sql BeginExecuteNonQuery, 0 params (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteNonQuery",
                sqlCallbacks.OnBeginForOneParameter,
                null,
                null,
                isStatic: false);

            // Decorates Sql BeginExecuteNonQuery(AsyncCallback, Object), 2 params (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteNonQuery",
                sqlCallbacks.OnBeginForThreeParameters,
                null,
                null,
                isStatic: false);

            // Decorates Sql EndExecuteNonQuery, 1 param (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.EndExecuteNonQuery",
                null,
                sqlCallbacks.OnEndForTwoParameters,
                sqlCallbacks.OnExceptionForTwoParameters,
                isStatic: false);

            // Decorate Sql ExecuteNonQuery, 0 param (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.ExecuteNonQuery",
                sqlCallbacks.OnBeginForOneParameter,
                sqlCallbacks.OnEndForOneParameter,
                sqlCallbacks.OnExceptionForOneParameter,
                isStatic: false);

            // Decorate Sql ExecuteNonQueryAsync(CancellationToken)
            // TODO - abaranch 10/6/16 - Only latest instrumentation engine supports Tasks so we need to uncomment this code and add funcs when StatusMonitor is out
            // + Decorate in the same way ExecuteReader, ExecuteXmlReader and ExecuteScalar and remove 2 decorations below
            ////Functions.Decorate(
            ////    "System.Data",
            ////    "System.Data.dll",
            ////    "System.Data.SqlClient.SqlCommand.ExecuteNonQueryAsync",
            ////    sqlCallbacks.OnBeginForTwoParameter,
            ////    null,
            ////    null,
            ////    isStatic: false);
            //// Instead of Decorating public methods we have to use private one that may change signature from one framework to the other:

            // Read comment above. Decorate BeginExecuteNonQueryAsync, 2 param (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteNonQueryAsync",
                sqlCallbacks.OnBeginForThreeParameters,
                null,
                null,
                isStatic: false);

            // Read comment above. Decorate EndExecuteNonQueryAsync, 1 param (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.EndExecuteNonQueryAsync",
                null,
                sqlCallbacks.OnEndForTwoParameters,
                sqlCallbacks.OnExceptionForTwoParameters,
                isStatic: false);

            //// ___ ExecuteReader ___ ////

            // Decorates Sql BeginExecuteReader, 0 param (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteReader",
                sqlCallbacks.OnBeginForOneParameter,
                null,
                null,
                isStatic: false);

            // Decorates Sql BeginExecuteReader(CommandBehavior), 1 param (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteReader",
                sqlCallbacks.OnBeginForTwoParameters,
                null,
                null,
                isStatic: false);

            // Decorates Sql BeginExecuteReader(AsyncCallback, Object), 2 param (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteReader",
                sqlCallbacks.OnBeginForThreeParameters,
                null,
                null,
                isStatic: false);

            // Decorates Sql BeginExecuteReader(AsyncCallback, Object, CommandBehavior), 3 params (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteReader",
                sqlCallbacks.OnBeginForFourParameters,
                null,
                null,
                isStatic: false);

            // Decorates Sql EndExecuteReader, 1 param (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.EndExecuteReader",
                null,
                sqlCallbacks.OnEndForTwoParameters,
                sqlCallbacks.OnExceptionForTwoParameters,
                isStatic: false);

            // Decorate Sql ExecuteReader, 0 params(+this) (we instrument 2 overloads of ExecuteReader because there are cases when methods get inlined or tail call optimized)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.ExecuteReader",
                sqlCallbacks.OnBeginForOneParameter,
                sqlCallbacks.OnEndForOneParameter,
                sqlCallbacks.OnExceptionForOneParameter,
                isStatic: false);

            // Decorate Sql ExecuteReader(CommandBehavior), 2 params(+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.ExecuteReader",
                sqlCallbacks.OnBeginForThreeParameters,
                sqlCallbacks.OnEndForThreeParameters,
                sqlCallbacks.OnExceptionForThreeParameters,
                isStatic: false);

            // Should be replaced with public method when InstrumentationEngine supports Tasks.
            // Decorate BeginExecuteReaderAsync, 3 param (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteReaderAsync",
                sqlCallbacks.OnBeginForFourParameters,
                null,
                null,
                isStatic: false);

            // Should be replaced with public method when InstrumentationEngine supports Tasks.
            // Decorate EndExecuteReaderAsync, 1 param (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.EndExecuteReaderAsync",
                null,
                sqlCallbacks.OnEndForTwoParameters,
                sqlCallbacks.OnExceptionForTwoParameters,
                isStatic: false);

            //// ___ ExecuteScalar ___ ////

            // Decorate Sql ExecuteScalar, 0 params(+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.ExecuteScalar",
                sqlCallbacks.OnBeginForOneParameter,
                sqlCallbacks.OnEndForOneParameter,
                sqlCallbacks.OnExceptionForOneParameter,
                isStatic: false);

            //// ___ ExecuteXmlReader ___ ////

            // Decorates Sql BeginExecuteXmlReader, 0 params(+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteXmlReader",
                sqlCallbacks.OnBeginForOneParameter,
                null,
                null,
                isStatic: false);

            // Decorates Sql BeginExecuteXmlReader(AsyncCallback, Object), 2 params(+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteXmlReader",
                sqlCallbacks.OnBeginForThreeParameters,
                null,
                null,
                isStatic: false);

            // Decorates Sql EndExecuteXmlReader(IAsyncResult), 1 param(+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.EndExecuteXmlReader",
                null,
                sqlCallbacks.OnEndForTwoParameters,
                sqlCallbacks.OnExceptionForTwoParameters,
                isStatic: false);

            // Decorate Sql ExecuteXmlReader, 0 params(+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.ExecuteXmlReader",
                sqlCallbacks.OnBeginForOneParameter,
                sqlCallbacks.OnEndForOneParameter,
                sqlCallbacks.OnExceptionForOneParameter,
                isStatic: false);

            // Should be replaced with public method when InstrumentationEngine supports Tasks.
            // Decorate BeginExecuteXmlReaderAsync, 2 param (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteXmlReaderAsync",
                sqlCallbacks.OnBeginForThreeParameters,
                null,
                null,
                isStatic: false);

            // Should be replaced with public method when InstrumentationEngine supports Tasks.
            // Decorate EndExecuteXmlReaderAsync, 1 param (+this)
            Functions.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.EndExecuteXmlReaderAsync",
                null,
                sqlCallbacks.OnEndForTwoParameters,
                sqlCallbacks.OnExceptionForTwoParameters,
                isStatic: false);
        }
Exemple #7
0
        internal static void DecorateProfilerForSql(ref ProfilerSqlProcessing sqlCallbacks)
        {
            // Decorate Sql ExecuteNonQuery
            Decorator.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.ExecuteNonQuery",
                0,
                sqlCallbacks.OnBeginForSync,
                sqlCallbacks.OnEndForSync,
                sqlCallbacks.OnExceptionForSync);

            // Decorate Sql ExecuteReader
            Decorator.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.ExecuteReader",
                2,
                sqlCallbacks.OnBeginForExecuteReader,
                sqlCallbacks.OnEndForExecuteReader,
                sqlCallbacks.OnExceptionForExecuteReader);

            // Decorate Sql ExecuteReader (we instrument 2 overloads of ExecuteReader because there are cases when methods get inlined or tail call optimized)
            Decorator.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.ExecuteReader",
                0,
                sqlCallbacks.OnBeginForSync,
                sqlCallbacks.OnEndForSync,
                sqlCallbacks.OnExceptionForSync);

            // Decorate Sql ExecuteScalar
            Decorator.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.ExecuteScalar",
                0,
                sqlCallbacks.OnBeginForSync,
                sqlCallbacks.OnEndForSync,
                sqlCallbacks.OnExceptionForSync);

            // Decorate Sql ExecuteXmlReader
            Decorator.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.ExecuteXmlReader",
                0,
                sqlCallbacks.OnBeginForSync,
                sqlCallbacks.OnEndForSync,
                sqlCallbacks.OnExceptionForSync);

            // Decorates Sql BeginExecuteNonQueryInternal
            Decorator.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteNonQueryInternal",
                4,
                sqlCallbacks.OnBeginForBeginExecuteNonQueryInternal,
                null,
                null);

            // Decorates Sql EndExecuteNonQueryInternal
            Decorator.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.EndExecuteNonQueryInternal",
                1,
                null,
                sqlCallbacks.OnEndForSqlAsync,
                sqlCallbacks.OnExceptionForSqlAsync);

            // Decorates Sql BeginExecuteReaderInternal
            Decorator.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteReaderInternal",
                5,
                sqlCallbacks.OnBeginForBeginExecuteReaderInternal,
                null,
                null);

            // Decorates Sql EndExecuteReaderInternal
            Decorator.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.EndExecuteReaderInternal",
                1,
                null,
                sqlCallbacks.OnEndForSqlAsync,
                sqlCallbacks.OnExceptionForSqlAsync);

            // Decorates Sql BeginExecuteXmlReaderInternal
            Decorator.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.BeginExecuteXmlReaderInternal",
                4,
                sqlCallbacks.OnBeginForBeginExecuteXmlReaderInternal,
                null,
                null);

            // Decorates Sql EndExecuteXmlReaderInternal
            Decorator.Decorate(
                "System.Data",
                "System.Data.dll",
                "System.Data.SqlClient.SqlCommand.EndExecuteXmlReaderInternal",
                1,
                null,
                sqlCallbacks.OnEndForSqlAsync,
                sqlCallbacks.OnExceptionForSqlAsync);
        }