NewClient returns a new error reporting client. Generally you will want
to create a client on program initialization and use it through the lifetime
of the process.
Flush blocks until all currently buffered error reports are sent.
If any errors occurred since the last call to Flush, or the
creation of the client if this is the first call, then Flush reports the
error via the Config.OnError handler.
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}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eThis is a Google Cloud Error Reporting library for Go, currently in an experimental phase, subject to change.\u003c/p\u003e\n"],["\u003cp\u003eThe library provides functionalities to report errors to Google Cloud Error Reporting, using \u003ccode\u003eClient\u003c/code\u003e for creating, flushing, and reporting errors.\u003c/p\u003e\n"],["\u003cp\u003eStack traces must adhere to the format specified by the Google Cloud Error Reporting documentation or the format produced by \u003ccode\u003eruntime.Stack\u003c/code\u003e for Go.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eConfig\u003c/code\u003e struct allows setting the \u003ccode\u003eServiceName\u003c/code\u003e, \u003ccode\u003eServiceVersion\u003c/code\u003e, and an \u003ccode\u003eOnError\u003c/code\u003e handler for handling background task errors.\u003c/p\u003e\n"],["\u003cp\u003eError reports are encapsulated within the \u003ccode\u003eEntry\u003c/code\u003e struct, which includes the \u003ccode\u003eError\u003c/code\u003e itself, request information, user identifier, and stack trace details.\u003c/p\u003e\n"]]],[],null,["# Cloud Error Reporting API - Package cloud.google.com/go/errorreporting (v0.3.2)\n\nVersion latestkeyboard_arrow_down\n\n- [0.3.2 (latest)](/go/docs/reference/cloud.google.com/go/errorreporting/latest)\n- [0.3.1](/go/docs/reference/cloud.google.com/go/errorreporting/0.3.1)\n- [0.2.0](/go/docs/reference/cloud.google.com/go/errorreporting/0.2.0)\n- [0.1.0](/go/docs/reference/cloud.google.com/go/errorreporting/0.1.0) \n**Note:** To get more information about this package, such as access to older versions, view [this package on pkg.go.dev](https://pkg.go.dev/cloud.google.com/go/errorreporting). \n\u003cbr /\u003e\n\nPackage errorreporting is a Google Cloud Error Reporting library.\n\nAny provided stacktraces must match the format produced by \u003chttps://golang.org/pkg/runtime/#Stack\u003e\nor as per \u003chttps://cloud.google.com/error-reporting/reference/rest/v1beta1/projects.events/report#ReportedErrorEvent\u003e\nfor language specific stacktrace formats.\n\nThis package is still experimental and subject to change.\n\nSee \u003chttps://cloud.google.com/error-reporting/\u003e for more information. \n\nClient\n------\n\n type Client struct {\n \t// contains filtered or unexported fields\n }\n\nClient represents a Google Cloud Error Reporting client. \n\n### func NewClient\n\n func NewClient(ctx https://pkg.go.dev/context.https://pkg.go.dev/context#Context, projectID https://pkg.go.dev/builtin#string, cfg #cloud_google_com_go_errorreporting_Config, opts ...https://pkg.go.dev/google.golang.org/api/option.https://pkg.go.dev/google.golang.org/api/option#ClientOption) (*#cloud_google_com_go_errorreporting_Client, https://pkg.go.dev/builtin#error)\n\nNewClient returns a new error reporting client. Generally you will want\nto create a client on program initialization and use it through the lifetime\nof the process. \n\n### func (\\*Client) Close\n\n func (c *#cloud_google_com_go_errorreporting_Client) Close() https://pkg.go.dev/builtin#error\n\nClose calls Flush, then closes any resources held by the client.\nClose should be called when the client is no longer needed. \n\n### func (\\*Client) Flush\n\n func (c *#cloud_google_com_go_errorreporting_Client) Flush()\n\nFlush blocks until all currently buffered error reports are sent.\n\nIf any errors occurred since the last call to Flush, or the\ncreation of the client if this is the first call, then Flush reports the\nerror via the Config.OnError handler. \n\n### func (\\*Client) Report\n\n func (c *#cloud_google_com_go_errorreporting_Client) Report(e #cloud_google_com_go_errorreporting_Entry)\n\nReport writes an error report. It doesn't block. Errors in\nwriting the error report can be handled via Config.OnError. \n\n### func (\\*Client) ReportSync\n\n func (c *#cloud_google_com_go_errorreporting_Client) ReportSync(ctx https://pkg.go.dev/context.https://pkg.go.dev/context#Context, e #cloud_google_com_go_errorreporting_Entry) https://pkg.go.dev/builtin#error\n\nReportSync writes an error report. It blocks until the entry is written. \n\nConfig\n------\n\n type Config struct {\n \t// ServiceName identifies the running program and is included in the error reports.\n \t// Optional.\n \tServiceName https://pkg.go.dev/builtin#string\n\n \t// ServiceVersion identifies the version of the running program and is\n \t// included in the error reports.\n \t// Optional.\n \tServiceVersion https://pkg.go.dev/builtin#string\n\n \t// OnError is the function to call if any background\n \t// tasks errored. By default, errors are logged.\n \tOnError func(err https://pkg.go.dev/builtin#error)\n }\n\nConfig is additional configuration for Client. \n\nEntry\n-----\n\n type Entry struct {\n \tError https://pkg.go.dev/builtin#error\n \tReq *https://pkg.go.dev/net/http.https://pkg.go.dev/net/http#Request // if error is associated with a request.\n \tUser https://pkg.go.dev/builtin#string // an identifier for the user affected by the error\n\n \t// Stack specifies the stacktrace and call sequence correlated with\n \t// the error. Stack's content must match the format specified by\n \t// https://cloud.google.com/error-reporting/reference/rest/v1beta1/projects.events/report#ReportedErrorEvent.message\n \t// or at least for Go programs, it must match the format produced\n \t// by https://golang.org/pkg/runtime/debug/#Stack.\n \t//\n \t// If Stack is blank, the result of runtime.Stack will be used instead.\n \tStack []https://pkg.go.dev/builtin#byte\n }\n\nEntry holds information about the reported error."]]