Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalff committed Dec 5, 2024
1 parent 150256c commit 9dbebb6
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ class InMemorySpanExporter final : public opentelemetry::sdk::trace::SpanExporte
return sdk::common::ExportResult::kSuccess;
}

virtual bool ForceFlush(std::chrono::microseconds /* timeout */) noexcept override
{
return true;
}

/**
* @param timeout an optional value containing the timeout of the exporter
* note: passing custom timeout values is not currently supported for this exporter
Expand Down
2 changes: 1 addition & 1 deletion sdk/include/opentelemetry/sdk/logs/exporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class OPENTELEMETRY_EXPORT LogRecordExporter
* Force flush the log records pushed into this log exporter.
*/
virtual bool ForceFlush(
std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept;
std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept = 0;

/**
* Marks the exporter as ShutDown and cleans up any resources as required.
Expand Down
2 changes: 1 addition & 1 deletion sdk/include/opentelemetry/sdk/logs/logger_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class OPENTELEMETRY_EXPORT LoggerProvider final : public opentelemetry::logs::Lo
/**
* Shutdown the log processor associated with this log provider.
*/
bool Shutdown() noexcept;
bool Shutdown(std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept;

/**
* Force flush the log processor associated with this log provider.
Expand Down
2 changes: 1 addition & 1 deletion sdk/include/opentelemetry/sdk/metrics/meter_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class MeterContext : public std::enable_shared_from_this<MeterContext>
/**
* Shutdown the Collectors associated with this meter provider.
*/
bool Shutdown() noexcept;
bool Shutdown(std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept;

private:
opentelemetry::sdk::resource::Resource resource_;
Expand Down
2 changes: 1 addition & 1 deletion sdk/include/opentelemetry/sdk/metrics/meter_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class OPENTELEMETRY_EXPORT MeterProvider final : public opentelemetry::metrics::
/**
* Shutdown the meter provider.
*/
bool Shutdown() noexcept;
bool Shutdown(std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept;

/**
* Force flush the meter provider.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class PushMetricExporter
* @return return the status of the operation.
*/
virtual bool Shutdown(
std::chrono::microseconds timeout = std::chrono::microseconds(0)) noexcept = 0;
std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept = 0;
};
} // namespace metrics
} // namespace sdk
Expand Down
4 changes: 2 additions & 2 deletions sdk/include/opentelemetry/sdk/trace/exporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ class OPENTELEMETRY_EXPORT SpanExporter

/**
* Export all spans that have been exported.
* @param timeout an optional timeout, the default timeout of 0 means that no
* @param timeout an optional timeout, the default timeout means that no
* timeout is applied.
* @return return true when all data are exported, and false when timeout
*/
virtual bool ForceFlush(
std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept;
std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept = 0;

/**
* Shut down the exporter.
Expand Down
4 changes: 2 additions & 2 deletions sdk/include/opentelemetry/sdk/trace/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class OPENTELEMETRY_EXPORT SpanProcessor

/**
* Export all ended spans that have not yet been exported.
* @param timeout an optional timeout, the default timeout of 0 means that no
* @param timeout an optional timeout, the default timeout means that no
* timeout is applied.
*/
virtual bool ForceFlush(
Expand All @@ -67,7 +67,7 @@ class OPENTELEMETRY_EXPORT SpanProcessor
* exported before shutdown. After the call to Shutdown, subsequent calls to
* OnStart, OnEnd, ForceFlush or Shutdown will return immediately without
* doing anything.
* @param timeout an optional timeout, the default timeout of 0 means that no
* @param timeout an optional timeout, the default timeout means that no
* timeout is applied.
*/
virtual bool Shutdown(
Expand Down
2 changes: 1 addition & 1 deletion sdk/include/opentelemetry/sdk/trace/tracer_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class OPENTELEMETRY_EXPORT TracerProvider final : public opentelemetry::trace::T
/**
* Shutdown the span processor associated with this tracer provider.
*/
bool Shutdown() noexcept;
bool Shutdown(std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept;

/**
* Force flush the span processor associated with this tracer provider.
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/logs/logger_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ const opentelemetry::sdk::resource::Resource &LoggerProvider::GetResource() cons
return context_->GetResource();
}

bool LoggerProvider::Shutdown() noexcept
bool LoggerProvider::Shutdown(std::chrono::microseconds timeout) noexcept
{
return context_->Shutdown();
return context_->Shutdown(timeout);
}

bool LoggerProvider::ForceFlush(std::chrono::microseconds timeout) noexcept
Expand Down
5 changes: 2 additions & 3 deletions sdk/src/metrics/meter_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,15 @@ void MeterContext::RemoveMeter(nostd::string_view name,
meters_.swap(filtered_meters);
}

bool MeterContext::Shutdown() noexcept
bool MeterContext::Shutdown(std::chrono::microseconds timeout) noexcept
{
bool result = true;
// Shutdown only once.
if (!shutdown_latch_.test_and_set(std::memory_order_acquire))
{

for (auto &collector : collectors_)
{
bool status = std::static_pointer_cast<MetricCollector>(collector)->Shutdown();
bool status = std::static_pointer_cast<MetricCollector>(collector)->Shutdown(timeout);
result = result && status;
}
if (!result)
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/metrics/meter_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ void MeterProvider::SetExemplarFilter(metrics::ExemplarFilterType exemplar_filte
/**
* Shutdown the meter provider.
*/
bool MeterProvider::Shutdown() noexcept
bool MeterProvider::Shutdown(std::chrono::microseconds timeout) noexcept
{
return context_->Shutdown();
return context_->Shutdown(timeout);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/trace/tracer_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ const resource::Resource &TracerProvider::GetResource() const noexcept
return context_->GetResource();
}

bool TracerProvider::Shutdown() noexcept
bool TracerProvider::Shutdown(std::chrono::microseconds timeout) noexcept
{
return context_->Shutdown();
return context_->Shutdown(timeout);
}

bool TracerProvider::ForceFlush(std::chrono::microseconds timeout) noexcept
Expand Down

0 comments on commit 9dbebb6

Please sign in to comment.