-
Notifications
You must be signed in to change notification settings - Fork 242
Expand file tree
/
Copy pathtemplate-shared.js
More file actions
43 lines (34 loc) · 1.14 KB
/
template-shared.js
File metadata and controls
43 lines (34 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/
'use strict'
exports.wrapCompile = function (agent, moduleName) {
function wrapTemplate (original) {
return function wrappedTemplate (data) {
var span = agent.startSpan(moduleName, 'template', moduleName, 'render')
var id = span && span.transaction.id
agent.logger.debug('intercepted call to %s render %o', moduleName, {
id,
data
})
var ret = original.apply(this, arguments)
if (span) span.end()
return ret
}
}
return function wrappedCompile (original) {
return function wrappedCompile (input) {
var span = agent.startSpan(moduleName, 'template', moduleName, 'compile')
var id = span && span.transaction.id
agent.logger.debug('intercepted call to %s compile %o', moduleName, {
id,
input
})
var ret = original.apply(this, arguments)
if (span) span.end()
return typeof ret === 'function' ? wrapTemplate(ret) : ret
}
}
}