diff --git a/docs/logs/customizing-the-sdk/Program.cs b/docs/logs/customizing-the-sdk/Program.cs index b6b3afd07d..5ef85ad0bd 100644 --- a/docs/logs/customizing-the-sdk/Program.cs +++ b/docs/logs/customizing-the-sdk/Program.cs @@ -30,7 +30,7 @@ public static void Main() builder.AddOpenTelemetry(options => { options.IncludeScopes = true; - options.ConfigureResource(r => r.AddService(serviceName: "MyService", serviceVersion: "1.0.0")); + options.ConfigureResourceBuilder(r => r.AddService(serviceName: "MyService", serviceVersion: "1.0.0")); options.AddConsoleExporter(); }); }); diff --git a/docs/logs/customizing-the-sdk/README.md b/docs/logs/customizing-the-sdk/README.md index 8b1d9bcb94..dc6ec39ef3 100644 --- a/docs/logs/customizing-the-sdk/README.md +++ b/docs/logs/customizing-the-sdk/README.md @@ -52,16 +52,16 @@ var loggerFactory = LoggerFactory.Create(builder => For more information on Processors, please review [Extending the SDK](../extending-the-sdk/README.md#processor) -### ConfigureResource +### ConfigureResourceBuilder [Resource](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md) is the immutable representation of the entity producing the telemetry. If no `Resource` is explicitly configured, the default is to use a resource indicating this [Telemetry SDK](https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/resource/semantic_conventions#telemetry-sdk). -The `ConfigureResource` method on `OpenTelemetryLoggerOptions` can be used to -configure the `ResourceBuilder`. It is not possible to change the resources -*after* creating the `LoggerFactory`. +The `ConfigureResourceBuilder` method on `OpenTelemetryLoggerOptions` can be +used to configure the `ResourceBuilder`. It is not possible to change the +resources *after* creating the `LoggerFactory`. The snippet below shows configuring the `ResourceBuilder` of the provider. @@ -70,7 +70,7 @@ var loggerFactory = LoggerFactory.Create(builder => { builder.AddOpenTelemetry(options => { - options.ConfigureResource(r => r.AddService( + options.ConfigureResourceBuilder(r => r.AddService( serviceName: "MyService", serviceVersion: "1.0.0" )); diff --git a/examples/AspNetCore/Program.cs b/examples/AspNetCore/Program.cs index ed5a4fdef4..7e6c66c0a7 100644 --- a/examples/AspNetCore/Program.cs +++ b/examples/AspNetCore/Program.cs @@ -45,7 +45,7 @@ builder.Services.AddOpenTelemetryTracing(options => { options - .ConfigureResource(configureResource) + .ConfigureResourceBuilder(configureResource) .SetSampler(new AlwaysOnSampler()) .AddHttpClientInstrumentation() .AddAspNetCoreInstrumentation(); @@ -89,7 +89,7 @@ builder.Logging.AddOpenTelemetry(options => { - options.ConfigureResource(configureResource); + options.ConfigureResourceBuilder(configureResource); var logExporter = builder.Configuration.GetValue("UseLogExporter").ToLowerInvariant(); switch (logExporter) { @@ -118,7 +118,7 @@ builder.Services.AddOpenTelemetryMetrics(options => { - options.ConfigureResource(configureResource) + options.ConfigureResourceBuilder(configureResource) .AddRuntimeInstrumentation() .AddHttpClientInstrumentation() .AddAspNetCoreInstrumentation(); diff --git a/examples/Console/TestConsoleExporter.cs b/examples/Console/TestConsoleExporter.cs index 031e6fc4e0..8c6d970291 100644 --- a/examples/Console/TestConsoleExporter.cs +++ b/examples/Console/TestConsoleExporter.cs @@ -39,7 +39,7 @@ private static object RunWithActivitySource() // and use Console exporter. using var tracerProvider = Sdk.CreateTracerProviderBuilder() .AddSource("Samples.SampleClient", "Samples.SampleServer") - .ConfigureResource(res => res.AddService("console-test")) + .ConfigureResourceBuilder(res => res.AddService("console-test")) .AddProcessor(new MyProcessor()) // This must be added before ConsoleExporter .AddConsoleExporter() .Build(); diff --git a/examples/Console/TestHttpClient.cs b/examples/Console/TestHttpClient.cs index ba122c5f09..1b8dcb8148 100644 --- a/examples/Console/TestHttpClient.cs +++ b/examples/Console/TestHttpClient.cs @@ -34,7 +34,7 @@ internal static object Run() using var tracerProvider = Sdk.CreateTracerProviderBuilder() .AddHttpClientInstrumentation() - .ConfigureResource(r => r.AddService("http-service-example")) + .ConfigureResourceBuilder(r => r.AddService("http-service-example")) .AddSource("http-client-test") .AddConsoleExporter() .Build(); diff --git a/examples/Console/TestInMemoryExporter.cs b/examples/Console/TestInMemoryExporter.cs index 5cfbe32741..d5075ffa1a 100644 --- a/examples/Console/TestInMemoryExporter.cs +++ b/examples/Console/TestInMemoryExporter.cs @@ -51,7 +51,7 @@ private static void RunWithActivitySource(ICollection exportedItems) // and use InMemory exporter. using var tracerProvider = Sdk.CreateTracerProviderBuilder() .AddSource("Samples.SampleClient", "Samples.SampleServer") - .ConfigureResource(r => r.AddService("inmemory-test")) + .ConfigureResourceBuilder(r => r.AddService("inmemory-test")) .AddInMemoryExporter(exportedItems) .Build(); diff --git a/examples/Console/TestJaegerExporter.cs b/examples/Console/TestJaegerExporter.cs index aca3909886..1248b6c38e 100644 --- a/examples/Console/TestJaegerExporter.cs +++ b/examples/Console/TestJaegerExporter.cs @@ -56,7 +56,7 @@ internal static object RunWithActivity(string host, int port) // Enable OpenTelemetry for the sources "Samples.SampleServer" and "Samples.SampleClient" // and use the Jaeger exporter. using var tracerProvider = Sdk.CreateTracerProviderBuilder() - .ConfigureResource(r => r.AddService("jaeger-test")) + .ConfigureResourceBuilder(r => r.AddService("jaeger-test")) .AddSource("Samples.SampleClient", "Samples.SampleServer") .AddJaegerExporter(o => { diff --git a/examples/Console/TestMetrics.cs b/examples/Console/TestMetrics.cs index 78ee9cbed9..60a7af7e55 100644 --- a/examples/Console/TestMetrics.cs +++ b/examples/Console/TestMetrics.cs @@ -33,7 +33,7 @@ internal static object Run(MetricsOptions options) using var meter = new Meter("TestMeter"); var providerBuilder = Sdk.CreateMeterProviderBuilder() - .ConfigureResource(r => r.AddService("myservice")) + .ConfigureResourceBuilder(r => r.AddService("myservice")) .AddMeter(meter.Name); // All instruments from this meter are enabled. if (options.UseExporter.Equals("otlp", StringComparison.OrdinalIgnoreCase)) diff --git a/examples/Console/TestOTelShimWithConsoleExporter.cs b/examples/Console/TestOTelShimWithConsoleExporter.cs index 31bb3c85f6..bebb4e2c5d 100644 --- a/examples/Console/TestOTelShimWithConsoleExporter.cs +++ b/examples/Console/TestOTelShimWithConsoleExporter.cs @@ -28,7 +28,7 @@ internal static object Run(OpenTelemetryShimOptions options) // and use a single pipeline with a custom MyProcessor, and Console exporter. using var tracerProvider = Sdk.CreateTracerProviderBuilder() .AddSource("MyCompany.MyProduct.MyWebServer") - .ConfigureResource(r => r.AddService("MyServiceName")) + .ConfigureResourceBuilder(r => r.AddService("MyServiceName")) .AddConsoleExporter() .Build(); diff --git a/examples/Console/TestOpenTracingShim.cs b/examples/Console/TestOpenTracingShim.cs index 7361c3aa4d..9ade72380c 100644 --- a/examples/Console/TestOpenTracingShim.cs +++ b/examples/Console/TestOpenTracingShim.cs @@ -31,7 +31,7 @@ internal static object Run(OpenTracingShimOptions options) // and use Console exporter. using var tracerProvider = Sdk.CreateTracerProviderBuilder() .AddSource("MyCompany.MyProduct.MyWebServer") - .ConfigureResource(r => r.AddService("MyServiceName")) + .ConfigureResourceBuilder(r => r.AddService("MyServiceName")) .AddConsoleExporter() .Build(); diff --git a/examples/Console/TestOtlpExporter.cs b/examples/Console/TestOtlpExporter.cs index f5417e77c6..d753146810 100644 --- a/examples/Console/TestOtlpExporter.cs +++ b/examples/Console/TestOtlpExporter.cs @@ -71,7 +71,7 @@ private static object RunWithActivitySource(string endpoint, string protocol) // and use OTLP exporter. using var tracerProvider = Sdk.CreateTracerProviderBuilder() .AddSource("Samples.SampleClient", "Samples.SampleServer") - .ConfigureResource(r => r.AddService("otlp-test")) + .ConfigureResourceBuilder(r => r.AddService("otlp-test")) .AddOtlpExporter(opt => { // If endpoint was not specified, the proper one will be selected according to the protocol. diff --git a/examples/Console/TestZipkinExporter.cs b/examples/Console/TestZipkinExporter.cs index 0f6bbce227..7f12030e61 100644 --- a/examples/Console/TestZipkinExporter.cs +++ b/examples/Console/TestZipkinExporter.cs @@ -39,7 +39,7 @@ internal static object Run(string zipkinUri) // and use the Zipkin exporter. using var tracerProvider = Sdk.CreateTracerProviderBuilder() .AddSource("Samples.SampleClient", "Samples.SampleServer") - .ConfigureResource(r => r.AddService("zipkin-test")) + .ConfigureResourceBuilder(r => r.AddService("zipkin-test")) .AddZipkinExporter(o => { o.Endpoint = new Uri(zipkinUri); diff --git a/examples/GrpcService/Startup.cs b/examples/GrpcService/Startup.cs index c7034011b0..6c2c0d98b2 100644 --- a/examples/GrpcService/Startup.cs +++ b/examples/GrpcService/Startup.cs @@ -45,7 +45,7 @@ public void ConfigureServices(IServiceCollection services) { case "jaeger": services.AddOpenTelemetryTracing((builder) => builder - .ConfigureResource(r => r.AddService(this.Configuration.GetValue("Jaeger:ServiceName"))) + .ConfigureResourceBuilder(r => r.AddService(this.Configuration.GetValue("Jaeger:ServiceName"))) .AddAspNetCoreInstrumentation() .AddJaegerExporter(jaegerOptions => { diff --git a/src/OpenTelemetry/.publicApi/net462/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/net462/PublicAPI.Unshipped.txt index ecaf006aa4..c221cc924a 100644 --- a/src/OpenTelemetry/.publicApi/net462/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry/.publicApi/net462/PublicAPI.Unshipped.txt @@ -10,6 +10,6 @@ OpenTelemetry.Logs.LogRecord.TraceState.set -> void OpenTelemetry.Logs.OpenTelemetryLoggerProvider.ForceFlush(int timeoutMilliseconds = -1) -> bool OpenTelemetry.Logs.OpenTelemetryLoggerProvider.OpenTelemetryLoggerProvider() -> void OpenTelemetry.Logs.OpenTelemetryLoggerProvider.OpenTelemetryLoggerProvider(System.Action! configure) -> void -OpenTelemetry.Logs.OpenTelemetryLoggerOptions.ConfigureResource(System.Action! configure) -> OpenTelemetry.Logs.OpenTelemetryLoggerOptions! -~static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.ConfigureResource(this OpenTelemetry.Metrics.MeterProviderBuilder meterProviderBuilder, System.Action configure) -> OpenTelemetry.Metrics.MeterProviderBuilder -~static OpenTelemetry.Trace.TracerProviderBuilderExtensions.ConfigureResource(this OpenTelemetry.Trace.TracerProviderBuilder tracerProviderBuilder, System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder +OpenTelemetry.Logs.OpenTelemetryLoggerOptions.ConfigureResourceBuilder(System.Action! configure) -> OpenTelemetry.Logs.OpenTelemetryLoggerOptions! +~static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.ConfigureResourceBuilder(this OpenTelemetry.Metrics.MeterProviderBuilder meterProviderBuilder, System.Action configure) -> OpenTelemetry.Metrics.MeterProviderBuilder +~static OpenTelemetry.Trace.TracerProviderBuilderExtensions.ConfigureResourceBuilder(this OpenTelemetry.Trace.TracerProviderBuilder tracerProviderBuilder, System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder diff --git a/src/OpenTelemetry/.publicApi/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/net6.0/PublicAPI.Unshipped.txt index 43156ee3c3..38c68b0e04 100644 --- a/src/OpenTelemetry/.publicApi/net6.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry/.publicApi/net6.0/PublicAPI.Unshipped.txt @@ -7,9 +7,9 @@ OpenTelemetry.Logs.LogRecord.Timestamp.set -> void OpenTelemetry.Logs.LogRecord.TraceFlags.set -> void OpenTelemetry.Logs.LogRecord.TraceId.set -> void OpenTelemetry.Logs.LogRecord.TraceState.set -> void -OpenTelemetry.Logs.OpenTelemetryLoggerOptions.ConfigureResource(System.Action! configure) -> OpenTelemetry.Logs.OpenTelemetryLoggerOptions! +OpenTelemetry.Logs.OpenTelemetryLoggerOptions.ConfigureResourceBuilder(System.Action! configure) -> OpenTelemetry.Logs.OpenTelemetryLoggerOptions! OpenTelemetry.Logs.OpenTelemetryLoggerProvider.ForceFlush(int timeoutMilliseconds = -1) -> bool OpenTelemetry.Logs.OpenTelemetryLoggerProvider.OpenTelemetryLoggerProvider() -> void OpenTelemetry.Logs.OpenTelemetryLoggerProvider.OpenTelemetryLoggerProvider(System.Action! configure) -> void -~static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.ConfigureResource(this OpenTelemetry.Metrics.MeterProviderBuilder meterProviderBuilder, System.Action configure) -> OpenTelemetry.Metrics.MeterProviderBuilder -~static OpenTelemetry.Trace.TracerProviderBuilderExtensions.ConfigureResource(this OpenTelemetry.Trace.TracerProviderBuilder tracerProviderBuilder, System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder \ No newline at end of file +~static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.ConfigureResourceBuilder(this OpenTelemetry.Metrics.MeterProviderBuilder meterProviderBuilder, System.Action configure) -> OpenTelemetry.Metrics.MeterProviderBuilder +~static OpenTelemetry.Trace.TracerProviderBuilderExtensions.ConfigureResourceBuilder(this OpenTelemetry.Trace.TracerProviderBuilder tracerProviderBuilder, System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder diff --git a/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt index ecaf006aa4..c221cc924a 100644 --- a/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt @@ -10,6 +10,6 @@ OpenTelemetry.Logs.LogRecord.TraceState.set -> void OpenTelemetry.Logs.OpenTelemetryLoggerProvider.ForceFlush(int timeoutMilliseconds = -1) -> bool OpenTelemetry.Logs.OpenTelemetryLoggerProvider.OpenTelemetryLoggerProvider() -> void OpenTelemetry.Logs.OpenTelemetryLoggerProvider.OpenTelemetryLoggerProvider(System.Action! configure) -> void -OpenTelemetry.Logs.OpenTelemetryLoggerOptions.ConfigureResource(System.Action! configure) -> OpenTelemetry.Logs.OpenTelemetryLoggerOptions! -~static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.ConfigureResource(this OpenTelemetry.Metrics.MeterProviderBuilder meterProviderBuilder, System.Action configure) -> OpenTelemetry.Metrics.MeterProviderBuilder -~static OpenTelemetry.Trace.TracerProviderBuilderExtensions.ConfigureResource(this OpenTelemetry.Trace.TracerProviderBuilder tracerProviderBuilder, System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder +OpenTelemetry.Logs.OpenTelemetryLoggerOptions.ConfigureResourceBuilder(System.Action! configure) -> OpenTelemetry.Logs.OpenTelemetryLoggerOptions! +~static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.ConfigureResourceBuilder(this OpenTelemetry.Metrics.MeterProviderBuilder meterProviderBuilder, System.Action configure) -> OpenTelemetry.Metrics.MeterProviderBuilder +~static OpenTelemetry.Trace.TracerProviderBuilderExtensions.ConfigureResourceBuilder(this OpenTelemetry.Trace.TracerProviderBuilder tracerProviderBuilder, System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder diff --git a/src/OpenTelemetry/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt b/src/OpenTelemetry/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt index 43156ee3c3..38c68b0e04 100644 --- a/src/OpenTelemetry/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry/.publicApi/netstandard2.1/PublicAPI.Unshipped.txt @@ -7,9 +7,9 @@ OpenTelemetry.Logs.LogRecord.Timestamp.set -> void OpenTelemetry.Logs.LogRecord.TraceFlags.set -> void OpenTelemetry.Logs.LogRecord.TraceId.set -> void OpenTelemetry.Logs.LogRecord.TraceState.set -> void -OpenTelemetry.Logs.OpenTelemetryLoggerOptions.ConfigureResource(System.Action! configure) -> OpenTelemetry.Logs.OpenTelemetryLoggerOptions! +OpenTelemetry.Logs.OpenTelemetryLoggerOptions.ConfigureResourceBuilder(System.Action! configure) -> OpenTelemetry.Logs.OpenTelemetryLoggerOptions! OpenTelemetry.Logs.OpenTelemetryLoggerProvider.ForceFlush(int timeoutMilliseconds = -1) -> bool OpenTelemetry.Logs.OpenTelemetryLoggerProvider.OpenTelemetryLoggerProvider() -> void OpenTelemetry.Logs.OpenTelemetryLoggerProvider.OpenTelemetryLoggerProvider(System.Action! configure) -> void -~static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.ConfigureResource(this OpenTelemetry.Metrics.MeterProviderBuilder meterProviderBuilder, System.Action configure) -> OpenTelemetry.Metrics.MeterProviderBuilder -~static OpenTelemetry.Trace.TracerProviderBuilderExtensions.ConfigureResource(this OpenTelemetry.Trace.TracerProviderBuilder tracerProviderBuilder, System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder \ No newline at end of file +~static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.ConfigureResourceBuilder(this OpenTelemetry.Metrics.MeterProviderBuilder meterProviderBuilder, System.Action configure) -> OpenTelemetry.Metrics.MeterProviderBuilder +~static OpenTelemetry.Trace.TracerProviderBuilderExtensions.ConfigureResourceBuilder(this OpenTelemetry.Trace.TracerProviderBuilder tracerProviderBuilder, System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder diff --git a/src/OpenTelemetry/CHANGELOG.md b/src/OpenTelemetry/CHANGELOG.md index 3b5674e684..6ab5616492 100644 --- a/src/OpenTelemetry/CHANGELOG.md +++ b/src/OpenTelemetry/CHANGELOG.md @@ -25,6 +25,11 @@ * Handle possible exception when initializing the default service name. ([#3405](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3405)) +* Add `ConfigureResourceBuilder` which can replace SetResourceBuilder more + succinctly in most cases and has greater flexibility (applies to + TracerProviderBuilder, MeterProviderBuilder, OpenTelemetryLoggingOptions). + ([#3307](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3307)) + * `LogRecord` instances are now reused to reduce memory pressure ([#3385](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3385)) @@ -41,10 +46,6 @@ Released 2022-June-1 * Swallow `ObjectDisposedException` in `BatchExportProcessor` and `PeriodicExportingMetricReader`. ([#3291](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3291)) -* Add `ConfigureResource` which can replace SetResourceBuilder more succinctly - in most cases and has greater flexibility (applies to - TracerProvicerBuilder, MeterProviderBuilder, OpenTelemetryLoggingOptions). - ([#3307](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3307)) ## 1.3.0-beta.2 diff --git a/src/OpenTelemetry/Logs/OpenTelemetryLoggerOptions.cs b/src/OpenTelemetry/Logs/OpenTelemetryLoggerOptions.cs index d20fcce2b4..2bbf5ea4f2 100644 --- a/src/OpenTelemetry/Logs/OpenTelemetryLoggerOptions.cs +++ b/src/OpenTelemetry/Logs/OpenTelemetryLoggerOptions.cs @@ -74,7 +74,7 @@ public OpenTelemetryLoggerOptions AddProcessor(BaseProcessor processo /// /// Sets the from which the Resource associated with /// this provider is built from. Overwrites currently set ResourceBuilder. - /// You should usually use instead + /// You should usually use instead /// (call if desired). /// /// from which Resource will be built. @@ -93,7 +93,7 @@ public OpenTelemetryLoggerOptions SetResourceBuilder(ResourceBuilder resourceBui /// /// An action which modifies the provided in-place. /// Returns for chaining. - public OpenTelemetryLoggerOptions ConfigureResource(Action configure) + public OpenTelemetryLoggerOptions ConfigureResourceBuilder(Action configure) { Guard.ThrowIfNull(configure, nameof(configure)); configure(this.ResourceBuilder); diff --git a/src/OpenTelemetry/Metrics/MeterProviderBuilderExtensions.cs b/src/OpenTelemetry/Metrics/MeterProviderBuilderExtensions.cs index c9ab472671..506285ef8e 100644 --- a/src/OpenTelemetry/Metrics/MeterProviderBuilderExtensions.cs +++ b/src/OpenTelemetry/Metrics/MeterProviderBuilderExtensions.cs @@ -183,7 +183,7 @@ public static MeterProviderBuilder SetMaxMetricPointsPerMetricStream(this MeterP /// /// Sets the from which the Resource associated with /// this provider is built from. Overwrites currently set ResourceBuilder. - /// You should usually use instead + /// You should usually use instead /// (call if desired). /// /// MeterProviderBuilder instance. @@ -206,7 +206,7 @@ public static MeterProviderBuilder SetResourceBuilder(this MeterProviderBuilder /// MeterProviderBuilder instance. /// An action which modifies the provided in-place. /// Returns for chaining. - public static MeterProviderBuilder ConfigureResource(this MeterProviderBuilder meterProviderBuilder, Action configure) + public static MeterProviderBuilder ConfigureResourceBuilder(this MeterProviderBuilder meterProviderBuilder, Action configure) { Guard.ThrowIfNull(meterProviderBuilder, nameof(meterProviderBuilder)); Guard.ThrowIfNull(configure, nameof(configure)); diff --git a/src/OpenTelemetry/README.md b/src/OpenTelemetry/README.md index e51346cd85..44c01be2e9 100644 --- a/src/OpenTelemetry/README.md +++ b/src/OpenTelemetry/README.md @@ -238,12 +238,12 @@ is the immutable representation of the entity producing the telemetry. If no `Resource` is explicitly configured, the default is to use a resource indicating this [Telemetry SDK](https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/resource/semantic_conventions#telemetry-sdk). -The `ConfigureResource` method on `TracerProviderBuilder` can be used to set a -configure the resource on the provider. When the provider is built, it automatically -builds the final `Resource` from the configured `ResourceBuilder`. As with -samplers, there can only be a single `Resource` associated with a provider. -It is not possible to change the resource builder *after* the provider is -built, by calling the `Build()` method on the `TracerProviderBuilder`. +The `ConfigureResourceBuilder` method on `TracerProviderBuilder` can be used to +set a configure the resource on the provider. When the provider is built, it +automatically builds the final `Resource` from the configured `ResourceBuilder`. +As with samplers, there can only be a single `Resource` associated with a +provider. It is not possible to change the resource builder *after* the provider +is built, by calling the `Build()` method on the `TracerProviderBuilder`. `ResourceBuilder` offers various methods to construct resource comprising of multiple attributes from various sources. @@ -255,7 +255,7 @@ using OpenTelemetry.Resources; using OpenTelemetry.Trace; using var tracerProvider = Sdk.CreateTracerProviderBuilder() - .ConfigureResource(r => r.AddService("MyServiceName")) + .ConfigureResourceBuilder(r => r.AddService("MyServiceName")) .Build(); ``` diff --git a/src/OpenTelemetry/Trace/TracerProviderBuilderExtensions.cs b/src/OpenTelemetry/Trace/TracerProviderBuilderExtensions.cs index 24f26e98e0..8a2b134905 100644 --- a/src/OpenTelemetry/Trace/TracerProviderBuilderExtensions.cs +++ b/src/OpenTelemetry/Trace/TracerProviderBuilderExtensions.cs @@ -62,7 +62,7 @@ public static TracerProviderBuilder SetSampler(this TracerProviderBuilder tracer /// /// Sets the from which the Resource associated with /// this provider is built from. Overwrites currently set ResourceBuilder. - /// You should usually use instead + /// You should usually use instead /// (call if desired). /// /// TracerProviderBuilder instance. @@ -85,7 +85,7 @@ public static TracerProviderBuilder SetResourceBuilder(this TracerProviderBuilde /// TracerProviderBuilder instance. /// An action which modifies the provided in-place. /// Returns for chaining. - public static TracerProviderBuilder ConfigureResource(this TracerProviderBuilder tracerProviderBuilder, Action configure) + public static TracerProviderBuilder ConfigureResourceBuilder(this TracerProviderBuilder tracerProviderBuilder, Action configure) { Guard.ThrowIfNull(tracerProviderBuilder, nameof(tracerProviderBuilder)); Guard.ThrowIfNull(configure, nameof(configure)); diff --git a/test/Benchmarks/Instrumentation/InstrumentedHttpClientBenchmark.cs b/test/Benchmarks/Instrumentation/InstrumentedHttpClientBenchmark.cs index ff2555eaeb..9413e13c8f 100644 --- a/test/Benchmarks/Instrumentation/InstrumentedHttpClientBenchmark.cs +++ b/test/Benchmarks/Instrumentation/InstrumentedHttpClientBenchmark.cs @@ -52,7 +52,7 @@ public void GlobalSetup() this.tracerProvider = Sdk.CreateTracerProviderBuilder() .AddHttpClientInstrumentation() - .ConfigureResource(r => r.AddService(ServiceName)) + .ConfigureResourceBuilder(r => r.AddService(ServiceName)) .AddSource(SourceName) .Build(); diff --git a/test/OpenTelemetry.Tests/Trace/TracerProviderSdkTest.cs b/test/OpenTelemetry.Tests/Trace/TracerProviderSdkTest.cs index 7463df9584..227eaa8df7 100644 --- a/test/OpenTelemetry.Tests/Trace/TracerProviderSdkTest.cs +++ b/test/OpenTelemetry.Tests/Trace/TracerProviderSdkTest.cs @@ -1076,7 +1076,7 @@ public void TracerProviderSdkBuildsWithSDKResource(bool useConfigure) var tracerProvider = useConfigure ? Sdk.CreateTracerProviderBuilder().SetResourceBuilder( ResourceBuilder.CreateDefault().AddTelemetrySdk()).Build() : - Sdk.CreateTracerProviderBuilder().ConfigureResource(r => r.AddTelemetrySdk()).Build(); + Sdk.CreateTracerProviderBuilder().ConfigureResourceBuilder(r => r.AddTelemetrySdk()).Build(); var resource = tracerProvider.GetResource(); var attributes = resource.Attributes;