Set user agent in stackdriver output (#5901)

This commit is contained in:
Javier Kohen 2019-05-24 14:24:14 -04:00 committed by Daniel Nelson
parent 597814ee83
commit adb7a52b93
1 changed files with 3 additions and 1 deletions

View File

@ -12,7 +12,9 @@ import (
monitoring "cloud.google.com/go/monitoring/apiv3" // Imports the Stackdriver Monitoring client package. monitoring "cloud.google.com/go/monitoring/apiv3" // Imports the Stackdriver Monitoring client package.
googlepb "github.com/golang/protobuf/ptypes/timestamp" googlepb "github.com/golang/protobuf/ptypes/timestamp"
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/plugins/outputs" "github.com/influxdata/telegraf/plugins/outputs"
"google.golang.org/api/option"
metricpb "google.golang.org/genproto/googleapis/api/metric" metricpb "google.golang.org/genproto/googleapis/api/metric"
monitoredrespb "google.golang.org/genproto/googleapis/api/monitoredres" monitoredrespb "google.golang.org/genproto/googleapis/api/monitoredres"
monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3" monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
@ -88,7 +90,7 @@ func (s *Stackdriver) Connect() error {
if s.client == nil { if s.client == nil {
ctx := context.Background() ctx := context.Background()
client, err := monitoring.NewMetricClient(ctx) client, err := monitoring.NewMetricClient(ctx, option.WithUserAgent(internal.ProductToken()))
if err != nil { if err != nil {
return err return err
} }