public void ReportErrorEvent()
        {
            string projectId = _fixture.ProjectId;

            // Snippet: ReportErrorEvent
            ReportErrorsServiceClient client = ReportErrorsServiceClient.Create();
            string             projectName   = ReportErrorsServiceClient.FormatProjectName(projectId);
            ReportedErrorEvent error         = new ReportedErrorEvent
            {
                Context = new ErrorContext
                {
                    ReportLocation = new SourceLocation
                    {
                        FilePath     = "SampleApp.BusinessLogic/ComplexLogic.cs",
                        FunctionName = "ComputeTrickyAnswer",
                        LineNumber   = 100
                    },
                    User = "******"
                },

                // If this is a stack trace, the service will parse it.
                Message = "Computation failed",

                EventTime      = Timestamp.FromDateTime(DateTime.UtcNow),
                ServiceContext = new ServiceContext
                {
                    Service = "SampleApp",
                    Version = "1.0.0"
                }
            };

            client.ReportErrorEvent(projectName, error);
            // End snippet
        }
Esempio n. 2
0
 private CloudErrorReportingExceptionLogger(
     ReportErrorsServiceClient client, string projectId, string serviceName, string version) : base()
 {
     _client = GaxPreconditions.CheckNotNull(client, nameof(client));
     _projectResourceName = ReportErrorsServiceClient.FormatProjectName(
         GaxPreconditions.CheckNotNull(projectId, nameof(projectId)));
     _serviceContext = new ServiceContext
     {
         Service = GaxPreconditions.CheckNotNull(serviceName, nameof(serviceName)),
         Version = GaxPreconditions.CheckNotNull(version, nameof(version)),
     };
 }
 public void ReportErrorEvent()
 {
     // Snippet: ReportErrorEvent(string,ReportedErrorEvent,CallSettings)
     // Create client
     ReportErrorsServiceClient reportErrorsServiceClient = ReportErrorsServiceClient.Create();
     // Initialize request argument(s)
     string formattedProjectName = ReportErrorsServiceClient.FormatProjectName("[PROJECT]");
     ReportedErrorEvent @event = new ReportedErrorEvent();
     // Make the request
     ReportErrorEventResponse response = reportErrorsServiceClient.ReportErrorEvent(formattedProjectName, @event);
     // End snippet
 }
 public async Task ReportErrorEventAsync()
 {
     // Snippet: ReportErrorEventAsync(string,ReportedErrorEvent,CallSettings)
     // Additional: ReportErrorEventAsync(string,ReportedErrorEvent,CancellationToken)
     // Create client
     ReportErrorsServiceClient reportErrorsServiceClient = ReportErrorsServiceClient.Create();
     // Initialize request argument(s)
     string formattedProjectName = ReportErrorsServiceClient.FormatProjectName("[PROJECT]");
     ReportedErrorEvent @event = new ReportedErrorEvent();
     // Make the request
     ReportErrorEventResponse response = await reportErrorsServiceClient.ReportErrorEventAsync(formattedProjectName, @event);
     // End snippet
 }