google-cloud-go
google-cloud-go copied to clipboard
datastore: add attribute to trace
Is your feature request related to a problem? Please describe.
When use stackdriver exporter and call datastore client public func (like datastore *Client.Get ),
child span ( like cloud.google.com/go/datastore.*
) added to our parent context(span).
But, added child span has no information like called datastore.Key
, datastore.Query
, etc...
It's more convenient if we can know which key or query related to child span.
Describe the solution you'd like How about calling *Span.AddAttributes when child span started in datastore package?
Describe alternatives you've considered
- Is there any reason (like security reason) that google-cloud-go can't add attribute to stackdriver trace automaticaly?
- If answer is yes, how about adding explicitly interface to add attribute?
Additional context
- Similarly, I have same feature request for other storage (like spanner)
- I tried to execute local test that I modified datastore.go to use trace.TracePrintf ( internal used trace.Annotatef ), but nothing changed at stackdriver trace label's output.
func (c *Client) Get(ctx context.Context, key *Key, dst interface{}) (err error) {
ctx = trace.StartSpan(ctx, "cloud.google.com/go/datastore.Get")
defer func() { trace.EndSpan(ctx, err) }()
+ trace.TracePrintf(ctx, map[string]interface{}{"Key": key.String()}, "my test")
- I found attribute size limits , so it's difficult to add long attribute text like query string .