Sync from SUSE:SLFO:Main python-opencensus revision ea9d0a5888b9d67a5702d7cfdc8bdddc

This commit is contained in:
2025-05-13 16:56:24 +02:00
commit 196a961b05
7 changed files with 1540 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

3
_multibuild Normal file
View File

@@ -0,0 +1,3 @@
<multibuild>
<package>test</package>
</multibuild>

File diff suppressed because it is too large Load Diff

BIN
opencensus-python-0.11.4-1.1.13-gh.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

97
python-opencensus.changes Normal file
View File

@@ -0,0 +1,97 @@
-------------------------------------------------------------------
Fri Feb 28 14:45:01 UTC 2025 - Nico Krapp <nico.krapp@suse.com>
- disable test broken in build env
-------------------------------------------------------------------
Tue Apr 9 02:34:22 UTC 2024 - Steve Kowalik <steven.kowalik@suse.com>
- Add patch use-correct-assertion-methods.patch:
* Use non-removed assertion methods.
-------------------------------------------------------------------
Tue Mar 26 12:57:43 UTC 2024 - John Paul Adrian Glaubitz <adrian.glaubitz@suse.com>
- Switch build system from setuptools to pyproject.toml
+ Add python-pip and python-wheel to BuildRequires
+ Replace %python_build with %pyproject_wheel
+ Replace %python_install with %pyproject_install
-------------------------------------------------------------------
Tue Mar 5 23:00:18 UTC 2024 - John Paul Adrian Glaubitz <adrian.glaubitz@suse.com>
- Update to 0.11.4
* Changed bit-mapping for `httpx` and `fastapi` integrations
- Refresh patches for new version
* opencensus-pr1002-remove-mock.patch
- Switch package to modern Python Stack on SLE-15
* Add %{?sle15_python_module_pythons}
* Drop %{?!python_module:%define python_module() python-%{**} python3-%{**}}
-------------------------------------------------------------------
Thu Oct 19 10:40:18 UTC 2023 - Markéta Machová <mmachova@suse.com>
- update to 0.11.3
* Updated azure modules
- sorry, six is still needed :(
-------------------------------------------------------------------
Mon Jul 24 20:19:56 UTC 2023 - Dirk Müller <dmueller@suse.com>
- update to 0.11.2:
* Updated `azure`, `fastapi`,`flask` modules
* Updated `azure`, `httpx` modules
-------------------------------------------------------------------
Tue Oct 18 10:24:27 UTC 2022 - John Paul Adrian Glaubitz <adrian.glaubitz@suse.com>
- Update to 0.11.0
* Updated `azure`, `context`, `flask`, `requests` modules
- from version 0.10.0
* Add kwargs to derived gauge (#1135)
- from version 0.9.0
* Make sure handler.flush() doesn't deadlock (#1112)
- Refresh patches for new version
* opencensus-pr1002-remove-mock.patch
- Update Requires from setup.py
-------------------------------------------------------------------
Sat Oct 23 10:47:21 UTC 2021 - Ben Greiner <code@bnavigator.de>
- Update to 0.8.0
* Added integration tracking functionality, includes django,
flask, http-lib, logging, mysql, postgresql, pymongo, pymysql,
pyramid, requests, sqlalchemy modules (#1065)
* Support Python 3.8, 3.9 (#1048)
- Releases 0.7.8 to 0.7.13
* Updated azure, django, flask, requests, grpc, httplib, pyramid
stackdriver modules
* Hotfix for breaking change (#915)
- Remove test mock requirement for python3
* opencensus-pr1002-remove-mock.patch
* gh#census-instrumentation/opencensus-python#1002
-------------------------------------------------------------------
Tue Mar 10 12:56:01 UTC 2020 - Tomáš Chvátal <tchvatal@suse.com>
- Provide init in opencensus/ext folder to provide basis
structure for all the extensions
-------------------------------------------------------------------
Tue Mar 10 11:25:01 UTC 2020 - Tomáš Chvátal <tchvatal@suse.com>
- Switch to multibuild to not cycle during testing
-------------------------------------------------------------------
Tue Feb 18 08:47:16 UTC 2020 - Tomáš Chvátal <tchvatal@suse.com>
- Update to 0.7.7:
* Minor fixes
- Fix dependencies
- Enable testsuite
-------------------------------------------------------------------
Wed Jan 29 12:57:16 UTC 2020 - John Paul Adrian Glaubitz <adrian.glaubitz@suse.com>
- Initial build
+ Version 0.7.6

100
python-opencensus.spec Normal file
View File

@@ -0,0 +1,100 @@
#
# spec file for package python-opencensus
#
# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define repo_version 0.11.4-1.1.13
%{?sle15_python_module_pythons}
%global flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == "test"
%define psuffix -test
%bcond_without test
%else
%define psuffix %{nil}
%bcond_with test
%endif
Name: python-opencensus%{psuffix}
Version: 0.11.4
Release: 0
Summary: A stats collection and distributed tracing framework
License: Apache-2.0
URL: https://github.com/census-instrumentation/opencensus-python
Source: https://github.com/census-instrumentation/opencensus-python/archive/v%{repo_version}.tar.gz#/opencensus-python-%{repo_version}-gh.tar.gz
# PATCH-FIX-UPSTREAM opencensus-pr1002-remove-mock.patch -- gh#census-instrumentation/opencensus-python#1002
Patch0: opencensus-pr1002-remove-mock.patch
# PATCH-FIX-UPSTREAM gh#census-instrumentation/opencensus-python#1243
Patch1: use-correct-assertion-methods.patch
BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module wheel}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-google-api-core < 3.0.0
Requires: python-google-api-core >= 1.0.0
Requires: python-opencensus-context >= 0.1.3
Requires: python-six >= 1.16
BuildArch: noarch
%if %{with test}
BuildRequires: %{python_module opencensus = %{version}}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module retrying}
%endif
%python_subpackages
%description
OpenCensus - A stats collection and distributed tracing framework
OpenCensus provides a framework to measure a server's resource usage
and collect performance stats. This repository contains Python related
utilities and supporting software needed by OpenCensus.
%prep
%autosetup -p1 -n opencensus-python-%{repo_version}
# do not hardcode versions
sed -i -e 's:==:>=:g' setup.py
%build
%pyproject_wheel
%install
%if !%{with test}
%pyproject_install
# add ext infrastructure
%python_expand mkdir %{buildroot}%{$python_sitelib}/opencensus/ext/
%python_expand cp %{buildroot}%{$python_sitelib}/opencensus/__init__* %{buildroot}%{$python_sitelib}/opencensus/ext
%python_expand [ -e %{buildroot}%{$python_sitelib}/opencensus/__pycache* ] && cp -r %{buildroot}%{$python_sitelib}/opencensus/__pycache* %{buildroot}%{$python_sitelib}/opencensus/ext
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%endif
%check
%if %{with test}
# recursion error in mock != 3; gh#census-instrumentation/opencensus-python#868
# test_create_from_traceback fails because paths are limited to 256 bytes and the path in the build env is too long.
donttest="TestGetExporterThreadPeriodic and (test_multiple_producers or test_threaded_export) or test_create_from_traceback"
%pytest tests/unit -k "not ($donttest)"
%endif
%if !%{with test}
%files %{python_files}
%doc CHANGELOG.md README.rst
%license LICENSE
%{python_sitelib}/opencensus
%{python_sitelib}/opencensus-%{version}.dist-info
%endif
%changelog

View File

@@ -0,0 +1,190 @@
From 9fc5f15d51ed33fa3d34592912c9e40c0756fd43 Mon Sep 17 00:00:00 2001
From: Steve Kowalik <steven@wedontsleep.org>
Date: Tue, 9 Apr 2024 12:23:25 +1000
Subject: [PATCH] Use non-deprecated assertion methods
Both assertDictContainsSubset and assertRaisesRegexp have been
deprecated, and removed in Python 3.12. Use assertGreaterEqual on the
dictionary items to compare dictionaries instead of
assertDictContainsSubset.
Fixes #1242
---
.../tests/test_prometheus_stats.py | 6 ++---
.../test_monitored_resource.py | 27 ++++++++++++-------
tests/unit/stats/test_aggregation_data.py | 12 ++++-----
tests/unit/stats/test_measurement_map.py | 8 +++---
4 files changed, 30 insertions(+), 23 deletions(-)
diff --git a/contrib/opencensus-ext-prometheus/tests/test_prometheus_stats.py b/contrib/opencensus-ext-prometheus/tests/test_prometheus_stats.py
index bc19b47ef..2b4e1c8c2 100644
--- a/contrib/opencensus-ext-prometheus/tests/test_prometheus_stats.py
+++ b/contrib/opencensus-ext-prometheus/tests/test_prometheus_stats.py
@@ -229,7 +229,7 @@ def test_collector_to_metric_invalid_dist(self):
collector.register_view(view)
desc = collector.registered_views[list(REGISTERED_VIEW)[0]]
- with self.assertRaisesRegexp(
+ with self.assertRaisesRegex(
ValueError,
'unsupported aggregation type <class \'mock.mock.Mock\'>'):
collector.to_metric(desc=desc, tag_values=[None], agg_data=agg)
@@ -278,8 +278,8 @@ def test_collector_collect_with_none_label_value(self):
class TestPrometheusStatsExporter(unittest.TestCase):
def test_exporter_constructor_no_namespace(self):
- with self.assertRaisesRegexp(ValueError,
- 'Namespace can not be empty string.'):
+ with self.assertRaisesRegex(ValueError,
+ 'Namespace can not be empty string.'):
prometheus.new_stats_exporter(prometheus.Options())
def test_emit(self):
diff --git a/tests/unit/common/monitored_resource_util/test_monitored_resource.py b/tests/unit/common/monitored_resource_util/test_monitored_resource.py
index 38a1fe4b5..a97038841 100644
--- a/tests/unit/common/monitored_resource_util/test_monitored_resource.py
+++ b/tests/unit/common/monitored_resource_util/test_monitored_resource.py
@@ -102,9 +102,11 @@ def test_gcp_gce_monitored_resource(self, gcp_md_mock):
with mock_gce_env():
resource = monitored_resource.get_instance()
self.assertEqual(resource.get_type(), 'mock_resource_type')
- self.assertDictContainsSubset(
- {'mock_label_key': 'mock_label_value'}, resource.get_labels())
- self.assertDictContainsSubset(mocked_labels, resource.get_labels())
+ self.assertGreaterEqual(
+ resource.get_labels().items(),
+ {'mock_label_key': 'mock_label_value'}.items())
+ self.assertGreaterEqual(
+ resource.get_labels().items(), mocked_labels.items())
@mock.patch('opencensus.common.monitored_resource.monitored_resource'
'.gcp_metadata_config.GcpMetadataConfig')
@@ -130,16 +132,19 @@ def test_gcp_k8s_monitored_resource(self, gcp_md_mock):
gcp_md_mock.get_attribute.assert_called_once_with(cluster_name_key)
self.assertEqual(r1.get_type(), 'k8s_container')
- self.assertDictContainsSubset(mocked_labels, r1.get_labels())
+ self.assertGreaterEqual(
+ r1.get_labels().items(), mocked_labels.items())
with mock_oc_env():
with mock_k8s_env():
r2 = monitored_resource.get_instance()
self.assertEqual(r1.get_type(), 'k8s_container')
- self.assertDictContainsSubset(mocked_labels, r1.get_labels())
- self.assertDictContainsSubset(
- {'mock_label_key': 'mock_label_value'}, r2.get_labels())
+ self.assertGreaterEqual(
+ r1.get_labels().items(), mocked_labels.items())
+ self.assertGreaterEqual(
+ r2.get_labels().items(),
+ {'mock_label_key': 'mock_label_value'}.items())
@mock.patch('opencensus.common.monitored_resource.monitored_resource'
'.aws_identity_doc_utils.AwsIdentityDocumentUtils')
@@ -163,9 +168,11 @@ def test_aws_monitored_resource(self, aws_md_mock):
with mock_aws_env():
resource = monitored_resource.get_instance()
self.assertEqual(resource.get_type(), 'mock_resource_type')
- self.assertDictContainsSubset(
- {'mock_label_key': 'mock_label_value'}, resource.get_labels())
- self.assertDictContainsSubset(mocked_labels, resource.get_labels())
+ self.assertGreaterEqual(
+ resource.get_labels().items(),
+ {'mock_label_key': 'mock_label_value'}.items())
+ self.assertGreaterEqual(
+ resource.get_labels().items(), mocked_labels.items())
def test_k8s_environment(self):
patch = mock.patch.dict(os.environ,
diff --git a/tests/unit/stats/test_aggregation_data.py b/tests/unit/stats/test_aggregation_data.py
index d1870f2c9..d009b91a2 100644
--- a/tests/unit/stats/test_aggregation_data.py
+++ b/tests/unit/stats/test_aggregation_data.py
@@ -295,15 +295,15 @@ def test_exemplar(self):
def test_exemplar_null_attachments(self):
timestamp = time.time()
- with self.assertRaisesRegexp(TypeError,
- 'attachments should not be empty'):
+ with self.assertRaisesRegex(TypeError,
+ 'attachments should not be empty'):
aggregation_data_module.Exemplar(6, timestamp, None)
def test_exemplar_null_attachment_key(self):
timestamp = time.time()
attachment = {None: "one", "Two": "two"}
- with self.assertRaisesRegexp(
+ with self.assertRaisesRegex(
TypeError,
'attachment key should not be empty and should be a string'):
aggregation_data_module.Exemplar(6, timestamp, attachment)
@@ -312,7 +312,7 @@ def test_exemplar_null_attachment_value(self):
timestamp = time.time()
attachment = {"One": "one", "Two": None}
- with self.assertRaisesRegexp(
+ with self.assertRaisesRegex(
TypeError,
'attachment value should not be empty and should be a string'):
aggregation_data_module.Exemplar(6, timestamp, attachment)
@@ -321,7 +321,7 @@ def test_exemplar_int_attachment_key(self):
timestamp = time.time()
attachment = {1: "one", "Two": "two"}
- with self.assertRaisesRegexp(
+ with self.assertRaisesRegex(
TypeError,
'attachment key should not be empty and should be a string'):
aggregation_data_module.Exemplar(6, timestamp, attachment)
@@ -330,7 +330,7 @@ def test_exemplar_int_attachment_value(self):
timestamp = time.time()
attachment = {"One": "one", "Two": 2}
- with self.assertRaisesRegexp(
+ with self.assertRaisesRegex(
TypeError,
'attachment value should not be empty and should be a string'):
aggregation_data_module.Exemplar(6, timestamp, attachment)
diff --git a/tests/unit/stats/test_measurement_map.py b/tests/unit/stats/test_measurement_map.py
index 89add276b..44d41ee86 100644
--- a/tests/unit/stats/test_measurement_map.py
+++ b/tests/unit/stats/test_measurement_map.py
@@ -58,7 +58,7 @@ def test_put_attachment_none_key(self):
test_value = 'testValue'
measurement_map = measurement_map_module.MeasurementMap(
measure_to_view_map=measure_to_view_map, attachments={})
- with self.assertRaisesRegexp(
+ with self.assertRaisesRegex(
TypeError,
'attachment key should not be empty and should be a string'):
measurement_map.measure_put_attachment(test_key, test_value)
@@ -69,7 +69,7 @@ def test_put_attachment_none_value(self):
test_value = None
measurement_map = measurement_map_module.MeasurementMap(
measure_to_view_map=measure_to_view_map, attachments={})
- with self.assertRaisesRegexp(
+ with self.assertRaisesRegex(
TypeError,
'attachment value should not be empty and should be a string'):
measurement_map.measure_put_attachment(test_key, test_value)
@@ -80,7 +80,7 @@ def test_put_attachment_int_key(self):
test_value = 'testValue'
measurement_map = measurement_map_module.MeasurementMap(
measure_to_view_map=measure_to_view_map, attachments={})
- with self.assertRaisesRegexp(
+ with self.assertRaisesRegex(
TypeError,
'attachment key should not be empty and should be a string'):
measurement_map.measure_put_attachment(test_key, test_value)
@@ -91,7 +91,7 @@ def test_put_attachment_int_value(self):
test_value = 42
measurement_map = measurement_map_module.MeasurementMap(
measure_to_view_map=measure_to_view_map, attachments={})
- with self.assertRaisesRegexp(
+ with self.assertRaisesRegex(
TypeError,
'attachment value should not be empty and should be a string'):
measurement_map.measure_put_attachment(test_key, test_value)