Skip to content

Commit

Permalink
Use LOWMEMORY as default temporality (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl authored Apr 18, 2023
1 parent 5f94a03 commit 796e586
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
26 changes: 22 additions & 4 deletions src/opentelemetry/launcher/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"OTEL_EXPORTER_OTLP_TRACES_INSECURE", False
)
_OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE = _env.str(
"OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE", "CUMULATIVE"
"OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE", "LOWMEMORY"
)
_OTEL_METRIC_EXPORT_INTERVAL = _env.int("OTEL_METRIC_EXPORT_INTERVAL", 60000)

Expand Down Expand Up @@ -179,8 +179,8 @@ def configure_opentelemetry(
exported. Defaults to `ingest.lightstep.com:443`.
metrics_exporter_temporality_preference (str): OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE,
The preferred association between instrument type and temporality,
meaningless if `metrics_enabled` is `False`. Can be `DELTA` or
`CUMULATIVE`, defaults to `CUMULATIVE`.
meaningless if `metrics_enabled` is `False`. Can be `DELTA`,
`CUMULATIVE` or `LOWMEMORY`, defaults to `LOWMEMORY`.
If `CUMULATIVE`:
Expand All @@ -199,6 +199,15 @@ def configure_opentelemetry(
`ObservableCounter`: `DELTA`
`ObservableUpDownCounter`: `CUMULATIVE`
`ObservableGauge`: `CUMULATIVE`
If `LOWMEMORY`:
`Counter`: `DELTA`
`UpDownCounter`: `CUMULATIVE`
`Histogram`: `DELTA`
`ObservableCounter`: `CUMULATIVE`
`ObservableUpDownCounter`: `CUMULATIVE`
`ObservableGauge`: `CUMULATIVE`
metrics_exporter_interval (int): OTEL_METRIC_EXPORT_INTERVAL, the
periodic interval in miliseconds to wait before exporting metrics.
service_name (str): OTEL_SERVICE_NAME, the name of the service that is
Expand Down Expand Up @@ -454,12 +463,21 @@ def configure_opentelemetry(
ObservableGauge: AggregationTemporality.CUMULATIVE,
}

elif metrics_exporter_temporality_preference == "LOWMEMORY":
instrument_class_temporality = {
Counter: AggregationTemporality.DELTA,
UpDownCounter: AggregationTemporality.CUMULATIVE,
Histogram: AggregationTemporality.DELTA,
ObservableCounter: AggregationTemporality.CUMULATIVE,
ObservableUpDownCounter: AggregationTemporality.CUMULATIVE,
ObservableGauge: AggregationTemporality.CUMULATIVE,
}
else:
message = (
f"Invalid configuration: "
f"invalid metrics_exporter_temporality_preference: "
f"{metrics_exporter_temporality_preference}. It must be "
f"DELTA or CUMULATIVE."
f"DELTA, CUMULATIVE or LOWMEMORY."
)
_logger.error(message)
raise InvalidConfigurationError(message)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ def test_metrics_enabled(self, mock_metrics_exporter):
credentials=ANY,
headers=(("lightstep-access-token", "a" * 104),),
preferred_temporality={
Counter: AggregationTemporality.CUMULATIVE,
Counter: AggregationTemporality.DELTA,
UpDownCounter: AggregationTemporality.CUMULATIVE,
Histogram: AggregationTemporality.CUMULATIVE,
Histogram: AggregationTemporality.DELTA,
ObservableCounter: AggregationTemporality.CUMULATIVE,
ObservableUpDownCounter: AggregationTemporality.CUMULATIVE,
ObservableGauge: AggregationTemporality.CUMULATIVE,
Expand Down

0 comments on commit 796e586

Please sign in to comment.