提交 2b4cdfd0 编写于 作者: X Xin,Zhang 提交者: wu-sheng

Fix the component of egg span is incorrect (#34)

上级 ddb0a8c7
......@@ -29,6 +29,8 @@
const loadProperty = require("./constants").PROPERTY_FIELD;
const activeContext = require("../constants").ACTIVE_CONTEXT;
const functionArguments = require("function-arguments");
const layerDefine = require("../../trace/span-layer");
const componentDefine = require("../../trace/component-define");
module.exports = function(fileLoaderModule, instrumentation, contextManager) {
instrumentation.enhanceMethod(fileLoaderModule.prototype, "parse", wrapParse);
......@@ -79,7 +81,11 @@ module.exports = function(fileLoaderModule, instrumentation, contextManager) {
let runningSpan = this.request.ctx[activeContext].span();
try {
let requestURL = this.request.ctx._matchedRoute;
contextManager.rewriteOperationName(runningSpan, requestURL);
contextManager.rewriteSpanInfo(runningSpan, {
"operationName": requestURL,
"component": componentDefine.Components.EGG,
"spanLayer": layerDefine.Layers.HTTP,
});
ret = origin.apply(this, arguments);
} catch (e) {
runningSpan.errorOccurred();
......
......@@ -160,3 +160,14 @@ ContextManager.prototype.rewriteOperationName = function(span, operationName) {
}
});
};
ContextManager.prototype.rewriteSpanInfo = function(span, spanInfo) {
let self = this;
Object.keys(spanInfo).forEach(function(property) {
if (property == "operationName") {
self.rewriteOperationName(span, spanInfo[property]);
} else {
span[property](spanInfo[property]);
}
});
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册