Skip to content

Commit

Permalink
Separate defaults for auto installation
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejgordon committed Dec 3, 2024
1 parent af51cc2 commit a5c07de
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build/scripts/Packaging.fs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ let downloadArtifacts (_:ParseResults<Build>) =
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
Expand Down
11 changes: 4 additions & 7 deletions examples/Example.AutoInstrumentation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,22 @@

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
```

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
```
2 changes: 1 addition & 1 deletion src/Elastic.OpenTelemetry/AutoInstrumentationPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit a5c07de

Please sign in to comment.