예제 #1
0
 /// <summary>
 /// Creates a <see cref="TraceOptions"/>.
 /// </summary>
 /// <param name="qpsSampleRate">Optional, the number of queries traced per second.  The sample rate determines
 ///     how often requests are automatically traced. Defaults to <see cref="DefaultQpsSampleRate"/>.
 /// </param>
 /// <param name="bufferOptions">Optional, the buffer options.  Defaults to a <see cref="BufferType.Timed"/>.</param>
 /// <param name="retryOptions">Optional, the retry options.  Defaults to a <see cref="RetryType.None"/>.</param>
 public static TraceOptions Create(
     double qpsSampleRate = DefaultQpsSampleRate, BufferOptions bufferOptions = null, RetryOptions retryOptions = null)
 {
     return(new TraceOptions(
                qpsSampleRate, bufferOptions ?? BufferOptions.TimedBuffer(), retryOptions ?? RetryOptions.NoRetry()));
 }
 /// <summary>
 /// Creates a <see cref="TraceConfiguration"/>.
 /// </summary>
 /// <param name="qpsSampleRate">Optional, the qps sample rate.  The sample rate determines
 ///     how often requests are automatically traced. Defaults to <see cref="DefaultQpsSampleRate"/>
 /// </param>
 /// <param name="bufferOptions">Optional, the buffer options.  Defaults to a <see cref="BufferType.Timed"/></param>
 public static TraceConfiguration Create(
     double qpsSampleRate = DefaultQpsSampleRate, BufferOptions bufferOptions = null)
 {
     return(new TraceConfiguration(qpsSampleRate, bufferOptions ?? BufferOptions.TimedBuffer()));
 }
예제 #3
0
 /// <summary>
 /// Creates an <see cref="ErrorReportingOptions"/> that will send error events to the
 /// Stackdriver Logging API.
 /// </summary>
 /// <param name="projectId">Optional if running on Google App Engine or Google Compute Engine.
 ///     The Google Cloud Platform project ID. If running on GAE or GCE the project ID will be
 ///     detected from the platform.</param>
 /// <param name="bufferOptions">The buffer options for the error reporter. Defaults to no buffer.</param>
 /// <param name="retryOptions">The retry options for the error reporter. Defaults to no retry.</param>
 public static ErrorReportingOptions Create(
     string projectId = null, BufferOptions bufferOptions = null, RetryOptions retryOptions = null) =>
 Create(EventTarget.ForLogging(projectId), bufferOptions, retryOptions);
예제 #4
0
 /// <summary>
 /// Creates an <see cref="ErrorReportingOptions"/>.
 /// </summary>
 /// <param name="eventTarget">Where the error events should be sent. Cannot be null.</param>
 /// <param name="bufferOptions">The buffer options for the error reporter. Defaults to no buffer.</param>
 /// <param name="retryOptions">The retry options for the error reporter. Defaults to no retry.</param>
 public static ErrorReportingOptions Create(
     EventTarget eventTarget, BufferOptions bufferOptions = null, RetryOptions retryOptions = null) =>
 new ErrorReportingOptions(eventTarget,
                           bufferOptions ?? BufferOptions.NoBuffer(), retryOptions ?? RetryOptions.NoRetry());
예제 #5
0
 private ErrorReportingOptions(EventTarget eventTarget, BufferOptions bufferOptions, RetryOptions retryOptions)
 {
     EventTarget   = GaxPreconditions.CheckNotNull(eventTarget, nameof(eventTarget));
     BufferOptions = GaxPreconditions.CheckNotNull(bufferOptions, nameof(bufferOptions));
     RetryOptions  = GaxPreconditions.CheckNotNull(retryOptions, nameof(retryOptions));
 }
        /// <summary>
        /// Gets a <see cref="IConsumer{T}"/> that wraps the passed in consumer based on the buffer options.
        /// </summary>
        /// <param name="consumer">The consumer to buffer <see cref="T"/> into.</param>
        /// <param name="sizer">A sizer for the type</param>
        /// <param name="options">Buffer options for the buffered consumer</param>
        internal static IConsumer <T> GetConsumer(IConsumer <T> consumer, ISizer <T> sizer, BufferOptions options)
        {
            GaxPreconditions.CheckNotNull(consumer, nameof(consumer));
            GaxPreconditions.CheckNotNull(options, nameof(options));

            switch (options.BufferType)
            {
            case BufferType.Sized:
                GaxPreconditions.CheckNotNull(sizer, nameof(sizer));
                return(SizedBufferingConsumer <T> .Create(consumer, sizer, options.BufferSizeBytes));

            case BufferType.Timed:
                return(TimedBufferingConsumer <T> .Create(consumer, options.BufferWaitTime));

            case BufferType.None:
                return(consumer);

            default:
                throw new ArgumentException($"Invalid BufferType: {options.BufferType}");
            }
        }
예제 #7
0
 /// <summary>
 /// Create a new instance of <see cref="LoggingOptions"/>.
 /// </summary>
 /// <param name="logLevel">Optional, the minimum log level. Defaults to <see cref="LogLevel.Information"/></param>
 /// <param name="logName">Optional, the name of the log. Defaults to 'aspnetcore'.</param>
 /// <param name="labels">Optional, custom labels to be added to log entries.
 /// Keys and values added to <paramref name="labels"/> should not be null.
 /// If they are, an exception will be thrown when attempting to log an entry.
 /// The entry won't be logged and the exception will be propagated depending
 /// on the value of <see cref="RetryOptions.ExceptionHandling"/>.</param>
 /// <param name="monitoredResource">Optional, the monitored resource. The monitored resource will
 /// be automatically detected if it is not set and will default to the global resource if the detection fails.
 /// See: https://cloud.google.com/logging/docs/api/v2/resource-list </param>
 /// <param name="bufferOptions">Optional, the buffer options. Defaults to a <see cref="BufferType.Timed"/></param>
 /// <param name="retryOptions">Optional, the retry options. Defaults to a <see cref="RetryType.None"/></param>
 public static LoggingOptions Create(LogLevel logLevel = LogLevel.Information, string logName = null,
                                     Dictionary <string, string> labels = null, MonitoredResource monitoredResource = null,
                                     BufferOptions bufferOptions        = null, RetryOptions retryOptions = null) =>
 new LoggingOptions(logLevel, logName ?? _baseLogName,
                    labels ?? new Dictionary <string, string>(), monitoredResource ?? MonitoredResourceBuilder.FromPlatform(),
                    bufferOptions ?? BufferOptions.TimedBuffer(), retryOptions ?? RetryOptions.NoRetry());