Giter Site home page Giter Site logo

Comments (6)

odeke-em avatar odeke-em commented on August 19, 2024

@sebglon thank you filing this issue and welcome to the OpenCensus project!

When starting your example code, did you try setting the environment variable GOOGLE_APPLICATION_CREDENTIALS i.e.
GOOGLE_APPLICATION_CREDENTIALS=<the_credentials_file.json> go run main.go?

Perhaps this codelab might be of use for you in the future https://opencensus.io/codelabs/stackdriver/

I would help also if you could paste in the "unauthenicated error" message that you get in its entirety but also a code snippet otherwise we are speculating while debugging the problem.

Thank you.

from opencensus-go-exporter-stackdriver.

odeke-em avatar odeke-em commented on August 19, 2024

Kindly pinging you @sebglon!

from opencensus-go-exporter-stackdriver.

vaijab avatar vaijab commented on August 19, 2024

I ran into the same issue. After few hours of debugging I got to the same place as @sebglon.

I think the logic at https://github.com/census-ecosystem/opencensus-go-exporter-stackdriver/blob/master/stackdriver.go#L238-L251 is potentially incorrect.

Application default credentials do not have projectID set like service account json keys do, so the above code will never be able to figure out project ID. And if projectID is passed in the Options, then the code will not try to find application default credentials.

from opencensus-go-exporter-stackdriver.

dsansot-ru avatar dsansot-ru commented on August 19, 2024

I also ran into this. As @vaijab says, my work around is to use a service account instead of my personal credentials.

Though, this is still not quite right, as I should be able to use a service account from ProjectA to connect to Stackdriver in ProjectB, as long as all the permissions are set up correctly.

from opencensus-go-exporter-stackdriver.

bmhatfield avatar bmhatfield commented on August 19, 2024

Chiming in here - running locally using per-user application-default-credentials, even with full permissions, did not work for stats. Tracing works fine. After creating a service account with the same credentials and exposing that as GOOGLE_APPLICATION_CREDENTIALS, stats exporting began working fine. We also experimented with GOOGLE_APPLICATION_CREDENTIALS pointing to our ~/.config/gcloud/application_default_credentials.json files; that also does not work.

While our running production environment uses per-application service accounts, engineers developing locally don't have full service accounts other than their Google Cloud account enabled in "service account mode" via gcloud auth application-default login. Every Google service except for stackdriver metrics works fine with this "user as a service account" mode.

I'd recommend considering this a bug. I see various reports of folks saying the example code doesn't work for them with an Unauthenticated error - they are likely using application-default credentials, which is broken for Stackdriver Metrics.

from opencensus-go-exporter-stackdriver.

ascherkus avatar ascherkus commented on August 19, 2024

Based on my investigation I think one source of Unauthenticated errors for metrics is caused by a regression introduced by #58.

I was able to rule out the application default credentials authentication issue by building a stand-alone program that issues the same gRPC calls to the monitoring v3 API as the stackdriver exporter. I still need to specify the Project ID as expected.

The clue for me was the error messages:
2019/07/02 19:39:28.874369 stackdriver.go:420: Failed to export to Stackdriver: rpc error: code = Unauthenticated desc = transport: context canceled

Compare the client creation in newStatsExporter():

	ctx, cancel := o.newContextWithTimeout()
	defer cancel()
	client, err := monitoring.NewMetricClient(ctx, opts...)

... with newTraceExporter():

	ctx := o.Context
	if ctx == nil {
		ctx = context.Background()
	}
	client, err := tracingclient.NewClient(ctx, o.TraceClientOptions...)

Digging through the code I believe gRPC does the client connection in the background (i.e., is non-blocking), meaning defer cancel() will get executed once newStatsExporter() completes and the resulting client connection will now use a cancelled context.

Changing the code to use a simple context.Background() object fixes the Unauthenticated issue I was seeing and metrics now show up in Stackdriver.

from opencensus-go-exporter-stackdriver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.