/// <summary>
        /// Shared code for creating <see cref="ErrorReportingExceptionFilter"/>.
        /// </summary>
        /// <param name="projectId">The Google Cloud Platform project ID. If null the project Id will be auto detected.</param>
        /// <param name="serviceName">An identifier of the service, such as the name of the executable or job.
        ///     Cannot be null.</param>
        /// <param name="version">Represents the source code version that the developer provided.
        ///     Cannot be null.</param>
        /// <param name="options">Optional, error reporting options.</param>
        private static ErrorReportingExceptionFilter CreateBase(string projectId, string serviceName, string version,
                                                                ErrorReportingOptions options = null)
        {
            GaxPreconditions.CheckNotNullOrEmpty(serviceName, nameof(serviceName));
            GaxPreconditions.CheckNotNullOrEmpty(version, nameof(version));

            options = options ?? ErrorReportingOptions.Create(projectId);
            var consumer = options.CreateConsumer();

            return(new ErrorReportingExceptionFilter(consumer, serviceName, version));
        }
        /// <summary>
        /// Shared code for creating error reporting middleware
        /// </summary>
        /// <param name="projectId">The Google Cloud Platform project ID. If null the project Id will be auto detected.</param>
        /// <param name="serviceName">An identifier of the service, such as the name of the executable or job.
        ///     Cannot be null.</param>
        /// <param name="version">Represents the source code version that the developer provided.
        ///     Cannot be null.</param>
        /// <param name="options">Optional, error reporting options.</param>
        private static void UseGoogleExceptionLoggingBase(
            this IApplicationBuilder app, string projectId, string serviceName, string version,
            ErrorReportingOptions options = null)
        {
            GaxPreconditions.CheckNotNullOrEmpty(serviceName, nameof(serviceName));
            GaxPreconditions.CheckNotNullOrEmpty(version, nameof(version));

            options = options ?? ErrorReportingOptions.Create(projectId);
            var consumer = options.CreateConsumer();
            var logger   = new ErrorReportingExceptionLogger(consumer, serviceName, version);

            app.UseMiddleware <ErrorReportingExceptionLoggerMiddleware>(logger);
        }