Documentation ¶
Overview ¶
Package stackdriver provides an error handler integration for Stackdriver.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler sends errors to Stackdriver.
func New ¶
func New(client *errorreporting.Client) *Handler
New returns a new Handler.
Example ¶
package main import ( "context" "cloud.google.com/go/errorreporting" "emperror.dev/handler/stackdriver" ) func main() { // Create the client ctx := context.Background() client, err := errorreporting.NewClient(ctx, "my-gcp-project", errorreporting.Config{ ServiceName: "myservice", ServiceVersion: "v1.0", }) if err != nil { // TODO: handle error return } defer client.Close() // Create the handler _ = stackdriver.New(client) }
Output:
Example (WithCredentials) ¶
package main import ( "context" "cloud.google.com/go/errorreporting" "golang.org/x/oauth2/google" "google.golang.org/api/option" "emperror.dev/handler/stackdriver" ) func main() { // Create the client ctx := context.Background() client, err := errorreporting.NewClient( ctx, "my-gcp-project", errorreporting.Config{ ServiceName: "myservice", ServiceVersion: "v1.0", }, option.WithCredentials(&google.Credentials{}), // OR // option.WithCredentialsFile("path/to/google_credentials.json"), ) if err != nil { // TODO: handle error return } defer client.Close() // Create the handler _ = stackdriver.New(client) }
Output:
Click to show internal directories.
Click to hide internal directories.