`JSON` attributes do not show up as valid json in event attributes
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia con il metodo emit dell'handler e la costruzione di HTTPLogItem mostrata nel report, quindi segui come log_ctx viene serializzato tramite LogsApi.submit_log. Riproduci l'esempio di logger.debug con x_request_body e verifica che gli attributi dell'evento inviato mantengano valori di oggetto JSON validi invece di essere visualizzati come stringhe.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
A clear and concise description of what the bug is.
When a valid json is passed as value of a custom event atrribute, In logs it is show as a string and not a json object
To Reproduce
# in the handler
def emit(self, record):
env = os.getenv("APP_ENV", "local")
log_ctx: LogCtxDict = record.__dict__.get("log_ctx", {})
tags_dict = log_ctx.pop('tags', {})
tags = [f"{k}:{v}" for k, v in tags_dict.items()]
tags.append("env:{}".format(env))
tags_merged = ",".join(tags)
body = HTTPLog(
[
HTTPLogItem(
ddsource="python",
ddtags=tags_merged,
hostname="vv-anyscale-ray-aps1",
message=self.format(record),
service="vv-ap-thumbnails-v1-{}-service".format(env),
timestamp=str(datetime.fromtimestamp(record.created).astimezone().timestamp()),
level=record.levelname.lower(),
**record.__dict__.get("log_ctx", {})
)
]
)
try:
with ApiClient(self.dd_configuration) as api_client:
resp = LogsApi(api_client).submit_log(content_encoding=ContentEncoding.GZIP, body=body)
if "errors" in resp:
self.handleError(record)
except (Exception, ):
self.handleError(record)
logger.debug(
"Test debug log",
log_ctx={
"x_request_body": json.dumps({"clip_id": "66abc57369bbe0000782ef42"}),
}
)
Expected behavior
A clear and concise description of what you expected to happen.
The object should be consumed and shown as json,
Screenshots
If applicable, add screenshots to help explain your problem.
Environment and Versions (please complete the following information):
A clear and precise description of your setup:
$ poetry show datadog-api-client
name : datadog-api-client
version : 2.27.0
description : Collection of all Datadog Public endpoints
dependencies
- certifi *
- python-dateutil *
- typing-extensions >=4.0.0
- urllib3 >=1.15
for logs parsing default python pipleline is used
- Lingua principale
- Python
- Stelle
- 166
- Fork
- 55
- Merge medio
- 2g 17h
- PR unite (30g)
- 73
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 DataDog/datadog-api-client-python
-
stale
Difficoltà 1/5 1-3 ore Idoneità per principianti 72/100
DataDog/datadog-api-client-python#3535 · 1 commento ·
-
kind/bug stale
Difficoltà 3/5 1-2 giorni Idoneità per principianti 66/100
DataDog/datadog-api-client-python#3717 · 3 commenti ·
-
kind/bug stale
Difficoltà 3/5 1-2 giorni Idoneità per principianti 75/100
DataDog/datadog-api-client-python#3656 · 1 commento ·
-
kind/bug stale
Difficoltà 3/5 1-2 giorni Idoneità per principianti 38/100
DataDog/datadog-api-client-python#3120 · 1 commento ·
-
stale
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
DataDog/datadog-api-client-python#2986 · 1 commento ·
Tutte le issue di DataDog/datadog-api-client-python
Issue simili
-
bug confirmed issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
open-webui/open-webui#30750 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
good first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100