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
13 changes: 13 additions & 0 deletions plugins/Jaeger/v1/configValidation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"steps": [
{
"displayName": "Check connection",
"dataStream": {
"name": "services"
},
"required": true,
"error": "Could not reach the Jaeger Query API. Check the URL is correct, that the instance is reachable (directly or via an on-prem relay agent), and enable 'Ignore certificate errors' if it uses a self-signed certificate.",
"success": "Connected successfully."
}
]
}
6 changes: 6 additions & 0 deletions plugins/Jaeger/v1/cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"words": [
"jaeger",
"opentelemetry"
]
}
16 changes: 16 additions & 0 deletions plugins/Jaeger/v1/custom_types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
{
"name": "Service",
"sourceType": "Service",
"icon": "server",
"singular": "Service",
"plural": "Services"
},
{
"name": "Dependency",
"sourceType": "Dependency",
"icon": "share-nodes",
"singular": "Dependency",
"plural": "Dependencies"
}
]
68 changes: 68 additions & 0 deletions plugins/Jaeger/v1/dataStreams/dependencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"name": "dependencies",
"displayName": "Dependencies",
"description": "Call dependencies between services, one row per parent-child pair",
"tags": [
"Services"
],
"baseDataSourceName": "httpRequestUnscoped",
"matches": "none",
"timeframes": [
"last1hour",
"last12hours",
"last24hours",
"last7days"
],
"config": {
"httpMethod": "get",
"endpointPath": "/api/dependencies",
"pathToData": "data",
"getArgs": [
{
"key": "endTs",
"value": "{{timeframe.unixEnd * 1000}}"
},
{
"key": "lookback",
"value": "{{(timeframe.unixEnd - timeframe.unixStart) * 1000}}"
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
],
"headers": []
},
"metadata": [
{
"name": "key",
"displayName": "Dependency",
"computed": true,
"valueExpression": "{{ $['parent'] + ' -> ' + $['child'] }}",
"shape": "string",
"role": "label"
},
{
"name": "parent",
"displayName": "Parent Service",
"shape": "string"
},
{
"name": "child",
"displayName": "Child Service",
"shape": "string"
},
{
"name": "callCount",
"displayName": "Call Count",
"shape": [
"number",
{
"thousandsSeparator": true
}
]
Comment thread
coderabbitai[bot] marked this conversation as resolved.
},
{
"name": "source",
"displayName": "Source",
"shape": "string",
"visible": false
}
]
}
41 changes: 41 additions & 0 deletions plugins/Jaeger/v1/dataStreams/operations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "operations",
"displayName": "Operations",
"description": "Operation names reported by a service",
"tags": [
"Operations"
],
"baseDataSourceName": "httpRequestScopedSingle",
"matches": {
"sourceType": {
"type": "equals",
"value": "Service"
}
},
"timeframes": false,
"config": {
"httpMethod": "get",
"endpointPath": "/api/v3/operations",
"getArgs": [
{
"key": "service",
"value": "{{object.rawId}}"
}
],
"headers": [],
"pathToData": "operations"
},
"metadata": [
{
"name": "name",
"displayName": "Operation",
"shape": "string",
"role": "label"
},
{
"name": "spanKind",
"displayName": "Span Kind",
"shape": "string"
}
]
}
99 changes: 99 additions & 0 deletions plugins/Jaeger/v1/dataStreams/scripts/traces.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// dataStreams/scripts/traces.js
//
// The /api/v3/traces response is a single JSON object shaped
// { "result": { "resourceSpans": [...] } } (OTLP JSON) - not NDJSON - so the
// platform's automatic JSON parse populates `data` and we read it directly.
//
// OTLP JSON encodes int64 (startTimeUnixNano/endTimeUnixNano) as STRING.
// Epoch nanoseconds (~1.7e18) exceed JS Number safe-integer precision, so we
// do the nanosecond arithmetic in BigInt and only convert to Number once
// we've reduced to milliseconds (~1.7e12, well within safe range).

const SPAN_KIND = {
0: "UNSPECIFIED",
1: "INTERNAL",
2: "SERVER",
3: "CLIENT",
4: "PRODUCER",
5: "CONSUMER",
};

const STATUS_CODE = {
0: "UNSET",
1: "OK",
2: "ERROR",
};

function anyValueToJs(value) {
if (!value) return undefined;
if (value.arrayValue) {
return (value.arrayValue.values || []).map(anyValueToJs);
}
if (value.kvlistValue) {
const obj = {};
(value.kvlistValue.values || []).forEach((kv) => {
obj[kv.key] = anyValueToJs(kv.value);
});
return obj;
}
return (
value.stringValue ??
value.boolValue ??
value.intValue ??
value.doubleValue ??
value.bytesValue
);
}

function attrsToObject(attributes) {
const obj = {};
(attributes || []).forEach((a) => {
obj[a.key] = anyValueToJs(a.value);
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.
return obj;
}

function nanoStrToBig(nanoStr) {
return BigInt(nanoStr || "0");
}

const resourceSpans = (data && data.result && data.result.resourceSpans) || [];

result = _.flatMap(resourceSpans, (rs) => {
const resourceAttrs = attrsToObject((rs.resource || {}).attributes);
const serviceName = resourceAttrs["service.name"] || "";

return _.flatMap(rs.scopeSpans || [], (ss) => {
return (ss.spans || []).map((s) => {
const startNsBig = nanoStrToBig(s.startTimeUnixNano);
const endNsBig = nanoStrToBig(s.endTimeUnixNano);
// Compute duration from the full-precision nanosecond values before
// rounding to ms — rounding each endpoint first and then subtracting
// can be off by up to 1ms (e.g. start=1.999999ms, end=2.000001ms
// truncate to 1ms/2ms, giving a 1ms duration for a ~2ns span).
const durationMsBig = (endNsBig - startNsBig) / 1000000n;
const status = s.status || {};
// proto3 JSON omits fields at their default value, so an
// INTERNAL/unspecified-kind span (kind 0) typically has no `kind`
// field at all — default the missing case to 0 rather than
// stringifying `undefined`.
const kind = s.kind ?? 0;

return {
traceId: s.traceId,
spanId: s.spanId,
parentSpanId: s.parentSpanId || "",
operationName: s.name,
serviceName,
kind: SPAN_KIND[kind] ?? String(kind),
startTime: new Date(
Number(startNsBig / 1000000n),
).toISOString(),
durationMs: Number(durationMsBig),
statusCode: STATUS_CODE[status.code] ?? "UNSET",
statusMessage: status.message || "",
attributes: attrsToObject(s.attributes),
};
});
});
});
25 changes: 25 additions & 0 deletions plugins/Jaeger/v1/dataStreams/services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "services",
"displayName": "Services",
"description": "Services known to the Jaeger backend",
"tags": [
"Services"
],
"baseDataSourceName": "httpRequestUnscoped",
"matches": "none",
"timeframes": false,
"config": {
"httpMethod": "get",
"endpointPath": "/api/v3/services",
"postRequestScript": "result = (data.services || []).map(service => ({ service }));",
"headers": []
},
"metadata": [
{
"name": "service",
"displayName": "Service",
"shape": "string",
"role": "label"
}
]
}
113 changes: 113 additions & 0 deletions plugins/Jaeger/v1/dataStreams/traces.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"name": "traces",
"displayName": "Traces",
"description": "Spans reported by a service within the selected timeframe",
"tags": [
"Traces"
],
"baseDataSourceName": "httpRequestScopedSingle",
"matches": {
"sourceType": {
"type": "equals",
"value": "Service"
}
},
"timeframes": true,
"config": {
"httpMethod": "get",
"endpointPath": "/api/v3/traces",
"getArgs": [
{
"key": "query.service_name",
"value": "{{object.rawId}}"
},
{
"key": "query.start_time_min",
"value": "{{timeframe.start}}"
},
{
"key": "query.start_time_max",
"value": "{{timeframe.end}}"
},
{
"key": "query.search_depth",
"value": "{{limit}}"
}
],
"headers": [],
"postRequestScript": "traces.js"
},
"ui": [
{
"name": "limit",
"label": "Number of Traces",
"type": "number",
"defaultValue": 20,
"min": 1
}
],
"metadata": [
{
"name": "traceId",
"displayName": "Trace ID",
"shape": "string"
},
{
"name": "spanId",
"displayName": "Span ID",
"shape": "string",
"visible": false
},
{
"name": "parentSpanId",
"displayName": "Parent Span ID",
"shape": "string",
"visible": false
},
{
"name": "operationName",
"displayName": "Operation",
"shape": "string",
"role": "label"
},
{
"name": "serviceName",
"displayName": "Service",
"shape": "string"
},
{
"name": "kind",
"displayName": "Kind",
"shape": "string"
},
{
"name": "startTime",
"displayName": "Start Time",
"shape": "date",
"role": "timestamp"
},
{
"name": "durationMs",
"displayName": "Duration (ms)",
"shape": "milliseconds",
"role": "value"
},
{
"name": "statusCode",
"displayName": "Status Code",
"shape": "string"
},
{
"name": "statusMessage",
"displayName": "Status Message",
"shape": "string",
"visible": false
},
{
"name": "attributes",
"displayName": "Attributes",
"shape": "json",
"visible": false
}
]
}
Loading
Loading