Skip to content

Commit 700848b

Browse files
kchoudhuocelotl
andauthored
Split serialization and export of spans into separate functions for http trace exporter (#3826)
Co-authored-by: Diego Hurtado <[email protected]>
1 parent c4c7378 commit 700848b

File tree

1 file changed

+14
-9
lines changed
  • exporter/opentelemetry-exporter-otlp-proto-http/src/opentelemetry/exporter/otlp/proto/http/trace_exporter

1 file changed

+14
-9
lines changed

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

+14-9
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,13 @@ def _retryable(resp: requests.Response) -> bool:
126126
return True
127127
return False
128128

129-
def export(self, spans) -> SpanExportResult:
130-
# After the call to Shutdown subsequent calls to Export are
131-
# not allowed and should return a Failure result.
132-
if self._shutdown:
133-
_logger.warning("Exporter already shutdown, ignoring batch")
134-
return SpanExportResult.FAILURE
135-
136-
serialized_data = encode_spans(spans).SerializeToString()
129+
def _serialize_spans(self, spans):
130+
return encode_spans(spans).SerializePartialToString()
137131

132+
def _export_serialized_spans(self, serialized_data):
138133
for delay in _create_exp_backoff_generator(
139134
max_value=self._MAX_RETRY_TIMEOUT
140135
):
141-
142136
if delay == self._MAX_RETRY_TIMEOUT:
143137
return SpanExportResult.FAILURE
144138

@@ -163,6 +157,17 @@ def export(self, spans) -> SpanExportResult:
163157
return SpanExportResult.FAILURE
164158
return SpanExportResult.FAILURE
165159

160+
def export(self, spans) -> SpanExportResult:
161+
# After the call to Shutdown subsequent calls to Export are
162+
# not allowed and should return a Failure result.
163+
if self._shutdown:
164+
_logger.warning("Exporter already shutdown, ignoring batch")
165+
return SpanExportResult.FAILURE
166+
167+
serialized_data = self._serialize_spans(spans)
168+
169+
return self._export_serialized_spans(serialized_data)
170+
166171
def shutdown(self):
167172
if self._shutdown:
168173
_logger.warning("Exporter already shutdown, ignoring call")

0 commit comments

Comments
 (0)