ERROR:aws_xray_sdk.core.context:cannot find the current segment/subsegment, please make sure you have a segment open
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- aws, python
- Ambito
- cloud, observability-sre
Direzione di ricerca
Inizia con la riproduzione generate_and_upload fornita, in particolare xray_recorder.configure e il contesto in_segment attorno a s3_client.upload_file. Eseguila con Python 3.11.1 e aws-xray-sdk 2.14.0, quindi analizza il comportamento del segmento durante l’upload e la pulizia. Il lavoro è completato quando l’upload continua ad avere esito positivo, l’errore di contesto è scomparso e il segmento è visibile nella console AWS X-Ray.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
``Hi,
I am experiencing an issue with the AWS X-Ray SDK for Python where segments are not being properly created or propagated, resulting in the following exception:
ERROR:aws_xray_sdk.core.context:cannot find the current segment/subsegment, please make sure you have a segment open
The file is being successfully being uploaded in my s3 bucket but the segment is not being traced.
Steps to Reproduce:
import json
import os
import boto3
from aws_xray_sdk.core import xray_recorder
from aws_xray_sdk.core import patch_all
import logging
from botocore.exceptions import NoCredentialsError, PartialCredentialsError
from aws_xray_sdk import global_sdk_config
from boto3.s3.transfer import TransferConfig
patch_all()
logging.basicConfig(level='ERROR')
logging.getLogger('aws_xray_sdk.core').setLevel(logging.ERROR)
.
.
.
.
def generate_and_upload(init, count):
session = boto3.Session(profile_name=aws_profile_name)
s3_client = session.client("s3")
# Create file path
file_path = os.path.join("generated", "data.json")
# Write data to the file
with open(file_path, "w") as file:
json.dump(
generate_json_document(init, count),
file,
separators=(",", ":"),
ensure_ascii=False,
)
xray_recorder.configure(service='data-generator')
with xray_recorder.in_segment('generate_and_upload') as segment:
trace_header = segment.trace_id
print(f"Trace Header: {trace_header}")
try:
trnasver_config = TransferConfig(max_concurrency=1)
s3_client.upload_file(
file_path,
f"{bucket}",
f"{path}",
ExtraArgs={"Metadata": {"X-Amzn-Trace-Id": trace_header}},
Config=trnasver_config,
)
print(
f"Uploaded"
)
finally:
xray_recorder.end_segment()
I tried to set os.environ['AWS_XRAY_SDK_ENABLED'] = 'false' and a dummy segment was created, but I am not able to see it in the AWS X-ray console.
I am using Python 3.11.1 and aws-xray-sdk is Version: 2.14.0
I have also tried to set off threading and also have 1 thread. The issue still exist,
@chanchiem
@luzfcb
@heitorlessa
- 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
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di aws/aws-xray-sdk-python
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
aws/aws-xray-sdk-python#490 · 1 commento ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 1/100
aws/aws-xray-sdk-python#460 ·
-
Next release Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
aws/aws-xray-sdk-python#457 · 1 reazione ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
aws/aws-xray-sdk-python#453 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
aws/aws-xray-sdk-python#451 · 2 commenti · 1 reazione ·
Tutte le issue di aws/aws-xray-sdk-python
Issue simili
-
agent-ready documentation needs-triage
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
-
documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 91/100
-
workflow-status page template still says reusable workflows are "triggered only by workflow_call:" Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
-
instance instance add
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
searxng/searx-instances#939 · 1 commento ·
-
area-deployment area-integrations triage:bot-seen
Difficoltà 2/5 Mezza giornata Idoneità per principianti 86/100