Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

package com.example.errorreporting;

//[START errorreporting_quickstart]
// [START errorreporting_quickstart]
// [START error_reporting_quickstart]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need both region tags?

Copy link
Member Author

@dzlier-gcp dzlier-gcp Dec 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case yes, because the currently published page refers to this old version.

Once this is submitted, I will post a CL to change the tag in the docs page in google3. And when that's published, I can remove these old tags.

Got to have them both during the transition though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


import com.google.cloud.ServiceOptions;
import com.google.cloud.errorreporting.v1beta1.ReportErrorsServiceClient;
import com.google.devtools.clouderrorreporting.v1beta1.ErrorContext;
Expand All @@ -26,7 +28,7 @@

/**
* Snippet demonstrates using the Stackdriver Error Reporting API to report a custom error event.

* <p>
* This library is not required on App Engine, errors written to stderr are automatically written
* to Stackdriver Error Reporting.
* It is also not required if you are writing logs to Stackdriver Logging.
Expand All @@ -46,21 +48,22 @@ public static void main(String[] args) throws Exception {
// Custom error events require an error reporting location as well.
ErrorContext errorContext = ErrorContext.newBuilder()
.setReportLocation(SourceLocation.newBuilder()
.setFilePath("Test.java")
.setLineNumber(10)
.setFunctionName("myMethod")
.build())
.setFilePath("Test.java")
.setLineNumber(10)
.setFunctionName("myMethod")
.build())
.build();

//Report a custom error event
ReportedErrorEvent customErrorEvent = ReportedErrorEvent.getDefaultInstance()
.toBuilder()
.setMessage("custom error event")
.setContext(errorContext)
.build();
.toBuilder()
.setMessage("custom error event")
.setContext(errorContext)
.build();
// Report an event synchronously, use .reportErrorEventCallable for asynchronous reporting.
reportErrorsServiceClient.reportErrorEvent(projectName, customErrorEvent);
}
}
}
// [END error_reporting_quickstart]
// [END errorreporting_quickstart]