DSM Queue tab CloudWatch metrics empty: eventSourceARN used as queue identifier instead of short name

Aberta Para iniciantes
#755 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
76/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Pouca atividade
Stack de tecnologia
aws, python

Direção de pesquisa

Comece em datadog_lambda/tracing.py, em _dsm_set_checkpoint(), e depois compare o tratamento dos nomes das filas em ddtrace/internal/datastreams/botocore.py, especialmente get_queue_name() e os chamadores dos checkpoints de SQS. Considera-se concluído quando os checkpoints do Lambda DSM usam o formato de identificador de fila esperado pela integração do CloudWatch, para que as consultas da aba Queue correspondam às tags de métricas do SQS.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Description

The DSM (Data Streams Monitoring) Queue tab shows empty CloudWatch metric graphs for SQS queues consumed by Lambda functions. The root cause is a mismatch between how datadog-lambda-python identifies queues in DSM checkpoints vs how the AWS CloudWatch integration tags SQS metrics.

Root Cause

In datadog_lambda/tracing.py, _dsm_set_checkpoint() passes the full eventSourceARN to set_consume_checkpoint():

# tracing.py line ~262
source_arn = first_record.get("eventSourceARN", "")
# ...
_dsm_set_checkpoint(context_json, event_type, source_arn)  # full ARN

This results in a DSM checkpoint with:

topic:arn:aws:sqs:eu-west-2:123456789012:my-queue.fifo

The DSM Queue tab then uses this full ARN value to construct CloudWatch metric queries:

sum:aws.sqs.number_of_messages_received{queuename:arn:aws:sqs:eu-west-2:123456789012:my-queue.fifo}

But the AWS CloudWatch integration tags SQS metrics with just the short queue name (from the CloudWatch QueueName dimension):

queuename:my-queue.fifo

Result: the query returns no data, and all Queue tab graphs are empty.

Comparison with botocore SDK path

The botocore instrumentation in dd-trace-py correctly extracts the short name:

# ddtrace/internal/datastreams/botocore.py
def get_queue_name(params):
    queue_url = params["QueueUrl"]
    url = parse.urlparse(queue_url)
    return url.path.rsplit("/", 1)[-1]  # returns "my-queue.fifo"

Both handle_sqs_sns_produce() and handle_sqs_receive() use this short name as the DSM topic: tag. When SQS messages are consumed by a long-running process polling with sqs.receive_message(), the botocore instrumentation handles the DSM checkpoint and the Queue tab works correctly. The bug is specific to Lambda functions triggered by SQS event source mappings, where datadog-lambda-python handles the checkpoint instead.

Expected Behavior

_dsm_set_checkpoint() should extract the short queue name from the ARN before passing it to set_consume_checkpoint(), e.g.:

queue_name = source_arn.rsplit(":", 1)[-1]  # "my-queue.fifo"
set_consume_checkpoint(event_type, queue_name, carrier_get, manual_checkpoint=False)

This would align the Lambda consumption path with the botocore SDK path, and the DSM Queue tab CloudWatch queries would match the actual queuename tag values.

Workaround

Users can manually change the metric filter from queuename to dd_resource_key (which contains the full ARN) to see data. But this must be done for each graph individually and doesn't persist.

Environment

  • datadog-lambda v8.123.0
  • dd-trace-py v4.6.0
  • Lambda Extension v92-next
  • Python 3.14
  • SQS FIFO queue consumed via Lambda event source mapping
  • AWS region: eu-west-2
Linguagem predominante
Python
Estrelas
102
Forks
52
Merge médio
5d 19h
PRs com merge (30d)
2

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de DataDog/datadog-lambda-python

Todas as issues de DataDog/datadog-lambda-python

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.