Browse Source

dataproxy: adds dashboardid and panelid as tags

closes #11315
bergquist 7 years ago
parent
commit
f142548969

+ 11 - 0
pkg/api/pluginproxy/ds_proxy.go

@@ -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

+ 1 - 0
public/app/features/panel/metrics_panel_ctrl.ts

@@ -222,6 +222,7 @@ class MetricsPanelCtrl extends PanelCtrl {
     var metricsQuery = {
       timezone: this.dashboard.getTimezone(),
       panelId: this.panel.id,
+      dashboardId: this.dashboard.id,
       range: this.range,
       rangeRaw: this.range.raw,
       interval: this.interval,

+ 2 - 0
public/app/plugins/datasource/graphite/datasource.ts

@@ -50,6 +50,8 @@ export function GraphiteDatasource(instanceSettings, $q, backendSrv, templateSrv
       data: params.join('&'),
       headers: {
         'Content-Type': 'application/x-www-form-urlencoded',
+        'X-Dashboard-Id': options.dashboardId, // enables distributed tracing in ds_proxy
+        'X-Panel-Id': options.panelId, // enables distributed tracing in ds_proxy
       },
     };