Skip to content

Commit d12fb71

Browse files
a-recknagelArne Caratti
authored and
Arne Caratti
committed
Merge remote-tracking branch 'origin/main'
1 parent c9b48cf commit d12fb71

File tree

31 files changed

+283
-159
lines changed

31 files changed

+283
-159
lines changed

.github/workflows/benchmarks.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
python-version: ${{ env[matrix.python-version] }}
2626
architecture: 'x64'
2727
- name: Install tox
28-
run: pip install tox==3.27.1 -U tox-factor
28+
run: pip install tox
2929
- name: Cache tox environment
3030
# Preserves .tox directory between runs for faster installs
3131
uses: actions/cache@v2

.github/workflows/public-api-check.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
python-version: '3.10'
3535

3636
- name: Install tox
37-
run: pip install tox==3.27.1 -U tox-factor
37+
run: pip install tox
3838

3939
- name: Public API Check
4040
run: tox -e public-symbols-check

.github/workflows/test.yml

+17-10
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ env:
1010
# Otherwise, set variable to the commit of your branch on
1111
# opentelemetry-python-contrib which is compatible with these Core repo
1212
# changes.
13-
CONTRIB_REPO_SHA: 2977f143df1d474735e8bdfecd91d92d534e80dc
13+
CONTRIB_REPO_SHA: 1a984d3ba18d4080c58485b7d807dba241179d41
1414
# This is needed because we do not clone the core repo in contrib builds anymore.
1515
# When running contrib builds as part of core builds, we use actions/checkout@v2 which
1616
# does not set an environment variable (simply just runs tox), which is different when
@@ -42,9 +42,6 @@ jobs:
4242
- "getting-started"
4343
- "opentracing-shim"
4444
- "opencensus-shim"
45-
- "exporter-jaeger-combined"
46-
- "exporter-jaeger-proto-grpc"
47-
- "exporter-jaeger-thrift"
4845
- "exporter-opencensus"
4946
- "exporter-otlp-proto-common"
5047
- "exporter-otlp-combined"
@@ -58,6 +55,16 @@ jobs:
5855
- "propagator-b3"
5956
- "propagator-jaeger"
6057
os: [ubuntu-20.04, windows-2019]
58+
exclude:
59+
- python-version: pypy3
60+
package: "opencensus-shim"
61+
- python-version: pypy3
62+
package: "exporter-opencensus"
63+
- python-version: pypy3
64+
package: "exporter-otlp-combined"
65+
- python-version: pypy3
66+
package: "exporter-otlp-proto-grpc"
67+
6168
steps:
6269
- name: Checkout Core Repo @ SHA - ${{ github.sha }}
6370
uses: actions/checkout@v2
@@ -67,15 +74,15 @@ jobs:
6774
python-version: ${{ env[matrix.python-version] }}
6875
architecture: 'x64'
6976
- name: Install tox
70-
run: pip install tox==3.27.1 -U tox-factor
77+
run: pip install tox
7178
- name: Cache tox environment
7279
# Preserves .tox directory between runs for faster installs
7380
uses: actions/cache@v2
7481
with:
7582
path: |
7683
.tox
7784
~/.cache/pip
78-
key: v3-tox-cache-${{ env.RUN_MATRIX_COMBINATION }}-${{ hashFiles('tox.ini',
85+
key: v4-tox-cache-${{ env.RUN_MATRIX_COMBINATION }}-${{ hashFiles('tox.ini',
7986
'dev-requirements.txt') }}-core
8087
- name: Windows does not let git check out files with long names
8188
if: ${{ matrix.os == 'windows-2019'}}
@@ -100,15 +107,15 @@ jobs:
100107
python-version: '3.10'
101108
architecture: 'x64'
102109
- name: Install tox
103-
run: pip install tox==3.27.1
110+
run: pip install tox
104111
- name: Cache tox environment
105112
# Preserves .tox directory between runs for faster installs
106113
uses: actions/cache@v2
107114
with:
108115
path: |
109116
.tox
110117
~/.cache/pip
111-
key: v3-tox-cache-${{ matrix.tox-environment }}-${{ hashFiles('tox.ini', 'dev-requirements.txt')
118+
key: v4-tox-cache-${{ matrix.tox-environment }}-${{ hashFiles('tox.ini', 'dev-requirements.txt')
112119
}}-core
113120
- name: run tox
114121
run: tox -e ${{ matrix.tox-environment }}
@@ -169,7 +176,7 @@ jobs:
169176
- "tornado"
170177
- "tortoiseorm"
171178
- "urllib"
172-
- "urllib3"
179+
- "urllib3v"
173180
- "wsgi"
174181
- "prometheus-remote-write"
175182
- "richconsole"
@@ -191,7 +198,7 @@ jobs:
191198
python-version: ${{ env[matrix.python-version] }}
192199
architecture: 'x64'
193200
- name: Install tox
194-
run: pip install tox==3.27.1 -U tox-factor
201+
run: pip install tox
195202
- name: Cache tox environment
196203
# Preserves .tox directory between runs for faster installs
197204
uses: actions/cache@v2

.pylintrc

+1-7
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ disable=missing-docstring,
7676
unused-argument, # temp-pylint-upgrade
7777
redefined-builtin,
7878
cyclic-import,
79+
broad-exception-raised,
7980

8081
# Enable the message, report, category or checker with the given id(s). You can
8182
# either give multiple identifier separated by comma (,) or put this option
@@ -480,10 +481,3 @@ max-statements=50
480481

481482
# Minimum number of public methods for a class (see R0903).
482483
min-public-methods=2
483-
484-
485-
[EXCEPTIONS]
486-
487-
# Exceptions that will emit a warning when being caught. Defaults to
488-
# "Exception".
489-
overgeneral-exceptions=Exception

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
- Fix flush error when no LoggerProvider configured for LoggingHandler
11+
([#3608](https://github.com/open-telemetry/opentelemetry-python/pull/3608))
12+
- Fix `OTLPMetricExporter` ignores `preferred_aggregation` property
13+
([#3603](https://github.com/open-telemetry/opentelemetry-python/pull/3603))
14+
- Logs: set `observed_timestamp` field
15+
([#3565](https://github.com/open-telemetry/opentelemetry-python/pull/3565))
1016
- Add missing Resource SchemaURL in OTLP exporters
1117
([#3652](https://github.com/open-telemetry/opentelemetry-python/pull/3652))
1218
- Fix loglevel warning text
@@ -35,6 +41,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3541
([#3645](https://github.com/open-telemetry/opentelemetry-python/pull/3645))
3642
- Add Proxy classes for logging
3743
([#3575](https://github.com/open-telemetry/opentelemetry-python/pull/3575))
44+
- Remove dependency on 'backoff' library
45+
([#3679](https://github.com/open-telemetry/opentelemetry-python/pull/3679))
3846

3947
## Version 1.22.0/0.43b0 (2023-12-15)
4048

CONTRIBUTING.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,12 @@ during their normal contribution hours.
3838

3939
This project uses [tox](https://tox.readthedocs.io) to automate
4040
some aspects of development, including testing against multiple Python versions.
41-
To install `tox`, run[^1]:
41+
To install `tox`, run:
4242

4343
```console
44-
$ pip install tox==3.27.1
44+
$ pip install tox
4545
```
4646

47-
[^1]: Right now we are experiencing issues with `tox==4.x.y`, so we recommend you use this version.
48-
4947
You can run `tox` with the following arguments:
5048

5149
- `tox` to run all existing tox commands, including unit tests for all packages

dev-requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ requests==2.31.0
1717
ruamel.yaml==0.17.21
1818
asgiref==3.7.2
1919
psutil==5.9.6
20-
GitPython==3.1.40
20+
GitPython==3.1.41
2121
flaky==3.7.0

docs/examples/fork-process-model/flask-gunicorn/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ opentelemetry-instrumentation==0.41b0
1212
opentelemetry-instrumentation-flask==0.41b0
1313
opentelemetry-instrumentation-wsgi==0.41b0
1414
opentelemetry-sdk==1.20.0
15-
protobuf==3.19.4
15+
protobuf==3.19.5
1616
six==1.15.0
1717
thrift==0.13.0
1818
uWSGI==2.0.22

docs/examples/fork-process-model/flask-uwsgi/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ opentelemetry-instrumentation==0.41b0
1212
opentelemetry-instrumentation-flask==0.41b0
1313
opentelemetry-instrumentation-wsgi==0.41b0
1414
opentelemetry-sdk==1.20.0
15-
protobuf==3.19.4
15+
protobuf==3.19.5
1616
six==1.15.0
1717
thrift==0.13.0
1818
uWSGI==2.0.22

docs/getting_started/tests/requirements.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ idna==3.4
1010
importlib-metadata==6.8.0
1111
iniconfig==2.0.0
1212
itsdangerous==2.1.2
13-
Jinja2==3.1.2
13+
Jinja2==3.1.3
1414
MarkupSafe==2.1.3
1515
packaging==23.2
1616
pluggy==1.3.0
1717
py==1.11.0
1818
py-cpuinfo==9.0.0
1919
pytest==7.1.3
2020
pytest-benchmark==4.0.0
21-
requests==2.26.0
21+
requests==2.31.0
2222
tomli==2.0.1
2323
typing_extensions==4.8.0
2424
urllib3==1.26.18

exporter/opentelemetry-exporter-otlp-proto-common/pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ classifiers = [
2525
]
2626
dependencies = [
2727
"opentelemetry-proto == 1.23.0.dev",
28-
"backoff >= 1.10.0, < 3.0.0; python_version>='3.8'",
2928
]
3029

3130
[project.optional-dependencies]

exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/__init__.py

+44-16
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,17 @@
1515

1616
import logging
1717
from collections.abc import Sequence
18-
from typing import Any, Mapping, Optional, List, Callable, TypeVar, Dict
19-
20-
import backoff
18+
from itertools import count
19+
from typing import (
20+
Any,
21+
Mapping,
22+
Optional,
23+
List,
24+
Callable,
25+
TypeVar,
26+
Dict,
27+
Iterator,
28+
)
2129

2230
from opentelemetry.sdk.util.instrumentation import InstrumentationScope
2331
from opentelemetry.proto.common.v1.common_pb2 import (
@@ -37,7 +45,6 @@
3745
from opentelemetry.sdk.trace import Resource
3846
from opentelemetry.util.types import Attributes
3947

40-
4148
_logger = logging.getLogger(__name__)
4249

4350
_TypingResourceT = TypeVar("_TypingResourceT")
@@ -113,7 +120,6 @@ def _get_resource_data(
113120
resource_class: Callable[..., _TypingResourceT],
114121
name: str,
115122
) -> List[_TypingResourceT]:
116-
117123
resource_data = []
118124

119125
for (
@@ -134,14 +140,36 @@ def _get_resource_data(
134140
return resource_data
135141

136142

137-
# Work around API change between backoff 1.x and 2.x. Since 2.0.0 the backoff
138-
# wait generator API requires a first .send(None) before reading the backoff
139-
# values from the generator.
140-
_is_backoff_v2 = next(backoff.expo()) is None
141-
142-
143-
def _create_exp_backoff_generator(*args, **kwargs):
144-
gen = backoff.expo(*args, **kwargs)
145-
if _is_backoff_v2:
146-
gen.send(None)
147-
return gen
143+
def _create_exp_backoff_generator(max_value: int = 0) -> Iterator[int]:
144+
"""
145+
Generates an infinite sequence of exponential backoff values. The sequence starts
146+
from 1 (2^0) and doubles each time (2^1, 2^2, 2^3, ...). If a max_value is specified
147+
and non-zero, the generated values will not exceed this maximum, capping at max_value
148+
instead of growing indefinitely.
149+
150+
Parameters:
151+
- max_value (int, optional): The maximum value to yield. If 0 or not provided, the
152+
sequence grows without bound.
153+
154+
Returns:
155+
Iterator[int]: An iterator that yields the exponential backoff values, either uncapped or
156+
capped at max_value.
157+
158+
Example:
159+
```
160+
gen = _create_exp_backoff_generator(max_value=10)
161+
for _ in range(5):
162+
print(next(gen))
163+
```
164+
This will print:
165+
1
166+
2
167+
4
168+
8
169+
10
170+
171+
Note: this functionality used to be handled by the 'backoff' package.
172+
"""
173+
for i in count(0):
174+
out = 2**i
175+
yield min(out, max_value) if max_value else out

exporter/opentelemetry-exporter-otlp-proto-common/src/opentelemetry/exporter/otlp/proto/common/_internal/metrics_encoder/__init__.py

+27-8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from opentelemetry.sdk.metrics.export import (
1717
MetricExporter,
1818
)
19+
from opentelemetry.sdk.metrics.view import Aggregation
1920
from os import environ
2021
from opentelemetry.sdk.metrics import (
2122
Counter,
@@ -65,9 +66,18 @@ class OTLPMetricExporterMixin:
6566
def _common_configuration(
6667
self,
6768
preferred_temporality: Dict[type, AggregationTemporality] = None,
69+
preferred_aggregation: Dict[type, Aggregation] = None,
6870
) -> None:
6971

70-
instrument_class_temporality = {}
72+
MetricExporter.__init__(
73+
self,
74+
preferred_temporality=self._get_temporality(preferred_temporality),
75+
preferred_aggregation=self._get_aggregation(preferred_aggregation),
76+
)
77+
78+
def _get_temporality(
79+
self, preferred_temporality: Dict[type, AggregationTemporality]
80+
) -> Dict[type, AggregationTemporality]:
7181

7282
otel_exporter_otlp_metrics_temporality_preference = (
7383
environ.get(
@@ -119,6 +129,13 @@ def _common_configuration(
119129

120130
instrument_class_temporality.update(preferred_temporality or {})
121131

132+
return instrument_class_temporality
133+
134+
def _get_aggregation(
135+
self,
136+
preferred_aggregation: Dict[type, Aggregation],
137+
) -> Dict[type, Aggregation]:
138+
122139
otel_exporter_otlp_metrics_default_histogram_aggregation = environ.get(
123140
OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION,
124141
"explicit_bucket_histogram",
@@ -128,7 +145,9 @@ def _common_configuration(
128145
"base2_exponential_bucket_histogram"
129146
):
130147

131-
histogram_aggregation_type = ExponentialBucketHistogramAggregation
148+
instrument_class_aggregation = {
149+
Histogram: ExponentialBucketHistogramAggregation(),
150+
}
132151

133152
else:
134153

@@ -145,13 +164,13 @@ def _common_configuration(
145164
otel_exporter_otlp_metrics_default_histogram_aggregation,
146165
)
147166

148-
histogram_aggregation_type = ExplicitBucketHistogramAggregation
167+
instrument_class_aggregation = {
168+
Histogram: ExplicitBucketHistogramAggregation(),
169+
}
149170

150-
MetricExporter.__init__(
151-
self,
152-
preferred_temporality=instrument_class_temporality,
153-
preferred_aggregation={Histogram: histogram_aggregation_type()},
154-
)
171+
instrument_class_aggregation.update(preferred_aggregation or {})
172+
173+
return instrument_class_aggregation
155174

156175

157176
def encode_metrics(data: MetricsData) -> ExportMetricsServiceRequest:

0 commit comments

Comments
 (0)