Skip to content

Commit 896b667

Browse files
committed
fix build error
1 parent 1471d7b commit 896b667

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

opentelemetry-sdk/src/trace/provider.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,13 @@ impl Builder {
398398
// For the uncommon case where there are multiple tracer providers with different resource
399399
// configurations, users can optionally provide their own borrowed static resource.
400400
if matches!(config.resource, Cow::Owned(_)) {
401-
let owned_resource = config.resource.clone().into_owned();
402-
config.resource = Cow::Borrowed(PROVIDER_RESOURCE.get_or_init(|| owned_resource));
401+
config.resource =
402+
match PROVIDER_RESOURCE.get_or_init(|| config.resource.clone().into_owned()) {
403+
static_resource if *static_resource == *config.resource.as_ref() => {
404+
Cow::Borrowed(static_resource)
405+
}
406+
_ => config.resource, // Use the new resource if different
407+
};
403408
}
404409

405410
// Create a new vector to hold the modified processors

0 commit comments

Comments
 (0)