Repository: elastic/elastic-otel-python

Issue:
cumulative histograms and cumulative exponential histograms should be converted to delta
For a better experience out of the box cumulative histograms and cumulative exponential histograms should be converted to delta.

Need to sort out if the histogram temporality may be changed by default or we need to employ some tricks.

Discussion:

Patch:
diff --git a/src/elasticotel/distro/__init__.py b/src/elasticotel/distro/__init__.py
index ae2c631..f1025be 100644
--- a/src/elasticotel/distro/__init__.py
+++ b/src/elasticotel/distro/__init__.py
@@ -48,6 +48,7 @@ from opentelemetry.sdk._logs.export import BatchLogRecordProcessor
 from opentelemetry.sdk.environment_variables import (
     OTEL_METRICS_EXEMPLAR_FILTER,
     OTEL_EXPERIMENTAL_RESOURCE_DETECTORS,
+    OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE,
     OTEL_EXPORTER_OTLP_PROTOCOL,
     _OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED,
 )
@@ -141,3 +142,5 @@ class ElasticOpenTelemetryDistro(BaseDistro):
         os.environ.setdefault(OTEL_EXPERIMENTAL_RESOURCE_DETECTORS, "process_runtime,os,otel,telemetry_distro")
         # disable exemplars by default for now
         os.environ.setdefault(OTEL_METRICS_EXEMPLAR_FILTER, "always_off")
+        # preference to use DELTA temporality as we can handle only this kind of Histograms
+        os.environ.setdefault(OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE, "DELTA")


Test patch:
diff --git a/tests/distro/test_distro.py b/tests/distro/test_distro.py
index 6f37c20..12b558a 100644
--- a/tests/distro/test_distro.py
+++ b/tests/distro/test_distro.py
@@ -27,6 +27,7 @@ from opentelemetry.environment_variables import (
 from opentelemetry.sdk.environment_variables import (
     OTEL_METRICS_EXEMPLAR_FILTER,
     OTEL_EXPERIMENTAL_RESOURCE_DETECTORS,
+    OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE,
     OTEL_EXPORTER_OTLP_PROTOCOL,
 )
 
@@ -44,6 +45,7 @@ class TestDistribution(TestCase):
             "process_runtime,os,otel,telemetry_distro", os.environ.get(OTEL_EXPERIMENTAL_RESOURCE_DETECTORS)
         )
         self.assertEqual("always_off", os.environ.get(OTEL_METRICS_EXEMPLAR_FILTER))
+        self.assertEqual("DELTA", os.environ.get(OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE))
 
     @mock.patch.dict("os.environ", {}, clear=True)
     def test_load_instrumentor_call_with_default_kwargs_for_SystemMetricsInstrumentor(self):