Skip to content

Commit c86a538

Browse files
get_attrs MappingProxyType
1 parent 01707e7 commit c86a538

File tree

1 file changed

+3
-2
lines changed
  • opentelemetry-instrumentation/src/opentelemetry/instrumentation/_labeler/_internal

1 file changed

+3
-2
lines changed

opentelemetry-instrumentation/src/opentelemetry/instrumentation/_labeler/_internal/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import contextvars
1616
import threading
17+
from types import MappingProxyType
1718
from typing import Any, Dict, Optional, Union
1819

1920
# Context variable to store the current labeler
@@ -105,7 +106,7 @@ def get_attributes(self) -> Dict[str, Union[str, int, float, bool]]:
105106
Returns a copy of all attributes added to the labeler.
106107
"""
107108
with self._lock:
108-
return self._attributes.copy()
109+
return MappingProxyType(self._attributes)
109110

110111
def clear(self) -> None:
111112
with self._lock:
@@ -160,7 +161,7 @@ def get_labeler_attributes() -> Dict[str, Union[str, int, float, bool]]:
160161
"""
161162
labeler = _labeler_context.get()
162163
if labeler is None:
163-
return {}
164+
return MappingProxyType({})
164165
return labeler.get_attributes()
165166

166167

0 commit comments

Comments
 (0)