Tracing: Standardize on otel tracing (#75528)
This commit is contained in:
committed by
GitHub
parent
4432c4c75c
commit
e4c1a7a141
@@ -12,6 +12,7 @@ import (
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
|
||||
"github.com/grafana/grafana/pkg/api/datasource"
|
||||
"github.com/grafana/grafana/pkg/infra/httpclient"
|
||||
@@ -142,10 +143,12 @@ func (proxy *DataSourceProxy) HandleRequest() {
|
||||
|
||||
proxy.ctx.Req = proxy.ctx.Req.WithContext(ctx)
|
||||
|
||||
span.SetAttributes("datasource_name", proxy.ds.Name, attribute.Key("datasource_name").String(proxy.ds.Name))
|
||||
span.SetAttributes("datasource_type", proxy.ds.Type, attribute.Key("datasource_type").String(proxy.ds.Type))
|
||||
span.SetAttributes("user", proxy.ctx.SignedInUser.Login, attribute.Key("user").String(proxy.ctx.SignedInUser.Login))
|
||||
span.SetAttributes("org_id", proxy.ctx.SignedInUser.OrgID, attribute.Key("org_id").Int64(proxy.ctx.SignedInUser.OrgID))
|
||||
span.SetAttributes(
|
||||
attribute.String("datasource_name", proxy.ds.Name),
|
||||
attribute.String("datasource_type", proxy.ds.Type),
|
||||
attribute.String("user", proxy.ctx.SignedInUser.Login),
|
||||
attribute.Int64("org_id", proxy.ctx.SignedInUser.OrgID),
|
||||
)
|
||||
|
||||
proxy.addTraceFromHeaderValue(span, "X-Panel-Id", "panel_id")
|
||||
proxy.addTraceFromHeaderValue(span, "X-Dashboard-Id", "dashboard_id")
|
||||
@@ -155,11 +158,11 @@ func (proxy *DataSourceProxy) HandleRequest() {
|
||||
reverseProxy.ServeHTTP(proxy.ctx.Resp, proxy.ctx.Req)
|
||||
}
|
||||
|
||||
func (proxy *DataSourceProxy) addTraceFromHeaderValue(span tracing.Span, headerName string, tagName string) {
|
||||
func (proxy *DataSourceProxy) addTraceFromHeaderValue(span trace.Span, headerName string, tagName string) {
|
||||
panelId := proxy.ctx.Req.Header.Get(headerName)
|
||||
dashId, err := strconv.Atoi(panelId)
|
||||
if err == nil {
|
||||
span.SetAttributes(tagName, dashId, attribute.Key(tagName).Int(dashId))
|
||||
span.SetAttributes(attribute.Int(tagName, dashId))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -109,8 +109,10 @@ func (proxy *PluginProxy) HandleRequest() {
|
||||
|
||||
proxy.ctx.Req = proxy.ctx.Req.WithContext(ctx)
|
||||
|
||||
span.SetAttributes("user", proxy.ctx.SignedInUser.Login, attribute.Key("user").String(proxy.ctx.SignedInUser.Login))
|
||||
span.SetAttributes("org_id", proxy.ctx.SignedInUser.OrgID, attribute.Key("org_id").Int64(proxy.ctx.SignedInUser.OrgID))
|
||||
span.SetAttributes(
|
||||
attribute.String("user", proxy.ctx.SignedInUser.Login),
|
||||
attribute.Int64("org_id", proxy.ctx.SignedInUser.OrgID),
|
||||
)
|
||||
|
||||
proxy.tracer.Inject(ctx, proxy.ctx.Req.Header, span)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user