Merge ticket/018-boolean-param-kind and ticket/019-docs-isError-use-case

This commit is contained in:
Hugh Kaznowski
2026-09-05 19:39:32 +01:00
7 changed files with 86 additions and 8 deletions
+8
View File
@@ -178,6 +178,14 @@ const SECTIONS: DocSection[] = [
a metric (see <em>Filtering</em> above — bare params aren't queryable by name on their own, only metric
labels/values are).
</p>
<p>
Given the same kind of lines, declaring a param named <Code>IsError</Code> with regex{' '}
<Code>{String.raw`(?i)error`}</Code> and type <Code>boolean</Code> — no capture group needed — shows{' '}
<Code>IsError</Code> as <Code>true</Code> or <Code>false</Code> on every line in the log table, based on
whether the regex matches that line's text case-insensitively. Unlike <Code>string</Code>/<Code>number</Code>
/<Code>timestamp</Code>/<Code>duration</Code> params, a <Code>boolean</Code> param is never omitted for a
non-matching line.
</p>
</div>
),
},
+12 -5
View File
@@ -21,12 +21,15 @@ export function Params({ params, onDeclared }: { params: ParamDeclaration[]; onD
const [submitting, setSubmitting] = useState(false)
const [collapsed, setCollapsed] = useSectionCollapsed('params')
const isBoolean = kind === 'boolean'
async function handleSubmit(e: React.FormEvent) {
e.preventDefault()
setSubmitError(null)
setSubmitting(true)
try {
await declareParam({ name, message_match_regex: regex, capture_group: captureGroup, kind })
// A boolean-kind param never uses a capture group — its value is just whether the regex matched.
await declareParam({ name, message_match_regex: regex, capture_group: isBoolean ? '' : captureGroup, kind })
setName('')
setRegex('')
setCaptureGroup('')
@@ -82,13 +85,16 @@ export function Params({ params, onDeclared }: { params: ParamDeclaration[]; onD
</div>
<div className="flex items-end gap-1">
<div className="min-w-0 flex-1">
<label className="mb-1 block text-xs text-text-subtle">Capture group</label>
<label className="mb-1 block text-xs text-text-subtle">
Capture group{isBoolean && ' (unused for boolean)'}
</label>
<input
className="w-full min-w-0 rounded border border-border-soft bg-surface-1 px-1.5 py-1 text-xs text-text placeholder:text-text-subtle focus:border-border-strong focus:outline-none"
className="w-full min-w-0 rounded border border-border-soft bg-surface-1 px-1.5 py-1 text-xs text-text placeholder:text-text-subtle focus:border-border-strong focus:outline-none disabled:opacity-50"
value={captureGroup}
onChange={(e) => setCaptureGroup(e.target.value)}
placeholder="path"
required
required={!isBoolean}
disabled={isBoolean}
/>
</div>
<select
@@ -100,6 +106,7 @@ export function Params({ params, onDeclared }: { params: ParamDeclaration[]; onD
<option value="number">number</option>
<option value="timestamp">timestamp</option>
<option value="duration">duration</option>
<option value="boolean">boolean</option>
</select>
</div>
{submitError && <div className="rounded border border-danger-border bg-danger-bg/50 px-2 py-1 text-xs text-danger-text">{submitError}</div>}
@@ -122,7 +129,7 @@ export function Params({ params, onDeclared }: { params: ParamDeclaration[]; onD
className="rounded border border-border-soft px-2 py-1 text-xs text-text-secondary"
title={p.message_match_regex}
>
{p.name} ({p.kind}, group {p.capture_group})
{p.name} ({p.kind}{p.kind === 'boolean' ? '' : `, group ${p.capture_group}`})
</span>
))}
</div>