`JSON` attributes do not show up as valid json in event attributes
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
Start with the handler's emit method and the HTTPLogItem construction shown in the report, then trace how log_ctx is serialized through LogsApi.submit_log. Reproduce the logger.debug example with x_request_body and verify that the submitted event attributes preserve valid JSON object values rather than displaying them as strings.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- Python
- Stars
- 166
- Forks
- 55
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 73
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from DataDog/datadog-api-client-python
-
stale
Difficulty 1/5 1-3 hours Newbie friendliness 72/100
DataDog/datadog-api-client-python#3535 · 1 comment ·
-
kind/bug stale
Difficulty 3/5 1-2 days Newbie friendliness 66/100
DataDog/datadog-api-client-python#3717 · 3 comments ·
-
kind/bug stale
Difficulty 3/5 1-2 days Newbie friendliness 75/100
DataDog/datadog-api-client-python#3656 · 1 comment ·
-
kind/bug stale
Difficulty 3/5 1-2 days Newbie friendliness 38/100
DataDog/datadog-api-client-python#3120 · 1 comment ·
-
stale
Difficulty 3/5 1-2 days Newbie friendliness 45/100
DataDog/datadog-api-client-python#2986 · 1 comment ·
All issues in DataDog/datadog-api-client-python
Similar issues
-
essnmx good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
[Feature] 奇物选择添加优先级 Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
syfoud/Simulated_Scepter#174 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Giskard-AI/giskard-oss#2840 · 1 comment ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Openarea: repo bug perceived difficulty: 2
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
yeti-platform/yeti#1380 ·