Comments (6)
@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.
Kindly pinging you @sebglon!
from opencensus-go-exporter-stackdriver.
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.
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.
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.
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)
- make travis-ci fails with goimports error in test.pb.go
- PushTraceSpans should return dropped spans instead of good spans
- Go exporter should detect GKE resource labels automatically HOT 10
- Stackdriver fails to export metrics after living long enough HOT 3
- "panic: assignment to entry in nil map" error HOT 4
- The start time must be before the end time for the non-gauge metric HOT 6
- Can't see any metrics after running example code HOT 2
- Unexpectedly large custom metric ingest volume generated HOT 3
- Rebrand to Cloud Monitoring
- Use Zap library for logging to support JSON
- Add an option `OnExport` to exporter
- MetricDescriptor should be created as soon as the view is registered HOT 3
- Traces don't respect X-Cloud-Trace-Context
- 0.13.5 was tagged, but not yet released? HOT 1
- Stop assuming zonal cluster deployment HOT 1
- [Question] Why does this work without calling `view.RegisterExporter` from the OpenCensus library? HOT 2
- go: warning: github.com/prometheus/[email protected]+incompatible: retracted by module author HOT 1
- Security Policy violation SECURITY.md HOT 5
- GetMetricDisplayName option does not work HOT 1
- Error while updating imports: cannot find module providing package github.com/prometheus/prometheus/model/value HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opencensus-go-exporter-stackdriver.