-
-
Notifications
You must be signed in to change notification settings - Fork 62
feat(eap): Allow arrays to be queried from EAP #7551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
926a015
d23fcab
c8ef22d
30cfed5
66cc844
09ff46a
36913e1
65b6813
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import json | ||
| import random | ||
| import uuid | ||
| from datetime import datetime | ||
|
|
@@ -58,6 +59,7 @@ | |
| "project_id", | ||
| "trace_id", | ||
| "sampling_factor", | ||
| "attributes_bool", | ||
| ] | ||
| APPLY_FINAL_ROLLOUT_PERCENTAGE_CONFIG_KEY = "EndpointGetTrace.apply_final_rollout_percentage" | ||
|
|
||
|
|
@@ -219,6 +221,14 @@ def _build_query( | |
| tuple(column(f"attributes_float_{i}") for i in range(40)), | ||
| ), | ||
| ), | ||
| SelectedExpression( | ||
| name=("attributes_array"), | ||
| expression=FunctionCall( | ||
| "attributes_array", | ||
| "toJSONString", | ||
| (column("attributes_array"),), | ||
| ), | ||
| ), | ||
| ] | ||
| selected_columns.extend( | ||
| map( | ||
|
|
@@ -418,6 +428,21 @@ def _value_to_attribute(key: str, value: Any) -> tuple[AttributeKey, AttributeVa | |
| ) | ||
|
|
||
|
|
||
| def _transform_array_value(value: dict[str, str]) -> Any: | ||
| for t, v in value.items(): | ||
| if t == "Int": | ||
| return int(v) | ||
| return v | ||
|
|
||
|
|
||
| def _process_arrays(raw: str) -> dict[str, list[Any]]: | ||
| parsed = json.loads(raw) | ||
| arrays = {} | ||
| for key, values in parsed.items(): | ||
| arrays[key] = [_transform_array_value(v) for v in values] | ||
| return arrays | ||
|
|
||
|
|
||
| def _process_results( | ||
| data: Iterable[Dict[str, Any]], | ||
| ) -> ProcessedResults: | ||
|
|
@@ -433,6 +458,7 @@ def _process_results( | |
| for row in data: | ||
| id = row.pop("id") | ||
| ts = row.pop("timestamp") | ||
| arrays = row.pop("attributes_array") | ||
| last_seen_timestamp_precise = float(ts) | ||
| last_seen_id = id | ||
|
|
||
|
|
@@ -459,6 +485,10 @@ def add_attribute(key: str, value: Any) -> None: | |
| else: | ||
| add_attribute(key, value) | ||
|
|
||
| attributes_array = _process_arrays(arrays) | ||
| for key, value in attributes_array.items(): | ||
| add_attribute(k, v) | ||
|
|
||
| item = GetTraceResponse.Item( | ||
|
Comment on lines
536
to
546
This comment was marked as outdated.
Sorry, something went wrong.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a real bug, was this come across in tests?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it was due to a late refactor before I commit (rename |
||
| id=id, | ||
| timestamp=timestamp, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug:
FunctionCallis instantiated with 3 positional arguments instead of the expected 2, leading to aTypeErrorat runtime.Severity: CRITICAL | Confidence: High
🔍 Detailed Analysis
The
FunctionCalldataclass is defined with two fields:function_nameandparameters. However, the code attempts to instantiateFunctionCallwith three positional arguments:"attributes_array","toJSONString", and(column("attributes_array"),). This mismatch in the number of arguments will lead to aTypeErrorat runtime when thetoJSONStringfunction call is constructed, causing an unexpected server crash for any request querying theattributes_arraycolumn.💡 Suggested Fix
Remove the extraneous first argument
"attributes_array"from theFunctionCallconstructor. The correct call should beFunctionCall("toJSONString", (column("attributes_array"),),).🤖 Prompt for AI Agent
Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID:
3924818