You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.
I am trying to get Stackdriver tracing working, however... nothing happens. I expect to see traces show up in the Stackdriver UI.
I'm using the instructions from Setting Up Stackdriver Tracing and running a simple local test. I have full access to this test project.
The slightly modified sample code looks like this:
package main
import (
"log""net/http""contrib.go.opencensus.io/exporter/stackdriver""contrib.go.opencensus.io/exporter/stackdriver/propagation""go.opencensus.io/plugin/ochttp""go.opencensus.io/trace"
)
funcmain() {
// Create and register a OpenCensus Stackdriver Trace exporter.exporter, err:=stackdriver.NewExporter(stackdriver.Options{
ProjectID: "<A-CORRECT-PROJECT-ID>",
Location: "brians-mac",
OnError: func(errerror) {
log.Println("Error: ", err)
},
})
iferr!=nil {
log.Fatal(err)
}
trace.RegisterExporter(exporter)
client:=&http.Client{
Transport: &ochttp.Transport{
// Use Google Cloud propagation format.Propagation: &propagation.HTTPFormat{},
},
}
handler:=http.HandlerFunc(func(w http.ResponseWriter, r*http.Request) {
req, _:=http.NewRequest("GET", "https://metadata/users", nil)
// The trace ID from the incoming request will be// propagated to the outgoing request.req=req.WithContext(r.Context())
// The outgoing request will be traced with r's trace ID.if_, err:=client.Do(req); err!=nil {
log.Println(err)
}
})
http.Handle("/foo", ochttp.WithRouteTag(handler, "/foo"))
log.Println("Starting handler on 6060...")
log.Fatal(http.ListenAndServe(":6060", &ochttp.Handler{}))
}
However, nothing happens at all. The only output in the log is because https://metadata/users doesn't exist on my mac, but that should not result in no spans at all sent to Stackdriver, right?
I have Google Application credentials configured via environment variable; however, GCP clients also generally "just work" without that step because I had GCloud enable service-account style access to my account.
I don't know what to troubleshoot, because I get no logged errors nor traces displayed in Stackdriver.
Help, pretty please!
Thank you!
The text was updated successfully, but these errors were encountered:
After reading this issue #100 which indicated that the examples don't work, and suggested that folks try this documentation, I was able to add the following line:
trace.ApplyConfig(trace.Config{DefaultSampler: trace.AlwaysSample()}) and then traces appeared in Stackdriver.
This is my first foray into tracing and I didn't have enough context to know a priori that my traces will be dropped due to sampling. I'd like to add on to #100's concern that the examples are insufficient.
Leaving this ticket open as a documentation ticket.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi,
I am trying to get Stackdriver tracing working, however... nothing happens. I expect to see traces show up in the Stackdriver UI.
I'm using the instructions from Setting Up Stackdriver Tracing and running a simple local test. I have full access to this test project.
The slightly modified sample code looks like this:
However, nothing happens at all. The only output in the log is because
https://metadata/users
doesn't exist on my mac, but that should not result in no spans at all sent to Stackdriver, right?I have Google Application credentials configured via environment variable; however, GCP clients also generally "just work" without that step because I had GCloud enable service-account style access to my account.
I don't know what to troubleshoot, because I get no logged errors nor traces displayed in Stackdriver.
Help, pretty please!
Thank you!
The text was updated successfully, but these errors were encountered: