Commit 980e0782 by Carl Bergquist Committed by GitHub

Merge pull request #11326 from bergquist/more_traces

dataproxy: adds dashboardid and panelid as tags
parents da83964a 519fd8b2
...@@ -89,6 +89,9 @@ func (proxy *DataSourceProxy) HandleRequest() { ...@@ -89,6 +89,9 @@ func (proxy *DataSourceProxy) HandleRequest() {
span.SetTag("user_id", proxy.ctx.SignedInUser.UserId) span.SetTag("user_id", proxy.ctx.SignedInUser.UserId)
span.SetTag("org_id", proxy.ctx.SignedInUser.OrgId) 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( opentracing.GlobalTracer().Inject(
span.Context(), span.Context(),
opentracing.HTTPHeaders, opentracing.HTTPHeaders,
...@@ -98,6 +101,14 @@ func (proxy *DataSourceProxy) HandleRequest() { ...@@ -98,6 +101,14 @@ func (proxy *DataSourceProxy) HandleRequest() {
proxy.ctx.Resp.Header().Del("Set-Cookie") 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) { func (proxy *DataSourceProxy) getDirector() func(req *http.Request) {
return func(req *http.Request) { return func(req *http.Request) {
req.URL.Scheme = proxy.targetUrl.Scheme req.URL.Scheme = proxy.targetUrl.Scheme
......
...@@ -28,12 +28,9 @@ func NewGraphiteExecutor(datasource *models.DataSource) (tsdb.TsdbQueryEndpoint, ...@@ -28,12 +28,9 @@ func NewGraphiteExecutor(datasource *models.DataSource) (tsdb.TsdbQueryEndpoint,
return &GraphiteExecutor{}, nil return &GraphiteExecutor{}, nil
} }
var ( var glog = log.New("tsdb.graphite")
glog log.Logger
)
func init() { func init() {
glog = log.New("tsdb.graphite")
tsdb.RegisterTsdbQueryEndpoint("graphite", NewGraphiteExecutor) tsdb.RegisterTsdbQueryEndpoint("graphite", NewGraphiteExecutor)
} }
...@@ -52,6 +49,7 @@ func (e *GraphiteExecutor) Query(ctx context.Context, dsInfo *models.DataSource, ...@@ -52,6 +49,7 @@ func (e *GraphiteExecutor) Query(ctx context.Context, dsInfo *models.DataSource,
} }
for _, query := range tsdbQuery.Queries { for _, query := range tsdbQuery.Queries {
glog.Info("graphite", "query", query.Model)
if fullTarget, err := query.Model.Get("targetFull").String(); err == nil { if fullTarget, err := query.Model.Get("targetFull").String(); err == nil {
target = fixIntervalFormat(fullTarget) target = fixIntervalFormat(fullTarget)
} else { } else {
...@@ -79,6 +77,9 @@ func (e *GraphiteExecutor) Query(ctx context.Context, dsInfo *models.DataSource, ...@@ -79,6 +77,9 @@ func (e *GraphiteExecutor) Query(ctx context.Context, dsInfo *models.DataSource,
span.SetTag("target", target) span.SetTag("target", target)
span.SetTag("from", from) span.SetTag("from", from)
span.SetTag("until", until) span.SetTag("until", until)
span.SetTag("datasource_id", dsInfo.Id)
span.SetTag("org_id", dsInfo.OrgId)
defer span.Finish() defer span.Finish()
opentracing.GlobalTracer().Inject( opentracing.GlobalTracer().Inject(
......
...@@ -225,6 +225,7 @@ class MetricsPanelCtrl extends PanelCtrl { ...@@ -225,6 +225,7 @@ class MetricsPanelCtrl extends PanelCtrl {
var metricsQuery = { var metricsQuery = {
timezone: this.dashboard.getTimezone(), timezone: this.dashboard.getTimezone(),
panelId: this.panel.id, panelId: this.panel.id,
dashboardId: this.dashboard.id,
range: this.range, range: this.range,
rangeRaw: this.range.raw, rangeRaw: this.range.raw,
interval: this.interval, interval: this.interval,
......
...@@ -50,6 +50,8 @@ export function GraphiteDatasource(instanceSettings, $q, backendSrv, templateSrv ...@@ -50,6 +50,8 @@ export function GraphiteDatasource(instanceSettings, $q, backendSrv, templateSrv
data: params.join('&'), data: params.join('&'),
headers: { headers: {
'Content-Type': 'application/x-www-form-urlencoded', '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
}, },
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment