`JSON` attributes do not show up as valid json in event attributes
まだ誰も着手していません。
評価
調査の方向性
まず、ハンドラーの emit メソッドとレポートに示されている HTTPLogItem の構築から始め、次に log_ctx が LogsApi.submit_log を通じてどのようにシリアライズされるかを追跡します。x_request_body を使った logger.debug の例を再現し、送信されたイベントの属性が文字列として表示されるのではなく、有効な JSON オブジェクト値を保持していることを確認します。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Python
- スター
- 166
- フォーク
- 55
- 平均マージ
- 2日 17時間
- マージ済み PR(30日)
- 73
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
DataDog/datadog-api-client-python のほかの issue
-
stale
難易度 1/5 1〜3時間 初心者へのやさしさ 72/100
DataDog/datadog-api-client-python#3535 · コメント 1 件 ·
-
kind/bug stale
難易度 3/5 1〜2日 初心者へのやさしさ 66/100
DataDog/datadog-api-client-python#3717 · コメント 3 件 ·
-
kind/bug stale
難易度 3/5 1〜2日 初心者へのやさしさ 75/100
DataDog/datadog-api-client-python#3656 · コメント 1 件 ·
-
kind/bug stale
難易度 3/5 1〜2日 初心者へのやさしさ 38/100
DataDog/datadog-api-client-python#3120 · コメント 1 件 ·
-
stale
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
DataDog/datadog-api-client-python#2986 · コメント 1 件 ·
DataDog/datadog-api-client-python の issue をすべて見る
似ている issue
-
essnmx good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
-
[Feature] 奇物选择添加优先级 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
syfoud/Simulated_Scepter#174 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Giskard-AI/giskard-oss#2840 · コメント 1 件 ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success オープンarea: repo bug perceived difficulty: 2
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
yeti-platform/yeti#1380 ·