diff --git a/api/CMakeLists.txt b/api/CMakeLists.txt index ecbb377725..fc26d9083f 100644 --- a/api/CMakeLists.txt +++ b/api/CMakeLists.txt @@ -104,7 +104,6 @@ if(WITH_NO_GETENV) endif() if(WIN32) - target_compile_definitions(opentelemetry_api INTERFACE NOMINMAX) if(WITH_ETW) target_compile_definitions(opentelemetry_api INTERFACE HAVE_MSGPACK) endif() diff --git a/api/include/opentelemetry/common/spin_lock_mutex.h b/api/include/opentelemetry/common/spin_lock_mutex.h index 1877c8eb40..ac52f700bc 100644 --- a/api/include/opentelemetry/common/spin_lock_mutex.h +++ b/api/include/opentelemetry/common/spin_lock_mutex.h @@ -10,9 +10,6 @@ #include "opentelemetry/version.h" #if defined(_MSC_VER) -# ifndef NOMINMAX -# define NOMINMAX -# endif # define _WINSOCKAPI_ // stops including winsock.h # include #elif defined(__i386__) || defined(__x86_64__) diff --git a/api/include/opentelemetry/common/timestamp.h b/api/include/opentelemetry/common/timestamp.h index 14aa457b5b..f7c79b8b57 100644 --- a/api/include/opentelemetry/common/timestamp.h +++ b/api/include/opentelemetry/common/timestamp.h @@ -178,7 +178,7 @@ class DurationUtil std::chrono::duration indefinite_value) noexcept { // Do not call now() when this duration is max value, now() may have a expensive cost. - if (timeout == std::chrono::duration::max()) + if (timeout == (std::chrono::duration::max)()) { return indefinite_value; } @@ -186,13 +186,13 @@ class DurationUtil // std::future::wait_for, std::this_thread::sleep_for, and std::condition_variable::wait_for // may use steady_clock or system_clock.We need make sure now() + timeout do not overflow. auto max_timeout = std::chrono::duration_cast>( - std::chrono::steady_clock::time_point::max() - std::chrono::steady_clock::now()); + (std::chrono::steady_clock::time_point::max)() - std::chrono::steady_clock::now()); if (timeout >= max_timeout) { return indefinite_value; } max_timeout = std::chrono::duration_cast>( - std::chrono::system_clock::time_point::max() - std::chrono::system_clock::now()); + (std::chrono::system_clock::time_point::max)() - std::chrono::system_clock::now()); if (timeout >= max_timeout) { return indefinite_value; diff --git a/api/include/opentelemetry/plugin/detail/dynamic_load_windows.h b/api/include/opentelemetry/plugin/detail/dynamic_load_windows.h index 3f5e05f198..5ed2833756 100644 --- a/api/include/opentelemetry/plugin/detail/dynamic_load_windows.h +++ b/api/include/opentelemetry/plugin/detail/dynamic_load_windows.h @@ -12,9 +12,6 @@ #include "opentelemetry/plugin/hook.h" #include "opentelemetry/version.h" -#ifndef NOMINMAX -# define NOMINMAX -#endif #include #include diff --git a/exporters/ostream/include/opentelemetry/exporters/ostream/log_record_exporter.h b/exporters/ostream/include/opentelemetry/exporters/ostream/log_record_exporter.h index 7b196ec9e8..a2897a5f26 100644 --- a/exporters/ostream/include/opentelemetry/exporters/ostream/log_record_exporter.h +++ b/exporters/ostream/include/opentelemetry/exporters/ostream/log_record_exporter.h @@ -47,13 +47,13 @@ class OStreamLogRecordExporter final : public opentelemetry::sdk::logs::LogRecor * @return return true when all data are exported, and false when timeout */ bool ForceFlush( - std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept override; + std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept override; /** * Marks the OStream Log Exporter as shut down. */ bool Shutdown( - std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept override; + std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept override; private: // The OStream to send the logs to diff --git a/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h b/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h index 05c8a89982..03c95c23f9 100644 --- a/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h +++ b/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h @@ -44,10 +44,10 @@ class OStreamSpanExporter final : public opentelemetry::sdk::trace::SpanExporter * @return return true when all data are exported, and false when timeout */ bool ForceFlush( - std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept override; + std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept override; bool Shutdown( - std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept override; + std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept override; private: std::ostream &sout_; diff --git a/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter.h b/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter.h index 2bf12b3a35..4de6513bfb 100644 --- a/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter.h +++ b/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter.h @@ -55,14 +55,14 @@ class ZipkinExporter final : public opentelemetry::sdk::trace::SpanExporter * @return return true when all data are exported, and false when timeout */ bool ForceFlush( - std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept override; + std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept override; /** * Shut down the exporter. * @param timeout an optional timeout, default to max. */ bool Shutdown( - std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept override; + std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept override; private: void InitializeLocalEndpoint(); diff --git a/sdk/include/opentelemetry/sdk/logs/exporter.h b/sdk/include/opentelemetry/sdk/logs/exporter.h index bdddc4209c..68c61603fa 100644 --- a/sdk/include/opentelemetry/sdk/logs/exporter.h +++ b/sdk/include/opentelemetry/sdk/logs/exporter.h @@ -62,7 +62,7 @@ class OPENTELEMETRY_EXPORT LogRecordExporter * @return true if the exporter shutdown succeeded, false otherwise */ virtual bool Shutdown( - std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept = 0; + std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept = 0; }; } // namespace logs } // namespace sdk diff --git a/sdk/include/opentelemetry/sdk/logs/logger_context.h b/sdk/include/opentelemetry/sdk/logs/logger_context.h index ee47c56a7f..bab002b231 100644 --- a/sdk/include/opentelemetry/sdk/logs/logger_context.h +++ b/sdk/include/opentelemetry/sdk/logs/logger_context.h @@ -70,7 +70,7 @@ class LoggerContext /** * Shutdown the log processor associated with this tracer provider. */ - bool Shutdown(std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept; + bool Shutdown(std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept; private: // order of declaration is important here - resource object should be destroyed after processor. diff --git a/sdk/include/opentelemetry/sdk/logs/processor.h b/sdk/include/opentelemetry/sdk/logs/processor.h index 79a25ff260..57dbdb2130 100644 --- a/sdk/include/opentelemetry/sdk/logs/processor.h +++ b/sdk/include/opentelemetry/sdk/logs/processor.h @@ -46,7 +46,7 @@ class LogRecordProcessor * @return a result code indicating whether it succeeded, failed or timed out */ virtual bool ForceFlush( - std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept = 0; + std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept = 0; /** * Shuts down the processor and does any cleanup required. @@ -56,7 +56,7 @@ class LogRecordProcessor * @return true if the shutdown succeeded, false otherwise */ virtual bool Shutdown( - std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept = 0; + std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept = 0; }; } // namespace logs } // namespace sdk diff --git a/sdk/include/opentelemetry/sdk/logs/simple_log_record_processor.h b/sdk/include/opentelemetry/sdk/logs/simple_log_record_processor.h index e195f89c10..a65c0eb7a9 100644 --- a/sdk/include/opentelemetry/sdk/logs/simple_log_record_processor.h +++ b/sdk/include/opentelemetry/sdk/logs/simple_log_record_processor.h @@ -39,10 +39,10 @@ class SimpleLogRecordProcessor : public LogRecordProcessor void OnEmit(std::unique_ptr &&record) noexcept override; bool ForceFlush( - std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept override; + std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept override; bool Shutdown( - std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept override; + std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept override; bool IsShutdown() const noexcept; diff --git a/sdk/include/opentelemetry/sdk/metrics/aggregation/histogram_aggregation.h b/sdk/include/opentelemetry/sdk/metrics/aggregation/histogram_aggregation.h index 4419ee81f3..04293e696f 100644 --- a/sdk/include/opentelemetry/sdk/metrics/aggregation/histogram_aggregation.h +++ b/sdk/include/opentelemetry/sdk/metrics/aggregation/histogram_aggregation.h @@ -93,8 +93,8 @@ void HistogramMerge(HistogramPointData ¤t, merge.record_min_max_ = current.record_min_max_ && delta.record_min_max_; if (merge.record_min_max_) { - merge.min_ = std::min(nostd::get(current.min_), nostd::get(delta.min_)); - merge.max_ = std::max(nostd::get(current.max_), nostd::get(delta.max_)); + merge.min_ = (std::min)(nostd::get(current.min_), nostd::get(delta.min_)); + merge.max_ = (std::max)(nostd::get(current.max_), nostd::get(delta.max_)); } } diff --git a/sdk/include/opentelemetry/sdk/metrics/metric_reader.h b/sdk/include/opentelemetry/sdk/metrics/metric_reader.h index 96b34a4427..21249439d6 100644 --- a/sdk/include/opentelemetry/sdk/metrics/metric_reader.h +++ b/sdk/include/opentelemetry/sdk/metrics/metric_reader.h @@ -48,12 +48,12 @@ class MetricReader /** * Shutdown the metric reader. */ - bool Shutdown(std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept; + bool Shutdown(std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept; /** * Force flush the metric read by the reader. */ - bool ForceFlush(std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept; + bool ForceFlush(std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept; /** * Return the status of Metric reader. diff --git a/sdk/include/opentelemetry/sdk/metrics/state/metric_collector.h b/sdk/include/opentelemetry/sdk/metrics/state/metric_collector.h index e94c005ecc..bf0a9ba86b 100644 --- a/sdk/include/opentelemetry/sdk/metrics/state/metric_collector.h +++ b/sdk/include/opentelemetry/sdk/metrics/state/metric_collector.h @@ -53,9 +53,9 @@ class MetricCollector : public MetricProducer, public CollectorHandle */ bool Collect(nostd::function_ref callback) noexcept override; - bool ForceFlush(std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept; + bool ForceFlush(std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept; - bool Shutdown(std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept; + bool Shutdown(std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept; private: MeterContext *meter_context_; diff --git a/sdk/include/opentelemetry/sdk/trace/exporter.h b/sdk/include/opentelemetry/sdk/trace/exporter.h index f9ed068b64..8795b69837 100644 --- a/sdk/include/opentelemetry/sdk/trace/exporter.h +++ b/sdk/include/opentelemetry/sdk/trace/exporter.h @@ -61,7 +61,7 @@ class OPENTELEMETRY_EXPORT SpanExporter * @return return the status of the operation. */ virtual bool Shutdown( - std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept = 0; + std::chrono::microseconds timeout = (std::chrono::microseconds::max)()) noexcept = 0; }; } // namespace trace } // namespace sdk diff --git a/sdk/src/logs/batch_log_record_processor.cc b/sdk/src/logs/batch_log_record_processor.cc index 92536d1c00..44e623e4f7 100644 --- a/sdk/src/logs/batch_log_record_processor.cc +++ b/sdk/src/logs/batch_log_record_processor.cc @@ -104,7 +104,7 @@ bool BatchLogRecordProcessor::ForceFlush(std::chrono::microseconds timeout) noex std::chrono::duration_cast(timeout); if (timeout_steady <= std::chrono::steady_clock::duration::zero()) { - timeout_steady = std::chrono::steady_clock::duration::max(); + timeout_steady = (std::chrono::steady_clock::duration::max)(); } bool result = false; diff --git a/sdk/src/metrics/aggregation/histogram_aggregation.cc b/sdk/src/metrics/aggregation/histogram_aggregation.cc index 3213c27f16..1aa02637ea 100644 --- a/sdk/src/metrics/aggregation/histogram_aggregation.cc +++ b/sdk/src/metrics/aggregation/histogram_aggregation.cc @@ -38,8 +38,8 @@ LongHistogramAggregation::LongHistogramAggregation(const AggregationConfig *aggr point_data_.sum_ = (int64_t)0; point_data_.count_ = 0; point_data_.record_min_max_ = record_min_max_; - point_data_.min_ = std::numeric_limits::max(); - point_data_.max_ = std::numeric_limits::min(); + point_data_.min_ = (std::numeric_limits::max)(); + point_data_.max_ = (std::numeric_limits::min)(); } LongHistogramAggregation::LongHistogramAggregation(HistogramPointData &&data) @@ -58,8 +58,8 @@ void LongHistogramAggregation::Aggregate(int64_t value, point_data_.sum_ = nostd::get(point_data_.sum_) + value; if (record_min_max_) { - point_data_.min_ = std::min(nostd::get(point_data_.min_), value); - point_data_.max_ = std::max(nostd::get(point_data_.max_), value); + point_data_.min_ = (std::min)(nostd::get(point_data_.min_), value); + point_data_.max_ = (std::max)(nostd::get(point_data_.max_), value); } size_t index = BucketBinarySearch(value, point_data_.boundaries_); point_data_.counts_[index] += 1; @@ -118,8 +118,8 @@ DoubleHistogramAggregation::DoubleHistogramAggregation(const AggregationConfig * point_data_.sum_ = 0.0; point_data_.count_ = 0; point_data_.record_min_max_ = record_min_max_; - point_data_.min_ = std::numeric_limits::max(); - point_data_.max_ = std::numeric_limits::min(); + point_data_.min_ = (std::numeric_limits::max)(); + point_data_.max_ = (std::numeric_limits::min)(); } DoubleHistogramAggregation::DoubleHistogramAggregation(HistogramPointData &&data) @@ -138,8 +138,8 @@ void DoubleHistogramAggregation::Aggregate(double value, point_data_.sum_ = nostd::get(point_data_.sum_) + value; if (record_min_max_) { - point_data_.min_ = std::min(nostd::get(point_data_.min_), value); - point_data_.max_ = std::max(nostd::get(point_data_.max_), value); + point_data_.min_ = (std::min)(nostd::get(point_data_.min_), value); + point_data_.max_ = (std::max)(nostd::get(point_data_.max_), value); } size_t index = BucketBinarySearch(value, point_data_.boundaries_); point_data_.counts_[index] += 1; diff --git a/sdk/src/metrics/export/periodic_exporting_metric_reader.cc b/sdk/src/metrics/export/periodic_exporting_metric_reader.cc index dfa4a5ee6b..91f604195e 100644 --- a/sdk/src/metrics/export/periodic_exporting_metric_reader.cc +++ b/sdk/src/metrics/export/periodic_exporting_metric_reader.cc @@ -133,7 +133,7 @@ bool PeriodicExportingMetricReader::OnForceFlush(std::chrono::microseconds timeo std::chrono::duration_cast(wait_timeout); if (timeout_steady <= std::chrono::steady_clock::duration::zero()) { - timeout_steady = std::chrono::steady_clock::duration::max(); + timeout_steady = (std::chrono::steady_clock::duration::max)(); } bool result = false; diff --git a/sdk/src/metrics/meter_context.cc b/sdk/src/metrics/meter_context.cc index 7a299bfc63..79f254fa93 100644 --- a/sdk/src/metrics/meter_context.cc +++ b/sdk/src/metrics/meter_context.cc @@ -136,7 +136,7 @@ bool MeterContext::ForceFlush(std::chrono::microseconds timeout) noexcept // Simultaneous flush not allowed. const std::lock_guard locked(forceflush_lock_); // Convert to nanos to prevent overflow - auto timeout_ns = std::chrono::nanoseconds::max(); + auto timeout_ns = (std::chrono::nanoseconds::max)(); if (std::chrono::duration_cast(timeout_ns) > timeout) { timeout_ns = std::chrono::duration_cast(timeout); @@ -144,7 +144,7 @@ bool MeterContext::ForceFlush(std::chrono::microseconds timeout) noexcept auto current_time = std::chrono::system_clock::now(); std::chrono::system_clock::time_point expire_time; - auto overflow_checker = std::chrono::system_clock::time_point::max(); + auto overflow_checker = (std::chrono::system_clock::time_point::max)(); // check if the expected expire time doesn't overflow. if (overflow_checker - current_time > timeout_ns) diff --git a/sdk/src/trace/batch_span_processor.cc b/sdk/src/trace/batch_span_processor.cc index 719a072e64..d5b96f2cc8 100644 --- a/sdk/src/trace/batch_span_processor.cc +++ b/sdk/src/trace/batch_span_processor.cc @@ -102,7 +102,7 @@ bool BatchSpanProcessor::ForceFlush(std::chrono::microseconds timeout) noexcept std::chrono::duration_cast(timeout); if (timeout_steady <= std::chrono::steady_clock::duration::zero()) { - timeout_steady = std::chrono::steady_clock::duration::max(); + timeout_steady = (std::chrono::steady_clock::duration::max)(); } bool result = false;