Azure Application Insights Node模块默认收集HTTP请求,但是,这些事件似乎不包含请求的标头。
我应该如何在这些事件中最好地包含标题?
这是一个例子:
const logHTTPheaders = (envelope, context) => {
const httpRequest = context['http.ServerRequest'];
if (httpRequest && appInsights.Contracts.domainSupportsProperties(envelope.data.baseData)) {
_.forOwn(httpRequest.headers, (headerValue, headerName) => {
_.set(envelope, `data.baseData.properties.[header-${headerName}]`, headerValue);
});
}
return true;
};
// Telemetry processor to record HTTP request header
appInsights.defaultClient.addTelemetryProcessor(logHTTPheaders);