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
7 changes: 7 additions & 0 deletions .changeset/plural-source-kind-labels.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@hyperdx/app': patch
---

fix: use plural source kind labels and "OTel" spelling on the Sources page

The source form's data type options and the sources list now read Logs, Traces, OTel metrics, Sessions, and PromQL.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function MetricTableModelForm({
if (!isValid) {
notifications.show({
color: 'red',
message: `${newValue} is not a valid OTEL ${metricType} schema.`,
message: `${newValue} is not a valid OTel ${metricType} schema.`,
});
}
}
Expand Down Expand Up @@ -121,7 +121,7 @@ export function MetricTableModelForm({
if (!isValid) {
notifications.show({
color: 'red',
message: `${seriesTable} is not a valid OTEL series schema.`,
message: `${seriesTable} is not a valid OTel series schema.`,
});
}
}
Expand Down
31 changes: 25 additions & 6 deletions packages/app/src/components/Sources/SourceForm/SourceForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ import {
PairingWarning,
} from '@/utils/sourceFieldSuggestions';

import { DEFAULT_DATABASE, PROMETHEUS_PLACEHOLDER } from './constants';
import {
DEFAULT_DATABASE,
PROMETHEUS_PLACEHOLDER,
SOURCE_KIND_LABELS,
} from './constants';
import {
CORRELATION_FIELD_MAP,
CorrelationField,
Expand Down Expand Up @@ -626,16 +630,31 @@ export function TableSourceForm({
withAsterisk
>
<Group>
<Radio value={SourceKind.Log} label="Log" />
<Radio value={SourceKind.Trace} label="Trace" />
<Radio
value={SourceKind.Log}
label={SOURCE_KIND_LABELS[SourceKind.Log]}
/>
<Radio
value={SourceKind.Trace}
label={SOURCE_KIND_LABELS[SourceKind.Trace]}
/>
{IS_METRICS_ENABLED && (
<Radio value={SourceKind.Metric} label="OTEL Metrics" />
<Radio
value={SourceKind.Metric}
label={SOURCE_KIND_LABELS[SourceKind.Metric]}
/>
)}
{IS_SESSIONS_ENABLED && (
<Radio value={SourceKind.Session} label="Session" />
<Radio
value={SourceKind.Session}
label={SOURCE_KIND_LABELS[SourceKind.Session]}
/>
)}
{IS_PROMQL_ENABLED && (
<Radio value={SourceKind.Promql} label="PromQL" />
<Radio
value={SourceKind.Promql}
label={SOURCE_KIND_LABELS[SourceKind.Promql]}
/>
)}
</Group>
</Radio.Group>
Expand Down
11 changes: 10 additions & 1 deletion packages/app/src/components/Sources/SourceForm/constants.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import { UseTextIndex } from '@hyperdx/common-utils/dist/types';
import { SourceKind, UseTextIndex } from '@hyperdx/common-utils/dist/types';

import {
MV_AGGREGATE_FUNCTIONS,
MV_GRANULARITY_OPTIONS,
} from '@/utils/materializedViews';

export const DEFAULT_DATABASE = 'default';

export const SOURCE_KIND_LABELS: Record<SourceKind, string> = {

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.

🔵 minor — SOURCE_KIND_LABELS lives in the source form's private constants, away from the existing kind→icon map

Move SOURCE_KIND_LABELS next to SOURCE_KIND_ICONS in packages/app/src/components/sourceSelectUtils.tsx, which is already the shared per-SourceKind display map. SourcesList would then import it from there instead of reaching into ./SourceForm/constants, and both kind maps (and any future kind) get updated in one place.

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

[SourceKind.Log]: 'Logs',
[SourceKind.Trace]: 'Traces',
[SourceKind.Metric]: 'OTel metrics',
[SourceKind.Session]: 'Sessions',
[SourceKind.Promql]: 'PromQL',
};

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
4 changes: 2 additions & 2 deletions packages/app/src/components/Sources/SourcesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import {
import { IS_LOCAL_MODE } from '@/config';
import { useConnections } from '@/connection';
import { useSources } from '@/source';
import { capitalizeFirstLetter } from '@/utils';

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

import styles from './Sources.module.scss';
Expand Down Expand Up @@ -213,7 +213,7 @@ export function SourcesList({
</Group>
<Text size={subtextSize} c="dimmed" mt={4}>
<Group gap="xs">
{capitalizeFirstLetter(s.kind)}
{SOURCE_KIND_LABELS[s.kind]}
{s.section && (
<Group gap={4}>
<IconFolder size={iconSize} />
Expand Down
34 changes: 28 additions & 6 deletions packages/app/src/components/__tests__/SourcesList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ jest.mock('next/router', () => ({
jest.mock('@/source', () => ({ useSources: jest.fn() }));
jest.mock('@/connection', () => ({ useConnections: jest.fn() }));
jest.mock('@/config', () => ({ IS_LOCAL_MODE: false }));
jest.mock('@/utils', () => ({
capitalizeFirstLetter: (s: string) => s.charAt(0).toUpperCase() + s.slice(1),
}));
// TableSourceForm only renders while editing/creating; stub it so the list test
// does not pull in the full source form.
jest.mock('../Sources/SourceForm', () => ({ TableSourceForm: () => null }));
Expand Down Expand Up @@ -61,13 +58,38 @@ describe('SourcesList section display', () => {

it('shows no section labels when no source has a section', () => {
asMock(useSources).mockReturnValue({
data: [makeSource('a', 'Logs'), makeSource('b', 'Traces')],
data: [makeSource('a', 'App'), makeSource('b', 'Host')],
isLoading: false,
refetch: jest.fn(),
});
renderWithMantine(<SourcesList withCard={false} />);

expect(screen.getByText('App')).toBeInTheDocument();
expect(screen.getByText('Host')).toBeInTheDocument();
});

it('shows the plural kind label for each source', () => {
asMock(useSources).mockReturnValue({
data: [
makeSource('a', 'A'),
makeSource('b', 'B', { kind: SourceKind.Trace }),
makeSource('c', 'C', { kind: SourceKind.Metric }),
makeSource('d', 'D', { kind: SourceKind.Session }),
makeSource('e', 'E', { kind: SourceKind.Promql }),
],
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
isLoading: false,
refetch: jest.fn(),
});
renderWithMantine(<SourcesList withCard={false} />);

expect(screen.getByText('Logs')).toBeInTheDocument();
expect(screen.getByText('Traces')).toBeInTheDocument();
for (const label of [
'Logs',
'Traces',
'OTel metrics',
'Sessions',
'PromQL',
]) {
expect(screen.getByText(label)).toBeInTheDocument();
}
});
});
4 changes: 0 additions & 4 deletions packages/app/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ export const isValidUrl = (input: string) => {
}
};

export const capitalizeFirstLetter = (input: string) => {
return input.charAt(0).toUpperCase() + input.slice(1);
};

export const getShortUrl = (url: string) => {
try {
const parsedUrl = new URL(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ test.describe(
await searchPage.sourceActionsMenu.click();
await searchPage.createNewSourceItem.click();

// Switching the kind to OTEL Metrics renders the metric table selects for
// Switching the kind to OTel metrics renders the metric table selects for
// the default database, which is what autofill reacts to.
await sourceForm.selectSourceKind('OTEL Metrics');
await sourceForm.selectSourceKind('OTel metrics');

await sourceForm.waitForMetricTableAutofill();
await expect(sourceForm.getMetricTableInput('gauge')).toHaveValue(
Expand Down
10 changes: 5 additions & 5 deletions packages/app/tests/e2e/features/sources.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ const editableSourcesData = [
{
name: DEFAULT_LOGS_SOURCE_NAME,
fields: LOG_FIELDS,
radioButtonName: 'Log',
radioButtonName: 'Logs',
},
{
name: DEFAULT_TRACES_SOURCE_NAME,
fields: TRACE_FIELDS,
radioButtonName: 'Trace',
radioButtonName: 'Traces',
},
];

Expand All @@ -94,12 +94,12 @@ const allSourcesData = [
{
name: DEFAULT_METRICS_SOURCE_NAME,
fields: METRIC_FIELDS,
radioButtonName: 'OTEL Metrics',
radioButtonName: 'OTel metrics',
},
{
name: DEFAULT_SESSIONS_SOURCE_NAME,
fields: SESSION_FIELDS,
radioButtonName: 'Session',
radioButtonName: 'Sessions',
},
];

Expand Down Expand Up @@ -348,7 +348,7 @@ test.describe('Sources Functionality', { tag: ['@sources'] }, () => {
await searchPage.createNewSourceItem.click();

await searchPage.page
.getByLabel('OTEL Metrics', { exact: true })
.getByLabel('OTel metrics', { exact: true })
.click();
await searchPage.sourceModalShowOptionalFields();

Expand Down
Loading