Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-opentelemetry-api for
openSUSE:Factory checked in at 2021-12-24 20:23:12
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-opentelemetry-api (Old)
and /work/SRC/openSUSE:Factory/.python-opentelemetry-api.new.2520 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-opentelemetry-api"
Fri Dec 24 20:23:12 2021 rev:6 rq:929161 version:1.5.0
Changes:
--------
---
/work/SRC/openSUSE:Factory/python-opentelemetry-api/python-opentelemetry-api.changes
2021-05-07 17:15:44.736926734 +0200
+++
/work/SRC/openSUSE:Factory/.python-opentelemetry-api.new.2520/python-opentelemetry-api.changes
2021-12-24 20:23:33.122031112 +0100
@@ -1,0 +2,90 @@
+Thu Nov 4 10:15:19 UTC 2021 - John Paul Adrian Glaubitz
<[email protected]>
+
+- Version update to 1.5.0
+ - Add pre and post instrumentation entry points (#1983)
+ - Fix documentation on well known exporters and variable OTEL_TRACES_EXPORTER
+ which were misnamed (#2023)
+ - `opentelemetry-sdk` `get_aggregated_resource()` returns default resource
and
+ service name whenever called (#2013)
+ - `opentelemetry-distro` & `opentelemetry-sdk` Moved Auto Instrumentation
Configurator
+ code to SDK to let distros use its default implementation (#1937)
+ - Add Trace ID validation to meet TraceID spec (#1992)
+ - Fixed Python 3.10 incompatibility in `opentelemetry-opentracing-shim`
tests (#2018)
+ - `opentelemetry-sdk` added support for
`OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT` (#2044)
+ - `opentelemetry-sdk` Fixed bugs (#2041, #2042 & #2045) in Span Limits
(#2044)
+ - `opentelemetry-sdk` Add support for `OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT`
env var (#2056)
+ - `opentelemetry-sdk` Treat limit even vars set to empty values as
unset/unlimited. (#2054)
+ - `opentelemetry-api` Attribute keys must be non-empty strings. (#2057)
+- from version 1.4.0
+ + Added
+ - Moved `opentelemetry-instrumentation` to core repository. (#1959)
+ - Add support for OTLP Exporter Protobuf over HTTP (#1868)
+ - Dropped attributes/events/links count available exposed on
ReadableSpans. (#1893)
+ - Added dropped count to otlp, jaeger and zipkin exporters. (#1893)
+ - Give OTLPHandler the ability to process attributes (#1952)
+ - Add global LogEmitterProvider and convenience function get_log_emitter
(#1901)
+ - Add OTLPHandler for standard library logging module (#1903)
+ + Changed
+ - Updated `opentelemetry-opencensus-exporter` to use `service_name` of
spans
+ instead of resource (#1897)
+ - Added descriptions to the env variables mentioned in the
opentelemetry-specification
+ (#1898)
+ - Ignore calls to `Span.set_status` with `StatusCode.UNSET` and also if
previous
+ status already had `StatusCode.OK`. (#1902)
+ - Attributes for `Link` and `Resource` are immutable as they are for
`Event`, which
+ means any attempt to modify attributes directly will result in a
`TypeError` exception.
+ (#1909)
+ - Added `BoundedAttributes` to the API to make it available for `Link`
which is defined
+ in the API. Marked `BoundedDict` in the SDK as deprecated as a result.
(#1915)
+ - Fix OTLP SpanExporter to distinguish spans based off Resource and
InstrumentationInfo
+ (#1927)
+ - Updating dependency for opentelemetry api/sdk packages to support major
version
+ instead of pinning to specific versions. (#1933)
+ - `opentelemetry-semantic-conventions` Generate semconv constants update
for OTel
+ Spec 1.5.0 (#1946)
+ + Fixed
+ - Updated `opentelementry-opentracing-shim` `ScopeShim` to report
exceptions in
+ opentelemetry specification format, rather than opentracing spec format.
(#1878)
+- from version 1.3.0
+ + Added
+ - Allow span limits to be set programatically via TracerProvider. (#1877)
+ - Added support for CreateKey functionality. (#1853)
+ + Changed
+ - Updated get_tracer to return an empty string when passed an invalid name
(#1854)
+ - Changed AttributeValue sequences to warn mypy users on adding None
values to array
+ (#1855)
+ - Fixed exporter OTLP header parsing to match baggage header formatting.
(#1869)
+ - Added optional `schema_url` field to `Resource` class (#1871)
+ - Update protos to latest version release 0.9.0 (#1873)
+- from version 1.2.0
+ + Added
+ - Added example for running Django with auto instrumentation. (#1803)
+ - Added `B3SingleFormat` and `B3MultiFormat` propagators to the
+ `opentelemetry-propagator-b3` package. (#1823)
+ - Added support for OTEL_SERVICE_NAME. (#1829)
+ - Lazily read/configure limits and allow limits to be unset. (#1839)
+ - Added support for OTEL_EXPORTER_JAEGER_TIMEOUT (#1863)
+ + Changed
+ - Fixed OTLP gRPC exporter silently failing if scheme is not specified
+ in endpoint. (#1806)
+ - Rename CompositeHTTPPropagator to CompositePropagator as per
specification.
+ (#1807)
+ - Propagators use the root context as default for `extract` and do not
modify
+ the context if extracting from carrier does not work. (#1811)
+ - Fixed `b3` propagator entrypoint to point to `B3SingleFormat` propagator.
+ (#1823)
+ - Added `b3multi` propagator entrypoint to point to `B3MultiFormat`
propagator.
+ (#1823)
+ - Improve warning when failing to decode byte attribute (#1810)
+ - Fixed inconsistency in parent_id formatting from the ConsoleSpanExporter
+ (#1833)
+ - Include span parent in Jaeger gRPC export as `CHILD_OF` reference (#1809)
+ - Fixed sequence values in OTLP exporter not translating (#1818)
+ - Update transient errors retry timeout and retryable status codes (#1842)
+ - Apply validation of attributes to `Resource`, move attribute related
logic
+ to separate package. (#1834)
+ - Fix start span behavior when excess links and attributes are included
(#1856)
+ + Removed
+ - Moved `opentelemetry-instrumentation` to contrib repository. (#1797)
+
+-------------------------------------------------------------------
Old:
----
opentelemetry-api-1.1.0.tar.gz
New:
----
opentelemetry-api-1.5.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-opentelemetry-api.spec ++++++
--- /var/tmp/diff_new_pack.x9yl0G/_old 2021-12-24 20:23:33.566031345 +0100
+++ /var/tmp/diff_new_pack.x9yl0G/_new 2021-12-24 20:23:33.570031346 +0100
@@ -19,7 +19,7 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define skip_python2 1
Name: python-opentelemetry-api
-Version: 1.1.0
+Version: 1.5.0
Release: 0
Summary: OpenTelemetry Python API
License: Apache-2.0
@@ -35,6 +35,7 @@
Requires: python-aiocontextvars
%endif
# SECTION test requirements
+BuildRequires: %{python_module Deprecated}
BuildRequires: %{python_module pytest}
# /SECTION
%python_subpackages
++++++ opentelemetry-api-1.1.0.tar.gz -> opentelemetry-api-1.5.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/opentelemetry-api-1.1.0/LICENSE
new/opentelemetry-api-1.5.0/LICENSE
--- old/opentelemetry-api-1.1.0/LICENSE 2021-04-20 23:27:16.000000000 +0200
+++ new/opentelemetry-api-1.5.0/LICENSE 2021-08-26 11:27:39.000000000 +0200
@@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
- Copyright [yyyy] [name of copyright owner]
+ Copyright The OpenTelemetry Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/opentelemetry-api-1.1.0/PKG-INFO
new/opentelemetry-api-1.5.0/PKG-INFO
--- old/opentelemetry-api-1.1.0/PKG-INFO 2021-04-20 23:27:19.000000000
+0200
+++ new/opentelemetry-api-1.5.0/PKG-INFO 2021-08-26 11:27:42.000000000
+0200
@@ -1,31 +1,11 @@
Metadata-Version: 2.1
Name: opentelemetry-api
-Version: 1.1.0
+Version: 1.5.0
Summary: OpenTelemetry Python API
Home-page:
https://github.com/open-telemetry/opentelemetry-python/tree/main/opentelemetry-api
Author: OpenTelemetry Authors
Author-email: [email protected]
License: Apache-2.0
-Description: OpenTelemetry Python API
-
============================================================================
-
- |pypi|
-
- .. |pypi| image:: https://badge.fury.io/py/opentelemetry-api.svg
- :target: https://pypi.org/project/opentelemetry-api/
-
- Installation
- ------------
-
- ::
-
- pip install opentelemetry-api
-
- References
- ----------
-
- * `OpenTelemetry Project <https://opentelemetry.io/>`_
-
Platform: any
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
@@ -36,6 +16,30 @@
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
+Classifier: Typing :: Typed
Requires-Python: >=3.6
Description-Content-Type: text/x-rst
Provides-Extra: test
+License-File: LICENSE
+
+OpenTelemetry Python API
+============================================================================
+
+|pypi|
+
+.. |pypi| image:: https://badge.fury.io/py/opentelemetry-api.svg
+ :target: https://pypi.org/project/opentelemetry-api/
+
+Installation
+------------
+
+::
+
+ pip install opentelemetry-api
+
+References
+----------
+
+* `OpenTelemetry Project <https://opentelemetry.io/>`_
+
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/opentelemetry-api-1.1.0/setup.cfg
new/opentelemetry-api-1.5.0/setup.cfg
--- old/opentelemetry-api-1.1.0/setup.cfg 2021-04-20 23:27:19.000000000
+0200
+++ new/opentelemetry-api-1.5.0/setup.cfg 2021-08-26 11:27:42.000000000
+0200
@@ -18,6 +18,7 @@
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
+ Typing :: Typed
[options]
python_requires = >=3.6
@@ -27,6 +28,7 @@
zip_safe = False
include_package_data = True
install_requires =
+ Deprecated >= 1.2.6
aiocontextvars; python_version<'3.7'
[options.packages.find]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/opentelemetry-api-1.1.0/src/opentelemetry/attributes/__init__.py
new/opentelemetry-api-1.5.0/src/opentelemetry/attributes/__init__.py
--- old/opentelemetry-api-1.1.0/src/opentelemetry/attributes/__init__.py
1970-01-01 01:00:00.000000000 +0100
+++ new/opentelemetry-api-1.5.0/src/opentelemetry/attributes/__init__.py
2021-08-26 11:27:39.000000000 +0200
@@ -0,0 +1,199 @@
+# Copyright The OpenTelemetry Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# type: ignore
+
+import logging
+import threading
+from collections import OrderedDict
+from collections.abc import MutableMapping
+from typing import Optional, Sequence, Union
+
+from opentelemetry.util import types
+
+# bytes are accepted as a user supplied value for attributes but
+# decoded to strings internally.
+_VALID_ATTR_VALUE_TYPES = (bool, str, bytes, int, float)
+
+
+_logger = logging.getLogger(__name__)
+
+
+def _clean_attribute(
+ key: str, value: types.AttributeValue, max_len: Optional[int]
+) -> Optional[types.AttributeValue]:
+ """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.
+
+ An attribute value is valid if it is either:
+ - A primitive type: string, boolean, double precision floating
+ point (IEEE 754-1985) or integer.
+ - An array of primitive type values. The array MUST be homogeneous,
+ i.e. it MUST NOT contain values of different types.
+
+ An attribute needs cleansing if:
+ - Its length is greater than the maximum allowed length.
+ - It needs to be encoded/decoded e.g, bytes to strings.
+ """
+
+ if not (key and isinstance(key, str)):
+ _logger.warning("invalid key `%s`. must be non-empty string.", key)
+ return None
+
+ if isinstance(value, _VALID_ATTR_VALUE_TYPES):
+ return _clean_attribute_value(value, max_len)
+
+ if isinstance(value, Sequence):
+ sequence_first_valid_type = None
+ cleaned_seq = []
+
+ for element in value:
+ # None is considered valid in any sequence
+ if element is None:
+ cleaned_seq.append(element)
+
+ element = _clean_attribute_value(element, max_len)
+ # reject invalid elements
+ if element is None:
+ continue
+
+ element_type = type(element)
+ # Reject attribute value if sequence contains a value with an
incompatible type.
+ if element_type not in _VALID_ATTR_VALUE_TYPES:
+ _logger.warning(
+ "Invalid type %s in attribute value sequence. Expected one
of "
+ "%s or None",
+ element_type.__name__,
+ [
+ valid_type.__name__
+ for valid_type in _VALID_ATTR_VALUE_TYPES
+ ],
+ )
+ return None
+
+ # The type of the sequence must be homogeneous. The first non-None
+ # element determines the type of the sequence
+ if sequence_first_valid_type is None:
+ sequence_first_valid_type = element_type
+ # use equality instead of isinstance as isinstance(True, int)
evaluates to True
+ elif element_type != sequence_first_valid_type:
+ _logger.warning(
+ "Mixed types %s and %s in attribute value sequence",
+ sequence_first_valid_type.__name__,
+ type(element).__name__,
+ )
+ return None
+
+ cleaned_seq.append(element)
+
+ # Freeze mutable sequences defensively
+ return tuple(cleaned_seq)
+
+ _logger.warning(
+ "Invalid type %s for attribute value. Expected one of %s or a "
+ "sequence of those types",
+ type(value).__name__,
+ [valid_type.__name__ for valid_type in _VALID_ATTR_VALUE_TYPES],
+ )
+ return None
+
+
+def _clean_attribute_value(
+ value: types.AttributeValue, limit: Optional[int]
+) -> Union[types.AttributeValue, None]:
+ if value is None:
+ return None
+
+ if isinstance(value, bytes):
+ try:
+ value = value.decode()
+ except UnicodeDecodeError:
+ _logger.warning("Byte attribute could not be decoded.")
+ return None
+
+ if limit is not None and isinstance(value, str):
+ value = value[:limit]
+ return value
+
+
+class BoundedAttributes(MutableMapping):
+ """An ordered dict with a fixed max capacity.
+
+ Oldest elements are dropped when the dict is full and a new element is
+ added.
+ """
+
+ def __init__(
+ self,
+ maxlen: Optional[int] = None,
+ attributes: types.Attributes = None,
+ immutable: bool = True,
+ max_value_len: Optional[int] = None,
+ ):
+ if maxlen is not None:
+ if not isinstance(maxlen, int) or maxlen < 0:
+ raise ValueError(
+ "maxlen must be valid int greater or equal to 0"
+ )
+ self.maxlen = maxlen
+ self.dropped = 0
+ self.max_value_len = max_value_len
+ self._dict = OrderedDict() # type: OrderedDict
+ self._lock = threading.Lock() # type: threading.Lock
+ if attributes:
+ for key, value in attributes.items():
+ self[key] = value
+ self._immutable = immutable
+
+ def __repr__(self):
+ return "{}({}, maxlen={})".format(
+ type(self).__name__, dict(self._dict), self.maxlen
+ )
+
+ def __getitem__(self, key):
+ return self._dict[key]
+
+ def __setitem__(self, key, value):
+ if getattr(self, "_immutable", False):
+ raise TypeError
+ with self._lock:
+ if self.maxlen is not None and self.maxlen == 0:
+ self.dropped += 1
+ return
+
+ if key in self._dict:
+ del self._dict[key]
+ elif self.maxlen is not None and len(self._dict) == self.maxlen:
+ del self._dict[next(iter(self._dict.keys()))]
+ self.dropped += 1
+
+ value = _clean_attribute(key, value, self.max_value_len)
+ if value is not None:
+ self._dict[key] = value
+
+ def __delitem__(self, key):
+ if getattr(self, "_immutable", False):
+ raise TypeError
+ with self._lock:
+ del self._dict[key]
+
+ def __iter__(self):
+ with self._lock:
+ return iter(self._dict.copy())
+
+ def __len__(self):
+ return len(self._dict)
+
+ def copy(self):
+ return self._dict.copy()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/opentelemetry-api-1.1.0/src/opentelemetry/baggage/__init__.py
new/opentelemetry-api-1.5.0/src/opentelemetry/baggage/__init__.py
--- old/opentelemetry-api-1.1.0/src/opentelemetry/baggage/__init__.py
2021-04-20 23:27:16.000000000 +0200
+++ new/opentelemetry-api-1.5.0/src/opentelemetry/baggage/__init__.py
2021-08-26 11:27:39.000000000 +0200
@@ -15,10 +15,10 @@
import typing
from types import MappingProxyType
-from opentelemetry.context import get_value, set_value
+from opentelemetry.context import create_key, get_value, set_value
from opentelemetry.context.context import Context
-_BAGGAGE_KEY = "baggage"
+_BAGGAGE_KEY = create_key("baggage")
def get_all(
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/opentelemetry-api-1.1.0/src/opentelemetry/context/__init__.py
new/opentelemetry-api-1.5.0/src/opentelemetry/context/__init__.py
--- old/opentelemetry-api-1.1.0/src/opentelemetry/context/__init__.py
2021-04-20 23:27:16.000000000 +0200
+++ new/opentelemetry-api-1.5.0/src/opentelemetry/context/__init__.py
2021-08-26 11:27:39.000000000 +0200
@@ -15,6 +15,7 @@
import logging
import threading
import typing
+import uuid
from functools import wraps
from os import environ
@@ -68,6 +69,18 @@
return typing.cast(_F, wrapper) # type: ignore[misc]
+def create_key(keyname: str) -> str:
+ """To allow cross-cutting concern to control access to their local state,
+ the RuntimeContext API provides a function which takes a keyname as input,
+ and returns a unique key.
+ Args:
+ keyname: The key name is for debugging purposes and is not required to
be unique.
+ Returns:
+ A unique string representing the newly created key.
+ """
+ return keyname + "-" + str(uuid.uuid4())
+
+
def get_value(key: str, context: typing.Optional[Context] = None) -> "object":
"""To access the local state of a concern, the RuntimeContext API
provides a function which takes a context and a key as input,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/opentelemetry-api-1.1.0/src/opentelemetry/context/aiocontextvarsfix.py
new/opentelemetry-api-1.5.0/src/opentelemetry/context/aiocontextvarsfix.py
--- old/opentelemetry-api-1.1.0/src/opentelemetry/context/aiocontextvarsfix.py
2021-04-20 23:27:16.000000000 +0200
+++ new/opentelemetry-api-1.5.0/src/opentelemetry/context/aiocontextvarsfix.py
1970-01-01 01:00:00.000000000 +0100
@@ -1,86 +0,0 @@
-# type: ignore
-# Copyright The OpenTelemetry Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# This module is a patch to allow aiocontextvars to work for older versions
-# of Python 3.5. It is copied and pasted from:
-# https://github.com/fantix/aiocontextvars/issues/88#issuecomment-522276290
-
-import asyncio
-import asyncio.coroutines
-import asyncio.futures
-import concurrent.futures
-
-if not hasattr(asyncio, "_get_running_loop"):
- # noinspection PyCompatibility
- # pylint:disable=protected-access
- import asyncio.events
- from threading import local as threading_local
-
- if not hasattr(asyncio.events, "_get_running_loop"):
-
- class _RunningLoop(threading_local):
- _loop = None
-
- _running_loop = _RunningLoop()
-
- def _get_running_loop():
- return _running_loop._loop
-
- def set_running_loop(loop): # noqa: F811
- _running_loop._loop = loop
-
- def _get_event_loop():
- current_loop = _get_running_loop()
- if current_loop is not None:
- return current_loop
- return asyncio.events.get_event_loop_policy().get_event_loop()
-
- asyncio.events.get_event_loop = _get_event_loop
- asyncio.events._get_running_loop = _get_running_loop
- asyncio.events._set_running_loop = set_running_loop
-
- asyncio._get_running_loop = asyncio.events._get_running_loop
- asyncio._set_running_loop = asyncio.events._set_running_loop
-
-# noinspection PyUnresolvedReferences
-import aiocontextvars # pylint:
disable=import-error,unused-import,wrong-import-position # noqa # isort:skip
-
-
-def _run_coroutine_threadsafe(coro, loop):
- """
- Patch to create task in the same thread instead of in the callback.
- This ensures that contextvars get copied. Python 3.7 copies contextvars
- without this.
- """
- if not asyncio.coroutines.iscoroutine(coro):
- raise TypeError("A coroutine object is required")
- future = concurrent.futures.Future()
- task = asyncio.ensure_future(coro, loop=loop)
-
- def callback() -> None:
- try:
- # noinspection PyProtectedMember,PyUnresolvedReferences
- # pylint:disable=protected-access
- asyncio.futures._chain_future(task, future)
- except Exception as exc:
- if future.set_running_or_notify_cancel():
- future.set_exception(exc)
- raise
-
- loop.call_soon_threadsafe(callback)
- return future
-
-
-asyncio.run_coroutine_threadsafe = _run_coroutine_threadsafe
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/opentelemetry-api-1.1.0/src/opentelemetry/context/contextvars_context.py
new/opentelemetry-api-1.5.0/src/opentelemetry/context/contextvars_context.py
---
old/opentelemetry-api-1.1.0/src/opentelemetry/context/contextvars_context.py
2021-04-20 23:27:16.000000000 +0200
+++
new/opentelemetry-api-1.5.0/src/opentelemetry/context/contextvars_context.py
2021-08-26 11:27:39.000000000 +0200
@@ -16,11 +16,10 @@
from opentelemetry.context.context import Context, _RuntimeContext
-if (3, 5, 3) <= version_info < (3, 7):
- import aiocontextvars # type: ignore #
pylint:disable=unused-import,import-error
+if version_info < (3, 7):
+ import aiocontextvars # type: ignore # pylint: disable=import-error
-elif (3, 4) < version_info <= (3, 5, 2):
- import opentelemetry.context.aiocontextvarsfix #
pylint:disable=unused-import
+ aiocontextvars # pylint: disable=pointless-statement
class ContextVarsRuntimeContext(_RuntimeContext):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/opentelemetry-api-1.1.0/src/opentelemetry/propagate/__init__.py
new/opentelemetry-api-1.5.0/src/opentelemetry/propagate/__init__.py
--- old/opentelemetry-api-1.1.0/src/opentelemetry/propagate/__init__.py
2021-04-20 23:27:16.000000000 +0200
+++ new/opentelemetry-api-1.5.0/src/opentelemetry/propagate/__init__.py
2021-08-26 11:27:39.000000000 +0200
@@ -16,13 +16,13 @@
API for propagation of context.
The propagators for the
-``opentelemetry.propagators.composite.CompositeHTTPPropagator`` can be defined
+``opentelemetry.propagators.composite.CompositePropagator`` can be defined
via configuration in the ``OTEL_PROPAGATORS`` environment variable. This
variable should be set to a comma-separated string of names of values for the
``opentelemetry_propagator`` entry point. For example, setting
``OTEL_PROPAGATORS`` to ``tracecontext,baggage`` (which is the default value)
would instantiate
-``opentelemetry.propagators.composite.CompositeHTTPPropagator`` with 2
+``opentelemetry.propagators.composite.CompositePropagator`` with 2
propagators, one of type
``opentelemetry.trace.propagation.tracecontext.TraceContextTextMapPropagator``
and other of type ``opentelemetry.baggage.propagation.W3CBaggagePropagator``.
@@ -96,7 +96,7 @@
used to construct a Context. This object
must be paired with an appropriate getter
which understands how to extract a value from it.
- context: an optional Context to use. Defaults to current
+ context: an optional Context to use. Defaults to root
context if not set.
"""
return get_global_textmap().extract(carrier, context, getter=getter)
@@ -142,7 +142,7 @@
logger.exception("Failed to load configured propagators")
raise
-_HTTP_TEXT_FORMAT = composite.CompositeHTTPPropagator(propagators) # type:
ignore
+_HTTP_TEXT_FORMAT = composite.CompositePropagator(propagators) # type: ignore
def get_global_textmap() -> textmap.TextMapPropagator:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/opentelemetry-api-1.1.0/src/opentelemetry/propagators/composite.py
new/opentelemetry-api-1.5.0/src/opentelemetry/propagators/composite.py
--- old/opentelemetry-api-1.1.0/src/opentelemetry/propagators/composite.py
2021-04-20 23:27:16.000000000 +0200
+++ new/opentelemetry-api-1.5.0/src/opentelemetry/propagators/composite.py
2021-08-26 11:27:39.000000000 +0200
@@ -14,14 +14,16 @@
import logging
import typing
+from deprecated import deprecated
+
from opentelemetry.context.context import Context
from opentelemetry.propagators import textmap
logger = logging.getLogger(__name__)
-class CompositeHTTPPropagator(textmap.TextMapPropagator):
- """CompositeHTTPPropagator provides a mechanism for combining multiple
+class CompositePropagator(textmap.TextMapPropagator):
+ """CompositePropagator provides a mechanism for combining multiple
propagators into a single one.
Args:
@@ -80,3 +82,10 @@
composite_fields.add(field)
return composite_fields
+
+
+@deprecated(version="1.2.0", reason="You should use CompositePropagator") #
type: ignore
+class CompositeHTTPPropagator(CompositePropagator):
+ """CompositeHTTPPropagator provides a mechanism for combining multiple
+ propagators into a single one.
+ """
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/opentelemetry-api-1.1.0/src/opentelemetry/propagators/textmap.py
new/opentelemetry-api-1.5.0/src/opentelemetry/propagators/textmap.py
--- old/opentelemetry-api-1.1.0/src/opentelemetry/propagators/textmap.py
2021-04-20 23:27:16.000000000 +0200
+++ new/opentelemetry-api-1.5.0/src/opentelemetry/propagators/textmap.py
2021-08-26 11:27:39.000000000 +0200
@@ -150,7 +150,7 @@
used to construct a Context. This object
must be paired with an appropriate getter
which understands how to extract a value from it.
- context: an optional Context to use. Defaults to current
+ context: an optional Context to use. Defaults to root
context if not set.
Returns:
A Context with configuration found in the carrier.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/opentelemetry-api-1.1.0/src/opentelemetry/trace/__init__.py
new/opentelemetry-api-1.5.0/src/opentelemetry/trace/__init__.py
--- old/opentelemetry-api-1.1.0/src/opentelemetry/trace/__init__.py
2021-04-20 23:27:16.000000000 +0200
+++ new/opentelemetry-api-1.5.0/src/opentelemetry/trace/__init__.py
2021-08-26 11:27:39.000000000 +0200
@@ -82,10 +82,11 @@
from typing import Iterator, Optional, Sequence, cast
from opentelemetry import context as context_api
+from opentelemetry.attributes import BoundedAttributes # type: ignore
from opentelemetry.context.context import Context
from opentelemetry.environment_variables import OTEL_PYTHON_TRACER_PROVIDER
from opentelemetry.trace.propagation import (
- SPAN_KEY,
+ _SPAN_KEY,
get_current_span,
set_span_in_context,
)
@@ -126,7 +127,7 @@
class Link(_LinkBase):
- """A link to a `Span`.
+ """A link to a `Span`. The attributes of a Link are immutable.
Args:
context: `SpanContext` of the `Span` to link to.
@@ -139,7 +140,9 @@
attributes: types.Attributes = None,
) -> None:
super().__init__(context)
- self._attributes = attributes
+ self._attributes = BoundedAttributes(
+ attributes=attributes
+ ) # type: types.Attributes
@property
def attributes(self) -> types.Attributes:
@@ -317,7 +320,7 @@
as the current span in this tracer's context.
Exiting the context manager will call the span's end method,
- as well as return the current span to it's previous value by
+ as well as return the current span to its previous value by
returning to the previous context.
Example::
@@ -517,7 +520,7 @@
this mechanism if it was previously set manually.
"""
try:
- token = context_api.attach(context_api.set_value(SPAN_KEY, span))
+ token = context_api.attach(context_api.set_value(_SPAN_KEY, span))
try:
yield span
finally:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/opentelemetry-api-1.1.0/src/opentelemetry/trace/propagation/__init__.py
new/opentelemetry-api-1.5.0/src/opentelemetry/trace/propagation/__init__.py
--- old/opentelemetry-api-1.1.0/src/opentelemetry/trace/propagation/__init__.py
2021-04-20 23:27:16.000000000 +0200
+++ new/opentelemetry-api-1.5.0/src/opentelemetry/trace/propagation/__init__.py
2021-08-26 11:27:39.000000000 +0200
@@ -13,11 +13,12 @@
# limitations under the License.
from typing import Optional
-from opentelemetry.context import get_value, set_value
+from opentelemetry.context import create_key, get_value, set_value
from opentelemetry.context.context import Context
from opentelemetry.trace.span import INVALID_SPAN, Span
SPAN_KEY = "current-span"
+_SPAN_KEY = create_key("current-span")
def set_span_in_context(
@@ -30,7 +31,7 @@
context: a Context object. if one is not passed, the
default current context is used instead.
"""
- ctx = set_value(SPAN_KEY, span, context=context)
+ ctx = set_value(_SPAN_KEY, span, context=context)
return ctx
@@ -44,7 +45,7 @@
Returns:
The Span set in the context if it exists. INVALID_SPAN otherwise.
"""
- span = get_value(SPAN_KEY, context=context)
+ span = get_value(_SPAN_KEY, context=context)
if span is None or not isinstance(span, Span):
return INVALID_SPAN
return span
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/opentelemetry-api-1.1.0/src/opentelemetry/trace/propagation/tracecontext.py
new/opentelemetry-api-1.5.0/src/opentelemetry/trace/propagation/tracecontext.py
---
old/opentelemetry-api-1.1.0/src/opentelemetry/trace/propagation/tracecontext.py
2021-04-20 23:27:16.000000000 +0200
+++
new/opentelemetry-api-1.5.0/src/opentelemetry/trace/propagation/tracecontext.py
2021-08-26 11:27:39.000000000 +0200
@@ -43,14 +43,17 @@
See `opentelemetry.propagators.textmap.TextMapPropagator.extract`
"""
+ if context is None:
+ context = Context()
+
header = getter.get(carrier, self._TRACEPARENT_HEADER_NAME)
if not header:
- return trace.set_span_in_context(trace.INVALID_SPAN, context)
+ return context
match = re.search(self._TRACEPARENT_HEADER_FORMAT_RE, header[0])
if not match:
- return trace.set_span_in_context(trace.INVALID_SPAN, context)
+ return context
version = match.group(1)
trace_id = match.group(2)
@@ -58,13 +61,13 @@
trace_flags = match.group(4)
if trace_id == "0" * 32 or span_id == "0" * 16:
- return trace.set_span_in_context(trace.INVALID_SPAN, context)
+ return context
if version == "00":
if match.group(5):
- return trace.set_span_in_context(trace.INVALID_SPAN, context)
+ return context
if version == "ff":
- return trace.set_span_in_context(trace.INVALID_SPAN, context)
+ return context
tracestate_headers = getter.get(carrier, self._TRACESTATE_HEADER_NAME)
if tracestate_headers is None:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/opentelemetry-api-1.1.0/src/opentelemetry/trace/span.py
new/opentelemetry-api-1.5.0/src/opentelemetry/trace/span.py
--- old/opentelemetry-api-1.1.0/src/opentelemetry/trace/span.py 2021-04-20
23:27:16.000000000 +0200
+++ new/opentelemetry-api-1.5.0/src/opentelemetry/trace/span.py 2021-08-26
11:27:39.000000000 +0200
@@ -389,6 +389,7 @@
DEFAULT_TRACE_STATE = TraceState.get_default()
+_TRACE_ID_HEX_LENGTH = 2 ** 128 - 1
class SpanContext(
@@ -420,7 +421,11 @@
if trace_state is None:
trace_state = DEFAULT_TRACE_STATE
- is_valid = trace_id != INVALID_TRACE_ID and span_id != INVALID_SPAN_ID
+ is_valid = (
+ trace_id != INVALID_TRACE_ID
+ and span_id != INVALID_SPAN_ID
+ and trace_id < _TRACE_ID_HEX_LENGTH
+ )
return tuple.__new__(
cls,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/opentelemetry-api-1.1.0/src/opentelemetry/util/_time.py
new/opentelemetry-api-1.5.0/src/opentelemetry/util/_time.py
--- old/opentelemetry-api-1.1.0/src/opentelemetry/util/_time.py 2021-04-20
23:27:16.000000000 +0200
+++ new/opentelemetry-api-1.5.0/src/opentelemetry/util/_time.py 2021-08-26
11:27:39.000000000 +0200
@@ -18,8 +18,8 @@
if version_info.minor < 7:
getLogger(__name__).warning( # pylint: disable=logging-not-lazy
"You are using Python 3.%s. This version does not support timestamps "
- "with nanosecond precision and the Opentelemetry SDK will use "
- "millisecond precision instead. Please refer to PEP 546 for more "
+ "with nanosecond precision and the OpenTelemetry SDK will use "
+ "millisecond precision instead. Please refer to PEP 564 for more "
"information. Please upgrade to Python 3.7 or newer to use nanosecond "
"precision." % version_info.minor
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/opentelemetry-api-1.1.0/src/opentelemetry/util/types.py
new/opentelemetry-api-1.5.0/src/opentelemetry/util/types.py
--- old/opentelemetry-api-1.1.0/src/opentelemetry/util/types.py 2021-04-20
23:27:16.000000000 +0200
+++ new/opentelemetry-api-1.5.0/src/opentelemetry/util/types.py 2021-08-26
11:27:39.000000000 +0200
@@ -20,10 +20,10 @@
bool,
int,
float,
- Sequence[Optional[str]],
- Sequence[Optional[bool]],
- Sequence[Optional[int]],
- Sequence[Optional[float]],
+ Sequence[str],
+ Sequence[bool],
+ Sequence[int],
+ Sequence[float],
]
Attributes = Optional[Mapping[str, AttributeValue]]
AttributesAsKey = Tuple[
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/opentelemetry-api-1.1.0/src/opentelemetry/version.py
new/opentelemetry-api-1.5.0/src/opentelemetry/version.py
--- old/opentelemetry-api-1.1.0/src/opentelemetry/version.py 2021-04-20
23:27:16.000000000 +0200
+++ new/opentelemetry-api-1.5.0/src/opentelemetry/version.py 2021-08-26
11:27:39.000000000 +0200
@@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-__version__ = "1.1.0"
+__version__ = "1.5.0"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/opentelemetry-api-1.1.0/src/opentelemetry_api.egg-info/PKG-INFO
new/opentelemetry-api-1.5.0/src/opentelemetry_api.egg-info/PKG-INFO
--- old/opentelemetry-api-1.1.0/src/opentelemetry_api.egg-info/PKG-INFO
2021-04-20 23:27:19.000000000 +0200
+++ new/opentelemetry-api-1.5.0/src/opentelemetry_api.egg-info/PKG-INFO
2021-08-26 11:27:42.000000000 +0200
@@ -1,31 +1,11 @@
Metadata-Version: 2.1
Name: opentelemetry-api
-Version: 1.1.0
+Version: 1.5.0
Summary: OpenTelemetry Python API
Home-page:
https://github.com/open-telemetry/opentelemetry-python/tree/main/opentelemetry-api
Author: OpenTelemetry Authors
Author-email: [email protected]
License: Apache-2.0
-Description: OpenTelemetry Python API
-
============================================================================
-
- |pypi|
-
- .. |pypi| image:: https://badge.fury.io/py/opentelemetry-api.svg
- :target: https://pypi.org/project/opentelemetry-api/
-
- Installation
- ------------
-
- ::
-
- pip install opentelemetry-api
-
- References
- ----------
-
- * `OpenTelemetry Project <https://opentelemetry.io/>`_
-
Platform: any
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
@@ -36,6 +16,30 @@
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
+Classifier: Typing :: Typed
Requires-Python: >=3.6
Description-Content-Type: text/x-rst
Provides-Extra: test
+License-File: LICENSE
+
+OpenTelemetry Python API
+============================================================================
+
+|pypi|
+
+.. |pypi| image:: https://badge.fury.io/py/opentelemetry-api.svg
+ :target: https://pypi.org/project/opentelemetry-api/
+
+Installation
+------------
+
+::
+
+ pip install opentelemetry-api
+
+References
+----------
+
+* `OpenTelemetry Project <https://opentelemetry.io/>`_
+
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/opentelemetry-api-1.1.0/src/opentelemetry_api.egg-info/SOURCES.txt
new/opentelemetry-api-1.5.0/src/opentelemetry_api.egg-info/SOURCES.txt
--- old/opentelemetry-api-1.1.0/src/opentelemetry_api.egg-info/SOURCES.txt
2021-04-20 23:27:19.000000000 +0200
+++ new/opentelemetry-api-1.5.0/src/opentelemetry_api.egg-info/SOURCES.txt
2021-08-26 11:27:42.000000000 +0200
@@ -5,10 +5,10 @@
setup.py
src/opentelemetry/py.typed
src/opentelemetry/version.py
+src/opentelemetry/attributes/__init__.py
src/opentelemetry/baggage/__init__.py
src/opentelemetry/baggage/propagation/__init__.py
src/opentelemetry/context/__init__.py
-src/opentelemetry/context/aiocontextvarsfix.py
src/opentelemetry/context/context.py
src/opentelemetry/context/contextvars_context.py
src/opentelemetry/environment_variables/__init__.py
@@ -33,6 +33,7 @@
tests/__init__.py
tests/mypysmoke.py
tests/test_implementation.py
+tests/attributes/test_attributes.py
tests/baggage/test_baggage.py
tests/baggage/test_baggage_propagation.py
tests/context/__init__.py
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/opentelemetry-api-1.1.0/src/opentelemetry_api.egg-info/requires.txt
new/opentelemetry-api-1.5.0/src/opentelemetry_api.egg-info/requires.txt
--- old/opentelemetry-api-1.1.0/src/opentelemetry_api.egg-info/requires.txt
2021-04-20 23:27:19.000000000 +0200
+++ new/opentelemetry-api-1.5.0/src/opentelemetry_api.egg-info/requires.txt
2021-08-26 11:27:42.000000000 +0200
@@ -1,3 +1,4 @@
+Deprecated>=1.2.6
[:python_version < "3.7"]
aiocontextvars
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/opentelemetry-api-1.1.0/tests/attributes/test_attributes.py
new/opentelemetry-api-1.5.0/tests/attributes/test_attributes.py
--- old/opentelemetry-api-1.1.0/tests/attributes/test_attributes.py
1970-01-01 01:00:00.000000000 +0100
+++ new/opentelemetry-api-1.5.0/tests/attributes/test_attributes.py
2021-08-26 11:27:39.000000000 +0200
@@ -0,0 +1,163 @@
+# Copyright The OpenTelemetry Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# type: ignore
+
+import collections
+import unittest
+from typing import MutableSequence
+
+from opentelemetry.attributes import BoundedAttributes, _clean_attribute
+
+
+class TestAttributes(unittest.TestCase):
+ def assertValid(self, value, key="k"):
+ expected = value
+ if isinstance(value, MutableSequence):
+ expected = tuple(value)
+ self.assertEqual(_clean_attribute(key, value, None), expected)
+
+ def assertInvalid(self, value, key="k"):
+ self.assertIsNone(_clean_attribute(key, value, None))
+
+ def test_attribute_key_validation(self):
+ # only non-empty strings are valid keys
+ self.assertInvalid(1, "")
+ self.assertInvalid(1, 1)
+ self.assertInvalid(1, {})
+ self.assertInvalid(1, [])
+ self.assertInvalid(1, b"1")
+ self.assertValid(1, "k")
+ self.assertValid(1, "1")
+
+ def test_clean_attribute(self):
+ self.assertInvalid([1, 2, 3.4, "ss", 4])
+ self.assertInvalid([dict(), 1, 2, 3.4, 4])
+ self.assertInvalid(["sw", "lf", 3.4, "ss"])
+ self.assertInvalid([1, 2, 3.4, 5])
+ self.assertInvalid(dict())
+ self.assertInvalid([1, True])
+ self.assertValid(True)
+ self.assertValid("hi")
+ self.assertValid(3.4)
+ self.assertValid(15)
+ self.assertValid([1, 2, 3, 5])
+ self.assertValid([1.2, 2.3, 3.4, 4.5])
+ self.assertValid([True, False])
+ self.assertValid(["ss", "dw", "fw"])
+ self.assertValid([])
+ # None in sequences are valid
+ self.assertValid(["A", None, None])
+ self.assertValid(["A", None, None, "B"])
+ self.assertValid([None, None])
+ self.assertInvalid(["A", None, 1])
+ self.assertInvalid([None, "A", None, 1])
+
+ # test keys
+ self.assertValid("value", "key")
+ self.assertInvalid("value", "")
+ self.assertInvalid("value", None)
+
+
+class TestBoundedAttributes(unittest.TestCase):
+ base = collections.OrderedDict(
+ [
+ ("name", "Firulais"),
+ ("age", 7),
+ ("weight", 13),
+ ("vaccinated", True),
+ ]
+ )
+
+ def test_negative_maxlen(self):
+ with self.assertRaises(ValueError):
+ BoundedAttributes(-1)
+
+ def test_from_map(self):
+ dic_len = len(self.base)
+ base_copy = collections.OrderedDict(self.base)
+ bdict = BoundedAttributes(dic_len, base_copy)
+
+ self.assertEqual(len(bdict), dic_len)
+
+ # modify base_copy and test that bdict is not changed
+ base_copy["name"] = "Bruno"
+ base_copy["age"] = 3
+
+ for key in self.base:
+ self.assertEqual(bdict[key], self.base[key])
+
+ # test that iter yields the correct number of elements
+ self.assertEqual(len(tuple(bdict)), dic_len)
+
+ # map too big
+ half_len = dic_len // 2
+ bdict = BoundedAttributes(half_len, self.base)
+ self.assertEqual(len(tuple(bdict)), half_len)
+ self.assertEqual(bdict.dropped, dic_len - half_len)
+
+ def test_bounded_dict(self):
+ # create empty dict
+ dic_len = len(self.base)
+ bdict = BoundedAttributes(dic_len, immutable=False)
+ self.assertEqual(len(bdict), 0)
+
+ # fill dict
+ for key in self.base:
+ bdict[key] = self.base[key]
+
+ self.assertEqual(len(bdict), dic_len)
+ self.assertEqual(bdict.dropped, 0)
+
+ for key in self.base:
+ self.assertEqual(bdict[key], self.base[key])
+
+ # test __iter__ in BoundedAttributes
+ for key in bdict:
+ self.assertEqual(bdict[key], self.base[key])
+
+ # updating an existing element should not drop
+ bdict["name"] = "Bruno"
+ self.assertEqual(bdict.dropped, 0)
+
+ # try to append more elements
+ for key in self.base:
+ bdict["new-" + key] = self.base[key]
+
+ self.assertEqual(len(bdict), dic_len)
+ self.assertEqual(bdict.dropped, dic_len)
+
+ # test that elements in the dict are the new ones
+ for key in self.base:
+ self.assertEqual(bdict["new-" + key], self.base[key])
+
+ # delete an element
+ del bdict["new-name"]
+ self.assertEqual(len(bdict), dic_len - 1)
+
+ with self.assertRaises(KeyError):
+ _ = bdict["new-name"]
+
+ def test_no_limit_code(self):
+ bdict = BoundedAttributes(maxlen=None, immutable=False)
+ for num in range(100):
+ bdict[str(num)] = num
+
+ for num in range(100):
+ self.assertEqual(bdict[str(num)], num)
+
+ def test_immutable(self):
+ bdict = BoundedAttributes()
+ with self.assertRaises(TypeError):
+ bdict["should-not-work"] = "dict immutable"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/opentelemetry-api-1.1.0/tests/context/test_context.py
new/opentelemetry-api-1.5.0/tests/context/test_context.py
--- old/opentelemetry-api-1.1.0/tests/context/test_context.py 2021-04-20
23:27:16.000000000 +0200
+++ new/opentelemetry-api-1.5.0/tests/context/test_context.py 2021-08-26
11:27:39.000000000 +0200
@@ -18,27 +18,39 @@
from opentelemetry.context.context import Context
-def do_work() -> None:
- context.attach(context.set_value("say", "bar"))
+def _do_work() -> str:
+ key = context.create_key("say")
+ context.attach(context.set_value(key, "bar"))
+ return key
class TestContext(unittest.TestCase):
def setUp(self):
context.attach(Context())
+ def test_context_key(self):
+ key1 = context.create_key("say")
+ key2 = context.create_key("say")
+ self.assertNotEqual(key1, key2)
+ first = context.set_value(key1, "foo")
+ second = context.set_value(key2, "bar")
+ self.assertEqual(context.get_value(key1, context=first), "foo")
+ self.assertEqual(context.get_value(key2, context=second), "bar")
+
def test_context(self):
- self.assertIsNone(context.get_value("say"))
+ key1 = context.create_key("say")
+ self.assertIsNone(context.get_value(key1))
empty = context.get_current()
- second = context.set_value("say", "foo")
- self.assertEqual(context.get_value("say", context=second), "foo")
+ second = context.set_value(key1, "foo")
+ self.assertEqual(context.get_value(key1, context=second), "foo")
- do_work()
- self.assertEqual(context.get_value("say"), "bar")
+ key2 = _do_work()
+ self.assertEqual(context.get_value(key2), "bar")
third = context.get_current()
- self.assertIsNone(context.get_value("say", context=empty))
- self.assertEqual(context.get_value("say", context=second), "foo")
- self.assertEqual(context.get_value("say", context=third), "bar")
+ self.assertIsNone(context.get_value(key1, context=empty))
+ self.assertEqual(context.get_value(key1, context=second), "foo")
+ self.assertEqual(context.get_value(key2, context=third), "bar")
def test_set_value(self):
first = context.set_value("a", "yyy")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/opentelemetry-api-1.1.0/tests/context/test_contextvars_context.py
new/opentelemetry-api-1.5.0/tests/context/test_contextvars_context.py
--- old/opentelemetry-api-1.1.0/tests/context/test_contextvars_context.py
2021-04-20 23:27:16.000000000 +0200
+++ new/opentelemetry-api-1.5.0/tests/context/test_contextvars_context.py
2021-08-26 11:27:39.000000000 +0200
@@ -12,22 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import unittest
from unittest.mock import patch
from opentelemetry import context
+from opentelemetry.context.contextvars_context import ContextVarsRuntimeContext
from .base_context import ContextTestCases
-try:
- import contextvars # pylint: disable=unused-import
-
- from opentelemetry.context.contextvars_context import (
- ContextVarsRuntimeContext,
- )
-except ImportError:
- raise unittest.SkipTest("contextvars not available")
-
class TestContextVarsContext(ContextTestCases.BaseTest):
def setUp(self) -> None:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/opentelemetry-api-1.1.0/tests/propagators/test_composite.py
new/opentelemetry-api-1.5.0/tests/propagators/test_composite.py
--- old/opentelemetry-api-1.1.0/tests/propagators/test_composite.py
2021-04-20 23:27:16.000000000 +0200
+++ new/opentelemetry-api-1.5.0/tests/propagators/test_composite.py
2021-08-26 11:27:39.000000000 +0200
@@ -17,7 +17,7 @@
import unittest
from unittest.mock import Mock
-from opentelemetry.propagators.composite import CompositeHTTPPropagator
+from opentelemetry.propagators.composite import CompositePropagator
def get_as_list(dict_object, key):
@@ -67,7 +67,7 @@
)
def test_no_propagators(self):
- propagator = CompositeHTTPPropagator([])
+ propagator = CompositePropagator([])
new_carrier = {}
propagator.inject(new_carrier)
self.assertEqual(new_carrier, {})
@@ -78,7 +78,7 @@
self.assertEqual(context, {})
def test_single_propagator(self):
- propagator = CompositeHTTPPropagator([self.mock_propagator_0])
+ propagator = CompositePropagator([self.mock_propagator_0])
new_carrier = {}
propagator.inject(new_carrier)
@@ -90,7 +90,7 @@
self.assertEqual(context, {"mock-0": "context"})
def test_multiple_propagators(self):
- propagator = CompositeHTTPPropagator(
+ propagator = CompositePropagator(
[self.mock_propagator_0, self.mock_propagator_1]
)
@@ -106,7 +106,7 @@
def test_multiple_propagators_same_key(self):
# test that when multiple propagators extract/inject the same
# key, the later propagator values are extracted/injected
- propagator = CompositeHTTPPropagator(
+ propagator = CompositePropagator(
[self.mock_propagator_0, self.mock_propagator_2]
)
@@ -120,7 +120,7 @@
self.assertEqual(context, {"mock-0": "context2"})
def test_fields(self):
- propagator = CompositeHTTPPropagator(
+ propagator = CompositePropagator(
[
self.mock_propagator_0,
self.mock_propagator_1,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/opentelemetry-api-1.1.0/tests/propagators/test_propagators.py
new/opentelemetry-api-1.5.0/tests/propagators/test_propagators.py
--- old/opentelemetry-api-1.1.0/tests/propagators/test_propagators.py
2021-04-20 23:27:16.000000000 +0200
+++ new/opentelemetry-api-1.5.0/tests/propagators/test_propagators.py
2021-08-26 11:27:39.000000000 +0200
@@ -27,7 +27,7 @@
class TestPropagators(TestCase):
- @patch("opentelemetry.propagators.composite.CompositeHTTPPropagator")
+ @patch("opentelemetry.propagators.composite.CompositePropagator")
def test_default_composite_propagators(self, mock_compositehttppropagator):
def test_propagators(propagators):
@@ -48,7 +48,7 @@
reload(opentelemetry.propagate)
@patch.dict(environ, {OTEL_PROPAGATORS: "a,b,c"})
- @patch("opentelemetry.propagators.composite.CompositeHTTPPropagator")
+ @patch("opentelemetry.propagators.composite.CompositePropagator")
@patch("pkg_resources.iter_entry_points")
def test_non_default_propagators(
self, mock_iter_entry_points, mock_compositehttppropagator
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/opentelemetry-api-1.1.0/tests/trace/propagation/test_tracecontexthttptextformat.py
new/opentelemetry-api-1.5.0/tests/trace/propagation/test_tracecontexthttptextformat.py
---
old/opentelemetry-api-1.1.0/tests/trace/propagation/test_tracecontexthttptextformat.py
2021-04-20 23:27:16.000000000 +0200
+++
new/opentelemetry-api-1.5.0/tests/trace/propagation/test_tracecontexthttptextformat.py
2021-08-26 11:27:39.000000000 +0200
@@ -19,6 +19,7 @@
from unittest.mock import Mock, patch
from opentelemetry import trace
+from opentelemetry.context import Context
from opentelemetry.trace.propagation import tracecontext
from opentelemetry.trace.span import TraceState
@@ -270,3 +271,51 @@
inject_fields.add(mock_call[1][1])
self.assertEqual(inject_fields, FORMAT.fields)
+
+ def test_extract_no_trace_parent_to_explicit_ctx(self):
+ carrier = {"tracestate": ["foo=1"]}
+ orig_ctx = Context({"k1": "v1"})
+
+ ctx = FORMAT.extract(carrier, orig_ctx)
+ self.assertDictEqual(orig_ctx, ctx)
+
+ def test_extract_no_trace_parent_to_implicit_ctx(self):
+ carrier = {"tracestate": ["foo=1"]}
+
+ ctx = FORMAT.extract(carrier)
+ self.assertDictEqual(Context(), ctx)
+
+ def test_extract_invalid_trace_parent_to_explicit_ctx(self):
+ trace_parent_headers = [
+ "invalid",
+ "00-00000000000000000000000000000000-1234567890123456-00",
+ "00-12345678901234567890123456789012-0000000000000000-00",
+ "00-12345678901234567890123456789012-1234567890123456-00-residue",
+ ]
+ for trace_parent in trace_parent_headers:
+ with self.subTest(trace_parent=trace_parent):
+ carrier = {
+ "traceparent": [trace_parent],
+ "tracestate": ["foo=1"],
+ }
+ orig_ctx = Context({"k1": "v1"})
+
+ ctx = FORMAT.extract(carrier, orig_ctx)
+ self.assertDictEqual(orig_ctx, ctx)
+
+ def test_extract_invalid_trace_parent_to_implicit_ctx(self):
+ trace_parent_headers = [
+ "invalid",
+ "00-00000000000000000000000000000000-1234567890123456-00",
+ "00-12345678901234567890123456789012-0000000000000000-00",
+ "00-12345678901234567890123456789012-1234567890123456-00-residue",
+ ]
+ for trace_parent in trace_parent_headers:
+ with self.subTest(trace_parent=trace_parent):
+ carrier = {
+ "traceparent": [trace_parent],
+ "tracestate": ["foo=1"],
+ }
+
+ ctx = FORMAT.extract(carrier)
+ self.assertDictEqual(Context(), ctx)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/opentelemetry-api-1.1.0/tests/trace/test_span_context.py
new/opentelemetry-api-1.5.0/tests/trace/test_span_context.py
--- old/opentelemetry-api-1.1.0/tests/trace/test_span_context.py
2021-04-20 23:27:16.000000000 +0200
+++ new/opentelemetry-api-1.5.0/tests/trace/test_span_context.py
2021-08-26 11:27:39.000000000 +0200
@@ -34,3 +34,12 @@
pickle_sc = pickle.loads(pickle.dumps(sc))
self.assertEqual(sc.trace_id, pickle_sc.trace_id)
self.assertEqual(sc.span_id, pickle_sc.span_id)
+
+ invalid_sc = trace.SpanContext(
+
9999999999999999999999999999999999999999999999999999999999999999999999999999,
+ 9,
+ is_remote=False,
+ trace_flags=trace.DEFAULT_TRACE_OPTIONS,
+ trace_state=trace.DEFAULT_TRACE_STATE,
+ )
+ self.assertFalse(invalid_sc.is_valid)