# Transaction result setting as failure/spindown

**URL:** <https://discuss.elastic.co/t/transaction-result-setting-as-failure-spindown/342950>\
**Category:** APM\
**Tags:** python, server, aws-lambda\
**Created:** [September 13, 2023, 12:28pm UTC](https://discuss.elastic.co/t/transaction-result-setting-as-failure-spindown/342950 "2023-09-13T12:28:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabriel-f-santos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel-f-santos/32/120655_2.png) [@gabriel-f-santos](https://discuss.elastic.co/u/gabriel-f-santos)\
**Post date:** [September 13, 2023, 12:28pm UTC](https://discuss.elastic.co/t/transaction-result-setting-as-failure-spindown/342950/1 "2023-09-13T12:28:12Z")

</div>

Hello everyone!

We are using agent and APM extensions for monitoring our serverless application with Python Lambdas. We're following this configuration for SAM applications:

**APM Agent language and version** :

Language: python running in aws lambda.

- arn:aws:lambda:us-east-1:267093732750:layer:elastic-apm-extension-ver-1-4-0-x86\_64:1
- arn:aws:lambda:us-east-1:267093732750:layer:elastic-apm-python-ver-6-18-0:1

Our environment is configured as follows:

| **se\*\*\*\*\*\*\*\*rvice.environment** | \*\*\* |
| --- | --- |
| **service.framework.name** | AWS Lambda |
| **service.language.name** | python |
| **service.language.version** | 3.9.17 |
| **service.runtime.name** | AWS\_Lambda\_python3.9 |
| **service.runtime.version** | 3.9.17 |
| **service.version** | $LATEST |

Environment Variables:

ELASTIC\_APM\_SERVICE\_NAME: SERVICE\_NAME  
ELASTIC\_APM\_SEND\_STRATEGY: background  
AWS\_LAMBDA\_EXEC\_WRAPPER: /opt/python/bin/elasticapm-lambda  
ELASTIC\_APM\_SECRET\_TOKEN: ELASTIC\_TOKEN  
ELASTIC\_APM\_LAMBDA\_APM\_SERVER: ELASTIC\_URL  
ELASTIC\_APM\_ENVIRONMENT: ENVIRONMENT

**Fresh install or upgraded from other version?**

**We observed this error after change from configuration elastic-apm python lib + lambda extension to lambda extension for both (elastic apm python and extension).**

**Is there anything special in your setup?**

**Description of the problem including expected versus actual behavior.**

However, we are facing a situation:

**The Lambda works normally and does what it's supposed to do. However, the transaction is being marked as failed.**

The configuration we'll describe in the message below consists of an SQS queue consumed by a Lambda function. We tried to reproduce this error by. As AWS spins up Lambdas to consume the data, we noticed this occurs when the transaction status is set to "spindown". According to the AWS extension documentation, the "spindown" event is emitted to the extensions when the Lambda is about to terminate its runtime ([Usar a API de extensões do Lambda para criar extensões - AWS Lambda](https://docs.aws.amazon.com/pt_br/lambda/latest/dg/runtimes-extensions-api.html)).

I would like some assistance in understanding if setting this value as the transaction result is the expected outcome, or if there is an issue.

How we can see in bellow image, lambda works fine but some transactions is marked as failed and transaction.result as spindown.

 ![elk](https://us1.discourse-cdn.com/elastic/original/3X/5/3/53fa9593128d00caabb28ccf34d73c0b6f48ab1e.png)

**Steps to reproduce** :

1. Just add some messages to the queue (we used 200 messages)

**Metada**  **ta** :

###### transaction

| **[transaction.duration.us](http://transaction.duration.us)** | 39998000 |
| --- | --- |
| **transaction.id** | \*\*\*\*\*\*\*\*\*\*\*\* |
| **transaction.message.age.ms** | 91 |
| **transaction.message.queue.name** | \*\*\*\*\*\*\*\*\*\*\*\* |
| **transaction.name** | \*\*\*\*\*\*\*\*\*\*\*\* |
| **transaction.name.text** | \*\*\*\*\*\*\*\*\*\*\*\* |
| **transaction.representative\_count** | 1 |
| **transaction.result** | spindown |
| **transaction.sampled** | true |
| **transaction.span\_count.dropped** | 0 |
| **transaction.span\_count.started** | 0 |
| **transaction.type** | messaging |

###### event

| **event.agent\_id\_status** | missing |
| --- | --- |
| **event.ingested** | 2023-09-12T17:45:32Z |
| **event.outcome** | failure |
| **event.success\_count** | 0 |

**Usefull logs from cloudwatch** :

`Environment variable:`

`` `ELASTIC_APM_LOG_LEVEL: trace`

> <https://gist.github.com/gabriel-f-santos/80b0aa87cde267626b5af9aa34d33f1a>

Thanks for any help.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 11, 2023, 12:28pm UTC](https://discuss.elastic.co/t/transaction-result-setting-as-failure-spindown/342950/2 "2023-10-11T12:28:35Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
