public HttpInListener(string name, AspNetCoreInstrumentationOptions options, ActivitySourceAdapter activitySource)
     : base(name)
 {
     this.hostingSupportsW3C = typeof(HttpRequest).Assembly.GetName().Version.Major >= 3;
     this.options            = options ?? throw new ArgumentNullException(nameof(options));
     this.activitySource     = activitySource;
 }
        public HttpInListener(AspNetCoreInstrumentationOptions options)
            : base(DiagnosticSourceName)
        {
            Guard.ThrowIfNull(options, nameof(options));

            this.options = options;
        }
        public void PropagatorSetDoesNotAffectGlobalPropagators()
        {
            var options = new AspNetCoreInstrumentationOptions();

            options.Propagator = new TraceContextPropagator();
            Assert.NotSame(Propagators.DefaultTextMapPropagator, options.Propagator);
        }
 private static TracerProviderBuilder AddAspNetCoreInstrumentation(
     TracerProviderBuilder builder,
     AspNetCoreInstrumentationOptions options,
     Action<AspNetCoreInstrumentationOptions> configure = null)
 {
     configure?.Invoke(options);
     return AddAspNetCoreInstrumentation(
         builder,
         new AspNetCoreInstrumentation(new HttpInListener(options)));
 }
        /// <summary>
        /// Enables the incoming requests automatic data collection for Asp.Net Core.
        /// </summary>
        /// <param name="builder"><see cref="OpenTelemetryBuilder"/> being configured.</param>
        /// <param name="configureAspNetCoreInstrumentationOptions">ASP.NET Core Request configuration options.</param>
        /// <returns>The instance of <see cref="OpenTelemetryBuilder"/> to chain the calls.</returns>
        public static OpenTelemetryBuilder AddRequestInstrumentation(
            this OpenTelemetryBuilder 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);
        }
Ejemplo n.º 6
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.AddDiagnosticSourceInstrumentation((activitySource) => new AspNetCoreInstrumentation(activitySource, aspnetCoreOptions));

            return(builder);
        }
Ejemplo n.º 7
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 <AspNetCoreInstrumentationOptions> configure)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

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

            var options = new AspNetCoreInstrumentationOptions();

            configure(options);

            return(builder.AddInstrumentation(t => new AspNetCoreInstrumentation(t, options)));
        }
Ejemplo n.º 8
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 incoming requests automatic data collection for Asp.Net Core.
        /// </summary>
        /// <param name="builder"><see cref="OpenTelemetryBuilder"/> being configured.</param>
        /// <param name="configureAspNetCoreInstrumentationOptions">ASP.NET Core Request configuration options.</param>
        /// <returns>The instance of <see cref="OpenTelemetryBuilder"/> to chain the calls.</returns>
        public static OpenTelemetryBuilder AddRequestInstrumentation(
            this OpenTelemetryBuilder builder,
            Action <AspNetCoreInstrumentationOptions> configureAspNetCoreInstrumentationOptions = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

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

            configureAspNetCoreInstrumentationOptions?.Invoke(aspnetCoreOptions);

            builder.AddInstrumentation(() => new AspNetCoreInstrumentation(aspnetCoreOptions));

            return(builder);
        }
Ejemplo n.º 10
0
 public HttpInListener(string name, Tracer tracer, AspNetCoreInstrumentationOptions options)
     : base(name, tracer)
 {
     this.hostingSupportsW3C = typeof(HttpRequest).Assembly.GetName().Version.Major >= 3;
     this.options            = options ?? throw new ArgumentNullException(nameof(options));
 }
Ejemplo n.º 11
0
 public TestHttpInListener(AspNetCoreInstrumentationOptions options)
     : base(options)
 {
 }
Ejemplo n.º 12
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
            builder.AddLegacySource(HttpInListener.ActivityNameByHttpInListener); // for the sibling activities created by the instrumentation library
            return(builder.AddInstrumentation(() => instrumentation));
        }
        public void DefaultPropagatorIsFromPropagators()
        {
            var options = new AspNetCoreInstrumentationOptions();

            Assert.Same(Propagators.DefaultTextMapPropagator, options.Propagator);
        }
 public HttpInListener(AspNetCoreInstrumentationOptions options)
     : base(DiagnosticSourceName)
 {
     this.options = options ?? throw new ArgumentNullException(nameof(options));
 }