Skip to content

Commit

Permalink
chore: break aggregation and temporality config in two functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Dudssource authored and ocelotl committed Feb 13, 2024
1 parent 14af46f commit 718ea2d
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ def _common_configuration(
preferred_aggregation: Dict[type, "opentelemetry.sdk.metrics.view.Aggregation"] = None,
) -> None:

MetricExporter.__init__(
self,
preferred_temporality=self.get_temporality(preferred_temporality),
preferred_aggregation=self.get_aggregation(preferred_aggregation),
)

def get_temporality(self, preferred_temporality: Dict[type, AggregationTemporality]) -> Dict[type, AggregationTemporality]:

instrument_class_temporality = {}

otel_exporter_otlp_metrics_temporality_preference = (
Expand Down Expand Up @@ -120,6 +128,10 @@ def _common_configuration(

instrument_class_temporality.update(preferred_temporality or {})

return instrument_class_temporality

def get_aggregation(self, preferred_aggregation: Dict[type, "opentelemetry.sdk.metrics.view.Aggregation"]) -> Dict[type, "opentelemetry.sdk.metrics.view.Aggregation"]:

instrument_class_aggregation = {}

otel_exporter_otlp_metrics_default_histogram_aggregation = environ.get(
Expand Down Expand Up @@ -156,11 +168,7 @@ def _common_configuration(

instrument_class_aggregation.update(preferred_aggregation or {})

MetricExporter.__init__(
self,
preferred_temporality=instrument_class_temporality,
preferred_aggregation=instrument_class_aggregation,
)
return instrument_class_aggregation


def encode_metrics(data: MetricsData) -> ExportMetricsServiceRequest:
Expand Down

0 comments on commit 718ea2d

Please sign in to comment.