/// <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); }
public EntityFrameworkDiagnosticListener(string sourceName, EntityFrameworkInstrumentationOptions options) : base(sourceName) { this.options = options ?? new EntityFrameworkInstrumentationOptions(); }