diff --git a/build/scripts/Packaging.fs b/build/scripts/Packaging.fs index a094c01..ed1f3c0 100644 --- a/build/scripts/Packaging.fs +++ b/build/scripts/Packaging.fs @@ -80,7 +80,7 @@ let downloadArtifacts (_:ParseResults) = async { Console.WriteLine($"Retrieving {asset.Name}"); let! fileData = httpClient.GetByteArrayAsync(asset.BrowserDownloadUrl) |> Async.AwaitTask - Console.WriteLine($"Saveing %i{fileData.Length} bytes to {f.FullName}") + Console.WriteLine($"Saving %i{fileData.Length} bytes to {f.FullName}") File.WriteAllBytes(f.FullName, fileData) f.Refresh() } |> Async.RunSynchronously diff --git a/examples/Example.AutoInstrumentation/README.md b/examples/Example.AutoInstrumentation/README.md index 42c48b9..7842eee 100644 --- a/examples/Example.AutoInstrumentation/README.md +++ b/examples/Example.AutoInstrumentation/README.md @@ -2,7 +2,7 @@ This is a very minimal .NET application that we use to validate our OpenTelemetry plugin loads correctly -This happens automated through our testing setup: +This happens automatically through our testing setup: ```bash $ ./build.sh test --test-suite=integration @@ -10,17 +10,14 @@ $ ./build.sh test --test-suite=integration Which ends up running the tests in `/tests/AutoInstrumentation.IntegrationTests` - -To quickly see the `DockerFile` in action run the following from the root of this repository. - +To quickly see the `DockerFile` in action run the following from the root of this repository. ```bash $ docker build -t example.autoinstrumentation:latest -f examples/Example.AutoInstrumentation/Dockerfile --no-cache . && \ - docker run -it --rm -p 5000:8080 --name autoin example.autoinstrumentation:latest + docker run -it --rm -p 5000:8080 --name autoin example.autoinstrumentation:latest ``` - ```bash docker build -t distribution.autoinstrumentation:latest -f examples/Example.AutoInstrumentation/distribution.Dockerfile --platform linux/arm64 --no-cache . && \ - docker run -it --rm -p 5000:8080 --name distri --platform linux/arm64 distribution.autoinstrumentation:latest + docker run -it --rm -p 5000:8080 --name distri --platform linux/arm64 distribution.autoinstrumentation:latest ``` \ No newline at end of file diff --git a/src/Elastic.OpenTelemetry/AutoInstrumentationPlugin.cs b/src/Elastic.OpenTelemetry/AutoInstrumentationPlugin.cs index 4b8a1f3..6bec4b5 100644 --- a/src/Elastic.OpenTelemetry/AutoInstrumentationPlugin.cs +++ b/src/Elastic.OpenTelemetry/AutoInstrumentationPlugin.cs @@ -52,7 +52,7 @@ public void MeterProviderInitialized(MeterProvider meterProvider) /// To configure tracing SDK before Auto Instrumentation configured SDK public TracerProviderBuilder BeforeConfigureTracerProvider(TracerProviderBuilder builder) => - builder.UseElasticDefaults(_skipOtlp, _logger); + builder.UseAutoInstrumentationElasticDefaults(_skipOtlp, _logger); /// To configure tracing SDK after Auto Instrumentation configured SDK public TracerProviderBuilder AfterConfigureTracerProvider(TracerProviderBuilder builder) => diff --git a/src/Elastic.OpenTelemetry/Extensions/TracerProviderBuilderExtensions.cs b/src/Elastic.OpenTelemetry/Extensions/TracerProviderBuilderExtensions.cs index 7622239..904a093 100644 --- a/src/Elastic.OpenTelemetry/Extensions/TracerProviderBuilderExtensions.cs +++ b/src/Elastic.OpenTelemetry/Extensions/TracerProviderBuilderExtensions.cs @@ -59,4 +59,23 @@ public static TracerProviderBuilder UseElasticDefaults(this TracerProviderBuilde logger.LogConfiguredSignalProvider(nameof(Traces), nameof(TracerProviderBuilder)); return builder; } + + internal static TracerProviderBuilder UseAutoInstrumentationElasticDefaults(this TracerProviderBuilder builder, bool skipOtlp = false, ILogger? logger = null) + { + logger ??= NullLogger.Instance; + + builder + .AddHttpClientInstrumentation() + .AddGrpcClientInstrumentation() + .AddEntityFrameworkCoreInstrumentation() + .AddSqlClientInstrumentation() + .AddSource("Elastic.Transport") + .AddElasticProcessors(logger); + + if (!skipOtlp) + builder.AddOtlpExporter(); + + logger.LogConfiguredSignalProvider(nameof(Traces), nameof(TracerProviderBuilder)); + return builder; + } }