예제 #1
0
 public HttpCorrelation(
     IOptions <CorrelationInfoOptions> options,
     IHttpContextAccessor httpContextAccessor,
     ICorrelationInfoAccessor <CorrelationInfo> correlationInfoAccessor,
     ILogger <HttpCorrelation> logger)
     : this(Options.Create(CreateHttpCorrelationOptions(options?.Value)), httpContextAccessor, correlationInfoAccessor, logger)
 {
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="CorrelationInfoEnricher{TCorrelationInfo}"/> class.
        /// </summary>
        /// <param name="correlationInfoAccessor">The accessor implementation for the custom <see cref="CorrelationInfo"/> model.</param>
        /// <param name="options">The user-configurable options to change the behavior of the enricher.</param>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="correlationInfoAccessor"/> is <c>null</c>.</exception>
        public CorrelationInfoEnricher(
            ICorrelationInfoAccessor <TCorrelationInfo> correlationInfoAccessor,
            CorrelationInfoEnricherOptions options)
        {
            Guard.NotNull(correlationInfoAccessor, nameof(correlationInfoAccessor), "Requires an correlation accessor to enrich the log events with correlation information");

            Options = options ?? new CorrelationInfoEnricherOptions();
            CorrelationInfoAccessor = correlationInfoAccessor;
        }
예제 #3
0
        public ServiceBusDeadLetterMonitorFunction(IConfiguration configuration, ICorrelationInfoAccessor correlationInfoAccessor, ILogger <ServiceBusDeadLetterMonitorFunction> logger)
        {
            Guard.NotNull(correlationInfoAccessor, nameof(correlationInfoAccessor));
            Guard.NotNull(configuration, nameof(configuration));
            Guard.NotNull(logger, nameof(logger));

            _logger                  = logger;
            _configuration           = configuration;
            _correlationInfoAccessor = correlationInfoAccessor;
        }
        /// <summary>
        /// Adds the <see cref="CorrelationInfoEnricher{TCorrelationInfo}"/> to the logger enrichment configuration which adds the <see cref="CorrelationInfo"/> information from the current context.
        /// </summary>
        /// <param name="enrichmentConfiguration">The configuration to add the enricher.</param>
        /// <param name="correlationInfoAccessor">The accessor implementation for the <see cref="CorrelationInfo"/> model.</param>
        /// <param name="configureOptions">The function to configure the options to change the behavior of the enricher.</param>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="enrichmentConfiguration"/> or <paramref name="correlationInfoAccessor"/> is <c>null</c>.</exception>
        public static LoggerConfiguration WithCorrelationInfo(
            this LoggerEnrichmentConfiguration enrichmentConfiguration,
            ICorrelationInfoAccessor correlationInfoAccessor,
            Action <CorrelationInfoEnricherOptions> configureOptions)
        {
            Guard.NotNull(enrichmentConfiguration, nameof(enrichmentConfiguration), "Requires an enrichment configuration to add the correlation information enricher");
            Guard.NotNull(correlationInfoAccessor, nameof(correlationInfoAccessor), "Requires an correlation accessor to retrieve the correlation information during the enrichment of the log events");

            return(WithCorrelationInfo <CorrelationInfo>(enrichmentConfiguration, correlationInfoAccessor, configureOptions));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CorrelationInfoEnricher{TCorrelationInfo}"/> class.
 /// </summary>
 /// <param name="correlationInfoAccessor">The accessor implementation for the custom <see cref="CorrelationInfo"/> model.</param>
 /// <param name="operationIdPropertyName">The name of the property to enrich the log event with the correlation operation ID.</param>
 /// <param name="transactionIdPropertyName">The name of the property to enrich the log event with the correlation transaction ID.</param>
 /// <exception cref="ArgumentNullException">Thrown when the <paramref name="correlationInfoAccessor"/> is <c>null</c>.</exception>
 /// <exception cref="ArgumentException">Thrown when the <paramref name="operationIdPropertyName"/> or <paramref name="transactionIdPropertyName"/> is blank.</exception>
 public CorrelationInfoEnricher(
     ICorrelationInfoAccessor <TCorrelationInfo> correlationInfoAccessor,
     string operationIdPropertyName,
     string transactionIdPropertyName)
     : this(correlationInfoAccessor, new CorrelationInfoEnricherOptions
 {
     OperationIdPropertyName = operationIdPropertyName,
     TransactionIdPropertyName = transactionIdPropertyName
 })
 {
 }
예제 #6
0
        /// <summary>
        /// Adds the <see cref="CorrelationInfoEnricher{TCorrelationInfo}"/> to the logger enrichment configuration which adds the <see cref="CorrelationInfo"/> information from the current context.
        /// </summary>
        /// <param name="enrichmentConfiguration">The configuration to add the enricher.</param>
        /// <param name="correlationInfoAccessor">The accessor implementation for the <see cref="CorrelationInfo"/> model.</param>
        /// <param name="operationIdPropertyName">The name of the property to enrich the log event with the correlation operation ID.</param>
        /// <param name="transactionIdPropertyName">The name of the property to enrich the log event with the correlation transaction ID.</param>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="enrichmentConfiguration"/> or <paramref name="correlationInfoAccessor"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when the <paramref name="operationIdPropertyName"/> or <paramref name="transactionIdPropertyName"/> is blank.</exception>
        public static LoggerConfiguration WithCorrelationInfo(
            this LoggerEnrichmentConfiguration enrichmentConfiguration,
            ICorrelationInfoAccessor correlationInfoAccessor,
            string operationIdPropertyName   = ContextProperties.Correlation.OperationId,
            string transactionIdPropertyName = ContextProperties.Correlation.TransactionId)
        {
            Guard.NotNull(enrichmentConfiguration, nameof(enrichmentConfiguration), "Requires an enrichment configuration to add the correlation information enricher");
            Guard.NotNull(correlationInfoAccessor, nameof(correlationInfoAccessor), "Requires an correlation accessor to retrieve the correlation information during the enrichment of the log events");
            Guard.NotNullOrWhitespace(operationIdPropertyName, nameof(operationIdPropertyName), "Requires a property name to enrich the log event with the correlation operation ID");
            Guard.NotNullOrWhitespace(transactionIdPropertyName, nameof(transactionIdPropertyName), "Requires a property name to enrich the log event with the correlation transaction ID");

            return(WithCorrelationInfo <CorrelationInfo>(enrichmentConfiguration, correlationInfoAccessor, operationIdPropertyName, transactionIdPropertyName));
        }
예제 #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CorrelationInfoEnricher{TCorrelationInfo}"/> class.
        /// </summary>
        /// <param name="correlationInfoAccessor">The accessor implementation for the custom <see cref="CorrelationInfo"/> model.</param>
        /// <param name="operationIdPropertyName">The name of the property to enrich the log event with the correlation operation ID.</param>
        /// <param name="transactionIdPropertyName">The name of the property to enrich the log event with the correlation transaction ID.</param>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="correlationInfoAccessor"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when the <paramref name="operationIdPropertyName"/> or <paramref name="transactionIdPropertyName"/> is blank.</exception>
        public CorrelationInfoEnricher(
            ICorrelationInfoAccessor <TCorrelationInfo> correlationInfoAccessor,
            string operationIdPropertyName,
            string transactionIdPropertyName)
        {
            Guard.NotNull(correlationInfoAccessor, nameof(correlationInfoAccessor), "Requires an correlation accessor to enrich the log events with correlation information");
            Guard.NotNullOrWhitespace(operationIdPropertyName, nameof(operationIdPropertyName), "Requires a property name to enrich the log event with the correlation operation ID");
            Guard.NotNullOrWhitespace(transactionIdPropertyName, nameof(transactionIdPropertyName), "Requires a property name to enrich the log event with the correlation transaction ID");

            _operationIdPropertyName   = operationIdPropertyName;
            _transactionIdPropertyName = transactionIdPropertyName;

            CorrelationInfoAccessor = correlationInfoAccessor;
        }
        /// <summary>
        /// Adds the <see cref="CorrelationInfoEnricher{TCorrelationInfo}"/> to the logger enrichment configuration which adds the custom <typeparamref name="TCorrelationInfo"/> information from the current context.
        /// </summary>
        /// <typeparam name="TCorrelationInfo">The type of the custom <see cref="CorrelationInfo"/> model.</typeparam>
        /// <param name="enrichmentConfiguration">The configuration to add the enricher.</param>
        /// <param name="correlationInfoAccessor">The accessor implementation for the <typeparamref name="TCorrelationInfo"/> model.</param>
        /// <param name="configureOptions">The function to configure the options to change the behavior of the enricher.</param>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="enrichmentConfiguration"/> or <paramref name="correlationInfoAccessor"/> is <c>null</c>.</exception>
        public static LoggerConfiguration WithCorrelationInfo <TCorrelationInfo>(
            this LoggerEnrichmentConfiguration enrichmentConfiguration,
            ICorrelationInfoAccessor <TCorrelationInfo> correlationInfoAccessor,
            Action <CorrelationInfoEnricherOptions> configureOptions)
            where TCorrelationInfo : CorrelationInfo
        {
            Guard.NotNull(enrichmentConfiguration, nameof(enrichmentConfiguration), "Requires an enrichment configuration to add the correlation information enricher");
            Guard.NotNull(correlationInfoAccessor, nameof(correlationInfoAccessor), "Requires an correlation accessor to retrieve the correlation information during the enrichment of the log events");

            var options = new CorrelationInfoEnricherOptions();

            configureOptions?.Invoke(options);

            return(enrichmentConfiguration.With(new CorrelationInfoEnricher <TCorrelationInfo>(correlationInfoAccessor, options)));
        }
예제 #9
0
        public HttpCorrelation(
            IOptions <HttpCorrelationInfoOptions> options,
            IHttpContextAccessor httpContextAccessor,
            ICorrelationInfoAccessor <CorrelationInfo> correlationInfoAccessor,
            ILogger <HttpCorrelation> logger)
        {
            Guard.NotNull(options, nameof(options), "Requires a set of options to configure the correlation process");
            Guard.NotNull(httpContextAccessor, nameof(httpContextAccessor), "Requires a HTTP context accessor to get the current HTTP context");
            Guard.NotNull(correlationInfoAccessor, nameof(correlationInfoAccessor), "Requires a correlation info instance to set and retrieve the correlation information");
            Guard.NotNull(options.Value, nameof(options.Value), "Requires a value in the set of options to configure the correlation process");

            _httpContextAccessor     = httpContextAccessor;
            _options                 = options.Value;
            _correlationInfoAccessor = correlationInfoAccessor;
            _logger = logger ?? NullLogger <HttpCorrelation> .Instance;
        }
예제 #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CorrelationController"/> class.
 /// </summary>
 public CorrelationController(ICorrelationInfoAccessor correlationInfoAccessor, DiagnosticContext diagnosticContext)
 {
     _correlationInfoAccessor = correlationInfoAccessor;
     _diagnosticContext       = diagnosticContext;
 }
예제 #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CorrelationInfoEnricher{TCorrelationInfo}"/> class.
 /// </summary>
 /// <param name="correlationInfoAccessor">The accessor implementation for the custom <see cref="CorrelationInfo"/> model.</param>
 public TestCorrelationInfoEnricher(ICorrelationInfoAccessor <TestCorrelationInfo> correlationInfoAccessor) :
     base(correlationInfoAccessor)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CorrelationInfoEnricher{TCorrelationInfo}"/> class.
 /// </summary>
 /// <param name="correlationInfoAccessor">The accessor implementation for the custom <see cref="CorrelationInfo"/> model.</param>
 /// <exception cref="ArgumentNullException">Thrown when the <paramref name="correlationInfoAccessor"/> is <c>null</c>.</exception>
 public CorrelationInfoEnricher(ICorrelationInfoAccessor <TCorrelationInfo> correlationInfoAccessor)
     : this(correlationInfoAccessor, ContextProperties.Correlation.OperationId, ContextProperties.Correlation.TransactionId)
 {
 }
예제 #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CorrelationController"/> class.
 /// </summary>
 public CorrelationController(ICorrelationInfoAccessor correlationInfoAccessor)
 {
     _correlationInfoAccessor = correlationInfoAccessor;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="CorrelationInfoAccessorProxy{TCorrelationInfo}"/> class.
        /// </summary>
        internal CorrelationInfoAccessorProxy(ICorrelationInfoAccessor <TCorrelationInfo> correlationInfoAccessor)
        {
            Guard.NotNull(correlationInfoAccessor, nameof(correlationInfoAccessor));

            _correlationInfoAccessor = correlationInfoAccessor;
        }
예제 #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Arcus.Observability.Telemetry.Serilog.Enrichers.CorrelationInfoEnricher`1" /> class.
 /// </summary>
 /// <param name="correlationInfoAccessor">The accessor implementation for the custom <see cref="T:Arcus.Observability.Correlation.CorrelationInfo" /> model.</param>
 public MessageCorrelationInfoEnricher(ICorrelationInfoAccessor <MessageCorrelationInfo> correlationInfoAccessor)
     : base(correlationInfoAccessor)
 {
 }