Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge the current Resource object with custom Resource Object. #5619

Merged
merged 3 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
Comparing source compatibility of against
No changes.
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.logs.SdkLoggerProviderBuilder (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.logs.SdkLoggerProviderBuilder mergeResource(io.opentelemetry.sdk.resources.Resource)
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
Comparing source compatibility of against
No changes.
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder mergeResource(io.opentelemetry.sdk.resources.Resource)
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
Comparing source compatibility of against
No changes.
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.trace.SdkTracerProviderBuilder (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.trace.SdkTracerProviderBuilder mergeResource(io.opentelemetry.sdk.resources.Resource)
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.opentelemetry.sdk.resources.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.function.Supplier;

/**
Expand Down Expand Up @@ -95,4 +96,15 @@ public SdkLoggerProviderBuilder setClock(Clock clock) {
public SdkLoggerProvider build() {
return new SdkLoggerProvider(resource, logLimitsSupplier, logRecordProcessors, clock);
}

/**
* Merge custom resource object with the current resource object.
*
* @param resource {@link Resource} object to merge with current.
*/
public SdkLoggerProviderBuilder mergeResource(Resource resource) {
parth1601 marked this conversation as resolved.
Show resolved Hide resolved
Objects.requireNonNull(resource, "resource");
this.resource.merge(resource);
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,15 @@ SdkMeterProviderBuilder registerMetricReader(
public SdkMeterProvider build() {
return new SdkMeterProvider(registeredViews, metricReaders, clock, resource, exemplarFilter);
}

/**
* Merge custom resource object with the current resource object.
*
* @param resource {@link Resource} object to merge with current.
*/
public SdkMeterProviderBuilder mergeResource(Resource resource) {
Objects.requireNonNull(resource, "resource");
this.resource.merge(resource);
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import io.opentelemetry.sdk.trace.samplers.Sampler;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.function.Supplier;

/** Builder of {@link SdkTracerProvider}. */
Expand Down Expand Up @@ -145,4 +146,15 @@ public SdkTracerProvider build() {
}

SdkTracerProviderBuilder() {}

/**
* Merge custom resource object with the current resource object.
*
* @param resource {@link Resource} object to merge with current.
*/
public SdkTracerProviderBuilder mergeResource(Resource resource) {
Objects.requireNonNull(resource, "resource");
this.resource.merge(resource);
return this;
}
}