You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Flush meter provider at end of lambda function handler (#1613)
* Flush meter provider at end of lambda function handler
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
* Update `force_flush()` check based on PR feedback
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
---------
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
-`opentelemetry/sdk/extension/aws` Implement [`aws.ecs.*`](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/cloud_provider/aws/ecs.md) and [`aws.logs.*`](https://opentelemetry.io/docs/reference/specification/resource/semantic_conventions/cloud_provider/aws/logs/) resource attributes in the `AwsEcsResourceDetector` detector when the ECS Metadata v4 is available
Copy file name to clipboardexpand all lines: instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py
# NOTE: `force_flush` before function quit in case of Lambda freeze.
358
-
# Assumes we are using the OpenTelemetry SDK implementation of the
359
-
# `TracerProvider`.
360
-
_tracer_provider.force_flush(flush_timeout)
361
-
exceptException: # pylint: disable=broad-except
362
-
logger.error(
363
-
"TracerProvider was missing `force_flush` method. This is necessary in case of a Lambda freeze and would exist in the OTel SDK implementation."
364
+
ifhasattr(_tracer_provider, "force_flush"):
365
+
try:
366
+
# NOTE: `force_flush` before function quit in case of Lambda freeze.
367
+
_tracer_provider.force_flush(flush_timeout)
368
+
exceptException: # pylint: disable=broad-except
369
+
logger.exception(
370
+
f"TracerProvider failed to flush traces"
371
+
)
372
+
else:
373
+
logger.warning("TracerProvider was missing `force_flush` method. This is necessary in case of a Lambda freeze and would exist in the OTel SDK implementation.")
0 commit comments