Send stat_tag metric when available

This commit is contained in:
Daniel García Aubert
2020-04-29 18:25:01 +02:00
parent dbc5d65d90
commit 7e31b956bf
3 changed files with 28 additions and 3 deletions
+12
View File
@@ -50,6 +50,7 @@ function getEventData (req, res, tags) {
map_id: getLayergroupid({ res }),
cache_buster: getCacheBuster({ res }),
template_hash: getTemplateHash({ res }),
stat_tag: getStatTag({ res }),
response_code: res.statusCode.toString(),
response_time: getResponseTime(res),
source_domain: req.hostname,
@@ -98,6 +99,17 @@ function getTemplateHash ({ res }) {
return res.locals.templateHash;
}
function getStatTag ({ res }) {
if (res.locals.mapConfig) {
return res.locals.mapConfig.obj().stat_tag;
}
// FIXME: don't expect that mapConfig is already set
if (res.locals.mapConfigProvider && res.locals.mapConfigProvider.mapConfig) {
return res.locals.mapConfigProvider.mapConfig.obj().stat_tag;
}
}
// FIXME: 'X-Tiler-Profiler' might not be accurate enough
function getResponseTime (res) {
const profiler = res.get('X-Tiler-Profiler');