mirror of
https://github.com/metrico/qryn.git
synced 2025-03-14 10:07:18 +00:00
Merge pull request #528 from metrico/fix/otlp_spans_527
fix otlp related select
This commit is contained in:
@ -47,7 +47,6 @@ const search = async (query, limit, from, to) => {
|
||||
(a, b) => b.startTimeUnixNano.localeCompare(a.startTimeUnixNano))
|
||||
)
|
||||
)
|
||||
console.log(JSON.stringify(res, 2))
|
||||
return res
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
const Otlp = require('../../lib/db/otlp')
|
||||
const Zipkin = require('../../lib/db/zipkin')
|
||||
const protobufjs = require('protobufjs')
|
||||
const path = require('path')
|
||||
const OTLPSpan = protobufjs.loadSync(path.join(__dirname, '..', '..',
|
||||
'lib', 'otlp.proto')).lookupType('Span')
|
||||
const { flatOTLPAttrs, OTLPgetServiceNames } = require('../../lib/utils')
|
||||
/**
|
||||
*
|
||||
* @param rows {Row[]}
|
||||
@ -27,16 +23,23 @@ function postProcess (rows, script) {
|
||||
...row,
|
||||
objs: row.payload.map((payload, i) => {
|
||||
let span = null
|
||||
let attrs = null
|
||||
let serviceName = null
|
||||
|
||||
switch (row.payload_type[i]) {
|
||||
case 1:
|
||||
return new Zipkin(JSON.parse(Buffer.from(payload, 'base64').toString()))
|
||||
case 2:
|
||||
span = OTLPSpan.toObject(
|
||||
OTLPSpan.decode(Buffer.from(payload, 'base64')), {
|
||||
longs: String,
|
||||
bytes: String
|
||||
})
|
||||
return new Otlp(span)
|
||||
span = JSON.parse(Buffer.from(payload, 'base64').toString())
|
||||
attrs = flatOTLPAttrs(span.attributes)
|
||||
serviceName = OTLPgetServiceNames(attrs)
|
||||
attrs.name = span.name
|
||||
attrs['service.name'] = serviceName.local
|
||||
if (serviceName.remote) {
|
||||
attrs['remoteService.name'] = serviceName.remote
|
||||
}
|
||||
attrs = [...Object.entries(attrs)]
|
||||
return { tags: attrs }
|
||||
}
|
||||
return null
|
||||
})
|
||||
|
Reference in New Issue
Block a user