Skip to content

Commit d5f98a3

Browse files
authored
Merge branch 'aws-observability:main' into update-bedrock
2 parents d9aed8a + 75af98a commit d5f98a3

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

aws-opentelemetry-distro/src/amazon/opentelemetry/distro/aws_span_metrics_processor.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0
3-
from typing import Dict, Optional
3+
from typing import Callable, Dict, Optional
44

55
from typing_extensions import override
66

@@ -45,19 +45,29 @@ class AwsSpanMetricsProcessor(SpanProcessor):
4545
_generator: MetricAttributeGenerator
4646
_resource: Resource
4747

48+
_force_flush_function: Callable
49+
50+
# no op function to act as a default function in case forceFlushFunction was
51+
# not supplied to the the constructor.
52+
# pylint: disable=no-self-use
53+
def _no_op_function(self, timeout_millis: float = None) -> bool:
54+
return True
55+
4856
def __init__(
4957
self,
5058
error_histogram: Histogram,
5159
fault_histogram: Histogram,
5260
latency_histogram: Histogram,
5361
generator: MetricAttributeGenerator,
5462
resource: Resource,
63+
force_flush_function: Callable = _no_op_function,
5564
):
5665
self._error_histogram = error_histogram
5766
self._fault_histogram = fault_histogram
5867
self._latency_histogram = latency_histogram
5968
self._generator = generator
6069
self._resource = resource
70+
self._force_flush_function = force_flush_function
6171

6272
# pylint: disable=no-self-use
6373
@override
@@ -78,8 +88,8 @@ def shutdown(self) -> None:
7888

7989
# pylint: disable=no-self-use
8090
@override
81-
def force_flush(self, timeout_millis: int = None) -> bool:
82-
return True
91+
def force_flush(self, timeout_millis: float = 10_000) -> bool:
92+
return self._force_flush_function(timeout_millis)
8393

8494
def _record_metrics(self, span: ReadableSpan, attributes: BoundedAttributes) -> None:
8595
# Only record metrics if non-empty attributes are returned.

aws-opentelemetry-distro/src/amazon/opentelemetry/distro/aws_span_metrics_processor_builder.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,10 @@ def build(self) -> AwsSpanMetricsProcessor:
6363
latency_histogram.name = _LATENCY
6464

6565
return AwsSpanMetricsProcessor(
66-
error_histogram, fault_histogram, latency_histogram, self._generator, self._resource
66+
error_histogram,
67+
fault_histogram,
68+
latency_histogram,
69+
self._generator,
70+
self._resource,
71+
self._meter_provider.force_flush,
6772
)

0 commit comments

Comments
 (0)