gtrace

package
v0.7.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2023 License: MIT Imports: 9 Imported by: 0

README

Google Cloud Trace in Go for Cloud Run and Cloud Functions

PkgGoDev

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

func NewHTTPClient() *http.Client

NewHTTPClient returns a tracing http.Client.

func NewHTTPHandler added in v0.6.6

func NewHTTPHandler() http.Handler

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL