Skip to content

Commit

Permalink
Rename ConfigureResources to sg ConfigureResource.
Browse files Browse the repository at this point in the history
  • Loading branch information
Oberon00 committed Jun 13, 2022
1 parent 4d6e747 commit 1834277
Show file tree
Hide file tree
Showing 22 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion docs/logs/customizing-the-sdk/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static void Main()
builder.AddOpenTelemetry(options =>
{
options.IncludeScopes = true;
options.ConfigureResources(r => r.AddService(serviceName: "MyService", serviceVersion: "1.0.0"));
options.ConfigureResource(r => r.AddService(serviceName: "MyService", serviceVersion: "1.0.0"));
options.AddConsoleExporter();
});
});
Expand Down
6 changes: 3 additions & 3 deletions docs/logs/customizing-the-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ var loggerFactory = LoggerFactory.Create(builder =>

For more information on Processors, please review [Extending the SDK](../extending-the-sdk/README.md#processor)

### ConfigureResources
### ConfigureResource

[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 `ConfigureResources` method on `OpenTelemetryLoggerOptions` can be used to
The `ConfigureResource` method on `OpenTelemetryLoggerOptions` can be used to
configure the `ResourceBuilder`. It is not possible to change the resources
*after* creating the `LoggerFactory`.

Expand All @@ -70,7 +70,7 @@ var loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddOpenTelemetry(options =>
{
options.ConfigureResources(r => r.AddService(
options.ConfigureResource(r => r.AddService(
serviceName: "MyService",
serviceVersion: "1.0.0"
));
Expand Down
6 changes: 3 additions & 3 deletions examples/AspNetCore/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
builder.Services.AddOpenTelemetryTracing(options =>
{
options
.ConfigureResources(configureResources)
.ConfigureResource(configureResources)
.SetSampler(new AlwaysOnSampler())
.AddHttpClientInstrumentation()
.AddAspNetCoreInstrumentation();
Expand Down Expand Up @@ -89,7 +89,7 @@

builder.Logging.AddOpenTelemetry(options =>
{
options.ConfigureResources(configureResources);
options.ConfigureResource(configureResources);
var logExporter = builder.Configuration.GetValue<string>("UseLogExporter").ToLowerInvariant();
switch (logExporter)
{
Expand All @@ -115,7 +115,7 @@
// Metrics
builder.Services.AddOpenTelemetryMetrics(options =>
{
options.ConfigureResources(configureResources)
options.ConfigureResource(configureResources)
.AddHttpClientInstrumentation()
.AddAspNetCoreInstrumentation();

Expand Down
2 changes: 1 addition & 1 deletion examples/Console/TestConsoleExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private static object RunWithActivitySource()
// and use Console exporter.
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddSource("Samples.SampleClient", "Samples.SampleServer")
.ConfigureResources(res => res.AddService("console-test"))
.ConfigureResource(res => res.AddService("console-test"))
.AddProcessor(new MyProcessor()) // This must be added before ConsoleExporter
.AddConsoleExporter()
.Build();
Expand Down
2 changes: 1 addition & 1 deletion examples/Console/TestHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal static object Run()

using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddHttpClientInstrumentation()
.ConfigureResources(r => r.AddService("http-service-example"))
.ConfigureResource(r => r.AddService("http-service-example"))
.AddSource("http-client-test")
.AddConsoleExporter()
.Build();
Expand Down
2 changes: 1 addition & 1 deletion examples/Console/TestInMemoryExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private static void RunWithActivitySource(ICollection<Activity> exportedItems)
// and use InMemory exporter.
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddSource("Samples.SampleClient", "Samples.SampleServer")
.ConfigureResources(r => r.AddService("inmemory-test"))
.ConfigureResource(r => r.AddService("inmemory-test"))
.AddInMemoryExporter(exportedItems)
.Build();

Expand Down
2 changes: 1 addition & 1 deletion examples/Console/TestJaegerExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
.ConfigureResources(r => r.AddService("jaeger-test"))
.ConfigureResource(r => r.AddService("jaeger-test"))
.AddSource("Samples.SampleClient", "Samples.SampleServer")
.AddJaegerExporter(o =>
{
Expand Down
2 changes: 1 addition & 1 deletion examples/Console/TestMetrics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal static object Run(MetricsOptions options)
using var meter = new Meter("TestMeter");

var providerBuilder = Sdk.CreateMeterProviderBuilder()
.ConfigureResources(r => r.AddService("myservice"))
.ConfigureResource(r => r.AddService("myservice"))
.AddMeter(meter.Name); // All instruments from this meter are enabled.

if (options.UseExporter.Equals("otlp", StringComparison.OrdinalIgnoreCase))
Expand Down
2 changes: 1 addition & 1 deletion examples/Console/TestOTelShimWithConsoleExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
.ConfigureResources(r => r.AddService("MyServiceName"))
.ConfigureResource(r => r.AddService("MyServiceName"))
.AddConsoleExporter()
.Build();

Expand Down
2 changes: 1 addition & 1 deletion examples/Console/TestOpenTracingShim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal static object Run(OpenTracingShimOptions options)
// and use Console exporter.
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddSource("MyCompany.MyProduct.MyWebServer")
.ConfigureResources(r => r.AddService("MyServiceName"))
.ConfigureResource(r => r.AddService("MyServiceName"))
.AddConsoleExporter()
.Build();

Expand Down
2 changes: 1 addition & 1 deletion examples/Console/TestOtlpExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
.ConfigureResources(r => r.AddService("otlp-test"))
.ConfigureResource(r => r.AddService("otlp-test"))
.AddOtlpExporter(opt =>
{
// If endpoint was not specified, the proper one will be selected according to the protocol.
Expand Down
2 changes: 1 addition & 1 deletion examples/Console/TestZipkinExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
.ConfigureResources(r => r.AddService("zipkin-test"))
.ConfigureResource(r => r.AddService("zipkin-test"))
.AddZipkinExporter(o =>
{
o.Endpoint = new Uri(zipkinUri);
Expand Down
2 changes: 1 addition & 1 deletion examples/GrpcService/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void ConfigureServices(IServiceCollection services)
{
case "jaeger":
services.AddOpenTelemetryTracing((builder) => builder
.ConfigureResources(r => r.AddService(this.Configuration.GetValue<string>("Jaeger:ServiceName")))
.ConfigureResource(r => r.AddService(this.Configuration.GetValue<string>("Jaeger:ServiceName")))
.AddAspNetCoreInstrumentation()
.AddJaegerExporter(jaegerOptions =>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#nullable enable
OpenTelemetry.Logs.OpenTelemetryLoggerOptions.ConfigureResources(System.Action<OpenTelemetry.Resources.ResourceBuilder!>! configure) -> OpenTelemetry.Logs.OpenTelemetryLoggerOptions!
~static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.ConfigureResources(this OpenTelemetry.Metrics.MeterProviderBuilder meterProviderBuilder, System.Action<OpenTelemetry.Resources.ResourceBuilder> configure) -> OpenTelemetry.Metrics.MeterProviderBuilder
~static OpenTelemetry.Trace.TracerProviderBuilderExtensions.ConfigureResources(this OpenTelemetry.Trace.TracerProviderBuilder tracerProviderBuilder, System.Action<OpenTelemetry.Resources.ResourceBuilder> configure) -> OpenTelemetry.Trace.TracerProviderBuilder
~static OpenTelemetry.Trace.TracerProviderBuilderExtensions.ConfigureResource(this OpenTelemetry.Trace.TracerProviderBuilder tracerProviderBuilder, System.Action<OpenTelemetry.Resources.ResourceBuilder> configure) -> OpenTelemetry.Trace.TracerProviderBuilder
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#nullable enable
OpenTelemetry.Logs.OpenTelemetryLoggerOptions.ConfigureResources(System.Action<OpenTelemetry.Resources.ResourceBuilder!>! configure) -> OpenTelemetry.Logs.OpenTelemetryLoggerOptions!
~static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.ConfigureResources(this OpenTelemetry.Metrics.MeterProviderBuilder meterProviderBuilder, System.Action<OpenTelemetry.Resources.ResourceBuilder> configure) -> OpenTelemetry.Metrics.MeterProviderBuilder
~static OpenTelemetry.Trace.TracerProviderBuilderExtensions.ConfigureResources(this OpenTelemetry.Trace.TracerProviderBuilder tracerProviderBuilder, System.Action<OpenTelemetry.Resources.ResourceBuilder> configure) -> OpenTelemetry.Trace.TracerProviderBuilder
~static OpenTelemetry.Trace.TracerProviderBuilderExtensions.ConfigureResource(this OpenTelemetry.Trace.TracerProviderBuilder tracerProviderBuilder, System.Action<OpenTelemetry.Resources.ResourceBuilder> configure) -> OpenTelemetry.Trace.TracerProviderBuilder
2 changes: 1 addition & 1 deletion src/OpenTelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Released 2022-June-1
* Swallow `ObjectDisposedException` in `BatchExportProcessor` and
`PeriodicExportingMetricReader`.
([#3291](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3291))
* Add `ConfigureResources` which can replace SetResourceBuilder more succinctly
* 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))
Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry/Logs/OpenTelemetryLoggerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public OpenTelemetryLoggerOptions AddProcessor(BaseProcessor<LogRecord> processo
/// <summary>
/// Sets the <see cref="ResourceBuilder"/> from which the Resource associated with
/// this provider is built from. Overwrites currently set ResourceBuilder.
/// You should usually use <see cref="ConfigureResources(Action{ResourceBuilder})"/> instead
/// You should usually use <see cref="ConfigureResource(Action{ResourceBuilder})"/> instead
/// (call <see cref="ResourceBuilder.Clear"/> if desired).
/// </summary>
/// <param name="resourceBuilder"><see cref="ResourceBuilder"/> from which Resource will be built.</param>
Expand All @@ -93,7 +93,7 @@ public OpenTelemetryLoggerOptions SetResourceBuilder(ResourceBuilder resourceBui
/// </summary>
/// <param name="configure">An action which modifies the provided <see cref="ResourceBuilder"/> in-place.</param>
/// <returns>Returns <see cref="OpenTelemetryLoggerOptions"/> for chaining.</returns>
public OpenTelemetryLoggerOptions ConfigureResources(Action<ResourceBuilder> configure)
public OpenTelemetryLoggerOptions ConfigureResource(Action<ResourceBuilder> configure)
{
Guard.ThrowIfNull(configure, nameof(configure));
configure(this.ResourceBuilder);
Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry/Metrics/MeterProviderBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public static MeterProviderBuilder SetMaxMetricPointsPerMetricStream(this MeterP
/// <summary>
/// Sets the <see cref="ResourceBuilder"/> from which the Resource associated with
/// this provider is built from. Overwrites currently set ResourceBuilder.
/// You should usually use <see cref="ConfigureResources(MeterProviderBuilder, Action{ResourceBuilder})"/> instead
/// You should usually use <see cref="ConfigureResource(MeterProviderBuilder, Action{ResourceBuilder})"/> instead
/// (call <see cref="ResourceBuilder.Clear"/> if desired).
/// </summary>
/// <param name="meterProviderBuilder">MeterProviderBuilder instance.</param>
Expand All @@ -206,7 +206,7 @@ public static MeterProviderBuilder SetResourceBuilder(this MeterProviderBuilder
/// <param name="meterProviderBuilder">MeterProviderBuilder instance.</param>
/// <param name="configure">An action which modifies the provided <see cref="ResourceBuilder"/> in-place.</param>
/// <returns>Returns <see cref="MeterProviderBuilder"/> for chaining.</returns>
public static MeterProviderBuilder ConfigureResources(this MeterProviderBuilder meterProviderBuilder, Action<ResourceBuilder> configure)
public static MeterProviderBuilder ConfigureResource(this MeterProviderBuilder meterProviderBuilder, Action<ResourceBuilder> configure)
{
Guard.ThrowIfNull(meterProviderBuilder, nameof(meterProviderBuilder));
Guard.ThrowIfNull(configure, nameof(configure));
Expand Down
2 changes: 1 addition & 1 deletion src/OpenTelemetry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ using OpenTelemetry.Resources;
using OpenTelemetry.Trace;

using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.ConfigureResources(r => r.AddService("MyServiceName"))
.ConfigureResource(r => r.AddService("MyServiceName"))
.Build();
```

Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry/Trace/TracerProviderBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static TracerProviderBuilder SetSampler(this TracerProviderBuilder tracer
/// <summary>
/// Sets the <see cref="ResourceBuilder"/> from which the Resource associated with
/// this provider is built from. Overwrites currently set ResourceBuilder.
/// You should usually use <see cref="ConfigureResources(TracerProviderBuilder, Action{ResourceBuilder})"/> instead
/// You should usually use <see cref="ConfigureResource(TracerProviderBuilder, Action{ResourceBuilder})"/> instead
/// (call <see cref="ResourceBuilder.Clear"/> if desired).
/// </summary>
/// <param name="tracerProviderBuilder">TracerProviderBuilder instance.</param>
Expand All @@ -85,7 +85,7 @@ public static TracerProviderBuilder SetResourceBuilder(this TracerProviderBuilde
/// <param name="tracerProviderBuilder">TracerProviderBuilder instance.</param>
/// <param name="configure">An action which modifies the provided <see cref="ResourceBuilder"/> in-place.</param>
/// <returns>Returns <see cref="TracerProviderBuilder"/> for chaining.</returns>
public static TracerProviderBuilder ConfigureResources(this TracerProviderBuilder tracerProviderBuilder, Action<ResourceBuilder> configure)
public static TracerProviderBuilder ConfigureResource(this TracerProviderBuilder tracerProviderBuilder, Action<ResourceBuilder> configure)
{
Guard.ThrowIfNull(tracerProviderBuilder, nameof(tracerProviderBuilder));
Guard.ThrowIfNull(configure, nameof(configure));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void GlobalSetup()

this.tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddHttpClientInstrumentation()
.ConfigureResources(r => r.AddService(ServiceName))
.ConfigureResource(r => r.AddService(ServiceName))
.AddSource(SourceName)
.Build();

Expand Down
2 changes: 1 addition & 1 deletion test/OpenTelemetry.Tests/Trace/TracerProviderSdkTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ public void TracerProviderSdkBuildsWithSDKResource(bool useConfigure)
var tracerProvider = useConfigure ?
Sdk.CreateTracerProviderBuilder().SetResourceBuilder(
ResourceBuilder.CreateDefault().AddTelemetrySdk()).Build() :
Sdk.CreateTracerProviderBuilder().ConfigureResources(r => r.AddTelemetrySdk()).Build();
Sdk.CreateTracerProviderBuilder().ConfigureResource(r => r.AddTelemetrySdk()).Build();
var resource = tracerProvider.GetResource();
var attributes = resource.Attributes;

Expand Down

0 comments on commit 1834277

Please sign in to comment.