Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: include endpoint in grpc logs #3362

Merged
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 @@ -18,6 +18,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#3341](https://github.com/open-telemetry/opentelemetry-python/pull/3341))
- Upgrade opentelemetry-proto to 0.20 and regen
[#3355](https://github.com/open-telemetry/opentelemetry-python/pull/3355))
- Include endpoint in Grpc transient error warning
[#3362](https://github.com/open-telemetry/opentelemetry-python/pull/3362))

## Version 1.18.0/0.39b0 (2023-05-04)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ def __init__(
):
super().__init__()

endpoint = endpoint or environ.get(
self._endpoint = endpoint or environ.get(
OTEL_EXPORTER_OTLP_ENDPOINT, "http://localhost:4317"
)

parsed_url = urlparse(endpoint)
parsed_url = urlparse(self._endpoint)

if parsed_url.scheme == "https":
insecure = False
Expand All @@ -197,7 +197,7 @@ def __init__(
insecure = False

if parsed_url.netloc:
endpoint = parsed_url.netloc
self._endpoint = parsed_url.netloc

self._headers = headers or environ.get(OTEL_EXPORTER_OTLP_HEADERS)
if isinstance(self._headers, str):
Expand All @@ -223,14 +223,16 @@ def __init__(

if insecure:
self._client = self._stub(
insecure_channel(endpoint, compression=compression)
insecure_channel(self._endpoint, compression=compression)
)
else:
credentials = _get_credentials(
credentials, OTEL_EXPORTER_OTLP_CERTIFICATE
)
self._client = self._stub(
secure_channel(endpoint, credentials, compression=compression)
secure_channel(
self._endpoint, credentials, compression=compression
)
)

self._export_lock = threading.Lock()
Expand Down Expand Up @@ -304,18 +306,20 @@ def _export(
logger.warning(
(
"Transient error %s encountered while exporting "
"%s, retrying in %ss."
"%s to %s, retrying in %ss."
),
error.code(),
self._exporting,
self._endpoint,
delay,
)
sleep(delay)
continue
else:
logger.error(
"Failed to export %s, error code: %s",
"Failed to export %s to %s, error code: %s",
self._exporting,
self._endpoint,
error.code(),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def _exporting(self) -> str:
otlp_mock_exporter._export(Mock())
self.assertEqual(
warning.records[0].message,
"Failed to export mock, error code: None",
"Failed to export mock to localhost:4317, error code: None",
)

def code(self): # pylint: disable=function-redefined
Expand All @@ -112,7 +112,7 @@ def trailing_metadata(self):
warning.records[0].message,
(
"Transient error StatusCode.CANCELLED encountered "
"while exporting mock, retrying in 0s."
"while exporting mock to localhost:4317, retrying in 0s."
),
)

Expand Down