Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spanner: failed to NewClient WithCredentialsJSON, might be caused by newBuiltinMetricsTracerFactory #11194

Open
RainbowDashy opened this issue Nov 26, 2024 · 0 comments
Assignees
Labels
api: spanner Issues related to the Spanner API. triage me I really want to be triaged.

Comments

@RainbowDashy
Copy link

Client

spanner

Environment

go 1.23.2

Code and Dependencies

package spanner_test

import (
	"context"
	"log"
	"testing"

	"cloud.google.com/go/spanner"
	"google.golang.org/api/option"
)

func TestConnect(t *testing.T) {
	ctx := context.Background()
	j := "<service account key in json format>"
	_, err := spanner.NewClient(ctx, "projects/foo/instances/bar/databases/d", option.WithCredentialsJSON([]byte(j)))
	if err != nil {
		log.Fatal(err)
	}
}
go.mod
module modname

go 1.23.2

require (
   	cloud.google.com/go/spanner v1.71.0
)

Expected behavior

I expect no error. But I get the error
credentials: could not find default credentials. See https://cloud.google.com/docs/authentication/external/set-up-adc for more information.

With some debugging, I found out that the error is returned by newBuiltinMetricsTracerFactory at L510.

metricsTracerFactory, err := newBuiltinMetricsTracerFactory(ctx, database, metricsProvider, config.Compression, opts...)

It seems to me that the problem is newBuiltinMetricsTracerFactory doesn't respect the WithCredentialsJSON option.

@RainbowDashy RainbowDashy added the triage me I really want to be triaged. label Nov 26, 2024
@product-auto-label product-auto-label bot added the api: spanner Issues related to the Spanner API. label Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the Spanner API. triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants