File tree 2 files changed +5
-4
lines changed
src/opentelemetry/sdk/resources
2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -197,9 +197,10 @@ def merge(self, other: "Resource") -> "Resource":
197
197
If a key exists on both the old and updating resource, the value of the
198
198
updating resource will override the old resource value.
199
199
200
- The new `schema_url` will take an updated value only if the original
200
+ The updating resource's `schema_url` will be used only if the old
201
201
`schema_url` is empty. Attempting to merge two resources with
202
- different, non-empty values for `schema_url` will result in an error.
202
+ different, non-empty values for `schema_url` will result in an error
203
+ and return an empty resource.
203
204
204
205
Args:
205
206
other: The other resource to be merged.
@@ -217,10 +218,10 @@ def merge(self, other: "Resource") -> "Resource":
217
218
elif self .schema_url == other .schema_url :
218
219
schema_url = other .schema_url
219
220
else :
220
- schema_url = ""
221
221
logger .error (
222
222
"Failed to merge resources: The Schema URL of the old and updating resources are not empty and are different"
223
223
)
224
+ return _EMPTY_RESOURCE
224
225
225
226
return Resource (merged_attributes , schema_url )
226
227
Original file line number Diff line number Diff line change @@ -147,7 +147,7 @@ def test_resource_merge(self):
147
147
left = resources .Resource .create ({}, schema_urls [0 ])
148
148
right = resources .Resource .create ({}, schema_urls [1 ])
149
149
with self .assertLogs (level = ERROR ):
150
- self .assertEqual (left .merge (right ). schema_url , "" )
150
+ self .assertEqual (left .merge (right ), resources . _EMPTY_RESOURCE )
151
151
152
152
def test_resource_merge_empty_string (self ):
153
153
"""Verify Resource.merge behavior with the empty string.
You can’t perform that action at this time.
0 commit comments