Skip to content

Commit 7b6ed70

Browse files
authored
fix: Support custom Timestamp Columns in Surrounding Context panel (#1309)
Fixes HDX-2664 # Summary This PR fixes an error in the surrounding context side panel that occurs when a source does not have a `Timestamp` column. To fix the error, the side panel will now reference the __hdx_timestamp alias queried by `useRowData`, which in turn is based on the Timestamp Column (or Displayed Timestamp Column) in the source's config. ## Testing To reproduce the issue, create a source without a `Timestamp` column: <details> <summary>Source schema</summary> ```sql CREATE TABLE default.otel_logs_other_ts ( `timestamp` DateTime64(9) CODEC(Delta(8), ZSTD(1)), `timestamp_time` DateTime DEFAULT toDateTime(timestamp), `TraceId` String CODEC(ZSTD(1)), `SpanId` String CODEC(ZSTD(1)), `TraceFlags` UInt8, `SeverityText` LowCardinality(String) CODEC(ZSTD(1)), `SeverityNumber` UInt8, `ServiceName` LowCardinality(String) CODEC(ZSTD(1)), `Body` String CODEC(ZSTD(1)), `ResourceSchemaUrl` LowCardinality(String) CODEC(ZSTD(1)), `ResourceAttributes` Map(LowCardinality(String), String) CODEC(ZSTD(1)), `ScopeSchemaUrl` LowCardinality(String) CODEC(ZSTD(1)), `ScopeName` String CODEC(ZSTD(1)), `ScopeVersion` LowCardinality(String) CODEC(ZSTD(1)), `ScopeAttributes` Map(LowCardinality(String), String) CODEC(ZSTD(1)), `LogAttributes` Map(LowCardinality(String), String) CODEC(ZSTD(1)), `__hdx_materialized_k8s.cluster.name` LowCardinality(String) MATERIALIZED ResourceAttributes['k8s.cluster.name'] CODEC(ZSTD(1)), `__hdx_materialized_k8s.container.name` LowCardinality(String) MATERIALIZED ResourceAttributes['k8s.container.name'] CODEC(ZSTD(1)), `__hdx_materialized_k8s.deployment.name` LowCardinality(String) MATERIALIZED ResourceAttributes['k8s.deployment.name'] CODEC(ZSTD(1)), `__hdx_materialized_k8s.namespace.name` LowCardinality(String) MATERIALIZED ResourceAttributes['k8s.namespace.name'] CODEC(ZSTD(1)), `__hdx_materialized_k8s.node.name` LowCardinality(String) MATERIALIZED ResourceAttributes['k8s.node.name'] CODEC(ZSTD(1)), `__hdx_materialized_k8s.pod.name` LowCardinality(String) MATERIALIZED ResourceAttributes['k8s.pod.name'] CODEC(ZSTD(1)), `__hdx_materialized_k8s.pod.uid` LowCardinality(String) MATERIALIZED ResourceAttributes['k8s.pod.uid'] CODEC(ZSTD(1)), `__hdx_materialized_deployment.environment.name` LowCardinality(String) MATERIALIZED ResourceAttributes['deployment.environment.name'] CODEC(ZSTD(1)), INDEX idx_trace_id TraceId TYPE bloom_filter(0.001) GRANULARITY 1, INDEX idx_res_attr_key mapKeys(ResourceAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, INDEX idx_res_attr_value mapValues(ResourceAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, INDEX idx_scope_attr_key mapKeys(ScopeAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, INDEX idx_scope_attr_value mapValues(ScopeAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, INDEX idx_log_attr_key mapKeys(LogAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, INDEX idx_log_attr_value mapValues(LogAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, INDEX idx_lower_body lower(Body) TYPE tokenbf_v1(32768, 3, 0) GRANULARITY 8 ) ENGINE = MergeTree PARTITION BY toDate(timestamp_time) PRIMARY KEY (ServiceName, timestamp_time) ORDER BY (ServiceName, timestamp_time, timestamp) TTL timestamp_time + toIntervalDay(30) SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1 ``` </details> Then try to open the surrounding context panel: https://github.com/user-attachments/assets/d5f14e3c-83ce-40c0-b2c4-ef9fe8e1467e With these changes, the error is fixed (as long as the source's timestamp column configuration is correct) https://github.com/user-attachments/assets/605c50e5-9306-4d2e-a9b1-9afc3adca9b6
1 parent 3ee93ae commit 7b6ed70

File tree

3 files changed

+30
-11
lines changed

3 files changed

+30
-11
lines changed

.changeset/brave-pants-shave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hyperdx/app": patch
3+
---
4+
5+
fix: Support custom Timestamp Columns in Surrounding Context panel

packages/app/src/components/ContextSidePanel.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import SearchInputV2 from '@/SearchInputV2';
1717
import { useSource } from '@/source';
1818
import { formatAttributeClause } from '@/utils';
1919

20+
import { ROW_DATA_ALIASES } from './DBRowDataPanel';
2021
import DBRowSidePanel, { RowSidePanelContext } from './DBRowSidePanel';
2122
import {
2223
BreadcrumbNavigationCallback,
@@ -76,7 +77,7 @@ export default function ContextSubpanel({
7677
onBreadcrumbClick,
7778
}: ContextSubpanelProps) {
7879
const QUERY_KEY_PREFIX = 'context';
79-
const { Timestamp: origTimestamp } = rowData;
80+
const origTimestamp = rowData[ROW_DATA_ALIASES.TIMESTAMP];
8081
const { whereLanguage: originalLanguage = 'lucene' } =
8182
dbSqlRowTableConfig ?? {};
8283
const [range, setRange] = useState<number>(ms('30s'));

packages/app/src/components/DBRowDataPanel.tsx

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@ import { getDisplayedTimestampValueExpression, getEventBody } from '@/source';
88

99
import { DBRowJsonViewer } from './DBRowJsonViewer';
1010

11+
export enum ROW_DATA_ALIASES {
12+
TIMESTAMP = '__hdx_timestamp',
13+
BODY = '__hdx_body',
14+
TRACE_ID = '__hdx_trace_id',
15+
SPAN_ID = '__hdx_span_id',
16+
SEVERITY_TEXT = '__hdx_severity_text',
17+
SERVICE_NAME = '__hdx_service_name',
18+
RESOURCE_ATTRIBUTES = '__hdx_resource_attributes',
19+
EVENT_ATTRIBUTES = '__hdx_event_attributes',
20+
EVENTS_EXCEPTION_ATTRIBUTES = '__hdx_events_exception_attributes',
21+
SPAN_EVENTS = '__hdx_span_events',
22+
}
23+
1124
export function useRowData({
1225
source,
1326
rowId,
@@ -32,73 +45,73 @@ export function useRowData({
3245
},
3346
{
3447
valueExpression: getDisplayedTimestampValueExpression(source),
35-
alias: '__hdx_timestamp',
48+
alias: ROW_DATA_ALIASES.TIMESTAMP,
3649
},
3750
...(eventBodyExpr
3851
? [
3952
{
4053
valueExpression: eventBodyExpr,
41-
alias: '__hdx_body',
54+
alias: ROW_DATA_ALIASES.BODY,
4255
},
4356
]
4457
: []),
4558
...(searchedTraceIdExpr
4659
? [
4760
{
4861
valueExpression: searchedTraceIdExpr,
49-
alias: '__hdx_trace_id',
62+
alias: ROW_DATA_ALIASES.TRACE_ID,
5063
},
5164
]
5265
: []),
5366
...(searchedSpanIdExpr
5467
? [
5568
{
5669
valueExpression: searchedSpanIdExpr,
57-
alias: '__hdx_span_id',
70+
alias: ROW_DATA_ALIASES.SPAN_ID,
5871
},
5972
]
6073
: []),
6174
...(severityTextExpr
6275
? [
6376
{
6477
valueExpression: severityTextExpr,
65-
alias: '__hdx_severity_text',
78+
alias: ROW_DATA_ALIASES.SEVERITY_TEXT,
6679
},
6780
]
6881
: []),
6982
...(source.serviceNameExpression
7083
? [
7184
{
7285
valueExpression: source.serviceNameExpression,
73-
alias: '__hdx_service_name',
86+
alias: ROW_DATA_ALIASES.SERVICE_NAME,
7487
},
7588
]
7689
: []),
7790
...(source.resourceAttributesExpression
7891
? [
7992
{
8093
valueExpression: source.resourceAttributesExpression,
81-
alias: '__hdx_resource_attributes',
94+
alias: ROW_DATA_ALIASES.RESOURCE_ATTRIBUTES,
8295
},
8396
]
8497
: []),
8598
...(source.eventAttributesExpression
8699
? [
87100
{
88101
valueExpression: source.eventAttributesExpression,
89-
alias: '__hdx_event_attributes',
102+
alias: ROW_DATA_ALIASES.EVENT_ATTRIBUTES,
90103
},
91104
]
92105
: []),
93106
...(source.kind === SourceKind.Trace && source.spanEventsValueExpression
94107
? [
95108
{
96109
valueExpression: `${source.spanEventsValueExpression}.Attributes[indexOf(${source.spanEventsValueExpression}.Name, 'exception')]`,
97-
alias: '__hdx_events_exception_attributes',
110+
alias: ROW_DATA_ALIASES.EVENTS_EXCEPTION_ATTRIBUTES,
98111
},
99112
{
100113
valueExpression: source.spanEventsValueExpression,
101-
alias: '__hdx_span_events',
114+
alias: ROW_DATA_ALIASES.SPAN_EVENTS,
102115
},
103116
]
104117
: []),

0 commit comments

Comments
 (0)