Skip to content

Commit

Permalink
chore(spanner): add details to fix permission error in native metrics (
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul2393 authored Nov 7, 2024
1 parent 1d074b5 commit ffb6380
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion spanner/metrics_monitoring_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import (
"google.golang.org/genproto/googleapis/api/distribution"
googlemetricpb "google.golang.org/genproto/googleapis/api/metric"
monitoredrespb "google.golang.org/genproto/googleapis/api/monitoredres"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/timestamppb"
)

Expand Down Expand Up @@ -145,7 +147,14 @@ func (me *monitoringExporter) exportTimeSeries(ctx context.Context, rm *otelmetr
Name: name,
TimeSeries: tss[i:j],
}
errs = append(errs, me.client.CreateServiceTimeSeries(ctx, req))
err = me.client.CreateServiceTimeSeries(ctx, req)
if err != nil {
if status.Code(err) == codes.PermissionDenied {
err = fmt.Errorf("%w Need monitoring metric writer permission on project=%s. Follow https://cloud.google.com/spanner/docs/view-manage-client-side-metrics#access-client-side-metrics to set up permissions",
err, me.projectID)
}
}
errs = append(errs, err)
}

return errors.Join(errs...)
Expand Down

0 comments on commit ffb6380

Please sign in to comment.