Skip to content

Commit

Permalink
Merge pull request #553 from metrico/pre-release
Browse files Browse the repository at this point in the history
Pre release
  • Loading branch information
akvlad authored Aug 27, 2024
2 parents c72565e + 56cd1aa commit ce49409
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions pyroscope/pyroscope.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ const render = require('./render')
const profileTypesHandler = async (req, res) => {
const dist = clusterName ? '_dist' : ''
const _res = new messages.ProfileTypesResponse()
const fromTimeSec = req.body && req.body.getStart
const fromTimeSec = Math.floor(req.body && req.body.getStart
? parseInt(req.body.getStart()) / 1000
: (Date.now() - HISTORY_TIMESPAN) / 1000
const toTimeSec = req.body && req.body.getEnd
: (Date.now() - HISTORY_TIMESPAN) / 1000)
const toTimeSec = Math.floor(req.body && req.body.getEnd
? parseInt(req.body.getEnd()) / 1000
: Date.now() / 1000
: Date.now() / 1000)
const profileTypes = await clickhouse.rawRequest(`SELECT DISTINCT type_id, sample_type_unit
FROM profiles_series${dist} ARRAY JOIN sample_types_units as sample_type_unit
WHERE date >= toDate(FROM_UNIXTIME(${Math.floor(fromTimeSec)})) AND date <= toDate(FROM_UNIXTIME(${Math.floor(toTimeSec)})) FORMAT JSON`,
Expand All @@ -54,12 +54,12 @@ WHERE date >= toDate(FROM_UNIXTIME(${Math.floor(fromTimeSec)})) AND date <= toDa

const labelNames = async (req, res) => {
const dist = clusterName ? '_dist' : ''
const fromTimeSec = req.body && req.body.getStart
const fromTimeSec = Math.floor(req.body && req.body.getStart
? parseInt(req.body.getStart()) / 1000
: (Date.now() - HISTORY_TIMESPAN) / 1000
const toTimeSec = req.body && req.body.getEnd
: (Date.now() - HISTORY_TIMESPAN) / 1000)
const toTimeSec = Math.floor(req.body && req.body.getEnd
? parseInt(req.body.getEnd()) / 1000
: Date.now() / 1000
: Date.now() / 1000)
const labelNames = await clickhouse.rawRequest(`SELECT DISTINCT key
FROM profiles_series_keys${dist}
WHERE date >= toDate(FROM_UNIXTIME(${Math.floor(fromTimeSec)})) AND date <= toDate(FROM_UNIXTIME(${Math.floor(toTimeSec)})) FORMAT JSON`,
Expand All @@ -74,12 +74,12 @@ const labelValues = async (req, res) => {
const name = req.body && req.body.getName
? req.body.getName()
: ''
const fromTimeSec = req.body && req.body.getStart && req.body.getStart()
const fromTimeSec = Math.floor(req.body && req.body.getStart && req.body.getStart()
? parseInt(req.body.getStart()) / 1000
: (Date.now() - HISTORY_TIMESPAN) / 1000
const toTimeSec = req.body && req.body.getEnd && req.body.getEnd()
: (Date.now() - HISTORY_TIMESPAN) / 1000)
const toTimeSec = Math.floor(req.body && req.body.getEnd && req.body.getEnd()
? parseInt(req.body.getEnd()) / 1000
: Date.now() / 1000
: Date.now() / 1000)
if (!name) {
throw new Error('No name provided')
}
Expand Down Expand Up @@ -113,7 +113,7 @@ const selectMergeStacktracesV2 = async (req, res) => {
const selectSeries = async (req, res) => {
const fromTimeSec = Math.floor(req.getStart && req.getStart()
? parseInt(req.getStart()) / 1000
: Date.now() / 1000 - HISTORY_TIMESPAN)
: (Date.now() - HISTORY_TIMESPAN) / 1000)
const toTimeSec = Math.floor(req.getEnd && req.getEnd()
? parseInt(req.getEnd()) / 1000
: Date.now() / 1000)
Expand All @@ -127,11 +127,11 @@ const selectMergeProfile = async (req, res) => {
const ctx = newCtxIdx()
try {
const _req = req.body
const fromTimeSec = Math.floor(req.getStart && req.getStart()
? parseInt(req.getStart()) / 1000
: Date.now() / 1000 - HISTORY_TIMESPAN)
const toTimeSec = Math.floor(req.getEnd && req.getEnd()
? parseInt(req.getEnd()) / 1000
const fromTimeSec = Math.floor(_req && _req.getStart
? parseInt(_req.getStart()) / 1000
: (Date.now() - HISTORY_TIMESPAN) / 1000)
const toTimeSec = Math.floor(_req && _req.getEnd
? parseInt(_req.getEnd()) / 1000
: Date.now() / 1000)
let typeID = _req.getProfileTypeid && _req.getProfileTypeid()
if (!typeID) {
Expand Down Expand Up @@ -248,7 +248,7 @@ const series = async (req, res) => {
const _req = req.body
const fromTimeSec = Math.floor(req.getStart && req.getStart()
? parseInt(req.getStart()) / 1000
: Date.now() / 1000 - HISTORY_TIMESPAN)
: (Date.now() - HISTORY_TIMESPAN) / 1000)
const toTimeSec = Math.floor(req.getEnd && req.getEnd()
? parseInt(req.getEnd()) / 1000
: Date.now() / 1000)
Expand Down Expand Up @@ -454,7 +454,7 @@ const analyzeQuery = async (req, res) => {
const query = req.body.getQuery()
const fromTimeSec = Math.floor(req.getStart && req.getStart()
? parseInt(req.getStart()) / 1000
: Date.now() / 1000 - HISTORY_TIMESPAN)
: (Date.now() - HISTORY_TIMESPAN) / 1000)
const toTimeSec = Math.floor(req.getEnd && req.getEnd()
? parseInt(req.getEnd()) / 1000
: Date.now() / 1000)
Expand Down

0 comments on commit ce49409

Please sign in to comment.