From 14e5eb1854315eb1f0ae6772f9c08496cda86c98 Mon Sep 17 00:00:00 2001 From: Cluas Date: Fri, 30 Aug 2024 01:25:49 +0800 Subject: [PATCH] feat: labelValues support json format --- pyroscope/json_parsers.js | 13 +++++++++++++ pyroscope/pyroscope.js | 1 + 2 files changed, 14 insertions(+) diff --git a/pyroscope/json_parsers.js b/pyroscope/json_parsers.js index 48d8e27a..a1b8ed23 100644 --- a/pyroscope/json_parsers.js +++ b/pyroscope/json_parsers.js @@ -37,6 +37,18 @@ const labelNames = async (req, payload) => { } } +const labelValues = async (req, payload) => { + req.type = 'json' + let body = await bufferize(payload) + body = JSON.parse(body.toString()) + return { + getName: () => body.name, + getMatchers: () => body.matchers, + getStart: () => body.start, + getEnd: () => body.end + } +} + const analyzeQuery = async (req, payload) => { req.type = 'json' let body = await bufferize(payload) @@ -52,6 +64,7 @@ module.exports = { series, getProfileStats, labelNames, + labelValues, settingsGet, analyzeQuery } diff --git a/pyroscope/pyroscope.js b/pyroscope/pyroscope.js index 1ed58ec2..b47e5dde 100644 --- a/pyroscope/pyroscope.js +++ b/pyroscope/pyroscope.js @@ -488,6 +488,7 @@ module.exports.init = (fastify) => { series: jsonParsers.series, getProfileStats: jsonParsers.getProfileStats, labelNames: jsonParsers.labelNames, + labelValues: jsonParsers.labelValues, analyzeQuery: jsonParsers.analyzeQuery } for (const name of Object.keys(fns)) {