Skip to content

Commit 48adbde

Browse files
Add Agent capability to parse the SketchPayload and return the parsed version from the /api/beta/sketches backend proxy
1 parent 260b4a3 commit 48adbde

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

utils/interfaces/_agent.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,20 @@ def get_metrics(self):
155155
for point in content:
156156
yield data, point
157157

158+
def get_sketches(self):
159+
"""Attempts to fetch the sketches the agent will submit to the backend."""
160+
161+
all_data = self.get_data(path_filters="/api/beta/sketches")
162+
163+
for data in all_data:
164+
if "sketches" not in data["request"]["content"]:
165+
raise ValueError("sketches property is missing in agent payload")
166+
167+
content = data["request"]["content"]["sketches"]
168+
169+
for point in content:
170+
yield data, point
171+
158172
def get_dsm_data(self):
159173
return self.get_data(path_filters="/api/v0.1/pipeline_stats")
160174

utils/proxy/_decoders/protobuf_schemas.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616

1717
TracePayload = _messages["datadog.trace.AgentPayload"]
1818
MetricPayload = _messages["datadog.agentpayload.MetricPayload"]
19+
SketchPayload = _messages["datadog.agentpayload.SketchPayload"]

utils/proxy/_deserializer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
ExportLogsServiceRequest,
2727
ExportLogsServiceResponse,
2828
)
29-
from _decoders.protobuf_schemas import MetricPayload, TracePayload
29+
from _decoders.protobuf_schemas import MetricPayload, TracePayload, SketchPayload
3030

3131

3232
logger = logging.getLogger(__name__)
@@ -177,6 +177,8 @@ def json_load():
177177
return result
178178
if path == "/api/v2/series":
179179
return MessageToDict(MetricPayload.FromString(content))
180+
if path == "/api/beta/sketches":
181+
return MessageToDict(SketchPayload.FromString(content))
180182

181183
if content_type == "application/x-www-form-urlencoded" and content == b"[]" and path == "/v0.4/traces":
182184
return []

0 commit comments

Comments
 (0)