Skip to content

Commit 570d27e

Browse files
sk-srikanthccv
andauthored
feat: include endpoint in grpc logs (#3362)
Co-authored-by: Srikanth Chekuri <[email protected]>
1 parent 84357bf commit 570d27e

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
([#3341](https://github.com/open-telemetry/opentelemetry-python/pull/3341))
1919
- Upgrade opentelemetry-proto to 0.20 and regen
2020
[#3355](https://github.com/open-telemetry/opentelemetry-python/pull/3355))
21+
- Include endpoint in Grpc transient error warning
22+
[#3362](https://github.com/open-telemetry/opentelemetry-python/pull/3362))
2123

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

exporter/opentelemetry-exporter-otlp-proto-grpc/src/opentelemetry/exporter/otlp/proto/grpc/exporter.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,11 @@ def __init__(
178178
):
179179
super().__init__()
180180

181-
endpoint = endpoint or environ.get(
181+
self._endpoint = endpoint or environ.get(
182182
OTEL_EXPORTER_OTLP_ENDPOINT, "http://localhost:4317"
183183
)
184184

185-
parsed_url = urlparse(endpoint)
185+
parsed_url = urlparse(self._endpoint)
186186

187187
if parsed_url.scheme == "https":
188188
insecure = False
@@ -197,7 +197,7 @@ def __init__(
197197
insecure = False
198198

199199
if parsed_url.netloc:
200-
endpoint = parsed_url.netloc
200+
self._endpoint = parsed_url.netloc
201201

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

224224
if insecure:
225225
self._client = self._stub(
226-
insecure_channel(endpoint, compression=compression)
226+
insecure_channel(self._endpoint, compression=compression)
227227
)
228228
else:
229229
credentials = _get_credentials(
230230
credentials, OTEL_EXPORTER_OTLP_CERTIFICATE
231231
)
232232
self._client = self._stub(
233-
secure_channel(endpoint, credentials, compression=compression)
233+
secure_channel(
234+
self._endpoint, credentials, compression=compression
235+
)
234236
)
235237

236238
self._export_lock = threading.Lock()
@@ -304,18 +306,20 @@ def _export(
304306
logger.warning(
305307
(
306308
"Transient error %s encountered while exporting "
307-
"%s, retrying in %ss."
309+
"%s to %s, retrying in %ss."
308310
),
309311
error.code(),
310312
self._exporting,
313+
self._endpoint,
311314
delay,
312315
)
313316
sleep(delay)
314317
continue
315318
else:
316319
logger.error(
317-
"Failed to export %s, error code: %s",
320+
"Failed to export %s to %s, error code: %s",
318321
self._exporting,
322+
self._endpoint,
319323
error.code(),
320324
)
321325

exporter/opentelemetry-exporter-otlp-proto-grpc/tests/test_otlp_exporter_mixin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def _exporting(self) -> str:
9393
otlp_mock_exporter._export(Mock())
9494
self.assertEqual(
9595
warning.records[0].message,
96-
"Failed to export mock, error code: None",
96+
"Failed to export mock to localhost:4317, error code: None",
9797
)
9898

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

0 commit comments

Comments
 (0)