google cloud platform - minimal stackdriver trace client usage failing -
here's minification of using stackdriver trace go client package.
it seems trivial example should work produces error.
package main import ( "context" "flag" "log" "net/http" "cloud.google.com/go/trace" "github.com/davecgh/go-spew/spew" "google.golang.org/api/option" ) var ( projectid = flag.string("projectid", "", "projcect id") serviceaccountkey = flag.string("serviceaccountkey", "", "path serviceacount json") ) func main() { flag.parse() mux := http.newservemux() log.fatalln(http.listenandserve(":9000", trace(*projectid, *serviceaccountkey, mux))) } func trace(projectid string, keypath string, h http.handler) http.handlerfunc { client, err := trace.newclient(context.background(), projectid, option.withserviceaccountfile(keypath)) if err != nil { panic(err) } return func(w http.responsewriter, r *http.request) { s := client.spanfromrequest(r) defer func() { err := s.finishwait(); spew.dump(err) }() h.servehttp(w, r) } } i'm running as:
$ teststackdrivertrace -projectid ${gcloud_project_id} -serviceaccountkey ${path_to_serviceaccount_json} and curling produces:
$ curl -s --header "x-cloud-trace-context: 205445aa7843bc8bf206b120001000/0;o=1" localhost:9000 $ (*googleapi.error)(0xc4203a2c80)(googleapi: error 400: request contains invalid argument., badrequest) what missing?
my traceid 30 bytes long not 32. took example curl https://cloud.google.com/trace/docs/faq 30 bytes.
Comments
Post a Comment