Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ import { GreptimeDBTraceQuerySpec } from './greptimedb-trace-query-types';

type GreptimeDBTraceQueryEditorProps = OptionsEditorProps<GreptimeDBTraceQuerySpec>;

const traceQueryExample = `SELECT trace_id, span_id, parent_span_id, service_name, span_name, span_kind, duration_nano, timestamp
FROM opentelemetry_traces
WHERE timestamp BETWEEN to_timestamp_millis($__from) AND to_timestamp_millis($__to)
ORDER BY timestamp DESC`;

export function GreptimeDBTraceQueryEditor(props: GreptimeDBTraceQueryEditorProps): ReactElement {
const { onChange, value } = props;
const { datasource } = value;
Expand Down Expand Up @@ -60,6 +65,17 @@ export function GreptimeDBTraceQueryEditor(props: GreptimeDBTraceQueryEditorProp
[handleQueryChange]
);

const examplesStyle = {
fontSize: '11px',
color: '#777',
backgroundColor: '#f5f5f5',
padding: '8px',
borderRadius: '4px',
fontFamily: 'Monaco, Menlo, "Ubuntu Mono", monospace',
whiteSpace: 'pre-wrap' as const,
lineHeight: '1.3',
};

return (
<Stack spacing={1.5}>
<DatasourceSelect
Expand All @@ -81,6 +97,19 @@ export function GreptimeDBTraceQueryEditor(props: GreptimeDBTraceQueryEditorProp
}}
placeholder="Enter SQL for trace search or trace details"
/>
<details>
<summary
style={{
cursor: 'pointer',
fontSize: '12px',
color: '#666',
marginBottom: '8px',
}}
>
Query Examples
</summary>
<div style={examplesStyle}>{traceQueryExample}</div>
</details>
</Stack>
);
}
Loading