Merge pull request #11326 from bergquist/more_traces

dataproxy: adds dashboardid and panelid as tags
This commit is contained in:
Carl Bergquist
2018-03-23 17:13:15 +01:00
committed by GitHub
4 changed files with 19 additions and 4 deletions
+11
View File
@@ -89,6 +89,9 @@ func (proxy *DataSourceProxy) HandleRequest() {
span.SetTag("user_id", proxy.ctx.SignedInUser.UserId)
span.SetTag("org_id", proxy.ctx.SignedInUser.OrgId)
proxy.addTraceFromHeaderValue(span, "X-Panel-Id", "panel_id")
proxy.addTraceFromHeaderValue(span, "X-Dashboard-Id", "dashboard_id")
opentracing.GlobalTracer().Inject(
span.Context(),
opentracing.HTTPHeaders,
@@ -98,6 +101,14 @@ func (proxy *DataSourceProxy) HandleRequest() {
proxy.ctx.Resp.Header().Del("Set-Cookie")
}
func (proxy *DataSourceProxy) addTraceFromHeaderValue(span opentracing.Span, headerName string, tagName string) {
panelId := proxy.ctx.Req.Header.Get(headerName)
dashId, err := strconv.Atoi(panelId)
if err == nil {
span.SetTag(tagName, dashId)
}
}
func (proxy *DataSourceProxy) getDirector() func(req *http.Request) {
return func(req *http.Request) {
req.URL.Scheme = proxy.targetUrl.Scheme