Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/opentelemetry/context/context.py: 92%
13 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-07 06:35 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-07 06:35 +0000
1# Copyright The OpenTelemetry Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
15import typing
16from abc import ABC, abstractmethod
19class Context(typing.Dict[str, object]):
20 def __setitem__(self, key: str, value: object) -> None:
21 raise ValueError
24class _RuntimeContext(ABC):
25 """The RuntimeContext interface provides a wrapper for the different
26 mechanisms that are used to propagate context in Python.
27 Implementations can be made available via entry_points and
28 selected through environment variables.
29 """
31 @abstractmethod
32 def attach(self, context: Context) -> object:
33 """Sets the current `Context` object. Returns a
34 token that can be used to reset to the previous `Context`.
36 Args:
37 context: The Context to set.
38 """
40 @abstractmethod
41 def get_current(self) -> Context:
42 """Returns the current `Context` object."""
44 @abstractmethod
45 def detach(self, token: object) -> None:
46 """Resets Context to a previous value
48 Args:
49 token: A reference to a previous Context.
50 """
53__all__ = ["Context"]