[APM] Add debug option (#19587) (#19612)

This commit is contained in:
Søren Louv-Jansen 2018-06-01 08:34:26 +02:00 committed by GitHub
parent 6ef0f514f4
commit 96a6bdd550
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 2 deletions

View file

@ -20,7 +20,10 @@ async function callApi(fetchOptions, kibanaOptions) {
const combinedFetchOptions = {
...fetchOptions,
query: fetchOptions.query
query: {
...fetchOptions.query,
_debug: sessionStorage.getItem('apm_debug') || false
}
};
const res = await kfetch(combinedFetchOptions, combinedKibanaOptions);

View file

@ -11,6 +11,7 @@ export const dateValidation = Joi.alternatives()
export const withDefaultValidators = (validators = {}) => {
return Joi.object().keys({
_debug: Joi.bool(),
start: dateValidation,
end: dateValidation,
esFilterQuery: Joi.string().allow(''),

View file

@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
/* eslint-disable no-console */
import moment from 'moment';
function decodeEsQuery(esQuery) {
@ -17,7 +18,18 @@ export function setupRequest(req, reply) {
start: moment.utc(req.query.start).valueOf(),
end: moment.utc(req.query.end).valueOf(),
esFilterQuery: decodeEsQuery(req.query.esFilterQuery),
client: cluster.callWithRequest.bind(null, req),
client: (type, params) => {
if (req.query._debug) {
console.log(`DEBUG ES QUERY:`);
console.log(
`${req.method.toUpperCase()} ${req.url.pathname} ${JSON.stringify(
req.query
)}`
);
console.log(JSON.stringify(params.body, null, 4));
}
return cluster.callWithRequest(req, type, params);
},
config: req.server.config()
};