Skip to content

Commit bc3110a

Browse files
committed
Make new _common directory in the http exporter for shared code
1 parent 0b54090 commit bc3110a

File tree

8 files changed

+38
-107
lines changed

8 files changed

+38
-107
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ classifiers = [
2828
]
2929
dependencies = [
3030
"opentelemetry-proto == 1.35.0.dev",
31-
"requests ~= 2.7",
3231
]
3332

3433
[project.urls]

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
TypeVar,
2828
)
2929

30-
import requests
31-
3230
from opentelemetry.proto.common.v1.common_pb2 import AnyValue as PB2AnyValue
3331
from opentelemetry.proto.common.v1.common_pb2 import (
3432
ArrayValue as PB2ArrayValue,
@@ -110,14 +108,6 @@ def _encode_key_value(
110108
)
111109

112110

113-
def _is_retryable(resp: requests.Response) -> bool:
114-
if resp.status_code == 408:
115-
return True
116-
if resp.status_code >= 500 and resp.status_code <= 599:
117-
return True
118-
return False
119-
120-
121111
def _encode_array(
122112
array: Sequence[Any], allow_null: bool = False
123113
) -> Sequence[PB2AnyValue]:

exporter/opentelemetry-exporter-otlp-proto-common/test-requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
asgiref==3.7.2
22
importlib-metadata==6.11.0
33
iniconfig==2.0.0
4-
requests == 2.7.0
54
packaging==24.0
65
pluggy==1.5.0
76
protobuf==5.26.1
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright The OpenTelemetry Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import requests
16+
17+
def _is_retryable(resp: requests.Response) -> bool:
18+
if resp.status_code == 408:
19+
return True
20+
if resp.status_code >= 500 and resp.status_code <= 599:
21+
return True
22+
return False

exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/_log_exporter/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
import requests
2525
from requests.exceptions import ConnectionError
2626

27-
from opentelemetry.exporter.otlp.proto.common._internal import (
28-
_is_retryable,
29-
)
3027
from opentelemetry.exporter.otlp.proto.common._log_encoder import encode_logs
3128
from opentelemetry.exporter.otlp.proto.http import (
3229
_OTLP_HTTP_HEADERS,
3330
Compression,
3431
)
32+
from opentelemetry.exporter.otlp.proto.http._common import (
33+
_is_retryable,
34+
)
3535
from opentelemetry.sdk._logs import LogData
3636
from opentelemetry.sdk._logs.export import (
3737
LogExporter,

exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/metric_exporter/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535

3636
from opentelemetry.exporter.otlp.proto.common._internal import (
3737
_get_resource_data,
38-
_is_retryable,
3938
)
4039
from opentelemetry.exporter.otlp.proto.common._internal.metrics_encoder import (
4140
OTLPMetricExporterMixin,
@@ -47,6 +46,9 @@
4746
_OTLP_HTTP_HEADERS,
4847
Compression,
4948
)
49+
from opentelemetry.exporter.otlp.proto.http._common import (
50+
_is_retryable,
51+
)
5052
from opentelemetry.proto.collector.metrics.v1.metrics_service_pb2 import ( # noqa: F401
5153
ExportMetricsServiceRequest,
5254
)

exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/trace_exporter/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@
2424
import requests
2525
from requests.exceptions import ConnectionError
2626

27-
from opentelemetry.exporter.otlp.proto.common._internal import (
28-
_is_retryable,
29-
)
3027
from opentelemetry.exporter.otlp.proto.common.trace_encoder import (
3128
encode_spans,
3229
)
3330
from opentelemetry.exporter.otlp.proto.http import (
3431
_OTLP_HTTP_HEADERS,
3532
Compression,
3633
)
34+
from opentelemetry.exporter.otlp.proto.http._common import (
35+
_is_retryable,
36+
)
3737
from opentelemetry.sdk.environment_variables import (
3838
OTEL_EXPORTER_OTLP_CERTIFICATE,
3939
OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE,

uv.lock

Lines changed: 7 additions & 88 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)