Cloud Error Reporting API - Package cloud.google.com/go/errorreporting (v0.3.2) Stay organized with collections Save and categorize content based on your preferences.
Package errorreporting is a Google Cloud Error Reporting library.
Any provided stacktraces must match the format produced byhttps://golang.org/pkg/runtime/#Stackor as perhttps://cloud.google.com/error-reporting/reference/rest/v1beta1/projects.events/report#ReportedErrorEventfor language specific stacktrace formats.
This package is still experimental and subject to change.
Seehttps://cloud.google.com/error-reporting/ for more information.
Client
typeClientstruct{// contains filtered or unexported fields}Client represents a Google Cloud Error Reporting client.
func NewClient
funcNewClient(ctxcontext.Context,projectIDstring,cfgConfig,opts...option.ClientOption)(*Client,error)NewClient returns a new error reporting client. Generally you will wantto create a client on program initialization and use it through the lifetimeof the process.
func (*Client) Close
Close calls Flush, then closes any resources held by the client.Close should be called when the client is no longer needed.
func (*Client) Flush
func(c*Client)Flush()Flush blocks until all currently buffered error reports are sent.
If any errors occurred since the last call to Flush, or thecreation of the client if this is the first call, then Flush reports theerror via the Config.OnError handler.
func (*Client) Report
Report writes an error report. It doesn't block. Errors inwriting the error report can be handled via Config.OnError.
func (*Client) ReportSync
ReportSync writes an error report. It blocks until the entry is written.
Config
typeConfigstruct{// ServiceName identifies the running program and is included in the error reports.// Optional.ServiceNamestring// ServiceVersion identifies the version of the running program and is// included in the error reports.// Optional.ServiceVersionstring// OnError is the function to call if any background// tasks errored. By default, errors are logged.OnErrorfunc(errerror)}Config is additional configuration for Client.
Entry
typeEntrystruct{ErrorerrorReq*http.Request// if error is associated with a request.Userstring// an identifier for the user affected by the error// Stack specifies the stacktrace and call sequence correlated with// the error. Stack's content must match the format specified by// https://cloud.google.com/error-reporting/reference/rest/v1beta1/projects.events/report#ReportedErrorEvent.message// or at least for Go programs, it must match the format produced// by https://golang.org/pkg/runtime/debug/#Stack.//// If Stack is blank, the result of runtime.Stack will be used instead.Stack[]byte}Entry holds information about the reported error.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-10-30 UTC.