Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Warning 'No subsegment to end' written to logs when X-Ray SDK is disabled.

Aperta
#331 4 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@srprash ci sta già lavorando.

Dal 18/4/2022.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

When running locally, I don't want X-Ray to be enabled. Out of the box, the sam local start-lambda logs warnings about the X-Ray SDK, but I'm trying to disable the SDK entirely.

I'm disabling the SDK by checking the environment variable AWS_SAM_LOCAL. If it's present and it's value is 'true', then the global SDK config is disabled. Then when I patch the desired libraries, nothing happens and there are no [INFO] logs. That's good.

from aws_xray_sdk import global_sdk_config as global_xray_sdk_config
from aws_xray_sdk.core import patch, xray_recorder

if environ.get('AWS_SAM_LOCAL', 'false') == 'true':
    global_xray_sdk_config.set_sdk_enabled(False)

patch(['boto3', 'requests'])

However, I have a function that adds a subsegment, and this is emitting logs even with the X-Ray SDK disabled.

def add_xray_subsegment(name: str, annotations: dict, e: Exception = None) -> None:
    with xray_recorder.capture(name) as subsegment:
        a = {k: v for k, v in annotations.items() if v is not None}
        for k, v in a.items():
            subsegment.put_annotation(k, v)
        if e:
            limit = xray_recorder._max_trace_back
            stack = traceback.extract_stack(limit=limit)
            subsegment.add_exception(e, stack)

[WARNING] {date} {request-id} No subsegment to end.

While the function still works locally, it's causing delay because people don't expect to see these warnings in the logs and are wasting their time investigating.

I'm guessing this isn't expected behaviour with the SDK disabled; so is this a bug, or is there some other configuration that I can add to remove the warnings?

Thanks.

Lingua principale
Python
Stelle
339
Fork
147
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di aws/aws-xray-sdk-python

Tutte le issue di aws/aws-xray-sdk-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.