generated from grafana/grafana-starter-datasource-backend
-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathotel.ts
77 lines (69 loc) · 2.14 KB
/
otel.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { ColumnHint, TimeUnit } from "types/queryBuilder";
export const defaultLogsTable = 'otel_logs';
export const defaultTraceTable = 'otel_traces';
export const traceTimestampTableSuffix = '_trace_id_ts';
export interface OtelVersion {
name: string;
version: string;
specUrl?: string;
logsTable: string;
logColumnMap: Map<ColumnHint, string>;
logLevels: string[];
traceTable: string;
traceColumnMap: Map<ColumnHint, string>;
traceDurationUnit: TimeUnit.Nanoseconds;
}
const otel129: OtelVersion = {
name: '1.2.9',
version: '1.29.0',
specUrl: 'https://opentelemetry.io/docs/specs/otel',
logsTable: defaultLogsTable,
logColumnMap: new Map<ColumnHint, string>([
[ColumnHint.Time, 'Timestamp'],
[ColumnHint.LogMessage, 'Body'],
[ColumnHint.LogLevel, 'SeverityText'],
[ColumnHint.LogLabels, 'LogAttributes'],
[ColumnHint.TraceId, 'TraceId'],
]),
logLevels: [
'TRACE',
'DEBUG',
'INFO',
'WARN',
'ERROR',
'FATAL'
],
traceTable: defaultTraceTable,
traceColumnMap: new Map<ColumnHint, string>([
[ColumnHint.Time, 'Timestamp'],
[ColumnHint.TraceId, 'TraceId'],
[ColumnHint.TraceSpanId, 'SpanId'],
[ColumnHint.TraceParentSpanId, 'ParentSpanId'],
[ColumnHint.TraceServiceName, 'ServiceName'],
[ColumnHint.TraceOperationName, 'SpanName'],
[ColumnHint.TraceDurationTime, 'Duration'],
[ColumnHint.TraceTags, 'SpanAttributes'],
[ColumnHint.TraceServiceTags, 'ResourceAttributes'],
[ColumnHint.TraceStatusCode, 'StatusCode'],
[ColumnHint.TraceEventsPrefix, 'Events'],
]),
traceDurationUnit: TimeUnit.Nanoseconds,
};
export const versions: readonly OtelVersion[] = [
// When selected, will always keep OTEL config up to date as new versions are added
{ ...otel129, name: `latest (${otel129.name})`, version: 'latest' },
otel129,
];
export const getLatestVersion = (): OtelVersion => versions[0];
export const getVersion = (version: string | undefined): OtelVersion | undefined => {
if (!version) {
return;
}
return versions.find(v => v.version === version);
};
export default {
traceTimestampTableSuffix,
versions,
getLatestVersion,
getVersion
};