diff --git a/opentelemetry-api/src/opentelemetry/attributes/__init__.py b/opentelemetry-api/src/opentelemetry/attributes/__init__.py index 0843982310a..74168037f52 100644 --- a/opentelemetry-api/src/opentelemetry/attributes/__init__.py +++ b/opentelemetry-api/src/opentelemetry/attributes/__init__.py @@ -16,7 +16,7 @@ import threading from collections import OrderedDict from collections.abc import MutableMapping -from typing import Optional, Sequence +from typing import Optional, Sequence, Union from opentelemetry.util import types @@ -30,7 +30,7 @@ def _clean_attribute( key: str, value: types.AttributeValue, max_len: Optional[int] -) -> Optional[types.AttributeValue]: +) -> Optional[Union[types.AttributeValue, tuple[str | int | float, ...]]]: """Checks if attribute value is valid and cleans it if required. The function returns the cleaned value or None if the value is not valid. diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py index e1e59c36248..81197fa3610 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py @@ -64,7 +64,7 @@ from json import dumps from os import environ from types import ModuleType -from typing import List, Optional +from typing import List, Optional, Sequence, Union from urllib import parse from opentelemetry.attributes import BoundedAttributes @@ -211,11 +211,11 @@ def create( if not resource.attributes.get(SERVICE_NAME, None): default_service_name = "unknown_service" - process_executable_name: Optional[str] = resource.attributes.get( + process_executable_name: Optional[Union[int, float, Sequence[str], Sequence[int], Sequence[float] ]] = resource.attributes.get( PROCESS_EXECUTABLE_NAME, None ) if process_executable_name: - default_service_name += ":" + process_executable_name + default_service_name += ":" + str(process_executable_name) resource = resource.merge( Resource({SERVICE_NAME: default_service_name}, schema_url) ) @@ -250,8 +250,8 @@ def merge(self, other: "Resource") -> "Resource": Returns: The newly-created Resource. """ - merged_attributes = self.attributes.copy() - merged_attributes.update(other.attributes) + merged_attributes = self.attributes.copy() # type: ignore + merged_attributes.update(other.attributes) # type: ignore if self.schema_url == "": schema_url = other.schema_url @@ -266,7 +266,7 @@ def merge(self, other: "Resource") -> "Resource": other.schema_url, ) return self - return Resource(merged_attributes, schema_url) + return Resource(merged_attributes, schema_url) # type: ignore def __eq__(self, other: object) -> bool: if not isinstance(other, Resource):