Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

- Fix intermittent `Connection aborted` error when using otlp/http exporters
([#4477](https://github.com/open-telemetry/opentelemetry-python/pull/4477))
- opentelemetry-sdk: use stable code attributes: `code.function` -> `code.function.name`, `code.lineno` -> `code.line.number`, `code.filepath` -> `code.file.path`
([#4508](https://github.com/open-telemetry/opentelemetry-python/pull/4508))
- Fix serialization of extended attributes for logs signal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from typing import Dict, Optional, Sequence

import requests
from requests.exceptions import ConnectionError

from opentelemetry.exporter.otlp.proto.common._internal import (
_create_exp_backoff_generator,
Expand Down Expand Up @@ -133,13 +134,27 @@ def _export(self, serialized_data: bytes):
elif self._compression == Compression.Deflate:
data = zlib.compress(serialized_data)

return self._session.post(
url=self._endpoint,
data=data,
verify=self._certificate_file,
timeout=self._timeout,
cert=self._client_cert,
)
# By default, keep-alive is enabled in Session's request
# headers. Backends may choose to close the connection
# while a post happens which causes an unhandled
# exception. This try/except will retry the post on such exceptions
try:
resp = self._session.post(
url=self._endpoint,
data=data,
verify=self._certificate_file,
timeout=self._timeout,
cert=self._client_cert,
)
except ConnectionError:
resp = self._session.post(
url=self._endpoint,
data=data,
verify=self._certificate_file,
timeout=self._timeout,
cert=self._client_cert,
)
return resp

@staticmethod
def _retryable(resp: requests.Response) -> bool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import requests
from deprecated import deprecated
from requests.exceptions import ConnectionError

from opentelemetry.exporter.otlp.proto.common._internal import (
_create_exp_backoff_generator,
Expand Down Expand Up @@ -175,13 +176,27 @@ def _export(self, serialized_data: bytes):
elif self._compression == Compression.Deflate:
data = zlib.compress(serialized_data)

return self._session.post(
url=self._endpoint,
data=data,
verify=self._certificate_file,
timeout=self._timeout,
cert=self._client_cert,
)
# By default, keep-alive is enabled in Session's request
# headers. Backends may choose to close the connection
# while a post happens which causes an unhandled
# exception. This try/except will retry the post on such exceptions
try:
resp = self._session.post(
url=self._endpoint,
data=data,
verify=self._certificate_file,
timeout=self._timeout,
cert=self._client_cert,
)
except ConnectionError:
resp = self._session.post(
url=self._endpoint,
data=data,
verify=self._certificate_file,
timeout=self._timeout,
cert=self._client_cert,
)
return resp

@staticmethod
def _retryable(resp: requests.Response) -> bool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from typing import Dict, Optional

import requests
from requests.exceptions import ConnectionError

from opentelemetry.exporter.otlp.proto.common._internal import (
_create_exp_backoff_generator,
Expand Down Expand Up @@ -130,13 +131,27 @@ def _export(self, serialized_data: bytes):
elif self._compression == Compression.Deflate:
data = zlib.compress(serialized_data)

return self._session.post(
url=self._endpoint,
data=data,
verify=self._certificate_file,
timeout=self._timeout,
cert=self._client_cert,
)
# By default, keep-alive is enabled in Session's request
# headers. Backends may choose to close the connection
# while a post happens which causes an unhandled
# exception. This try/except will retry the post on such exceptions
try:
resp = self._session.post(
url=self._endpoint,
data=data,
verify=self._certificate_file,
timeout=self._timeout,
cert=self._client_cert,
)
except ConnectionError:
resp = self._session.post(
url=self._endpoint,
data=data,
verify=self._certificate_file,
timeout=self._timeout,
cert=self._client_cert,
)
return resp

@staticmethod
def _retryable(resp: requests.Response) -> bool:
Expand Down