コード例 #1
0
 /// <summary>
 /// Create a new instance of <see cref="LoggerOptions"/>.
 /// </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 throw 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>
 /// <param name="loggerDiagnosticsOutput">Optional. If set some logger diagnostics info will be written
 /// to the given <see cref="TextWriter"/>. Currently the only diagnostics info we provide is the URL where
 /// the logs written with these options can be found.</param>
 /// <param name="serviceName">A string that represents the version of the service or the source code that logs are written for.
 /// When set, it will be included in the <code>serviceContext</code> field of the log entry JSON payload.</param>
 /// <param name="version">A string that represents the version of the service or the source code that logs are written for.
 /// When set, it will be included in the <code>serviceContext</code> field of the log entry JSON payload.</param>
 public static LoggerOptions CreateWithServiceContext(
     LogLevel logLevel = LogLevel.Information,
     string logName    = null,
     Dictionary <string, string> labels  = null,
     MonitoredResource monitoredResource = null,
     BufferOptions bufferOptions         = null,
     RetryOptions retryOptions           = null,
     TextWriter loggerDiagnosticsOutput  = null,
     string serviceName = null,
     string version     = null)
 {
     logName ??= _baseLogName;
     labels ??= new Dictionary <string, string>();
     monitoredResource ??= MonitoredResourceBuilder.FromPlatform();
     bufferOptions ??= BufferOptions.TimedBuffer();
     retryOptions ??= RetryOptions.NoRetry();
     return(new LoggerOptions(logLevel, logName, labels, monitoredResource, bufferOptions, retryOptions, loggerDiagnosticsOutput, serviceName, version));
 }
コード例 #2
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()));
 }
コード例 #3
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());