Skip to content

Commit

Permalink
Add force_flush to span exporters (#2919)
Browse files Browse the repository at this point in the history
* Add force_flush to span exporters

* Fix lint

* add missing method to grpc exporter

* Update contrib SHA

* Add CHANGELOG entry
  • Loading branch information
srikanthccv authored Sep 22, 2022
1 parent 725c580 commit c0e8f40
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add support for setting OTLP export protocol with env vars, as defined in the
[specifications](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#specify-protocol)
([#2893](https://github.com/open-telemetry/opentelemetry-python/pull/2893))
- Add force_flush to span exporters
([#2919](https://github.com/open-telemetry/opentelemetry-python/pull/2919))

## [1.12.0-0.33b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.12.0) - 2022-08-08

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,6 @@ def export(self, spans) -> SpanExportResult:

def shutdown(self):
pass

def force_flush(self, timeout_millis: int = 30000) -> bool:
return True
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,6 @@ def export(self, spans) -> SpanExportResult:

def shutdown(self):
pass

def force_flush(self, timeout_millis: int = 30000) -> bool:
return True
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ def generate_span_requests(self, spans):
)
yield service_request

def force_flush(self, timeout_millis: int = 30000) -> bool:
return True


# pylint: disable=too-many-branches
def translate_to_collector(spans: Sequence[ReadableSpan]):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ def _translate_data(
def export(self, spans: Sequence[ReadableSpan]) -> SpanExportResult:
return self._export(spans)

def force_flush(self, timeout_millis: int = 30000) -> bool:
return True

@property
def _exporting(self):
return "traces"
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ def shutdown(self):
self._session.close()
self._shutdown = True

def force_flush(self, timeout_millis: int = 30000) -> bool:
return True


def _compression_from_env() -> Compression:
compression = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,6 @@ def shutdown(self) -> None:
return
self.session.close()
self._closed = True

def force_flush(self, timeout_millis: int = 30000) -> bool:
return True
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,6 @@ def shutdown(self) -> None:
return
self.session.close()
self._closed = True

def force_flush(self, timeout_millis: int = 30000) -> bool:
return True
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ def shutdown(self) -> None:
Called when the SDK is shut down.
"""

def force_flush(self, timeout_millis: int = 30000) -> bool:
"""Hint to ensure that the export of any spans the exporter has received
prior to the call to ForceFlush SHOULD be completed as soon as possible, preferably
before returning from this method.
"""


class SimpleSpanProcessor(SpanProcessor):
"""Simple SpanProcessor implementation.
Expand Down Expand Up @@ -438,3 +444,6 @@ def export(self, spans: typing.Sequence[ReadableSpan]) -> SpanExportResult:
self.out.write(self.formatter(span))
self.out.flush()
return SpanExportResult.SUCCESS

def force_flush(self, timeout_millis: int = 30000) -> bool:
return True
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ def shutdown(self):
Calls to export after the exporter has been shut down will fail.
"""
self._stopped = True

def force_flush(self, timeout_millis: int = 30000) -> bool:
return True

0 comments on commit c0e8f40

Please sign in to comment.