Skip to content

Commit 6a9ec7d

Browse files
authored
Support the has_all and has_any operators, then Remove flamegraph widget and increase recent traces height (#209)
* Support the has_all and has_any operators * Remove flamegraph widget and increase recent traces height in overview dashboard
1 parent 8269d1a commit 6a9ec7d

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

src/Pkg/Parser/Expr.hs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,20 @@ pAgoFunction = do
329329
--
330330
-- >>> parse pValues "" "ago(7d)"
331331
-- Right (AgoExpression "7d")
332+
--
333+
-- Test single-quoted strings:
334+
-- >>> parse pValues "" "'hello'"
335+
-- Right (Str "hello")
336+
--
337+
-- >>> parse pValues "" "['SELECT','INSERT']"
338+
-- Right (List [Str "SELECT",Str "INSERT"])
332339
pValues :: Parser Values
333340
pValues =
334341
choice @[]
335342
[ Null <$ string "null"
336343
, Boolean <$> (True <$ string "true" <|> False <$ string "false" <|> False <$ string "FALSE" <|> True <$ string "TRUE")
337344
, Str . toText <$> (char '\"' *> manyTill L.charLiteral (char '\"'))
345+
, Str . toText <$> (char '\'' *> manyTill L.charLiteral (char '\''))
338346
, List [] <$ string "[]"
339347
, List <$> sqParens (pValues `sepBy` (space *> char ',' <* space))
340348
, List [] <$ string "()"
@@ -375,6 +383,13 @@ pValues =
375383
-- >>> parse pTerm "" "description has_all [\"user\", \"login\"]"
376384
-- Right (HasAll (Subject "description" "description" []) (List [Str "user",Str "login"]))
377385
--
386+
-- Test has_any and has_all with single-quoted strings:
387+
-- >>> parse pTerm "" "attributes.db.operation.name has_any ['SELECT','INSERT']"
388+
-- Right (HasAny (Subject "attributes.db.operation.name" "attributes" [FieldKey "db",FieldKey "operation",FieldKey "name"]) (List [Str "SELECT",Str "INSERT"]))
389+
--
390+
-- >>> parse pTerm "" "tags has_all ['urgent','critical']"
391+
-- Right (HasAll (Subject "tags" "tags" []) (List [Str "urgent",Str "critical"]))
392+
--
378393
-- >>> parse pTerm "" "url contains \"api\""
379394
-- Right (Contains (Subject "url" "url" []) (Str "api"))
380395
--

static/public/dashboards/_overview.yaml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -828,24 +828,10 @@ tabs:
828828
unit: ns
829829
layout: { w: 6, h: 4 }
830830

831-
# Trace Waterfall/Flamegraph
832-
- type: flamegraph
833-
title: 'Trace Visualization'
834-
layout: { w: 12, h: 8 }
835-
sql: |
836-
SELECT *
837-
FROM otel_logs_and_spans
838-
WHERE project_id='{{project_id}}'
839-
AND parent_id = ''
840-
AND ('{{var-service}}' = '' OR resource___service___name = '{{var-service}}')
841-
{{time_filter}}
842-
ORDER BY timestamp DESC
843-
LIMIT 1
844-
845831
# Trace List
846832
- type: traces
847833
title: 'Recent Traces'
848-
layout: { w: 12, h: 6 }
834+
layout: { w: 12, h: 9 }
849835
columns:
850836
- field: resource_name
851837
title: Resource

web-components/src/query-editor/query-editor.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ const REGEX_PATTERNS = {
128128

129129
// Operator patterns
130130
operatorMatch:
131-
/([\w\.]+)\s*(==|!=|>=|<=|>|<|=~|in|!in|has|!has|has_any|has_all|contains|!contains|startswith|!startswith|endswith|!endswith|matches)\s*$/,
131+
/([\w\.]+)\s*(==|!=|>=|<=|>|<|=~|!in|in|has_any|has_all|!has|has|!contains|contains|!startswith|startswith|!endswith|endswith|matches)\s*$/,
132132

133133
// Value patterns
134134
afterQuotedValue: /".*"\s*$/,
@@ -411,6 +411,14 @@ monaco.languages.registerCompletionItemProvider('aql', {
411411
insertText: '("value1", "value2") ',
412412
range: createRange(),
413413
});
414+
} else if (operator === 'has_any' || operator === 'has_all') {
415+
// Special handling for 'has_any' and 'has_all' operators - suggest array syntax
416+
suggestions.push({
417+
label: '["value1", "value2"]',
418+
kind: monaco.languages.CompletionItemKind.Snippet,
419+
insertText: '["value1", "value2"] ',
420+
range: createRange(),
421+
});
414422
} else {
415423
values.forEach((v) =>
416424
suggestions.push({

0 commit comments

Comments
 (0)