From 0f7676975a883c5e637e277eaac09e528e137f96 Mon Sep 17 00:00:00 2001 From: Diego Hurtado Date: Tue, 14 Feb 2023 12:23:01 -0600 Subject: [PATCH 01/11] Update some test environments to 3.10 (#3149) * Update some test environments to 3.10 Fixes #3148 * Update environments in workflows file as well --- .github/workflows/public-api-check.yml | 2 +- .github/workflows/test.yml | 2 +- scripts/public_symbols_checker.py | 20 ++++++++++++-------- tox.ini | 6 +++--- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.github/workflows/public-api-check.yml b/.github/workflows/public-api-check.yml index eead4fa3681..46432af0b54 100644 --- a/.github/workflows/public-api-check.yml +++ b/.github/workflows/public-api-check.yml @@ -31,7 +31,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.9 + python-version: '3.10' - name: Install tox run: pip install tox==3.27.1 -U tox-factor diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e0951b7afd0..b2dbeb6e77f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -101,7 +101,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.9 + python-version: '3.10' architecture: 'x64' - name: Install tox run: pip install tox==3.27.1 diff --git a/scripts/public_symbols_checker.py b/scripts/public_symbols_checker.py index ac8ca060ba9..c485c4740e9 100644 --- a/scripts/public_symbols_checker.py +++ b/scripts/public_symbols_checker.py @@ -76,9 +76,11 @@ def get_symbols(change_type, diff_lines_getter, prefix): def a_diff_lines_getter(diff_lines): return diff_lines.b_blob.data_stream.read().decode("utf-8").split("\n") + def d_diff_lines_getter(diff_lines): return diff_lines.a_blob.data_stream.read().decode("utf-8").split("\n") + def m_diff_lines_getter(diff_lines): return unified_diff( diff_lines.a_blob.data_stream.read().decode("utf-8").split("\n"), @@ -91,6 +93,7 @@ def m_diff_lines_getter(diff_lines): get_symbols("M", m_diff_lines_getter, r"\+") get_symbols("M", m_diff_lines_getter, r"\-") + def remove_common_symbols(): # For each file, we remove the symbols that are added and removed in the # same commit. @@ -115,6 +118,7 @@ def remove_common_symbols(): if not removed_symbols[file_path]: del removed_symbols[file_path] + if added_symbols or removed_symbols: # If a symbol is added and removed in the same commit, we consider it @@ -122,10 +126,10 @@ def remove_common_symbols(): remove_common_symbols() print("The code in this branch adds the following public symbols:") print() - for file_path, symbols in added_symbols.items(): - print(f"- {file_path}") - for symbol in symbols: - print(f"\t{symbol}") + for file_path_, symbols_ in added_symbols.items(): + print(f"- {file_path_}") + for symbol_ in symbols_: + print(f"\t{symbol_}") print() print( @@ -137,10 +141,10 @@ def remove_common_symbols(): print() print("The code in this branch removes the following public symbols:") print() - for file_path, symbols in removed_symbols.items(): - print(f"- {file_path}") - for symbol in symbols: - print(f"\t{symbol}") + for file_path_, symbols_ in removed_symbols.items(): + print(f"- {file_path_}") + for symbol_ in symbols_: + print(f"\t{symbol_}") print() print( diff --git a/tox.ini b/tox.ini index fd357987a61..a757f2dd022 100644 --- a/tox.ini +++ b/tox.ini @@ -189,7 +189,7 @@ commands = mypyinstalled: mypy --install-types --non-interactive --namespace-packages opentelemetry-api/tests/mypysmoke.py --strict [testenv:spellcheck] -basepython: python3.9 +basepython: python3.10 recreate = True deps = codespell @@ -254,7 +254,7 @@ commands = sphinx-build -E -a -W -b html -T . _build/html [testenv:tracecontext] -basepython: python3.9 +basepython: python3.10 deps = # needed for tracecontext aiohttp~=3.6 @@ -312,7 +312,7 @@ commands_post = docker-compose down -v [testenv:public-symbols-check] -basepython: python3.9 +basepython: python3.10 recreate = True deps = GitPython From e03650ac45cb74510f779f6e27fe4b920095f8be Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Wed, 15 Feb 2023 01:21:52 +0100 Subject: [PATCH 02/11] Update `__all__` to statically define reexports (#3143) * Statically define __all__ for stable modules This prevents errors from typecheckers since they can now see that members are explicitly reexported * Add explicit __all__ to experimental _logs modules * Add changelog for 3143 --------- Co-authored-by: Srikanth Chekuri --- CHANGELOG.md | 2 ++ .../src/opentelemetry/_logs/__init__.py | 28 +++++++++-------- .../src/opentelemetry/sdk/_logs/__init__.py | 16 +++++----- .../sdk/_logs/export/__init__.py | 19 ++++++------ .../src/opentelemetry/sdk/metrics/__init__.py | 28 ++++++++--------- .../sdk/metrics/export/__init__.py | 30 ++++++++++++++----- .../sdk/metrics/view/__init__.py | 20 +++++++------ 7 files changed, 83 insertions(+), 60 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f562971aeb7..e6ddd580e7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased +- Change ``__all__`` to be statically defined. + ([#3143](https://github.com/open-telemetry/opentelemetry-python/pull/3143)) - Remove the ability to set a global metric prefix for Prometheus exporter ([#3137](https://github.com/open-telemetry/opentelemetry-python/pull/3137)) - Adds environment variables for log exporter diff --git a/opentelemetry-api/src/opentelemetry/_logs/__init__.py b/opentelemetry-api/src/opentelemetry/_logs/__init__.py index d9677a5f220..a01d1b14ee5 100644 --- a/opentelemetry-api/src/opentelemetry/_logs/__init__.py +++ b/opentelemetry-api/src/opentelemetry/_logs/__init__.py @@ -34,9 +34,7 @@ .. versionadded:: 1.15.0 """ -# pylint: disable=unused-import - -from opentelemetry._logs._internal import ( # noqa: F401 +from opentelemetry._logs._internal import ( Logger, LoggerProvider, LogRecord, @@ -46,13 +44,17 @@ get_logger_provider, set_logger_provider, ) -from opentelemetry._logs.severity import ( # noqa: F401 - SeverityNumber, - std_to_otel, -) - -__all__ = [] -for key, value in globals().copy().items(): # type: ignore - if not key.startswith("_"): - value.__module__ = __name__ # type: ignore - __all__.append(key) +from opentelemetry._logs.severity import SeverityNumber, std_to_otel + +__all__ = [ + "Logger", + "LoggerProvider", + "LogRecord", + "NoOpLogger", + "NoOpLoggerProvider", + "get_logger", + "get_logger_provider", + "set_logger_provider", + "SeverityNumber", + "std_to_otel", +] diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/__init__.py index a548ef3793b..a86fbaee0f1 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/__init__.py @@ -12,9 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -# pylint: disable=unused-import -from opentelemetry.sdk._logs._internal import ( # noqa: F401 +from opentelemetry.sdk._logs._internal import ( LogData, Logger, LoggerProvider, @@ -23,8 +22,11 @@ LogRecordProcessor, ) -__all__ = [] -for key, value in globals().copy().items(): - if not key.startswith("_"): - value.__module__ = __name__ - __all__.append(key) +__all__ = [ + "LogData", + "Logger", + "LoggerProvider", + "LoggingHandler", + "LogRecord", + "LogRecordProcessor", +] diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/export/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/export/__init__.py index 10402886671..37a9eca7a08 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/export/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/export/__init__.py @@ -12,9 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# pylint: disable=unused-import - -from opentelemetry.sdk._logs._internal.export import ( # noqa: F401 +from opentelemetry.sdk._logs._internal.export import ( BatchLogRecordProcessor, ConsoleLogExporter, LogExporter, @@ -23,12 +21,15 @@ ) # The point module is not in the export directory to avoid a circular import. -from opentelemetry.sdk._logs._internal.export.in_memory_log_exporter import ( # noqa: F401 +from opentelemetry.sdk._logs._internal.export.in_memory_log_exporter import ( InMemoryLogExporter, ) -__all__ = [] -for key, value in globals().copy().items(): - if not key.startswith("_"): - value.__module__ = __name__ - __all__.append(key) +__all__ = [ + "BatchLogRecordProcessor", + "ConsoleLogExporter", + "LogExporter", + "LogExportResult", + "SimpleLogRecordProcessor", + "InMemoryLogExporter", +] diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/__init__.py index 2219bc35c52..1ca14283cf6 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/__init__.py @@ -12,16 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -# pylint: disable=unused-import -from opentelemetry.sdk.metrics._internal import ( # noqa: F401 - Meter, - MeterProvider, -) -from opentelemetry.sdk.metrics._internal.exceptions import ( # noqa: F401 - MetricsTimeoutError, -) -from opentelemetry.sdk.metrics._internal.instrument import ( # noqa: F401 +from opentelemetry.sdk.metrics._internal import Meter, MeterProvider +from opentelemetry.sdk.metrics._internal.exceptions import MetricsTimeoutError +from opentelemetry.sdk.metrics._internal.instrument import ( Counter, Histogram, ObservableCounter, @@ -30,8 +24,14 @@ UpDownCounter, ) -__all__ = [] -for key, value in globals().copy().items(): - if not key.startswith("_"): - value.__module__ = __name__ - __all__.append(key) +__all__ = [ + "Meter", + "MeterProvider", + "MetricsTimeoutError", + "Counter", + "Histogram", + "ObservableCounter", + "ObservableGauge", + "ObservableUpDownCounter", + "UpDownCounter", +] diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/__init__.py index 76021bd576d..a87beadce56 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/__init__.py @@ -12,9 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -# pylint: disable=unused-import -from opentelemetry.sdk.metrics._internal.export import ( # noqa: F401 +from opentelemetry.sdk.metrics._internal.export import ( AggregationTemporality, ConsoleMetricExporter, InMemoryMetricReader, @@ -25,7 +24,7 @@ ) # The point module is not in the export directory to avoid a circular import. -from opentelemetry.sdk.metrics._internal.point import ( # noqa: F401 +from opentelemetry.sdk.metrics._internal.point import ( DataPointT, DataT, Gauge, @@ -39,8 +38,23 @@ Sum, ) -__all__ = [] -for key, value in globals().copy().items(): - if not key.startswith("_"): - value.__module__ = __name__ - __all__.append(key) +__all__ = [ + "AggregationTemporality", + "ConsoleMetricExporter", + "InMemoryMetricReader", + "MetricExporter", + "MetricExportResult", + "MetricReader", + "PeriodicExportingMetricReader", + "DataPointT", + "DataT", + "Gauge", + "Histogram", + "HistogramDataPoint", + "Metric", + "MetricsData", + "NumberDataPoint", + "ResourceMetrics", + "ScopeMetrics", + "Sum", +] diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/view/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/view/__init__.py index b20053d876d..f6e4dcb3aae 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/view/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/view/__init__.py @@ -12,9 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# pylint: disable=unused-import - -from opentelemetry.sdk.metrics._internal.aggregation import ( # noqa: F401 +from opentelemetry.sdk.metrics._internal.aggregation import ( Aggregation, DefaultAggregation, DropAggregation, @@ -22,10 +20,14 @@ LastValueAggregation, SumAggregation, ) -from opentelemetry.sdk.metrics._internal.view import View # noqa: F401 +from opentelemetry.sdk.metrics._internal.view import View -__all__ = [] -for key, value in globals().copy().items(): - if not key.startswith("_"): - value.__module__ = __name__ - __all__.append(key) +__all__ = [ + "Aggregation", + "DefaultAggregation", + "DropAggregation", + "ExplicitBucketHistogramAggregation", + "LastValueAggregation", + "SumAggregation", + "View", +] From 541a7496ecac19916a4a56c74134944bb8eef7dc Mon Sep 17 00:00:00 2001 From: OpenTelemetry Bot <107717825+opentelemetrybot@users.noreply.github.com> Date: Fri, 17 Feb 2023 10:11:54 -0800 Subject: [PATCH 03/11] Update version to 1.17.0.dev/0.38b0.dev (#3178) --- .github/workflows/test.yml | 2 +- CHANGELOG.md | 2 ++ eachdist.ini | 4 ++-- .../src/opentelemetry/exporter/jaeger/proto/grpc/version.py | 2 +- .../src/opentelemetry/exporter/jaeger/thrift/version.py | 2 +- exporter/opentelemetry-exporter-jaeger/pyproject.toml | 4 ++-- .../src/opentelemetry/exporter/jaeger/version.py | 2 +- exporter/opentelemetry-exporter-opencensus/pyproject.toml | 2 +- .../src/opentelemetry/exporter/opencensus/version.py | 2 +- .../opentelemetry-exporter-otlp-proto-grpc/pyproject.toml | 4 ++-- .../src/opentelemetry/exporter/otlp/proto/grpc/version.py | 2 +- .../opentelemetry-exporter-otlp-proto-http/pyproject.toml | 4 ++-- .../src/opentelemetry/exporter/otlp/proto/http/version.py | 2 +- exporter/opentelemetry-exporter-otlp/pyproject.toml | 4 ++-- .../src/opentelemetry/exporter/otlp/version.py | 2 +- .../src/opentelemetry/exporter/prometheus/version.py | 2 +- .../src/opentelemetry/exporter/zipkin/json/version.py | 2 +- .../opentelemetry-exporter-zipkin-proto-http/pyproject.toml | 2 +- .../src/opentelemetry/exporter/zipkin/proto/http/version.py | 2 +- exporter/opentelemetry-exporter-zipkin/pyproject.toml | 4 ++-- .../src/opentelemetry/exporter/zipkin/version.py | 2 +- opentelemetry-api/src/opentelemetry/version.py | 2 +- opentelemetry-proto/src/opentelemetry/proto/version.py | 2 +- opentelemetry-sdk/pyproject.toml | 4 ++-- opentelemetry-sdk/src/opentelemetry/sdk/version.py | 2 +- .../src/opentelemetry/semconv/version.py | 2 +- .../src/opentelemetry/propagators/b3/version.py | 2 +- .../src/opentelemetry/propagators/jaeger/version.py | 2 +- shim/opentelemetry-opentracing-shim/pyproject.toml | 2 +- .../src/opentelemetry/shim/opentracing_shim/version.py | 2 +- tests/opentelemetry-test-utils/pyproject.toml | 4 ++-- .../src/opentelemetry/test/version.py | 2 +- 32 files changed, 41 insertions(+), 39 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b2dbeb6e77f..5ee26e52471 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ env: # Otherwise, set variable to the commit of your branch on # opentelemetry-python-contrib which is compatible with these Core repo # changes. - CONTRIB_REPO_SHA: 1f0dda9865b3c83e6dea2f2b127a2b0971853543 + CONTRIB_REPO_SHA: ca2c23fd3b91c48f2b6515658993480f634cf1b2 # This is needed because we do not clone the core repo in contrib builds anymore. # When running contrib builds as part of core builds, we use actions/checkout@v2 which # does not set an environment variable (simply just runs tox), which is different when diff --git a/CHANGELOG.md b/CHANGELOG.md index e6ddd580e7d..641e83a0874 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased + +## Version 1.16.0/0.37b0 (2023-02-15) - Change ``__all__`` to be statically defined. ([#3143](https://github.com/open-telemetry/opentelemetry-python/pull/3143)) - Remove the ability to set a global metric prefix for Prometheus exporter diff --git a/eachdist.ini b/eachdist.ini index 6606776ecb4..164faad3d17 100644 --- a/eachdist.ini +++ b/eachdist.ini @@ -11,7 +11,7 @@ sortfirst= exporter/* [stable] -version=1.16.0.dev +version=1.17.0.dev packages= opentelemetry-sdk @@ -30,7 +30,7 @@ packages= opentelemetry-api [prerelease] -version=0.37b0.dev +version=0.38b0.dev packages= opentelemetry-opentracing-shim diff --git a/exporter/opentelemetry-exporter-jaeger-proto-grpc/src/opentelemetry/exporter/jaeger/proto/grpc/version.py b/exporter/opentelemetry-exporter-jaeger-proto-grpc/src/opentelemetry/exporter/jaeger/proto/grpc/version.py index 4209aaad38f..f90e55e55a1 100644 --- a/exporter/opentelemetry-exporter-jaeger-proto-grpc/src/opentelemetry/exporter/jaeger/proto/grpc/version.py +++ b/exporter/opentelemetry-exporter-jaeger-proto-grpc/src/opentelemetry/exporter/jaeger/proto/grpc/version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "1.16.0.dev" +__version__ = "1.17.0.dev" diff --git a/exporter/opentelemetry-exporter-jaeger-thrift/src/opentelemetry/exporter/jaeger/thrift/version.py b/exporter/opentelemetry-exporter-jaeger-thrift/src/opentelemetry/exporter/jaeger/thrift/version.py index 4209aaad38f..f90e55e55a1 100644 --- a/exporter/opentelemetry-exporter-jaeger-thrift/src/opentelemetry/exporter/jaeger/thrift/version.py +++ b/exporter/opentelemetry-exporter-jaeger-thrift/src/opentelemetry/exporter/jaeger/thrift/version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "1.16.0.dev" +__version__ = "1.17.0.dev" diff --git a/exporter/opentelemetry-exporter-jaeger/pyproject.toml b/exporter/opentelemetry-exporter-jaeger/pyproject.toml index c595f817f3b..5c64b989be7 100644 --- a/exporter/opentelemetry-exporter-jaeger/pyproject.toml +++ b/exporter/opentelemetry-exporter-jaeger/pyproject.toml @@ -26,8 +26,8 @@ classifiers = [ "Typing :: Typed", ] dependencies = [ - "opentelemetry-exporter-jaeger-proto-grpc == 1.16.0.dev", - "opentelemetry-exporter-jaeger-thrift == 1.16.0.dev", + "opentelemetry-exporter-jaeger-proto-grpc == 1.17.0.dev", + "opentelemetry-exporter-jaeger-thrift == 1.17.0.dev", ] [project.optional-dependencies] diff --git a/exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/version.py b/exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/version.py index 4209aaad38f..f90e55e55a1 100644 --- a/exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/version.py +++ b/exporter/opentelemetry-exporter-jaeger/src/opentelemetry/exporter/jaeger/version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "1.16.0.dev" +__version__ = "1.17.0.dev" diff --git a/exporter/opentelemetry-exporter-opencensus/pyproject.toml b/exporter/opentelemetry-exporter-opencensus/pyproject.toml index 81d4546dd0c..8e359f5d4d5 100644 --- a/exporter/opentelemetry-exporter-opencensus/pyproject.toml +++ b/exporter/opentelemetry-exporter-opencensus/pyproject.toml @@ -28,7 +28,7 @@ classifiers = [ dependencies = [ "grpcio >= 1.0.0, < 2.0.0", "opencensus-proto >= 0.1.0, < 1.0.0", - "opentelemetry-api >= 1.16.0.dev", + "opentelemetry-api >= 1.17.0.dev", "opentelemetry-sdk >= 1.15", "protobuf ~= 3.13", "setuptools >= 16.0", diff --git a/exporter/opentelemetry-exporter-opencensus/src/opentelemetry/exporter/opencensus/version.py b/exporter/opentelemetry-exporter-opencensus/src/opentelemetry/exporter/opencensus/version.py index 0a47df4f5a0..8778b43b174 100644 --- a/exporter/opentelemetry-exporter-opencensus/src/opentelemetry/exporter/opencensus/version.py +++ b/exporter/opentelemetry-exporter-opencensus/src/opentelemetry/exporter/opencensus/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.37b0.dev" +__version__ = "0.38b0.dev" diff --git a/exporter/opentelemetry-exporter-otlp-proto-grpc/pyproject.toml b/exporter/opentelemetry-exporter-otlp-proto-grpc/pyproject.toml index 36401ac1069..aa369caf00b 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-grpc/pyproject.toml +++ b/exporter/opentelemetry-exporter-otlp-proto-grpc/pyproject.toml @@ -30,8 +30,8 @@ dependencies = [ "googleapis-common-protos ~= 1.52", "grpcio >= 1.0.0, < 2.0.0", "opentelemetry-api ~= 1.15", - "opentelemetry-proto == 1.16.0.dev", - "opentelemetry-sdk ~= 1.16.0.dev", + "opentelemetry-proto == 1.17.0.dev", + "opentelemetry-sdk ~= 1.17.0.dev", ] [project.optional-dependencies] diff --git a/exporter/opentelemetry-exporter-otlp-proto-grpc/src/opentelemetry/exporter/otlp/proto/grpc/version.py b/exporter/opentelemetry-exporter-otlp-proto-grpc/src/opentelemetry/exporter/otlp/proto/grpc/version.py index 0b4a18e0a24..904e2b48efe 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-grpc/src/opentelemetry/exporter/otlp/proto/grpc/version.py +++ b/exporter/opentelemetry-exporter-otlp-proto-grpc/src/opentelemetry/exporter/otlp/proto/grpc/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "1.16.0.dev" +__version__ = "1.17.0.dev" diff --git a/exporter/opentelemetry-exporter-otlp-proto-http/pyproject.toml b/exporter/opentelemetry-exporter-otlp-proto-http/pyproject.toml index b3a12fc91d1..9675d1d9826 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-http/pyproject.toml +++ b/exporter/opentelemetry-exporter-otlp-proto-http/pyproject.toml @@ -29,8 +29,8 @@ dependencies = [ "backoff >= 1.10.0, < 3.0.0; python_version>='3.7'", "googleapis-common-protos ~= 1.52", "opentelemetry-api ~= 1.15", - "opentelemetry-proto == 1.16.0.dev", - "opentelemetry-sdk ~= 1.16.0.dev", + "opentelemetry-proto == 1.17.0.dev", + "opentelemetry-sdk ~= 1.17.0.dev", "requests ~= 2.7", ] diff --git a/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/version.py b/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/version.py index 0b4a18e0a24..904e2b48efe 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/version.py +++ b/exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "1.16.0.dev" +__version__ = "1.17.0.dev" diff --git a/exporter/opentelemetry-exporter-otlp/pyproject.toml b/exporter/opentelemetry-exporter-otlp/pyproject.toml index ab605eb3e9d..6de1ff977b6 100644 --- a/exporter/opentelemetry-exporter-otlp/pyproject.toml +++ b/exporter/opentelemetry-exporter-otlp/pyproject.toml @@ -26,8 +26,8 @@ classifiers = [ "Typing :: Typed", ] dependencies = [ - "opentelemetry-exporter-otlp-proto-grpc == 1.16.0.dev", - "opentelemetry-exporter-otlp-proto-http == 1.16.0.dev", + "opentelemetry-exporter-otlp-proto-grpc == 1.17.0.dev", + "opentelemetry-exporter-otlp-proto-http == 1.17.0.dev", ] [project.entry-points.opentelemetry_logs_exporter] diff --git a/exporter/opentelemetry-exporter-otlp/src/opentelemetry/exporter/otlp/version.py b/exporter/opentelemetry-exporter-otlp/src/opentelemetry/exporter/otlp/version.py index 0b4a18e0a24..904e2b48efe 100644 --- a/exporter/opentelemetry-exporter-otlp/src/opentelemetry/exporter/otlp/version.py +++ b/exporter/opentelemetry-exporter-otlp/src/opentelemetry/exporter/otlp/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "1.16.0.dev" +__version__ = "1.17.0.dev" diff --git a/exporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus/version.py b/exporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus/version.py index 0a47df4f5a0..8778b43b174 100644 --- a/exporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus/version.py +++ b/exporter/opentelemetry-exporter-prometheus/src/opentelemetry/exporter/prometheus/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.37b0.dev" +__version__ = "0.38b0.dev" diff --git a/exporter/opentelemetry-exporter-zipkin-json/src/opentelemetry/exporter/zipkin/json/version.py b/exporter/opentelemetry-exporter-zipkin-json/src/opentelemetry/exporter/zipkin/json/version.py index 0b4a18e0a24..904e2b48efe 100644 --- a/exporter/opentelemetry-exporter-zipkin-json/src/opentelemetry/exporter/zipkin/json/version.py +++ b/exporter/opentelemetry-exporter-zipkin-json/src/opentelemetry/exporter/zipkin/json/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "1.16.0.dev" +__version__ = "1.17.0.dev" diff --git a/exporter/opentelemetry-exporter-zipkin-proto-http/pyproject.toml b/exporter/opentelemetry-exporter-zipkin-proto-http/pyproject.toml index 1c4137c9292..c6fe12e0ca4 100644 --- a/exporter/opentelemetry-exporter-zipkin-proto-http/pyproject.toml +++ b/exporter/opentelemetry-exporter-zipkin-proto-http/pyproject.toml @@ -27,7 +27,7 @@ classifiers = [ ] dependencies = [ "opentelemetry-api ~= 1.3", - "opentelemetry-exporter-zipkin-json == 1.16.0.dev", + "opentelemetry-exporter-zipkin-json == 1.17.0.dev", "opentelemetry-sdk ~= 1.11", "protobuf ~= 3.12", "requests ~= 2.7", diff --git a/exporter/opentelemetry-exporter-zipkin-proto-http/src/opentelemetry/exporter/zipkin/proto/http/version.py b/exporter/opentelemetry-exporter-zipkin-proto-http/src/opentelemetry/exporter/zipkin/proto/http/version.py index 0b4a18e0a24..904e2b48efe 100644 --- a/exporter/opentelemetry-exporter-zipkin-proto-http/src/opentelemetry/exporter/zipkin/proto/http/version.py +++ b/exporter/opentelemetry-exporter-zipkin-proto-http/src/opentelemetry/exporter/zipkin/proto/http/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "1.16.0.dev" +__version__ = "1.17.0.dev" diff --git a/exporter/opentelemetry-exporter-zipkin/pyproject.toml b/exporter/opentelemetry-exporter-zipkin/pyproject.toml index d982aaf896e..50ec818a09d 100644 --- a/exporter/opentelemetry-exporter-zipkin/pyproject.toml +++ b/exporter/opentelemetry-exporter-zipkin/pyproject.toml @@ -26,8 +26,8 @@ classifiers = [ "Typing :: Typed", ] dependencies = [ - "opentelemetry-exporter-zipkin-json == 1.16.0.dev", - "opentelemetry-exporter-zipkin-proto-http == 1.16.0.dev", + "opentelemetry-exporter-zipkin-json == 1.17.0.dev", + "opentelemetry-exporter-zipkin-proto-http == 1.17.0.dev", ] [project.optional-dependencies] diff --git a/exporter/opentelemetry-exporter-zipkin/src/opentelemetry/exporter/zipkin/version.py b/exporter/opentelemetry-exporter-zipkin/src/opentelemetry/exporter/zipkin/version.py index 0b4a18e0a24..904e2b48efe 100644 --- a/exporter/opentelemetry-exporter-zipkin/src/opentelemetry/exporter/zipkin/version.py +++ b/exporter/opentelemetry-exporter-zipkin/src/opentelemetry/exporter/zipkin/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "1.16.0.dev" +__version__ = "1.17.0.dev" diff --git a/opentelemetry-api/src/opentelemetry/version.py b/opentelemetry-api/src/opentelemetry/version.py index 0b4a18e0a24..904e2b48efe 100644 --- a/opentelemetry-api/src/opentelemetry/version.py +++ b/opentelemetry-api/src/opentelemetry/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "1.16.0.dev" +__version__ = "1.17.0.dev" diff --git a/opentelemetry-proto/src/opentelemetry/proto/version.py b/opentelemetry-proto/src/opentelemetry/proto/version.py index 0b4a18e0a24..904e2b48efe 100644 --- a/opentelemetry-proto/src/opentelemetry/proto/version.py +++ b/opentelemetry-proto/src/opentelemetry/proto/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "1.16.0.dev" +__version__ = "1.17.0.dev" diff --git a/opentelemetry-sdk/pyproject.toml b/opentelemetry-sdk/pyproject.toml index 4798f4fbc65..bffc677fd00 100644 --- a/opentelemetry-sdk/pyproject.toml +++ b/opentelemetry-sdk/pyproject.toml @@ -26,8 +26,8 @@ classifiers = [ "Typing :: Typed", ] dependencies = [ - "opentelemetry-api == 1.16.0.dev", - "opentelemetry-semantic-conventions == 0.37b0.dev", + "opentelemetry-api == 1.17.0.dev", + "opentelemetry-semantic-conventions == 0.38b0.dev", "setuptools >= 16.0", "typing-extensions >= 3.7.4", ] diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/version.py b/opentelemetry-sdk/src/opentelemetry/sdk/version.py index 0b4a18e0a24..904e2b48efe 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/version.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "1.16.0.dev" +__version__ = "1.17.0.dev" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/version.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/version.py index 0a47df4f5a0..8778b43b174 100644 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/version.py +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.37b0.dev" +__version__ = "0.38b0.dev" diff --git a/propagator/opentelemetry-propagator-b3/src/opentelemetry/propagators/b3/version.py b/propagator/opentelemetry-propagator-b3/src/opentelemetry/propagators/b3/version.py index 0b4a18e0a24..904e2b48efe 100644 --- a/propagator/opentelemetry-propagator-b3/src/opentelemetry/propagators/b3/version.py +++ b/propagator/opentelemetry-propagator-b3/src/opentelemetry/propagators/b3/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "1.16.0.dev" +__version__ = "1.17.0.dev" diff --git a/propagator/opentelemetry-propagator-jaeger/src/opentelemetry/propagators/jaeger/version.py b/propagator/opentelemetry-propagator-jaeger/src/opentelemetry/propagators/jaeger/version.py index 0b4a18e0a24..904e2b48efe 100644 --- a/propagator/opentelemetry-propagator-jaeger/src/opentelemetry/propagators/jaeger/version.py +++ b/propagator/opentelemetry-propagator-jaeger/src/opentelemetry/propagators/jaeger/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "1.16.0.dev" +__version__ = "1.17.0.dev" diff --git a/shim/opentelemetry-opentracing-shim/pyproject.toml b/shim/opentelemetry-opentracing-shim/pyproject.toml index d831379655d..742eabd2f49 100644 --- a/shim/opentelemetry-opentracing-shim/pyproject.toml +++ b/shim/opentelemetry-opentracing-shim/pyproject.toml @@ -33,7 +33,7 @@ dependencies = [ [project.optional-dependencies] test = [ - "opentelemetry-test-utils == 0.37b0.dev", + "opentelemetry-test-utils == 0.38b0.dev", "opentracing ~= 2.2.0", ] diff --git a/shim/opentelemetry-opentracing-shim/src/opentelemetry/shim/opentracing_shim/version.py b/shim/opentelemetry-opentracing-shim/src/opentelemetry/shim/opentracing_shim/version.py index 0a47df4f5a0..8778b43b174 100644 --- a/shim/opentelemetry-opentracing-shim/src/opentelemetry/shim/opentracing_shim/version.py +++ b/shim/opentelemetry-opentracing-shim/src/opentelemetry/shim/opentracing_shim/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.37b0.dev" +__version__ = "0.38b0.dev" diff --git a/tests/opentelemetry-test-utils/pyproject.toml b/tests/opentelemetry-test-utils/pyproject.toml index b9f84602a2a..7db7c0145e6 100644 --- a/tests/opentelemetry-test-utils/pyproject.toml +++ b/tests/opentelemetry-test-utils/pyproject.toml @@ -25,8 +25,8 @@ classifiers = [ ] dependencies = [ "asgiref ~= 3.0", - "opentelemetry-api == 1.16.0.dev", - "opentelemetry-sdk == 1.16.0.dev", + "opentelemetry-api == 1.17.0.dev", + "opentelemetry-sdk == 1.17.0.dev", ] [project.optional-dependencies] diff --git a/tests/opentelemetry-test-utils/src/opentelemetry/test/version.py b/tests/opentelemetry-test-utils/src/opentelemetry/test/version.py index 6b7ff9a9463..9d323a2a659 100644 --- a/tests/opentelemetry-test-utils/src/opentelemetry/test/version.py +++ b/tests/opentelemetry-test-utils/src/opentelemetry/test/version.py @@ -1 +1 @@ -__version__ = "0.37b0.dev" +__version__ = "0.38b0.dev" From 3df55e93a10d2dc5fb9487f04692b0396d9dd9c5 Mon Sep 17 00:00:00 2001 From: OpenTelemetry Bot <107717825+opentelemetrybot@users.noreply.github.com> Date: Tue, 21 Feb 2023 10:08:01 -0800 Subject: [PATCH 04/11] Copy change log updates from release/v1.16.x-0.37bx (#3187) --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 641e83a0874..796fda683e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased -## Version 1.16.0/0.37b0 (2023-02-15) +## Version 1.16.0/0.37b0 (2023-02-17) - Change ``__all__`` to be statically defined. ([#3143](https://github.com/open-telemetry/opentelemetry-python/pull/3143)) - Remove the ability to set a global metric prefix for Prometheus exporter From 588c5fbf49a9c8e476cdca3f1bca5969c0b3a65c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Feb 2023 19:04:04 +0000 Subject: [PATCH 05/11] Bump werkzeug in /docs/examples/fork-process-model/flask-uwsgi (#3180) Bumps [werkzeug](https://github.com/pallets/werkzeug) from 1.0.1 to 2.2.3. - [Release notes](https://github.com/pallets/werkzeug/releases) - [Changelog](https://github.com/pallets/werkzeug/blob/main/CHANGES.rst) - [Commits](https://github.com/pallets/werkzeug/compare/1.0.1...2.2.3) --- updated-dependencies: - dependency-name: werkzeug dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Srikanth Chekuri --- docs/examples/fork-process-model/flask-uwsgi/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/fork-process-model/flask-uwsgi/requirements.txt b/docs/examples/fork-process-model/flask-uwsgi/requirements.txt index 86b654a95dc..3f9f6f6454a 100644 --- a/docs/examples/fork-process-model/flask-uwsgi/requirements.txt +++ b/docs/examples/fork-process-model/flask-uwsgi/requirements.txt @@ -16,5 +16,5 @@ protobuf==3.18.3 six==1.15.0 thrift==0.13.0 uWSGI==2.0.19.1 -Werkzeug==1.0.1 +Werkzeug==2.2.3 wrapt==1.12.1 From c757e4a26f0b3c5157869150965aa3341532776e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Feb 2023 20:00:56 +0000 Subject: [PATCH 06/11] Bump werkzeug in /docs/examples/fork-process-model/flask-gunicorn (#3179) Bumps [werkzeug](https://github.com/pallets/werkzeug) from 1.0.1 to 2.2.3. - [Release notes](https://github.com/pallets/werkzeug/releases) - [Changelog](https://github.com/pallets/werkzeug/blob/main/CHANGES.rst) - [Commits](https://github.com/pallets/werkzeug/compare/1.0.1...2.2.3) --- updated-dependencies: - dependency-name: werkzeug dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Leighton Chen Co-authored-by: Srikanth Chekuri --- .../examples/fork-process-model/flask-gunicorn/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/fork-process-model/flask-gunicorn/requirements.txt b/docs/examples/fork-process-model/flask-gunicorn/requirements.txt index 86b654a95dc..3f9f6f6454a 100644 --- a/docs/examples/fork-process-model/flask-gunicorn/requirements.txt +++ b/docs/examples/fork-process-model/flask-gunicorn/requirements.txt @@ -16,5 +16,5 @@ protobuf==3.18.3 six==1.15.0 thrift==0.13.0 uWSGI==2.0.19.1 -Werkzeug==1.0.1 +Werkzeug==2.2.3 wrapt==1.12.1 From 2d1f0b9f5fce62549d1338882f37b91b95881c75 Mon Sep 17 00:00:00 2001 From: Shalev Roda <65566801+shalevr@users.noreply.github.com> Date: Thu, 23 Feb 2023 03:38:59 +0200 Subject: [PATCH 07/11] Add metrics base tests (#3182) --- .../src/opentelemetry/test/test_base.py | 122 +++++++++++++++++- 1 file changed, 120 insertions(+), 2 deletions(-) diff --git a/tests/opentelemetry-test-utils/src/opentelemetry/test/test_base.py b/tests/opentelemetry-test-utils/src/opentelemetry/test/test_base.py index 0d81fcb4f53..f7451f0d3c6 100644 --- a/tests/opentelemetry-test-utils/src/opentelemetry/test/test_base.py +++ b/tests/opentelemetry-test-utils/src/opentelemetry/test/test_base.py @@ -15,12 +15,19 @@ import logging import unittest from contextlib import contextmanager -from typing import Tuple +from typing import Optional, Sequence, Tuple from opentelemetry import metrics as metrics_api from opentelemetry import trace as trace_api from opentelemetry.sdk.metrics import MeterProvider -from opentelemetry.sdk.metrics.export import InMemoryMetricReader, MetricReader +from opentelemetry.sdk.metrics._internal.point import Metric +from opentelemetry.sdk.metrics.export import ( + DataPointT, + HistogramDataPoint, + InMemoryMetricReader, + MetricReader, + NumberDataPoint, +) from opentelemetry.sdk.trace import TracerProvider, export from opentelemetry.sdk.trace.export.in_memory_span_exporter import ( InMemorySpanExporter, @@ -130,6 +137,117 @@ def disable_logging(highest_level=logging.CRITICAL): finally: logging.disable(logging.NOTSET) + def get_sorted_metrics(self): + resource_metrics = ( + self.memory_metrics_reader.get_metrics_data().resource_metrics + ) + + all_metrics = [] + for metrics in resource_metrics: + for scope_metrics in metrics.scope_metrics: + all_metrics.extend(scope_metrics.metrics) + + return self.sorted_metrics(all_metrics) + + @staticmethod + def sorted_metrics(metrics): + """ + Sorts metrics by metric name. + """ + return sorted( + metrics, + key=lambda m: m.name, + ) + + def assert_metric_expected( + self, + metric: Metric, + expected_data_points: Sequence[DataPointT], + est_value_delta: Optional[float] = 0, + ): + self.assertEqual( + len(expected_data_points), len(metric.data.data_points) + ) + for expected_data_point in expected_data_points: + self.assert_data_point_expected( + expected_data_point, metric.data.data_points, est_value_delta + ) + + # pylint: disable=unidiomatic-typecheck + @staticmethod + def is_data_points_equal( + expected_data_point: DataPointT, + data_point: DataPointT, + est_value_delta: Optional[float] = 0, + ): + if type(expected_data_point) != type(data_point) or not isinstance( + expected_data_point, (HistogramDataPoint, NumberDataPoint) + ): + return False + + values_diff = None + if isinstance(data_point, NumberDataPoint): + values_diff = abs(expected_data_point.value - data_point.value) + elif isinstance(data_point, HistogramDataPoint): + values_diff = abs(expected_data_point.sum - data_point.sum) + if expected_data_point.count != data_point.count or ( + est_value_delta == 0 + and ( + expected_data_point.min != data_point.min + or expected_data_point.max != data_point.max + ) + ): + return False + + return ( + values_diff <= est_value_delta + and expected_data_point.attributes == dict(data_point.attributes) + ) + + def assert_data_point_expected( + self, + expected_data_point: DataPointT, + data_points: Sequence[DataPointT], + est_value_delta: Optional[float] = 0, + ): + is_data_point_exist = False + for data_point in data_points: + if self.is_data_points_equal( + expected_data_point, data_point, est_value_delta + ): + is_data_point_exist = True + break + + self.assertTrue( + is_data_point_exist, + msg=f"Data point {expected_data_point} does not exist", + ) + + @staticmethod + def create_number_data_point(value, attributes): + return NumberDataPoint( + value=value, + attributes=attributes, + start_time_unix_nano=0, + time_unix_nano=0, + ) + + @staticmethod + def create_histogram_data_point( + sum_data_point, count, max_data_point, min_data_point, attributes + ): + return HistogramDataPoint( + count=count, + sum=sum_data_point, + min=min_data_point, + max=max_data_point, + attributes=attributes, + start_time_unix_nano=0, + time_unix_nano=0, + bucket_counts=[], + explicit_bounds=[], + ) + class FinishedTestSpans(list): def __init__(self, test, spans): From 54a1003eed042c9eea7346fca534b41e7077960a Mon Sep 17 00:00:00 2001 From: Srikanth Chekuri Date: Thu, 23 Feb 2023 23:11:39 +0530 Subject: [PATCH 08/11] Update approvers/maintainers list (#3194) --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 03fcdf73b0b..ec94eb8fe22 100644 --- a/README.md +++ b/README.md @@ -136,15 +136,16 @@ Meeting notes are available as a public [Google doc](https://docs.google.com/doc Approvers ([@open-telemetry/python-approvers](https://github.com/orgs/open-telemetry/teams/python-approvers)): - [Aaron Abbott](https://github.com/aabmass), Google -- [Owais Lone](https://github.com/owais), Splunk -- [Nathaniel Ruiz Nowell](https://github.com/NathanielRN), AWS +- [Sanket Mehta](https://github.com/sanketmehta28), Cisco Emeritus Approvers +- [Ashutosh Goel](https://github.com/ashu658), Cisco - [Carlos Alberto Cortez](https://github.com/carlosalberto), Lightstep - [Christian Neumüller](https://github.com/Oberon00), Dynatrace - [Hector Hernandez](https://github.com/hectorhdzg), Microsoft - [Mauricio Vásquez](https://github.com/mauriciovasquezbernal), Kinvolk +- [Nathaniel Ruiz Nowell](https://github.com/NathanielRN), AWS - [Tahir H. Butt](https://github.com/majorgreys) DataDog *For more information about the approver role, see the [community repository](https://github.com/open-telemetry/community/blob/main/community-membership.md#approver).* @@ -159,6 +160,7 @@ Emeritus Maintainers: - [Alex Boten](https://github.com/codeboten), Lightstep - [Chris Kleinknecht](https://github.com/c24t), Google +- [Owais Lone](https://github.com/owais), Splunk - [Reiley Yang](https://github.com/reyang), Microsoft - [Yusuke Tsutsumi](https://github.com/toumorokoshi), Google From 559e06d577f50d0130cdc34a4f6a7b75b0704c18 Mon Sep 17 00:00:00 2001 From: Mark Allanson Date: Thu, 23 Feb 2023 18:59:20 +0000 Subject: [PATCH 09/11] PeriodicExportingMetricReader will continue collection times out (#3098) (#3100) In cases where collection times out, the period exporting reader thread should not terminate, but instead catch, log, and continue on after the regular interval seconds. Prior to this commit, a metric collection timeout would terminate the thread and stop reporting metrics to the wrapped exporter resulting in the appearance in observability tooling of metrics just stopping without reason. --- CHANGELOG.md | 5 ++- .../sdk/metrics/_internal/export/__init__.py | 10 ++++- .../test_periodic_exporting_metric_reader.py | 41 +++++++++++++++++-- 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 796fda683e2..e3dd0a0c56a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased +- PeriodicExportingMetricReader will continue if collection times out + ([#3100](https://github.com/open-telemetry/opentelemetry-python/pull/3100)) + ## Version 1.16.0/0.37b0 (2023-02-17) - Change ``__all__`` to be statically defined. @@ -28,10 +31,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#3156](https://github.com/open-telemetry/opentelemetry-python/pull/3156)) - deprecate jaeger exporters ([#3158](https://github.com/open-telemetry/opentelemetry-python/pull/3158)) - - Create a single resource instance ([#3118](https://github.com/open-telemetry/opentelemetry-python/pull/3118)) + ## Version 1.15.0/0.36b0 (2022-12-09) - PeriodicExportingMetricsReader with +Inf interval diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/export/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/export/__init__.py index 836bb8eecef..5bd94d5aacc 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/export/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/export/__init__.py @@ -41,6 +41,7 @@ AggregationTemporality, DefaultAggregation, ) +from opentelemetry.sdk.metrics._internal.exceptions import MetricsTimeoutError from opentelemetry.sdk.metrics._internal.instrument import ( Counter, Histogram, @@ -497,7 +498,14 @@ def _at_fork_reinit(self): def _ticker(self) -> None: interval_secs = self._export_interval_millis / 1e3 while not self._shutdown_event.wait(interval_secs): - self.collect(timeout_millis=self._export_timeout_millis) + try: + self.collect(timeout_millis=self._export_timeout_millis) + except MetricsTimeoutError: + _logger.warning( + "Metric collection timed out. Will try again after %s seconds", + interval_secs, + exc_info=True, + ) # one last collection below before shutting down completely self.collect(timeout_millis=self._export_interval_millis) diff --git a/opentelemetry-sdk/tests/metrics/test_periodic_exporting_metric_reader.py b/opentelemetry-sdk/tests/metrics/test_periodic_exporting_metric_reader.py index 532f25b9e7f..aa0eed285d7 100644 --- a/opentelemetry-sdk/tests/metrics/test_periodic_exporting_metric_reader.py +++ b/opentelemetry-sdk/tests/metrics/test_periodic_exporting_metric_reader.py @@ -14,12 +14,12 @@ import math from time import sleep, time_ns -from typing import Sequence +from typing import Optional, Sequence from unittest.mock import Mock from flaky import flaky -from opentelemetry.sdk.metrics import Counter +from opentelemetry.sdk.metrics import Counter, MetricsTimeoutError from opentelemetry.sdk.metrics._internal import _Counter from opentelemetry.sdk.metrics.export import ( AggregationTemporality, @@ -67,6 +67,25 @@ def force_flush(self, timeout_millis: float = 10_000) -> bool: return True +class ExceptionAtCollectionPeriodicExportingMetricReader( + PeriodicExportingMetricReader +): + def __init__( + self, + exporter: MetricExporter, + exception: Exception, + export_interval_millis: Optional[float] = None, + export_timeout_millis: Optional[float] = None, + ) -> None: + super().__init__( + exporter, export_interval_millis, export_timeout_millis + ) + self._collect_exception = exception + + def collect(self, timeout_millis: float = 10_000) -> None: + raise self._collect_exception + + metrics_list = [ Metric( name="sum_name", @@ -111,11 +130,13 @@ def test_defaults(self): pmr.shutdown() def _create_periodic_reader( - self, metrics, exporter, collect_wait=0, interval=60000 + self, metrics, exporter, collect_wait=0, interval=60000, timeout=30000 ): pmr = PeriodicExportingMetricReader( - exporter, export_interval_millis=interval + exporter, + export_interval_millis=interval, + export_timeout_millis=timeout, ) def _collect(reader, timeout_millis): @@ -219,3 +240,15 @@ def test_exporter_aggregation_preference(self): self.assertTrue(isinstance(value, DefaultAggregation)) else: self.assertTrue(isinstance(value, LastValueAggregation)) + + def test_metric_timeout_does_not_kill_worker_thread(self): + exporter = FakeMetricsExporter() + pmr = ExceptionAtCollectionPeriodicExportingMetricReader( + exporter, + MetricsTimeoutError("test timeout"), + export_timeout_millis=1, + ) + + sleep(0.1) + self.assertTrue(pmr._daemon_thread.is_alive()) + pmr.shutdown() From 69de3dc599b1f40c82d061c11e3ae259dfe22a90 Mon Sep 17 00:00:00 2001 From: Srikanth Chekuri Date: Fri, 24 Feb 2023 01:02:26 +0530 Subject: [PATCH 10/11] Update docs (#3188) * Update docs * fix spell --- CONTRIBUTING.md | 23 +++------ README.md | 130 ++++++++++++++++-------------------------------- rationale.md | 19 +++---- 3 files changed, 55 insertions(+), 117 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e97e9daff22..daef82f90a6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,12 +1,9 @@ # Contributing to opentelemetry-python -The Python special interest group (SIG) meets regularly. See the OpenTelemetry -[community](https://github.com/open-telemetry/community#python-sdk) repo for -information on this and other language SIGs. +The Python special interest group (SIG) meets weekly on Thursdays at 9AM PST. Check the [OpenTelemetry community calendar](https://calendar.google.com/calendar/embed?src=google.com_b79e3e90j7bbsa2n2p5an5lf60%40group.calendar.google.com) for specific dates and Zoom meeting links. See the [public meeting notes](https://docs.google.com/document/d/1CIMGoIOZ-c3-igzbd6_Pnxx1SjAkjwqoYSUWxPY8XIs/edit) -for a summary description of past meetings. To request edit access, join the -meeting or get in touch on [Slack](https://cloud-native.slack.com/archives/C01PD4HUVBL). +for a summary description of past meetings. See to the [community membership document](https://github.com/open-telemetry/community/blob/main/community-membership.md) on how to become a [**Member**](https://github.com/open-telemetry/community/blob/main/community-membership.md#member), @@ -19,13 +16,7 @@ This is the main repo for OpenTelemetry Python. Nevertheless, there are other re Please take a look at this list first, your contributions may belong in one of these repos better: 1. [OpenTelemetry Contrib](https://github.com/open-telemetry/opentelemetry-python-contrib): Instrumentations for third-party - libraries and frameworks. There is an ongoing effort to migrate into the OpenTelemetry Contrib repo some of the existing - programmatic instrumentations that are now in the `ext` directory in the main OpenTelemetry repo. Please ask in the Slack - channel (see below) for guidance if you want to contribute with these instrumentations. - -# Find the right branch - -The default branch for this repo is `main`. All feature work is accomplished on branches from `main`. + libraries and frameworks. ## Find a Buddy and get Started Quickly! @@ -75,8 +66,8 @@ An easier way to do so is: We try to keep the amount of _public symbols_ in our code minimal. A public symbol is any Python identifier that does not start with an underscore. Every public symbol is something that has to be kept in order to maintain backwards compatibility, so we try to have as few as possible. -To check if your PR is adding public symbols, run `tox -e public-symbols-check`. This will always fail if public symbols are being added. The idea -behind this is that every PR that adds public symbols fails in CI, forcing reviewers to check the symbols to make sure they are strictly necessary. +To check if your PR is adding public symbols, run `tox -e public-symbols-check`. This will always fail if public symbols are being added/removed. The idea +behind this is that every PR that adds/removes public symbols fails in CI, forcing reviewers to check the symbols to make sure they are strictly necessary. If after checking them, it is considered that they are indeed necessary, the PR will be labeled with `Skip Public API check` so that this check is not run. @@ -95,7 +86,7 @@ CONTRIB_REPO_SHA=dde62cebffe519c35875af6d06fae053b3be65ec tox ``` The continuation integration overrides that environment variable with as per the configuration -[here](https://github.com/open-telemetry/opentelemetry-python/blob/9020b0baaeb41b7137badca988bb5c2d562cddee/.github/workflows/test.yml#L13). +[here](https://github.com/open-telemetry/opentelemetry-python/blob/main/.github/workflows/test.yml#L13). ### Benchmarks @@ -196,7 +187,7 @@ updating the GitHub workflow to reference a PR in the Contrib repo * Trivial change (typo, cosmetic, doc, etc.) doesn't have to wait for one day. * Urgent fix can take exception as long as it has been actively communicated. -Any Approver / Maintainer can merge the PR once it is **ready to merge**. +One of the maintainers will merge the PR once it is **ready to merge**. ## Design Choices diff --git a/README.md b/README.md index ec94eb8fe22..1cad936e57c 100644 --- a/README.md +++ b/README.md @@ -1,50 +1,47 @@ -## OpenTelemetry Python ---- -

- - Getting Started -   •   - API Documentation -   •   - Getting In Touch (GitHub Discussions) - -

- -

- - GitHub release (latest by date including pre-releases) - - - Codecov Status - - - license - -
- - Build Status - - Beta -

- -

- - Contributing -   •   - Examples - -

- ---- - -This page describes the Python [OpenTelemetry](https://opentelemetry.io/) implementation. OpenTelemetry is an observability framework for cloud-native software. - -## Requirements -Unless otherwise noted, all published artifacts support Python 3.7 or higher. See CONTRIBUTING.md for additional instructions for building this project for development. +# OpenTelemetry Python +[![Slack](https://img.shields.io/badge/slack-@cncf/otel/python-brightgreen.svg?logo=slack)](https://cloud-native.slack.com/archives/C01PD4HUVBL) +[![Build Status](https://github.com/open-telemetry/opentelemetry-python/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/open-telemetry/opentelemetry-python/actions) +[![Minimum Python Version](https://img.shields.io/badge/python-3.7+-blue.svg)](https://www.python.org/downloads/) +[![Release](https://img.shields.io/github/v/release/open-telemetry/opentelemetry-python?include_prereleases&style=)](https://github.com/open-telemetry/opentelemetry-python/releases/) +[![Read the Docs](https://readthedocs.org/projects/opentelemetry-python/badge/?version=latest)](https://opentelemetry-python.readthedocs.io/en/latest/) + +## Project Status + +See the [OpenTelemetry Instrumentation for Python](https://opentelemetry.io/docs/instrumentation/python/#status-and-releases). + +| Signal | Status | Project | +| ------- | ------------ | ------- | +| Traces | Stable | N/A | +| Metrics | Stable | N/A | +| Logs | Experimental | N/A | + +Project versioning information and stability guarantees can be found [here](./rationale.md#versioning-and-releasing). ## Getting started -The goal of OpenTelemetry is to provide a single set of APIs to capture distributed traces and metrics from your application and send them to an observability platform. This project lets you do just that for applications written in Python. +You can find the getting started guide for OpenTelemetry Python [here](https://opentelemetry.io/docs/instrumentation/python/getting-started/). + +If you are looking for **examples** on how to use the OpenTelemetry API to +instrument your code manually, or how to set up the OpenTelemetry +Python SDK, see https://opentelemetry.io/docs/instrumentation/python/manual/. + +## Python Version Support + +This project ensures compatibility with the current supported versions of the Python. As new Python versions are released, support for them is added and +as old Python versions reach their end of life, support for them is removed. + +We add support for new Python versions no later than 3 months after they become stable. + +We remove support for old Python versions 6 months after they reach their [end of life](https://devguide.python.org/devcycle/#end-of-life-branches). + + +## Documentation + +The online documentation is available at https://opentelemetry-python.readthedocs.io/. +To access the latest version of the documentation, see +https://opentelemetry-python.readthedocs.io/en/latest/. + +## Install This repository includes multiple installable packages. The `opentelemetry-api` package includes abstract classes and no-op implementations that comprise the OpenTelemetry API following the @@ -91,47 +88,13 @@ pip install -e ./instrumentation/opentelemetry-instrumentation-{instrumentation} For additional exporter and instrumentation packages, see the [`opentelemetry-python-contrib`](https://github.com/open-telemetry/opentelemetry-python-contrib) repository. -## Running Performance Tests - -This section provides details on how to reproduce performance tests results on your own -machine. - -### Resource Usage Tests - -1. Install scalene using the following command - -```sh -pip install scalene -``` - -2. Run the `scalene` tests on any of the example Python programs - -```sh -scalene opentelemetry-/tests/performance/resource-usage//profile_resource_usage_.py -``` - -## Python Version Support Addition and Removal - -This project supports the latest Python versions. As new Python versions are released, support for them is added and -as old Python versions reach their end of life, support for them is removed. - -We add support for new Python versions no later than 3 months after they become stable. - -We remove support for old Python versions 6 months after they reach their [end of life](https://devguide.python.org/devcycle/#end-of-life-branches). - -## Documentation - -The online documentation is available at https://opentelemetry-python.readthedocs.io/. -To access the latest version of the documentation, see -https://opentelemetry-python.readthedocs.io/en/latest/. - ## Contributing For information about contributing to OpenTelemetry Python, see [CONTRIBUTING.md](CONTRIBUTING.md). We meet weekly on Thursdays at 9AM PST. The meeting is subject to change depending on contributors' availability. Check the [OpenTelemetry community calendar](https://calendar.google.com/calendar/embed?src=google.com_b79e3e90j7bbsa2n2p5an5lf60%40group.calendar.google.com) for specific dates and Zoom meeting links. -Meeting notes are available as a public [Google doc](https://docs.google.com/document/d/1CIMGoIOZ-c3-igzbd6_Pnxx1SjAkjwqoYSUWxPY8XIs/edit). For edit access, get in touch on [GitHub Discussions](https://github.com/open-telemetry/opentelemetry-python/discussions). +Meeting notes are available as a public [Google doc](https://docs.google.com/document/d/1CIMGoIOZ-c3-igzbd6_Pnxx1SjAkjwqoYSUWxPY8XIs/edit). Approvers ([@open-telemetry/python-approvers](https://github.com/orgs/open-telemetry/teams/python-approvers)): @@ -171,12 +134,3 @@ Emeritus Maintainers: - -## Project Status - -For project boards and milestones, see the following links: -- [Project boards](https://github.com/open-telemetry/opentelemetry-python/projects) -- [Milestones](https://github.com/open-telemetry/opentelemetry-python/milestones) - -We try to keep these links accurate, so they're the best place to go for questions about project status. The dates and features described in the issues -and milestones are estimates and subject to change. diff --git a/rationale.md b/rationale.md index 8ff92e902c7..4f1dd3ab82e 100644 --- a/rationale.md +++ b/rationale.md @@ -40,7 +40,7 @@ Pre-release packages are denoted by appending identifiers such as -Alpha, -Beta, ### Immature or experimental signals -Modules for experimental signals will be released in a separate versions that will be marked as pre-releases, and must be installed manually. Modules will remain at version v0.x.y to make it abundantly clear that depending on them is at your own risk. For example, the `opentelemetry-api` v0.x.y-b0 module will provide experimental access to the latest features in development, which will include the experimental metrics signals. Notice the `b0` suffix which indicates that the release is still in beta, and therefore deemed to be in pre-release. NO STABILITY GUARANTEES ARE MADE. +Modules for experimental signals will be released in the same packages as the core components, but prefixed with `_` to indicate that they are unstable and subject to change. NO STABILITY GUARANTEES ARE MADE. ## Examples @@ -53,13 +53,6 @@ Purely for illustration purposes, not intended to represent actual releases: - `opentelemetry-sdk` 1.0.0 - Contains SDK components for tracing, baggage, propagators, and context -##### Contains the following experimental packages - -- `opentelemetry-api` 1.x.y-b0 - - Contains the EXPERIMENTAL API for metrics plus other unstable features. There are no stability guarantees. -- `opentelemetry-sdk` 1.x.y-b0 - - Contains the EXPERIMENTAL SDK for metrics plus other unstable features. There are no stability guarantees. - #### V1.15.0 Release (with metrics) - `opentelemetry-api` 1.15.0 @@ -67,9 +60,9 @@ Purely for illustration purposes, not intended to represent actual releases: - `opentelemetry-sdk` 1.15.0 - Contains SDK components for tracing, baggage, propagators, context and metrics -##### Contains the following experimental packages +##### Contains the following pre-release packages -- `opentelemetry-api` 1.x.y-b0 - - Contains the EXPERIMENTAL API for logging plus other unstable features. There are no stability guarantees. -- `opentelemetry-sdk` 1.x.y-b0 - - Contains the EXPERIMENTAL SDK for logging plus other unstable features. There are no stability guarantees. +- `opentelemetry-api` 1.x.yrc1 + - Contains the experimental public API for logging plus other unstable features. There are no stability guarantees. +- `opentelemetry-sdk` 1.x.yrc1 + - Contains the experimental public SDK for logging plus other unstable features. There are no stability guarantees. From a9a96aad8b930a7efdea1ad979aefc173e1710d0 Mon Sep 17 00:00:00 2001 From: Alex Boten Date: Fri, 24 Feb 2023 11:11:05 -0800 Subject: [PATCH 11/11] bugfix: indent not used in MetricsData to_json (#3197) --- CHANGELOG.md | 3 ++- .../src/opentelemetry/sdk/metrics/_internal/point.py | 3 ++- .../tests/metrics/integration_test/test_console_exporter.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3dd0a0c56a..d43b64cfaf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased - PeriodicExportingMetricReader will continue if collection times out ([#3100](https://github.com/open-telemetry/opentelemetry-python/pull/3100)) - +- Fix formatting of ConsoleMetricExporter. + ([#3197](https://github.com/open-telemetry/opentelemetry-python/pull/3197)) ## Version 1.16.0/0.37b0 (2023-02-17) - Change ``__all__`` to be statically defined. diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/point.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/point.py index b4d813accaf..410c7754d88 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/point.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/point.py @@ -211,5 +211,6 @@ def to_json(self, indent=4) -> str: loads(resource_metrics.to_json(indent=indent)) for resource_metrics in self.resource_metrics ] - } + }, + indent=indent, ) diff --git a/opentelemetry-sdk/tests/metrics/integration_test/test_console_exporter.py b/opentelemetry-sdk/tests/metrics/integration_test/test_console_exporter.py index 59f026661c5..60c4227c3b2 100644 --- a/opentelemetry-sdk/tests/metrics/integration_test/test_console_exporter.py +++ b/opentelemetry-sdk/tests/metrics/integration_test/test_console_exporter.py @@ -49,7 +49,7 @@ def test_console_exporter(self): provider.shutdown() output.seek(0) - result_0 = loads(output.readlines()[0]) + result_0 = loads("".join(output.readlines())) self.assertGreater(len(result_0), 0)