diff --git a/docs/CHANGELOG.rst b/docs/CHANGELOG.rst index d9acd6dfb..48d33eb18 100644 --- a/docs/CHANGELOG.rst +++ b/docs/CHANGELOG.rst @@ -6,6 +6,16 @@ All notable changes to this project are documented in this file. This project adheres to `Semantic Versioning `_. +========== +Unreleased +========== + +Added +----- +- Allow overriding the number of max metrics points that are exported in the + same batch via ``METRICS_EXPORT_SIZE`` environmental variable (defaults to + 1000) + =================== 40.2.0 - 2024-08-19 =================== diff --git a/resolwe/flow/managers/listener/metrics.py b/resolwe/flow/managers/listener/metrics.py index d577a3b4d..b4d3356e2 100644 --- a/resolwe/flow/managers/listener/metrics.py +++ b/resolwe/flow/managers/listener/metrics.py @@ -26,6 +26,16 @@ METRICS_EXPORT_INTERVAL = 30000 # TODO: Remove this when metrics are properly implemented. METRICS_INSECURE_EXPORT = True +# The number of data points to send in one request. +# See +# https://github.com/open-telemetry/opentelemetry-python/pull/2809 +# and +# https://github.com/open-telemetry/opentelemetry-python/issues/2710 +# for details. +try: + METRICS_EXPORT_SIZE = int(os.environ.get("METRICS_EXPORT_SIZE", 1000)) +except ValueError: + METRICS_EXPORT_SIZE = 1000 class MetricsEventReporter(MessageProcessingCallback): @@ -60,7 +70,9 @@ def _init_metrics(self, metric_endpoint): # Initialize the opentelemetry metrics. metric_exporter = OTLPMetricExporter( - endpoint=metric_endpoint, insecure=METRICS_INSECURE_EXPORT + endpoint=metric_endpoint, + insecure=METRICS_INSECURE_EXPORT, + max_export_batch_size=METRICS_EXPORT_SIZE, ) metric_reader = PeriodicExportingMetricReader( metric_exporter, METRICS_EXPORT_INTERVAL