コード例 #1
0
 internal static TracerProviderBuilder AddHttpClientInstrumentation(
     this TracerProviderBuilder builder,
     HttpClientInstrumentation instrumentation)
 {
     builder.AddSource(HttpHandlerDiagnosticListener.ActivitySourceName);
     builder.AddLegacySource("System.Net.Http.HttpRequestOut");
     return(builder.AddInstrumentation(() => instrumentation));
 }
コード例 #2
0
 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);
 }
コード例 #3
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>
        /// Configures OpenTelemetry to listen for the Activities created by the client and server interceptors.
        /// </summary>
        /// <param name="builder">The builder.</param>
        /// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
        public static TracerProviderBuilder AddGrpcCoreInstrumentation(
            this TracerProviderBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            return(builder.AddSource(GrpcCoreInstrumentation.ActivitySourceName));
        }
コード例 #5
0
        /// <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));
        }
コード例 #6
0
        /// <summary>
        /// Enables the automatic data collection for Blueprint and all modules.
        /// </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 AddBlueprintInstrumentation(
            this TracerProviderBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            // Enables all Blueprint activities (Blueprint or Blueprint.[Module]).
            builder.AddSource(BlueprintActivitySource.ActivitySourceName + "*");

            return(builder);
        }
コード例 #7
0
        /// <summary>
        /// Enables HttpClient and HttpWebRequest instrumentation.
        /// </summary>
        /// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
        /// <param name="configureHttpWebRequestInstrumentationOptions">HttpWebRequest configuration options.</param>
        /// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
        public static TracerProviderBuilder AddHttpClientInstrumentation(
            this TracerProviderBuilder builder,
            Action <HttpWebRequestInstrumentationOptions> configureHttpWebRequestInstrumentationOptions = null)
        {
            HttpWebRequestInstrumentationOptions options = new HttpWebRequestInstrumentationOptions();

            configureHttpWebRequestInstrumentationOptions?.Invoke(options);

            HttpWebRequestActivitySource.Options = options;

            builder.AddSource(HttpWebRequestActivitySource.ActivitySourceName);

            return(builder);
        }
コード例 #8
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);
        }
        /// <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);
        }
        /// <summary>
        /// Add AWS Lambda configurations.
        /// </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 AddAWSLambdaConfigurations(this TracerProviderBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            builder.AddSource(AWSLambdaUtils.ActivitySourceName);
            builder.SetResourceBuilder(ResourceBuilder
                                       .CreateEmpty()
                                       .AddService(AWSLambdaUtils.GetFunctionName(), null, null, false)
                                       .AddTelemetrySdk()
                                       .AddAttributes(AWSLambdaResourceDetector.Detect()));

            return(builder);
        }
コード例 #11
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);
        }
コード例 #12
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);
        }
コード例 #13
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);
        }
コード例 #14
0
        /// <summary>
        /// Enables AWS Instrumentation.
        /// </summary>
        /// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
        /// <param name="configure">AWS client configuration options.</param>
        /// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
        public static TracerProviderBuilder AddAWSInstrumentation(
            this TracerProviderBuilder builder,
            Action <AWSClientInstrumentationOptions> configure = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var awsClientOptions = new AWSClientInstrumentationOptions();

            configure?.Invoke(awsClientOptions);

            new AWSClientsInstrumentation(awsClientOptions);
            builder.AddSource("Amazon.AWS.AWSClientInstrumentation");
            return(builder);
        }
コード例 #15
0
        /// <summary>
        /// Enables the incoming requests automatic data collection for OWIN.
        /// </summary>
        /// <param name="builder"><see cref="TracerProviderBuilder"/> being configured.</param>
        /// <param name="configureOwinInstrumentationOptions">OWIN Request configuration options.</param>
        /// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
        public static TracerProviderBuilder AddOwinInstrumentation(
            this TracerProviderBuilder builder,
            Action <OwinInstrumentationOptions> configureOwinInstrumentationOptions = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var owinOptions = new OwinInstrumentationOptions();

            configureOwinInstrumentationOptions?.Invoke(owinOptions);

            OwinInstrumentationActivitySource.Options = owinOptions;

            return(builder.AddSource(OwinInstrumentationActivitySource.ActivitySourceName));
        }
コード例 #16
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);
        }
コード例 #17
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);
        }
コード例 #18
0
        /// <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);
        }
        /// <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);
        }
コード例 #20
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);
        }
        /// <summary>
        /// Enables the outgoing requests automatic data collection for WCF.
        /// </summary>
        /// <param name="builder"><see cref="TracerProviderBuilderExtensions"/> being configured.</param>
        /// <param name="configure">Wcf configuration options.</param>
        /// <returns>The instance of <see cref="TracerProviderBuilderExtensions"/> to chain the calls.</returns>
        public static TracerProviderBuilder AddWcfInstrumentation(this TracerProviderBuilder builder, Action <WcfInstrumentationOptions> configure = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (WcfInstrumentationActivitySource.Options != null)
            {
                throw new NotSupportedException("WCF instrumentation has already been registered and doesn't support multiple registrations.");
            }

            var options = new WcfInstrumentationOptions();

            configure?.Invoke(options);

            WcfInstrumentationActivitySource.Options = options;

            return(builder.AddSource(WcfInstrumentationActivitySource.ActivitySourceName));
        }
コード例 #22
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);
        }
コード例 #23
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(() => new HttpClientInstrumentation(httpClientOptions));
            builder.AddSource(HttpHandlerDiagnosticListener.ActivitySourceName);
            builder.AddLegacySource("System.Net.Http.HttpRequestOut");

#if NETFRAMEWORK
            builder.AddHttpWebRequestInstrumentation(configureHttpWebRequestInstrumentationOptions);
#endif
            return(builder);
        }
コード例 #24
0
 public static TracerProviderBuilder AddMongoDBInstrumentation(this TracerProviderBuilder builder)
 => builder.AddSource("MongoDB.Driver.Core.Extensions.DiagnosticSources");