-
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
3,970 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const { asyncLogError } = require('../../common') | ||
const { queryTempoTags } = require('../db/clickhouse') | ||
async function handler (req, res) { | ||
try { | ||
const resp = await queryTempoTags() | ||
return res.send({ scopes: [{ name: 'span', tags: resp.map(e => `${e.key}`) }] }) | ||
} catch (e) { | ||
asyncLogError(e, req.log) | ||
res.code(500) | ||
} | ||
} | ||
|
||
module.exports = handler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* Tag Value Handler V2 */ | ||
/* | ||
For retrieving the tag values tempo can query on. | ||
Responses looks like this: | ||
{ | ||
"tagValues": [ | ||
{ | ||
"type": "string", | ||
"value": "a" | ||
}, | ||
.... | ||
] | ||
} | ||
*/ | ||
const { asyncLogError } = require('../../common') | ||
const { queryTempoValues } = require('../db/clickhouse') | ||
|
||
async function handler (req, res) { | ||
req.log.debug(`GET /api/v2/search/tag/${req.params.name}/values`) | ||
if (!req.params.name) { | ||
return res.send({ tagValues: [] }) | ||
} | ||
try { | ||
req.params.name = req.params.name.replace(/^resource\.|^span\./, '') | ||
const vals = (await queryTempoValues(req.params.name)).map(e => e.val) | ||
return res.send({ tagValues: vals.map(v => ({ type: 'string', value: v })) }) | ||
} catch (e) { | ||
asyncLogError(e, req.log) | ||
res.code(500) | ||
} | ||
}; | ||
|
||
module.exports = handler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
const { TranspileTraceQL } = require('../wasm_parts/main') | ||
const { clusterName } = require('../common') | ||
const { DATABASE_NAME } = require('../lib/utils') | ||
const dist = clusterName ? '_dist' : '' | ||
const { rawRequest } = require('../lib/db/clickhouse') | ||
|
||
/** | ||
* | ||
* @param query {string} | ||
* @param limit {number} | ||
* @param from {Date} | ||
* @param to {Date} | ||
* @returns {Promise<[]>} | ||
*/ | ||
const search = async (query, limit, from, to) => { | ||
const request = { | ||
Request: query, | ||
Ctx: { | ||
IsCluster: !!clusterName, | ||
OrgID: '0', | ||
FromS: Math.floor(from.getTime() / 1000) - 600, | ||
ToS: Math.floor(to.getTime() / 1000), | ||
Limit: parseInt(limit), | ||
|
||
TimeSeriesGinTableName: 'time_series_gin', | ||
SamplesTableName: `samples_v3${dist}`, | ||
TimeSeriesTableName: 'time_series', | ||
TimeSeriesDistTableName: 'time_series_dist', | ||
Metrics15sTableName: `metrics_15s${dist}`, | ||
|
||
TracesAttrsTable: 'tempo_traces_attrs_gin', | ||
TracesAttrsDistTable: 'tempo_traces_attrs_gin_dist', | ||
TracesTable: 'tempo_traces', | ||
TracesDistTable: 'tempo_traces_dist' | ||
} | ||
} | ||
console.log(JSON.stringify(request)) | ||
const sql = TranspileTraceQL(request) | ||
const response = await rawRequest(sql + ' FORMAT JSON', null, DATABASE_NAME()) | ||
const traces = response.data.data.map(row => ({ | ||
traceID: row.trace_id, | ||
rootServiceName: row.root_service_name, | ||
rootTraceName: row.root_trace_name, | ||
startTimeUnixNano: row.start_time_unix_nano, | ||
durationMs: row.duration_ms, | ||
spanSets: [ | ||
{ | ||
spans: row.span_id.map((spanId, i) => ({ | ||
spanID: spanId, | ||
startTimeUnixNano: row.timestamps_ns[i], | ||
durationNanos: row.duration[i], | ||
attributes: [] | ||
})), | ||
matched: row.span_id.length | ||
} | ||
] | ||
})) | ||
return traces | ||
} | ||
|
||
module.exports = { | ||
search | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.