Skip to content

Commit

Permalink
release notes + format
Browse files Browse the repository at this point in the history
Signed-off-by: Eliott Bouhana <eliott.bouhana@datadoghq.com>
  • Loading branch information
eliottness committed Aug 13, 2024
1 parent 382a42b commit 53ef913
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 26 deletions.
14 changes: 10 additions & 4 deletions ddapm_test_agent/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,19 @@ def verify_span(d: Any) -> Span:
assert isinstance(d["meta_struct"], dict)
for k, v in d["meta_struct"].items():
assert isinstance(k, str), f"Expected key 'meta_struct.{k}' to be of type: 'str', got: {type(k)}"
assert isinstance(v, bytes), f"Expected msgpack'd value of key 'meta_struct.{k}' to be of type: 'bytes', got: {type(v)}"
assert isinstance(
v, bytes
), f"Expected msgpack'd value of key 'meta_struct.{k}' to be of type: 'bytes', got: {type(v)}"
# Decode meta_struct msgpack values
decoded_meta_struct = { key: msgpack.unpackb(val_bytes) for key, val_bytes in d["meta_struct"].items() }
decoded_meta_struct = {key: msgpack.unpackb(val_bytes) for key, val_bytes in d["meta_struct"].items()}
for k, val in decoded_meta_struct.items():
assert isinstance(val, dict), f"Expected msgpack decoded value of key 'meta_struct.{k}' to be of type: 'dict', got: {type(val)}"
assert isinstance(
val, dict
), f"Expected msgpack decoded value of key 'meta_struct.{k}' to be of type: 'dict', got: {type(val)}"
for inner_k in val:
assert isinstance(inner_k, str), f"Expected key 'meta_struct.{k}.{inner_k}' to be of type: 'str', got: {type(inner_k)}"
assert isinstance(
inner_k, str
), f"Expected key 'meta_struct.{k}.{inner_k}' to be of type: 'str', got: {type(inner_k)}"
d["meta_struct"] = decoded_meta_struct
if "metrics" in d:
assert isinstance(d["metrics"], dict)
Expand Down
6 changes: 6 additions & 0 deletions releasenotes/notes/meta-struct-2cce08475cb05470.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
features:
- |
Add support for parsing the `meta_struct` field in traces. This field just like the `meta` field map but the values
are arbitrary inner msgpack-encoded values. When the `meta_struct` field is present, its inner messages will be
parsed and added to the trace as a dictionary.
44 changes: 22 additions & 22 deletions tests/test_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,34 +91,34 @@ def test_decode_v04(content_type, payload):
),
),
(
"application/msgpack",
msgpack.packb(
"application/msgpack",
msgpack.packb(
[
[
[
{
"name": "span",
"span_id": 1234,
"trace_id": 321,
"meta_struct": ["this is not a dict"],
}
]
{
"name": "span",
"span_id": 1234,
"trace_id": 321,
"meta_struct": ["this is not a dict"],
}
]
),
]
),
),
(
"application/msgpack",
msgpack.packb(
"application/msgpack",
msgpack.packb(
[
[
[
{
"name": "span",
"span_id": 1234,
"trace_id": 321,
"meta_struct": {"key": msgpack.packb(["this is not a dict"])},
}
]
{
"name": "span",
"span_id": 1234,
"trace_id": 321,
"meta_struct": {"key": msgpack.packb(["this is not a dict"])},
}
]
),
]
),
),
],
)
Expand Down

0 comments on commit 53ef913

Please sign in to comment.