/// <summary>
        /// Enables Azure Instrumentation.
        /// </summary>
        /// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
        /// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
        public static TracerProviderBuilder AddAzureInstrumentation(
            this TracerProviderBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            builder.AddInstrumentation((activitySource) => new AzureClientsInstrumentation());
            builder.AddInstrumentation((activitySource) => new AzurePipelineInstrumentation());
            return(builder);
        }
예제 #2
0
 internal static TracerProviderBuilder AddHttpClientInstrumentation(
     this TracerProviderBuilder builder,
     HttpClientInstrumentation instrumentation)
 {
     builder.AddSource(HttpHandlerDiagnosticListener.ActivitySourceName);
     builder.AddLegacySource("System.Net.Http.HttpRequestOut");
     return(builder.AddInstrumentation(() => instrumentation));
 }
 internal static TracerProviderBuilder AddAspNetCoreInstrumentation(
     this TracerProviderBuilder builder,
     AspNetCoreInstrumentation instrumentation)
 {
     builder.AddSource(HttpInListener.ActivitySourceName);
     builder.AddLegacySource(HttpInListener.ActivityOperationName); // for the activities created by AspNetCore
     return builder.AddInstrumentation(() => instrumentation);
 }
        public static TracerProviderBuilder AddQuartzInstrumentation(
            this TracerProviderBuilder builder,
            Action <QuartzInstrumentationOptions>?configure = null)
        {
            var options = new QuartzInstrumentationOptions();

            configure?.Invoke(options);
            return(builder.AddInstrumentation(t => new QuartzJobInstrumentation(t, options)));
        }
예제 #5
0
        private static TracerProviderBuilder AddAspNetCoreInstrumentation(TracerProviderBuilder builder, AspNetCoreInstrumentationOptions options, Action <AspNetCoreInstrumentationOptions> configure = null)
        {
            configure?.Invoke(options);
            var instrumentation = new AspNetCoreInstrumentation(options);

            builder.AddSource(HttpInListener.ActivitySourceName);
            builder.AddLegacySource(HttpInListener.ActivityOperationName); // for the activities created by AspNetCore
            return(builder.AddInstrumentation(() => instrumentation));
        }
        /// <summary>
        /// Enables gRPClient Instrumentation.
        /// </summary>
        /// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
        /// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
        public static TracerProviderBuilder AddGrpcClientInstrumentation(
            this TracerProviderBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            builder.AddInstrumentation((activitySource) => new GrpcClientInstrumentation(activitySource));
            return(builder);
        }
        private static TracerProviderBuilder AddRedisInstrumentation(
            TracerProviderBuilder builder,
            IConnectionMultiplexer connection,
            StackExchangeRedisCallsInstrumentationOptions options,
            Action <StackExchangeRedisCallsInstrumentationOptions> configure = null)
        {
            configure?.Invoke(options);

            return(builder
                   .AddInstrumentation(() => new StackExchangeRedisCallsInstrumentation(connection, options))
                   .AddSource(StackExchangeRedisCallsInstrumentation.ActivitySourceName));
        }
        /// <summary>
        /// Enables the message eventing data collection for CAP.
        /// </summary>
        /// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
        /// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
        public static TracerProviderBuilder AddCapInstrumentation(this TracerProviderBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            builder.AddSource(DiagnosticListener.SourceName);

            var instrumentation = new CapInstrumentation(new DiagnosticListener());

            return(builder.AddInstrumentation(() => instrumentation));
        }
        /// <summary>
        /// Enables SqlClient instrumentation.
        /// </summary>
        /// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
        /// <param name="configureSqlClientInstrumentationOptions">SqlClient configuration options.</param>
        /// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
        public static TracerProviderBuilder AddSqlClientInstrumentation(
            this TracerProviderBuilder builder,
            Action <SqlClientInstrumentationOptions> configureSqlClientInstrumentationOptions = null)
        {
            Guard.ThrowIfNull(builder);

            var sqlOptions = new SqlClientInstrumentationOptions();

            configureSqlClientInstrumentationOptions?.Invoke(sqlOptions);

            builder.AddInstrumentation(() => new SqlClientInstrumentation(sqlOptions));
            builder.AddSource(SqlActivitySourceHelper.ActivitySourceName);

            return(builder);
        }
예제 #10
0
        /// <summary>
        /// Enables the incoming requests automatic data collection for ASP.NET.
        /// </summary>
        /// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
        /// <param name="configureAspNetInstrumentationOptions">ASP.NET Request configuration options.</param>
        /// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
        public static TracerProviderBuilder AddAspNetInstrumentation(
            this TracerProviderBuilder builder,
            Action <AspNetInstrumentationOptions> configureAspNetInstrumentationOptions = null)
        {
            Guard.ThrowIfNull(builder, nameof(builder));

            var aspnetOptions = new AspNetInstrumentationOptions();

            configureAspNetInstrumentationOptions?.Invoke(aspnetOptions);

            builder.AddInstrumentation(() => new AspNetInstrumentation(aspnetOptions));
            builder.AddSource(TelemetryHttpModule.AspNetSourceName);

            return(builder);
        }
예제 #11
0
        /// <summary>
        /// Enables the outgoing requests automatic data collection for MassTransit.
        /// </summary>
        /// <param name="builder"><see cref="TracerProviderBuilderExtensions"/> being configured.</param>
        /// <param name="configureMassTransitInstrumentationOptions">MassTransit configuration options.</param>
        /// <returns>The instance of <see cref="TracerProviderBuilderExtensions"/> to chain the calls.</returns>
        public static TracerProviderBuilder AddMassTransitInstrumentation(
            this TracerProviderBuilder builder,
            Action <MassTransitInstrumentationOptions> configureMassTransitInstrumentationOptions = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var options = new MassTransitInstrumentationOptions();

            configureMassTransitInstrumentationOptions?.Invoke(options);

            return(builder.AddInstrumentation(activitySource => new MassTransitInstrumentation(activitySource, options)));
        }
        /// <summary>
        /// Enables gRPClient Instrumentation.
        /// </summary>
        /// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
        /// <param name="configure">GrpcClient configuration options.</param>
        /// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
        public static TracerProviderBuilder AddGrpcClientInstrumentation(
            this TracerProviderBuilder builder,
            Action <GrpcClientInstrumentationOptions> configure = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var grpcOptions = new GrpcClientInstrumentationOptions();

            configure?.Invoke(grpcOptions);

            builder.AddInstrumentation((activitySource) => new GrpcClientInstrumentation(activitySource, grpcOptions));
            return(builder);
        }
예제 #13
0
        /// <summary>
        /// Enables the Quartz.NET Job automatic data collection for Quartz.NET.
        /// </summary>
        /// <param name="builder"><see cref="TraceProviderBuilderExtensions"/> being configured.</param>
        /// <param name="configureQuartzInstrumentationOptions">Quartz configuration options.</param>
        /// <returns>The instance of <see cref="TraceProviderBuilderExtensions"/> to chain the calls.</returns>
        public static TracerProviderBuilder AddQuartzInstrumentation(
            this TracerProviderBuilder builder,
            Action <QuartzInstrumentationOptions> configureQuartzInstrumentationOptions = null)
        {
            var options = new QuartzInstrumentationOptions();

            configureQuartzInstrumentationOptions?.Invoke(options);

            builder.AddInstrumentation(() => new QuartzJobInstrumentation(options));
            builder.AddSource(QuartzDiagnosticListener.ActivitySourceName);

            builder.AddLegacySource(OperationName.Job.Execute);
            builder.AddLegacySource(OperationName.Job.Veto);

            return(builder);
        }
        /// <summary>
        /// Enables the outgoing requests automatic data collection for HttpClient.
        /// </summary>
        /// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
        /// <param name="configureHttpClientInstrumentationOptions">HttpClient configuration options.</param>
        /// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
        public static TracerProviderBuilder AddHttpClientDependencyInstrumentation(
            this TracerProviderBuilder builder,
            Action <HttpClientInstrumentationOptions> configureHttpClientInstrumentationOptions = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var httpClientOptions = new HttpClientInstrumentationOptions();

            configureHttpClientInstrumentationOptions?.Invoke(httpClientOptions);

            builder.AddInstrumentation((activitySource) => new HttpClientInstrumentation(activitySource, httpClientOptions));
            return(builder);
        }
예제 #15
0
        /// <summary>
        /// Enables gRPClient Instrumentation.
        /// </summary>
        /// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
        /// <param name="configure">GrpcClient configuration options.</param>
        /// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
        public static TracerProviderBuilder AddGrpcClientInstrumentation(
            this TracerProviderBuilder builder,
            Action <GrpcClientInstrumentationOptions> configure = null)
        {
            Guard.Null(builder, nameof(builder));

            var grpcOptions = new GrpcClientInstrumentationOptions();

            configure?.Invoke(grpcOptions);

            builder.AddInstrumentation(() => new GrpcClientInstrumentation(grpcOptions));
            builder.AddSource(GrpcClientDiagnosticListener.ActivitySourceName);
            builder.AddLegacySource("Grpc.Net.Client.GrpcOut");

            return(builder);
        }
예제 #16
0
        /// <summary>
        /// Enables HttpClient instrumentation.
        /// </summary>
        /// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
        /// <param name="configureHttpClientInstrumentationOptions">HttpClient configuration options.</param>
        /// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
        public static TracerProviderBuilder AddHttpClientInstrumentation(
            this TracerProviderBuilder builder,
            Action <HttpClientInstrumentationOptions> configureHttpClientInstrumentationOptions = null)
        {
            Guard.ThrowIfNull(builder, nameof(builder));

            var httpClientOptions = new HttpClientInstrumentationOptions();

            configureHttpClientInstrumentationOptions?.Invoke(httpClientOptions);

            builder.AddInstrumentation(() => new HttpClientInstrumentation(httpClientOptions));
            builder.AddSource(HttpHandlerDiagnosticListener.ActivitySourceName);
            builder.AddLegacySource("System.Net.Http.HttpRequestOut");

            return(builder);
        }
예제 #17
0
        /// <summary>
        /// Enables the incoming requests automatic data collection for ASP.NET Core.
        /// </summary>
        /// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
        /// <param name="configureAspNetCoreInstrumentationOptions">ASP.NET Core Request configuration options.</param>
        /// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
        public static TracerProviderBuilder AddAspNetCoreInstrumentation(
            this TracerProviderBuilder builder,
            Action <AspNetCoreInstrumentationOptions> configureAspNetCoreInstrumentationOptions = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var aspnetCoreOptions = new AspNetCoreInstrumentationOptions();

            configureAspNetCoreInstrumentationOptions?.Invoke(aspnetCoreOptions);
            builder.AddInstrumentation((activitySource) => new AspNetCoreInstrumentation(activitySource, aspnetCoreOptions));

            return(builder);
        }
        /// <summary>
        /// Enables the outgoing requests automatic data collection for Redis.
        /// </summary>
        /// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
        /// <param name="connection"><see cref="ConnectionMultiplexer"/> to instrument.</param>
        /// <param name="configureOptions">Redis configuration options.</param>
        /// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
        public static TracerProviderBuilder AddRedisInstrumentation(
            this TracerProviderBuilder builder,
            ConnectionMultiplexer connection,
            Action <StackExchangeRedisCallsInstrumentationOptions> configureOptions = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            StackExchangeRedisCallsInstrumentationOptions options = new StackExchangeRedisCallsInstrumentationOptions();

            configureOptions?.Invoke(options);

            return(builder
                   .AddInstrumentation((activitySourceAdapter) => new StackExchangeRedisCallsInstrumentation(connection, options))
                   .AddSource(StackExchangeRedisCallsInstrumentation.ActivitySourceName));
        }
        /// <summary>
        /// Enables SqlClient instrumentation.
        /// </summary>
        /// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
        /// <param name="configureSqlClientInstrumentationOptions">SqlClient configuration options.</param>
        /// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
        public static TracerProviderBuilder AddSqlClientInstrumentation(
            this TracerProviderBuilder builder,
            Action <SqlClientInstrumentationOptions> configureSqlClientInstrumentationOptions = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var sqlOptions = new SqlClientInstrumentationOptions();

            configureSqlClientInstrumentationOptions?.Invoke(sqlOptions);

            builder.AddInstrumentation(() => new SqlClientInstrumentation(sqlOptions));
            builder.AddSource(SqlClientDiagnosticListener.ActivitySourceName);

            return(builder);
        }
예제 #20
0
        /// <summary>
        /// Enables SqlClient instrumentation.
        /// </summary>
        /// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
        /// <param name="configureMySqlDataInstrumentationOptions">SqlClient configuration options.</param>
        /// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
        public static TracerProviderBuilder AddMySqlDataInstrumentation(
            this TracerProviderBuilder builder,
            Action <MySqlDataInstrumentationOptions> configureMySqlDataInstrumentationOptions = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var sqlOptions = new MySqlDataInstrumentationOptions();

            configureMySqlDataInstrumentationOptions?.Invoke(sqlOptions);

            builder.AddInstrumentation(() => new MySqlDataInstrumentation(sqlOptions));
            builder.AddSource(MySqlActivitySourceHelper.ActivitySourceName);

            return(builder);
        }
예제 #21
0
        /// <summary>
        /// Enables Microsoft.EntityFrameworkCore instrumentation.
        /// </summary>
        /// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
        /// <param name="configureOptions">EntityFrameworkCore configuration options.</param>
        /// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
        public static TracerProviderBuilder AddEntityFrameworkCoreInstrumentation(
            this TracerProviderBuilder builder,
            Action <EntityFrameworkInstrumentationOptions> configureOptions = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var options = new EntityFrameworkInstrumentationOptions();

            configureOptions?.Invoke(options);

            builder.AddInstrumentation((activitySource) => new EntityFrameworkInstrumentation(options));
            builder.AddSource(EntityFrameworkDiagnosticListener.ActivitySourceName);

            return(builder);
        }
        /// <summary>
        /// Enables Elasticsearch client Instrumentation.
        /// </summary>
        /// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
        /// <param name="configure">Elasticsearch client configuration options.</param>
        /// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
        public static TracerProviderBuilder AddElasticsearchClientInstrumentation(
            this TracerProviderBuilder builder,
            Action <ElasticsearchClientInstrumentationOptions> configure = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var elasticsearchClientOptions = new ElasticsearchClientInstrumentationOptions();

            configure?.Invoke(elasticsearchClientOptions);

            builder.AddInstrumentation(() => new ElasticsearchClientInstrumentation(elasticsearchClientOptions));
            builder.AddSource(ElasticsearchRequestPipelineDiagnosticListener.ActivitySourceName);
            builder.AddLegacySource("CallElasticsearch");

            return(builder);
        }
예제 #23
0
        /// <summary>
        /// Enables the incoming requests automatic data collection for ASP.NET Core.
        /// </summary>
        /// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
        /// <param name="configureAspNetCoreInstrumentationOptions">ASP.NET Core Request configuration options.</param>
        /// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
        public static TracerProviderBuilder AddAspNetCoreInstrumentation(
            this TracerProviderBuilder builder,
            Action <AspNetCoreInstrumentationOptions> configureAspNetCoreInstrumentationOptions = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var aspnetCoreOptions = new AspNetCoreInstrumentationOptions();

            configureAspNetCoreInstrumentationOptions?.Invoke(aspnetCoreOptions);
            builder.AddInstrumentation(() => new AspNetCoreInstrumentation(aspnetCoreOptions));
            builder.AddSource(HttpInListener.ActivitySourceName);
            builder.AddLegacySource(HttpInListener.ActivityOperationName);        // for the activities created by AspNetCore
            builder.AddLegacySource(HttpInListener.ActivityNameByHttpInListener); // for the sibling activities created by the instrumentation library

            return(builder);
        }
예제 #24
0
        /// <summary>
        /// Enables HttpClient instrumentation.
        /// </summary>
        /// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
        /// <param name="configureHttpClientInstrumentationOptions">HttpClient configuration options.</param>
        /// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
        public static TracerProviderBuilder AddHttpClientInstrumentation(
            this TracerProviderBuilder builder,
            Action <HttpClientInstrumentationOptions> configureHttpClientInstrumentationOptions = null)
#endif
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var httpClientOptions = new HttpClientInstrumentationOptions();

            configureHttpClientInstrumentationOptions?.Invoke(httpClientOptions);

            builder.AddInstrumentation((activitySource) => new HttpClientInstrumentation(activitySource, httpClientOptions));

#if NETFRAMEWORK
            builder.AddHttpWebRequestInstrumentation(configureHttpWebRequestInstrumentationOptions);
#endif
            return(builder);
        }
예제 #25
0
        /// <summary>
        /// Enables the outgoing requests automatic data collection for MassTransit.
        /// </summary>
        /// <param name="builder"><see cref="TracerProviderBuilderExtensions"/> being configured.</param>
        /// <param name="configureMassTransitInstrumentationOptions">MassTransit configuration options.</param>
        /// <returns>The instance of <see cref="TracerProviderBuilderExtensions"/> to chain the calls.</returns>
        public static TracerProviderBuilder AddMassTransitInstrumentation(
            this TracerProviderBuilder builder,
            Action <MassTransitInstrumentationOptions> configureMassTransitInstrumentationOptions = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var options = new MassTransitInstrumentationOptions();

            configureMassTransitInstrumentationOptions?.Invoke(options);

            builder.AddInstrumentation(() => new MassTransitInstrumentation(options));
            builder.AddSource(MassTransitDiagnosticListener.ActivitySourceName);

            builder.AddLegacySource(OperationName.Consumer.Consume);
            builder.AddLegacySource(OperationName.Consumer.Handle);
            builder.AddLegacySource(OperationName.Transport.Send);
            builder.AddLegacySource(OperationName.Transport.Receive);

            return(builder);
        }
        /// <summary>
        /// Enables HttpClient instrumentation.
        /// </summary>
        /// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
        /// <param name="configureHttpClientInstrumentationOptions">HttpClient configuration options.</param>
        /// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
        public static TracerProviderBuilder AddHttpClientInstrumentation(
            this TracerProviderBuilder builder,
            Action <HttpClientInstrumentationOptions> configureHttpClientInstrumentationOptions = null)
#endif
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var httpClientOptions = new HttpClientInstrumentationOptions();

            configureHttpClientInstrumentationOptions?.Invoke(httpClientOptions);

            builder.AddInstrumentation(() => new HttpClientInstrumentation(httpClientOptions));
            builder.AddSource(HttpHandlerDiagnosticListener.ActivitySourceName);
            builder.AddLegacySource("System.Net.Http.HttpRequestOut");

#if NETFRAMEWORK
            builder.AddHttpWebRequestInstrumentation(configureHttpWebRequestInstrumentationOptions);
#endif
            return(builder);
        }