コード例 #1
0
        public HttpInListener(AspNetInstrumentationOptions options)
        {
            this.options = options ?? throw new ArgumentNullException(nameof(options));

            TelemetryHttpModule.Options.TextMapPropagator = Propagators.DefaultTextMapPropagator;

            TelemetryHttpModule.Options.OnRequestStartedCallback += this.OnStartActivity;
            TelemetryHttpModule.Options.OnRequestStoppedCallback += this.OnStopActivity;
            TelemetryHttpModule.Options.OnExceptionCallback      += this.OnException;
        }
コード例 #2
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);
        }
コード例 #3
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)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var aspnetOptions = new AspNetInstrumentationOptions();

            configureAspNetInstrumentationOptions?.Invoke(aspnetOptions);

            builder.AddInstrumentation((activitySource) => new AspNetInstrumentation(activitySource, aspnetOptions));

            return(builder);
        }
コード例 #4
0
        /// <summary>
        /// Enables the incoming requests automatic data collection.
        /// </summary>
        /// <param name="builder">Trace builder to use.</param>
        /// <param name="configure">Configuration options.</param>
        /// <returns>The instance of <see cref="TracerBuilder"/> to chain the calls.</returns>
        public static TracerBuilder AddRequestInstrumentation(this TracerBuilder builder, Action <AspNetInstrumentationOptions> configure)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (configure == null)
            {
                throw new ArgumentNullException(nameof(configure));
            }

            var options = new AspNetInstrumentationOptions();

            configure(options);

            return(builder.AddInstrumentation(t => new AspNetInstrumentation(t, options)));
        }
コード例 #5
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)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var aspnetOptions = new AspNetInstrumentationOptions();

            configureAspNetInstrumentationOptions?.Invoke(aspnetOptions);

            builder.AddInstrumentation(() => new AspNetInstrumentation(aspnetOptions));
            builder.AddSource(HttpInListener.ActivitySourceName);
            builder.AddLegacySource("Microsoft.AspNet.HttpReqIn");      // for the activities created by AspNetCore
            builder.AddLegacySource("ActivityCreatedByHttpInListener"); // for the sibling activities created by the instrumentation library

            return(builder);
        }
コード例 #6
0
        /// <summary>
        /// Enables the incoming requests automatic data collection for Asp.Net.
        /// </summary>
        /// <param name="builder"><see cref="OpenTelemetryBuilder"/> being configured.</param>
        /// <param name="configureAspNetInstrumentationOptions">ASP.NET Request configuration options.</param>
        /// <returns>The instance of <see cref="OpenTelemetryBuilder"/> to chain the calls.</returns>
        public static OpenTelemetryBuilder AddRequestInstrumentation(
            this OpenTelemetryBuilder builder,
            Action <AspNetInstrumentationOptions> configureAspNetInstrumentationOptions = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            // Asp.Net is not instrumented with ActivitySource, hence
            // it'll have a default ActivitySource with name string.Empty.
            builder.AddActivitySource(string.Empty);
            var aspnetOptions = new AspNetInstrumentationOptions();

            configureAspNetInstrumentationOptions?.Invoke(aspnetOptions);

            builder.AddInstrumentation(() => new AspNetInstrumentation(aspnetOptions));

            return(builder);
        }
コード例 #7
0
 public HttpInListener(string name, AspNetInstrumentationOptions options)
     : base(name)
 {
     this.options = options ?? throw new ArgumentNullException(nameof(options));
 }
コード例 #8
0
 public HttpInListener(string name, AspNetInstrumentationOptions options, ActivitySourceAdapter activitySource)
     : base(name)
 {
     this.options        = options ?? throw new ArgumentNullException(nameof(options));
     this.activitySource = activitySource;
 }