Skip to content

Commit

Permalink
Fix *_trace_id_ts table (#768)
Browse files Browse the repository at this point in the history
  • Loading branch information
SpencerTorres authored Mar 21, 2024
1 parent c53e0de commit 0c56685
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Fixes

- Changed trace timestamp table from the constant `otel_traces_trace_id_ts` to a suffix `_trace_id_ts` applied to the current table name.

## 4.0.3

### Features
Expand Down
2 changes: 1 addition & 1 deletion src/data/sqlGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ const generateTraceIdQuery = (options: QueryBuilderOptions): string => {
const applyTraceIdOptimization = hasTraceIdFilter && options.meta?.otelEnabled && otelVersion;
if (applyTraceIdOptimization) {
const traceId = options.meta!.traceId;
const timestampTable = getTableIdentifier(database, otelVersion.traceTimestampTable);
const timestampTable = getTableIdentifier(database, table + otel.traceTimestampTableSuffix);
queryParts.push('WITH');
queryParts.push(`'${traceId}' as trace_id,`);
queryParts.push(`(SELECT min(Start) FROM ${timestampTable} WHERE TraceId = trace_id) as trace_start,`);
Expand Down
6 changes: 3 additions & 3 deletions src/otel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { ColumnHint, TimeUnit } from "types/queryBuilder";

const defaultLogsTable = 'otel_logs';
const defaultTraceTable = 'otel_traces';
const defaultTraceTimestampTable = 'otel_traces_trace_id_ts';

export const traceTimestampTableSuffix = '_trace_id_ts';

export interface OtelVersion {
name: string;
Expand All @@ -12,7 +13,6 @@ export interface OtelVersion {
logColumnMap: Map<ColumnHint, string>;
logLevels: string[];
traceTable: string;
traceTimestampTable: string;
traceColumnMap: Map<ColumnHint, string>;
traceDurationUnit: TimeUnit.Nanoseconds;
}
Expand All @@ -37,7 +37,6 @@ const otel129: OtelVersion = {
'FATAL'
],
traceTable: defaultTraceTable,
traceTimestampTable: defaultTraceTimestampTable,
traceColumnMap: new Map<ColumnHint, string>([
[ColumnHint.Time, 'Timestamp'],
[ColumnHint.TraceId, 'TraceId'],
Expand Down Expand Up @@ -68,6 +67,7 @@ export const getVersion = (version: string | undefined): OtelVersion | undefined
};

export default {
traceTimestampTableSuffix,
versions,
getLatestVersion,
getVersion
Expand Down

0 comments on commit 0c56685

Please sign in to comment.