Skip to content
Merged
Show file tree
Hide file tree
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
15 changes: 15 additions & 0 deletions .changeset/rename-promql-source-type-label.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
'@hyperdx/app': patch
'@hyperdx/api': patch
---

feat: Name PromQL sources "Time Series" or "Prometheus" by their connection

The source type for a PromQL source now reads "Time Series" when it queries a
ClickHouse TimeSeries table and "Prometheus" when it queries an external
Prometheus API. Where no connection is known yet, such as the source form before
a connection is picked or a data source variable's kinds, it reads "Time Series
/ Prometheus". The stored kind is still `promql`.

The PromQL source created by onboarding auto-detection and the local dev default
sources is now named "Time Series" instead of "PromQL".
2 changes: 1 addition & 1 deletion packages/api/.env.development
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ USAGE_STATS_ENABLED=false
NODE_OPTIONS="--max-http-header-size=131072"
ENABLE_SWAGGER=true
DEFAULT_CONNECTIONS=[{"name":"Local ClickHouse","host":"http://localhost:${HDX_DEV_CH_HTTP_PORT}","username":"default","password":""}]
DEFAULT_SOURCES=[{"from":{"databaseName":"default","tableName":"otel_logs"},"kind":"log","timestampValueExpression":"Timestamp","name":"Logs","displayedTimestampValueExpression":"Timestamp","implicitColumnExpression":"Body","serviceNameExpression":"ServiceName","bodyExpression":"Body","eventAttributesExpression":"LogAttributes","resourceAttributesExpression":"ResourceAttributes","defaultTableSelectExpression":"Timestamp,ServiceName,SeverityText,Body","severityTextExpression":"SeverityText","severityNumberExpression":"SeverityNumber","eventNameExpression":"EventName","traceIdExpression":"TraceId","spanIdExpression":"SpanId","metadataMaterializedViews":{"kvRollupTable":"otel_logs_kv_rollup_15m","granularity":"15 minute"},"connection":"Local ClickHouse","traceSourceId":"Traces","metricSourceId":"Metrics"},{"from":{"databaseName":"default","tableName":"otel_traces"},"kind":"trace","timestampValueExpression":"Timestamp","name":"Traces","displayedTimestampValueExpression":"Timestamp","implicitColumnExpression":"SpanName","serviceNameExpression":"ServiceName","eventAttributesExpression":"SpanAttributes","resourceAttributesExpression":"ResourceAttributes","defaultTableSelectExpression":"Timestamp,ServiceName,StatusCode,round(Duration/1e6),SpanName","traceIdExpression":"TraceId","spanIdExpression":"SpanId","durationExpression":"Duration","durationPrecision":9,"parentSpanIdExpression":"ParentSpanId","spanNameExpression":"SpanName","spanKindExpression":"SpanKind","statusCodeExpression":"StatusCode","statusMessageExpression":"StatusMessage","spanEventsValueExpression":"Events","spanLinksValueExpression":"Links","metadataMaterializedViews":{"kvRollupTable":"otel_traces_kv_rollup_15m","granularity":"15 minute"},"connection":"Local ClickHouse","logSourceId":"Logs","sessionSourceId":"Sessions","metricSourceId":"Metrics"},{"from":{"databaseName":"default","tableName":""},"kind":"metric","timestampValueExpression":"TimeUnix","name":"Metrics","resourceAttributesExpression":"ResourceAttributes","metricTables":{"gauge":"otel_metrics_gauge","histogram":"otel_metrics_histogram","sum":"otel_metrics_sum","summary":"otel_metrics_summary","exponential histogram":"otel_metrics_exponential_histogram"},"connection":"Local ClickHouse","logSourceId":"Logs"},{"from":{"databaseName":"default","tableName":"hyperdx_sessions"},"kind":"session","timestampValueExpression":"TimestampTime","name":"Sessions","resourceAttributesExpression":"ResourceAttributes","connection":"Local ClickHouse","traceSourceId":"Traces"},{"from":{"databaseName":"otel_json","tableName":"otel_logs"},"kind":"log","timestampValueExpression":"Timestamp","name":"JSON Logs","displayedTimestampValueExpression":"Timestamp","implicitColumnExpression":"Body","serviceNameExpression":"ServiceName","bodyExpression":"Body","eventAttributesExpression":"LogAttributes","resourceAttributesExpression":"ResourceAttributes","defaultTableSelectExpression":"Timestamp,ServiceName,SeverityText,Body","severityTextExpression":"SeverityText","severityNumberExpression":"SeverityNumber","eventNameExpression":"EventName","traceIdExpression":"TraceId","spanIdExpression":"SpanId","connection":"Local ClickHouse","traceSourceId":"JSON Traces","metricSourceId":"JSON Metrics"},{"from":{"databaseName":"otel_json","tableName":"otel_traces"},"kind":"trace","timestampValueExpression":"Timestamp","name":"JSON Traces","displayedTimestampValueExpression":"Timestamp","implicitColumnExpression":"SpanName","serviceNameExpression":"ServiceName","eventAttributesExpression":"SpanAttributes","resourceAttributesExpression":"ResourceAttributes","defaultTableSelectExpression":"Timestamp,ServiceName,StatusCode,round(Duration/1e6),SpanName","traceIdExpression":"TraceId","spanIdExpression":"SpanId","durationExpression":"Duration","durationPrecision":9,"parentSpanIdExpression":"ParentSpanId","spanNameExpression":"SpanName","spanKindExpression":"SpanKind","statusCodeExpression":"StatusCode","statusMessageExpression":"StatusMessage","spanEventsValueExpression":"Events","spanLinksValueExpression":"Links","connection":"Local ClickHouse","logSourceId":"JSON Logs","metricSourceId":"JSON Metrics"},{"from":{"databaseName":"otel_json","tableName":""},"kind":"metric","timestampValueExpression":"TimeUnix","name":"JSON Metrics","resourceAttributesExpression":"ResourceAttributes","metricTables":{"gauge":"otel_metrics_gauge","histogram":"otel_metrics_histogram","sum":"otel_metrics_sum","summary":"otel_metrics_summary","exponential histogram":"otel_metrics_exponential_histogram"},"connection":"Local ClickHouse","logSourceId":"JSON Logs"},{"kind":"promql","name":"PromQL","connection":"Local ClickHouse","from":{"databaseName":"default","tableName":"metrics_ts"},"timestampValueExpression":"timestamp"}]
DEFAULT_SOURCES=[{"from":{"databaseName":"default","tableName":"otel_logs"},"kind":"log","timestampValueExpression":"Timestamp","name":"Logs","displayedTimestampValueExpression":"Timestamp","implicitColumnExpression":"Body","serviceNameExpression":"ServiceName","bodyExpression":"Body","eventAttributesExpression":"LogAttributes","resourceAttributesExpression":"ResourceAttributes","defaultTableSelectExpression":"Timestamp,ServiceName,SeverityText,Body","severityTextExpression":"SeverityText","severityNumberExpression":"SeverityNumber","eventNameExpression":"EventName","traceIdExpression":"TraceId","spanIdExpression":"SpanId","metadataMaterializedViews":{"kvRollupTable":"otel_logs_kv_rollup_15m","granularity":"15 minute"},"connection":"Local ClickHouse","traceSourceId":"Traces","metricSourceId":"Metrics"},{"from":{"databaseName":"default","tableName":"otel_traces"},"kind":"trace","timestampValueExpression":"Timestamp","name":"Traces","displayedTimestampValueExpression":"Timestamp","implicitColumnExpression":"SpanName","serviceNameExpression":"ServiceName","eventAttributesExpression":"SpanAttributes","resourceAttributesExpression":"ResourceAttributes","defaultTableSelectExpression":"Timestamp,ServiceName,StatusCode,round(Duration/1e6),SpanName","traceIdExpression":"TraceId","spanIdExpression":"SpanId","durationExpression":"Duration","durationPrecision":9,"parentSpanIdExpression":"ParentSpanId","spanNameExpression":"SpanName","spanKindExpression":"SpanKind","statusCodeExpression":"StatusCode","statusMessageExpression":"StatusMessage","spanEventsValueExpression":"Events","spanLinksValueExpression":"Links","metadataMaterializedViews":{"kvRollupTable":"otel_traces_kv_rollup_15m","granularity":"15 minute"},"connection":"Local ClickHouse","logSourceId":"Logs","sessionSourceId":"Sessions","metricSourceId":"Metrics"},{"from":{"databaseName":"default","tableName":""},"kind":"metric","timestampValueExpression":"TimeUnix","name":"Metrics","resourceAttributesExpression":"ResourceAttributes","metricTables":{"gauge":"otel_metrics_gauge","histogram":"otel_metrics_histogram","sum":"otel_metrics_sum","summary":"otel_metrics_summary","exponential histogram":"otel_metrics_exponential_histogram"},"connection":"Local ClickHouse","logSourceId":"Logs"},{"from":{"databaseName":"default","tableName":"hyperdx_sessions"},"kind":"session","timestampValueExpression":"TimestampTime","name":"Sessions","resourceAttributesExpression":"ResourceAttributes","connection":"Local ClickHouse","traceSourceId":"Traces"},{"from":{"databaseName":"otel_json","tableName":"otel_logs"},"kind":"log","timestampValueExpression":"Timestamp","name":"JSON Logs","displayedTimestampValueExpression":"Timestamp","implicitColumnExpression":"Body","serviceNameExpression":"ServiceName","bodyExpression":"Body","eventAttributesExpression":"LogAttributes","resourceAttributesExpression":"ResourceAttributes","defaultTableSelectExpression":"Timestamp,ServiceName,SeverityText,Body","severityTextExpression":"SeverityText","severityNumberExpression":"SeverityNumber","eventNameExpression":"EventName","traceIdExpression":"TraceId","spanIdExpression":"SpanId","connection":"Local ClickHouse","traceSourceId":"JSON Traces","metricSourceId":"JSON Metrics"},{"from":{"databaseName":"otel_json","tableName":"otel_traces"},"kind":"trace","timestampValueExpression":"Timestamp","name":"JSON Traces","displayedTimestampValueExpression":"Timestamp","implicitColumnExpression":"SpanName","serviceNameExpression":"ServiceName","eventAttributesExpression":"SpanAttributes","resourceAttributesExpression":"ResourceAttributes","defaultTableSelectExpression":"Timestamp,ServiceName,StatusCode,round(Duration/1e6),SpanName","traceIdExpression":"TraceId","spanIdExpression":"SpanId","durationExpression":"Duration","durationPrecision":9,"parentSpanIdExpression":"ParentSpanId","spanNameExpression":"SpanName","spanKindExpression":"SpanKind","statusCodeExpression":"StatusCode","statusMessageExpression":"StatusMessage","spanEventsValueExpression":"Events","spanLinksValueExpression":"Links","connection":"Local ClickHouse","logSourceId":"JSON Logs","metricSourceId":"JSON Metrics"},{"from":{"databaseName":"otel_json","tableName":""},"kind":"metric","timestampValueExpression":"TimeUnix","name":"JSON Metrics","resourceAttributesExpression":"ResourceAttributes","metricTables":{"gauge":"otel_metrics_gauge","histogram":"otel_metrics_histogram","sum":"otel_metrics_sum","summary":"otel_metrics_summary","exponential histogram":"otel_metrics_exponential_histogram"},"connection":"Local ClickHouse","logSourceId":"JSON Logs"},{"kind":"promql","name":"Time Series","connection":"Local ClickHouse","from":{"databaseName":"default","tableName":"metrics_ts"},"timestampValueExpression":"timestamp"}]

INGESTION_API_KEY="super-secure-ingestion-api-key"
HYPERDX_API_KEY=$INGESTION_API_KEY
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/__tests__/setupDefaults.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jest.mock('@/config', () => ({
},
{
kind: 'promql',
name: 'PromQL',
name: 'Time Series',
connection: 'Local ClickHouse',
from: { databaseName: 'default', tableName: 'metrics_ts' },
timestampValueExpression: 'timestamp',
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/components/OnboardingModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ function OnboardingModalComponent({
const promqlSource = await createSourceMutation.mutateAsync({
source: {
kind: SourceKind.Promql,
name: 'PromQL',
name: 'Time Series',
connection: connectionId,
from: timeSeriesTable,
timestampValueExpression: PROMQL_TIMESTAMP_EXPRESSION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import {

import {
DEFAULT_DATABASE,
getSourceKindLabel,
PROMETHEUS_PLACEHOLDER,
SOURCE_KIND_LABELS,
} from './constants';
Expand Down Expand Up @@ -653,7 +654,10 @@ export function TableSourceForm({
{IS_PROMQL_ENABLED && (
<Radio
value={SourceKind.Promql}
label={SOURCE_KIND_LABELS[SourceKind.Promql]}
label={getSourceKindLabel(
SourceKind.Promql,
selectedConnection,
)}
/>
)}
</Group>
Expand Down
17 changes: 16 additions & 1 deletion packages/app/src/components/Sources/SourceForm/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,24 @@ export const SOURCE_KIND_LABELS: Record<SourceKind, string> = {
[SourceKind.Trace]: 'Traces',
[SourceKind.Metric]: 'OTel metrics',
[SourceKind.Session]: 'Sessions',
[SourceKind.Promql]: 'PromQL',
[SourceKind.Promql]: 'Time Series / Prometheus',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 P2 — New source-kind labels "Time Series" and "Time Series / Prometheus" are Title Case, which the repo's sentence-case rule for UI text forbids

Use "Time series" and "Time series / Prometheus" here and in getSourceKindLabel (line 109), so they match the sibling "OTel metrics". Update the expected strings in SourcesList.test.tsx to match. Consider the same casing for the default source name in OnboardingModal.tsx:547 and packages/api/.env.development.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

};

/**
* The kind label for a source on a known connection. A PromQL source reads a
* ClickHouse TimeSeries table or an external Prometheus API, depending on the
* connection, so it is named after which one it uses.
*/
export function getSourceKindLabel(
kind: SourceKind,
connection?: { isPrometheusEndpoint?: boolean },
): string {
if (kind !== SourceKind.Promql || connection == null) {
return SOURCE_KIND_LABELS[kind];
}
return connection.isPrometheusEndpoint ? 'Prometheus' : 'Time Series';
}

export const KNOWN_COLUMNS_EXPRESSION_HELP_TEXT =
'For Distributed table sources whose target tables have non-matching column sets. Provide a list of columns supported across all target tables; it is used instead of SELECT * when fetching full row data (e.g. the row side panel). Leave blank to select all columns. This should be a comma-separated list of column names - do not include non-column expressions or aliases.';

Expand Down
7 changes: 5 additions & 2 deletions packages/app/src/components/Sources/SourcesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { IS_LOCAL_MODE } from '@/config';
import { useConnections } from '@/connection';
import { useSources } from '@/source';

import { SOURCE_KIND_LABELS } from './SourceForm/constants';
import { getSourceKindLabel } from './SourceForm/constants';
import { TableSourceForm } from './SourceForm';

import styles from './Sources.module.scss';
Expand Down Expand Up @@ -210,7 +210,10 @@ export function SourcesList({
</Group>
<Text size={subtextSize} c="dimmed" mt={4}>
<Group gap="xs">
{SOURCE_KIND_LABELS[s.kind]}
{getSourceKindLabel(
s.kind,
connections?.find(c => c.id === s.connection),
)}
{s.section && (
<Group gap={4}>
<IconFolder size={iconSize} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('OnboardingModal auto-detection', () => {
expect(mockCreateSource).toHaveBeenLastCalledWith({
source: {
kind: SourceKind.Promql,
name: 'PromQL',
name: 'Time Series',
connection: 'conn-1',
from: { databaseName: 'default', tableName: 'metrics_ts' },
timestampValueExpression: 'timestamp',
Expand Down
33 changes: 32 additions & 1 deletion packages/app/src/components/__tests__/SourcesList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,40 @@ describe('SourcesList section display', () => {
'Traces',
'OTel metrics',
'Sessions',
'PromQL',
'Time Series',
]) {
expect(screen.getByText(label)).toBeInTheDocument();
}
});

it('names a PromQL source after the connection it reads from', () => {
asMock(useConnections).mockReturnValue({
data: [
{ id: 'conn-a', name: 'Default' },
{ id: 'conn-prom', name: 'Thanos', isPrometheusEndpoint: true },
],
isLoading: false,
refetch: jest.fn(),
});
asMock(useSources).mockReturnValue({
data: [
makeSource('a', 'A', { kind: SourceKind.Promql }),
makeSource('b', 'B', {
kind: SourceKind.Promql,
connection: 'conn-prom',
}),
makeSource('c', 'C', {
kind: SourceKind.Promql,
connection: 'conn-missing',
}),
],
isLoading: false,
refetch: jest.fn(),
});
renderWithMantine(<SourcesList withCard={false} />);

expect(screen.getByText('Time Series')).toBeInTheDocument();
expect(screen.getByText('Prometheus')).toBeInTheDocument();
expect(screen.getByText('Time Series / Prometheus')).toBeInTheDocument();
});
});
Loading