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

            // Sample: ReportErrorEvent
            // Additional: ReportErrorEvent(*,*,*)
            ReportErrorsServiceClient client = ReportErrorsServiceClient.Create();
            ProjectName        projectName   = new ProjectName(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 sample
        }
 /// <summary>Snippet for ReportErrorEvent</summary>
 public void ReportErrorEventResourceNames()
 {
     // Snippet: ReportErrorEvent(ProjectName, ReportedErrorEvent, CallSettings)
     // Create client
     ReportErrorsServiceClient reportErrorsServiceClient = ReportErrorsServiceClient.Create();
     // Initialize request argument(s)
     ProjectName        projectName = ProjectName.FromProject("[PROJECT]");
     ReportedErrorEvent @event      = new ReportedErrorEvent();
     // Make the request
     ReportErrorEventResponse response = reportErrorsServiceClient.ReportErrorEvent(projectName, @event);
     // End snippet
 }
 /// <summary>Snippet for ReportErrorEvent</summary>
 public void ReportErrorEvent()
 {
     // Snippet: ReportErrorEvent(string, ReportedErrorEvent, CallSettings)
     // Create client
     ReportErrorsServiceClient reportErrorsServiceClient = ReportErrorsServiceClient.Create();
     // Initialize request argument(s)
     string             projectName = "projects/[PROJECT]";
     ReportedErrorEvent @event      = new ReportedErrorEvent();
     // Make the request
     ReportErrorEventResponse response = reportErrorsServiceClient.ReportErrorEvent(projectName, @event);
     // End snippet
 }
Пример #4
0
 public void SendReport(Exception ex)
 {
     _client.ReportErrorEvent(_projectName, new ReportedErrorEvent()
     {
         Message        = ex.ToString(),
         ServiceContext = new ServiceContext()
         {
             Service = _serviceName,
             Version = _serviceVersion
         }
     });
 }
Пример #5
0
        /// <inheritdoc />
        public void Receive(IEnumerable <ReportedErrorEvent> events)
        {
            GaxPreconditions.CheckNotNull(events, nameof(events));
            if (!events.Any())
            {
                return;
            }

            foreach (var errorEvent in events)
            {
                _client.ReportErrorEvent(_projectName, errorEvent);
            }
        }
 /// <summary>Snippet for ReportErrorEvent</summary>
 public void ReportErrorEventRequestObject()
 {
     // Snippet: ReportErrorEvent(ReportErrorEventRequest, CallSettings)
     // Create client
     ReportErrorsServiceClient reportErrorsServiceClient = ReportErrorsServiceClient.Create();
     // Initialize request argument(s)
     ReportErrorEventRequest request = new ReportErrorEventRequest
     {
         ProjectNameAsProjectName = ProjectName.FromProject("[PROJECT]"),
         Event = new ReportedErrorEvent(),
     };
     // Make the request
     ReportErrorEventResponse response = reportErrorsServiceClient.ReportErrorEvent(request);
     // End snippet
 }
        public static int Main(string[] args)
        {
            // Read projectId from args
            if (args.Length != 1)
            {
                Console.WriteLine("Usage: Project ID must be passed as first argument.");
                Console.WriteLine();
                return(1);
            }
            string projectId = args[0];

            // Create client
            ReportErrorsServiceClient client = ReportErrorsServiceClient.Create();

            // Initialize request argument(s)
            ProjectName        projectName = new ProjectName(projectId);
            ReportedErrorEvent @event      = new ReportedErrorEvent
            {
                Message        = "[MESSAGE]",
                ServiceContext = new ServiceContext
                {
                    Service = "[SERVICE]",
                },
                Context = new ErrorContext
                {
                    ReportLocation = new SourceLocation
                    {
                        FilePath     = "path/to/file.lang",
                        LineNumber   = 42,
                        FunctionName = "meaningOfLife",
                    },
                },
            };

            // Call API method
            ReportErrorEventResponse response = client.ReportErrorEvent(projectName, @event);

            // Show the result
            Console.WriteLine(response);

            // Success
            Console.WriteLine("Smoke test passed OK");
            return(0);
        }
Пример #8
0
        /// <inheritdoc />
        public override void Log(ExceptionLoggerContext context)
        {
            ReportedErrorEvent errorEvent = CreateReportRequest(context);

            _client.ReportErrorEvent(_projectResourceName, errorEvent);
        }