Documentation ¶
Overview ¶
Package gtrace implements tracing for Google Cloud Run and Cloud Functions.
Example ¶
package main import ( "net/http" "os" "github.com/ncruces/go-gcp/glog" "github.com/ncruces/go-gcp/gtrace" ) func main() { go gtrace.Init() glog.Notice("Starting server...") port := os.Getenv("PORT") if port == "" { port = "8080" } http.HandleFunc("/", http.NotFound) glog.Critical(http.ListenAndServe(":"+port, gtrace.NewHTTPHandler())) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ProjectID string = os.Getenv("GOOGLE_CLOUD_PROJECT")
ProjectID should be set to the Google Cloud project ID.
Functions ¶
func Init ¶
func Init() (err error)
Init initializes Cloud Trace. Can be called multiple times. Logs the error if called asynchronously.
func NewHTTPClient ¶ added in v0.6.6
NewHTTPClient returns a tracing http.Client.
func NewHTTPHandler ¶ added in v0.6.6
NewHTTPHandler returns a tracing http.Handler.
func NewHTTPTransport ¶ added in v0.6.6
func NewHTTPTransport() http.RoundTripper
NewHTTPTransport returns a tracing http.RoundTripper.
Types ¶
type HTTPFormat ¶
type HTTPFormat struct {
propagation.HTTPFormat
}
HTTPFormat implements propagation.HTTPFormat to propagate traces in HTTP headers for Cloud Trace.
Click to show internal directories.
Click to hide internal directories.