// The Initialize method is not thread-safe. Please only call this on one thread and do so before the pipeline starts sending // data to this output private void Initialize(EventHubOutputConfiguration configuration) { Debug.Assert(configuration != null); Debug.Assert(this.healthReporter != null); if (string.IsNullOrWhiteSpace(configuration.ConnectionString)) { var errorMessage = $"{nameof(EventHubOutput)}: '{nameof(EventHubOutputConfiguration.ConnectionString)}' configuration parameter must be set to a valid connection string"; healthReporter.ReportProblem(errorMessage, EventFlowContextIdentifiers.Configuration); throw new Exception(errorMessage); } EventHubsConnectionStringBuilder connStringBuilder = new EventHubsConnectionStringBuilder(configuration.ConnectionString); this.eventHubName = connStringBuilder.EntityPath ?? configuration.EventHubName; if (string.IsNullOrWhiteSpace(this.eventHubName)) { var errorMessage = $"{nameof(EventHubOutput)}: Event Hub name must not be empty. It can be specified in the '{nameof(EventHubOutputConfiguration.ConnectionString)}' or '{nameof(EventHubOutputConfiguration.EventHubName)}' configuration parameter"; healthReporter.ReportProblem(errorMessage, EventFlowContextIdentifiers.Configuration); throw new Exception(errorMessage); } connStringBuilder.EntityPath = this.eventHubName; this.clients = new EventHubClient[ConcurrentConnections]; for (uint i = 0; i < this.clients.Length; i++) { this.clients[i] = EventHubClient.CreateFromConnectionString(connStringBuilder.ToString()); } }
public EtwInput(IConfiguration configuration, IHealthReporter healthReporter) { Requires.NotNull(configuration, nameof(configuration)); Requires.NotNull(healthReporter, nameof(healthReporter)); IConfiguration providersConfiguration = configuration.GetSection(ProvidersSectionName); if (providersConfiguration == null) { healthReporter.ReportProblem($"{nameof(EtwInput)}: required configuration section '{ProvidersSectionName}' is missing"); return; } var providers = new List <EtwProviderConfiguration>(); try { providersConfiguration.Bind(providers); } catch { healthReporter.ReportProblem($"{nameof(EtwInput)}: configuration is invalid", EventFlowContextIdentifiers.Configuration); return; } Initialize(providers, healthReporter); }
public EventSourceInput(IConfiguration configuration, IHealthReporter healthReporter) { Requires.NotNull(configuration, nameof(configuration)); Requires.NotNull(healthReporter, nameof(healthReporter)); IConfiguration sourcesConfiguration = configuration.GetSection("sources"); if (sourcesConfiguration == null) { healthReporter.ReportProblem($"{nameof(EventSourceInput)}: required configuration section 'sources' is missing"); return; } var eventSources = new List <EventSourceConfiguration>(); try { sourcesConfiguration.Bind(eventSources); } catch { healthReporter.ReportProblem($"{nameof(EventSourceInput)}: configuration is invalid", EventFlowContextIdentifiers.Configuration); return; } Initialize(eventSources, healthReporter); }
public EtwInput(IConfiguration configuration, IHealthReporter healthReporter) { Requires.NotNull(configuration, nameof(configuration)); Requires.NotNull(healthReporter, nameof(healthReporter)); string sessionNamePrefix = configuration.GetValue <string>("sessionNamePrefix", DefaultSessionnamePrefix); bool cleanupOldSessions = configuration.GetValue <bool>("cleanupOldSessions", false); bool reuseExistingSession = configuration.GetValue <bool>("reuseExistingSession", false); IConfiguration providersConfiguration = configuration.GetSection(ProvidersSectionName); if (providersConfiguration == null) { healthReporter.ReportProblem($"{nameof(EtwInput)}: required configuration section '{ProvidersSectionName}' is missing"); return; } var providers = new List <EtwProviderConfiguration>(); try { providersConfiguration.Bind(providers); } catch { healthReporter.ReportProblem($"{nameof(EtwInput)}: configuration is invalid", EventFlowContextIdentifiers.Configuration); return; } Initialize(providers, sessionNamePrefix, cleanupOldSessions, reuseExistingSession, healthReporter); }
public EventMetadataFilter CreateItem(IConfiguration configuration, IHealthReporter healthReporter) { Requires.NotNull(configuration, nameof(configuration)); Requires.NotNull(healthReporter, nameof(healthReporter)); var metadataFilterConfiguration = new EventMetadataFilterConfiguration(); try { configuration.Bind(metadataFilterConfiguration); } catch { healthReporter.ReportProblem($"{nameof(EventMetadataFilterFactory)}: configuration is invalid for filter {configuration.ToString()}"); return(null); } if (string.IsNullOrWhiteSpace(metadataFilterConfiguration.Metadata)) { healthReporter.ReportProblem($"{nameof(EventMetadataFilterFactory)}: metadata type ('metadata' property) must be specified for metadata filter"); return(null); } var metadata = new EventMetadata(metadataFilterConfiguration.Metadata); var filter = new EventMetadataFilter(metadata, metadataFilterConfiguration.Include); foreach (var configurationProperty in configuration.AsEnumerable()) { if (configurationProperty.Value == null) { // The enumerable includes an item that represents the whole configuration fragment. It's value is null continue; } // The Key property contains full path, with path elements separated by colons. We need to extract the last path fragment int lastColonIndex = configurationProperty.Key.LastIndexOf(':'); if (lastColonIndex < 0 || lastColonIndex == configurationProperty.Key.Length - 1) { continue; } string propertyName = configurationProperty.Key.Substring(lastColonIndex + 1); // Do not store generic metadata filter properties if (nameof(EventMetadataFilterConfiguration.Metadata).Equals(propertyName, StringComparison.OrdinalIgnoreCase) || nameof(ItemConfiguration.Type).Equals(propertyName, StringComparison.OrdinalIgnoreCase) || nameof(EventMetadataFilterConfiguration.Include).Equals(propertyName, StringComparison.OrdinalIgnoreCase)) { continue; } metadata.Properties[propertyName] = configurationProperty.Value; } return(filter); }
private IEventHubClient CreateEventHubClient(EventHubOutputConfiguration _) { Debug.Assert(this.outputConfiguration != null); if (this.outputConfiguration.UseAzureIdentity) { this.eventHubName = this.outputConfiguration.EventHubName; ensureEventHubName(); if (string.IsNullOrWhiteSpace(this.outputConfiguration.FullyQualifiedNamespace)) { var emptyNamespaceMsg = $"{nameof(EventHubOutput)}: Event Hub namespace must not be empty when using Azure Identity. It can be specified in the '{nameof(EventHubOutputConfiguration.FullyQualifiedNamespace)}' configuration parameter"; healthReporter.ReportProblem(emptyNamespaceMsg, EventFlowContextIdentifiers.Configuration); throw new Exception(emptyNamespaceMsg); } TokenCredential azureTokenCredential = this.outputConfiguration.AzureTokenCredential ?? new DefaultAzureCredential(); return(new EventHubClientImpl( new EventHubProducerClient(this.outputConfiguration.FullyQualifiedNamespace, this.eventHubName, azureTokenCredential) )); } if (!string.IsNullOrWhiteSpace(this.outputConfiguration.ConnectionString)) { var connString = EventHubsConnectionStringProperties.Parse(this.outputConfiguration.ConnectionString); this.eventHubName = connString.EventHubName ?? this.outputConfiguration.EventHubName; ensureEventHubName(); return(new EventHubClientImpl( new EventHubProducerClient(this.outputConfiguration.ConnectionString, this.eventHubName) )); } var invalidConfigMsg = $"Invalid {nameof(EventHubOutput)} configuration encountered: '{nameof(EventHubOutputConfiguration.ConnectionString)}' value is empty and '{nameof(EventHubOutputConfiguration.UseAzureIdentity)}' is set to false. " + $"You need to specify either '{nameof(EventHubOutputConfiguration.ConnectionString)}' to EventHub or set '{nameof(EventHubOutputConfiguration.UseAzureIdentity)}' flag."; healthReporter.ReportProblem(invalidConfigMsg, EventFlowContextIdentifiers.Configuration); throw new Exception(invalidConfigMsg); void ensureEventHubName() { if (string.IsNullOrWhiteSpace(this.eventHubName)) { var emptyEventHubNameMsg = $"{nameof(EventHubOutput)}: Event Hub name must not be empty. It can be specified in the '{nameof(EventHubOutputConfiguration.ConnectionString)}' or '{nameof(EventHubOutputConfiguration.EventHubName)}' configuration parameter"; healthReporter.ReportProblem(emptyEventHubNameMsg); throw new Exception(emptyEventHubNameMsg); } } }
private static void ReportSectionEmptyAndThrow(IHealthReporter healthReporter, IConfigurationSection configurationSection) { var errMsg = $"{nameof(DiagnosticPipelineFactory)}: '{configurationSection.Key}' configuration section is empty"; healthReporter.ReportProblem(errMsg); throw new Exception(errMsg); }
/// <summary> /// Sends the events asynchronous. /// </summary> /// <param name="events">The events.</param> /// <param name="transmissionSequenceNumber">The transmission sequence number.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns></returns> public Task SendEventsAsync(IReadOnlyCollection <EventData> events, long transmissionSequenceNumber, CancellationToken cancellationToken) { if (events == null || !events.Any()) { return(CompletedTask); } try { foreach (var evt in events) { if (cancellationToken.IsCancellationRequested) { return(CompletedTask); } var level = evt.Level.ToString(); RIExtendedMessageProperty.AttachToRequest(TraceTag, "Provider", evt.ProviderName); RIExtendedMessageProperty.AttachToRequest(TraceTag, "Level", level); evt.Payload.TryGetValue("Message", out object message); _reflectInsight.SendJSON($"[{level}] {(message as string) ?? evt.ProviderName}", evt); } _healthReporter.ReportHealthy(); return(CompletedTask); } catch (Exception ex) { _healthReporter.ReportProblem($"{TraceTag}: Fail to send events in batch. Error details: {ex.ToString()}"); throw; } }
private static void ReportNoItemsCreatedAndThrow(IHealthReporter healthReporter, IConfigurationSection configurationSection) { var errMsg = $"{nameof(DiagnosticPipelineFactory)}: could not create any pipeline items out of configuration section '{configurationSection.Key}'"; healthReporter.ReportProblem(errMsg); throw new Exception(errMsg); }
private static void ReportUnknownItemTypeAndThrow(IHealthReporter healthReporter, IConfigurationSection configurationSection, ItemConfiguration itemConfiguration) { var errMsg = $"{nameof(DiagnosticPipelineFactory)}: unknown type '{itemConfiguration.Type}' in configuration section '{configurationSection.Path}'"; healthReporter.ReportProblem(errMsg); throw new Exception(errMsg); }
private void Initialize(PerformanceCounterInputConfiguration configuration, IHealthReporter healthReporter) { this.syncObject = new object(); this.subject = new EventFlowSubject <EventData>(); this.healthReporter = healthReporter; this.processInstanceNameCache = new ProcessInstanceNameCache(); this.sampleInterval = TimeSpan.FromMilliseconds(configuration.SampleIntervalMsec); var currentProcess = Process.GetCurrentProcess(); this.currentProcessName = currentProcess.ProcessName; this.currentProcessId = currentProcess.Id; // The CLR Process ID counter used for process ID to counter instance name mapping for CLR counters will not read correctly // until at least one garbage collection is performed, so we will force one now. // The listener is usually created during service startup so the GC should not take very long. GC.Collect(); this.trackedPerformanceCounters = new List <TrackedPerformanceCounter>(); foreach (var counterConfiguration in configuration.Counters) { if (!counterConfiguration.Validate()) { healthReporter.ReportProblem($"{nameof(PerformanceCounterInput)}: configuration for counter {counterConfiguration.CounterName} is invalid"); } else { this.trackedPerformanceCounters.Add(new TrackedPerformanceCounter(counterConfiguration)); } } this.collectionTimer = new Timer(this.DoCollection, null, this.sampleInterval, TimeSpan.FromDays(1)); }
private static void ReportInvalidConfigurationFragmentAndThrow(IHealthReporter healthReporter, IConfigurationSection itemFragment) { // It would be ideal to print the whole fragment, but we didn't find a way to serialize the configuration. So we give the configuration path instead. var errMsg = $"{nameof(DiagnosticPipelineFactory)}: invalid configuration fragment '{itemFragment.Path}'"; healthReporter.ReportProblem(errMsg); throw new Exception(errMsg); }
// The Initialize method is not thread-safe. Please only call this on one thread and do so before the pipeline starts sending // data to this output private void Initialize() { Debug.Assert(this.healthReporter != null); if (string.IsNullOrWhiteSpace(this.outputConfiguration.ConnectionString)) { var errorMessage = $"{nameof(EventHubOutput)}: '{nameof(EventHubOutputConfiguration.ConnectionString)}' configuration parameter must be set to a valid connection string"; healthReporter.ReportProblem(errorMessage, EventFlowContextIdentifiers.Configuration); throw new Exception(errorMessage); } this.clients = new IEventHubClient[ConcurrentConnections]; for (uint i = 0; i < this.clients.Length; i++) { this.clients[i] = this.eventHubClientFactory(this.outputConfiguration.ConnectionString); } }
private void Initialize(List <EventSourceConfiguration> eventSources, IHealthReporter healthReporter) { this.healthReporter = healthReporter; this.subject = new EventFlowSubject <EventData>(); if (eventSources.Count() == 0) { healthReporter.ReportWarning($"{nameof(EventSourceInput)}: no event sources configured, the input will not produce any data", EventFlowContextIdentifiers.Configuration); } var invalidConfigurationItems = new List <EventSourceConfiguration>(); foreach (var eventSourceConfiguration in eventSources) { if (!eventSourceConfiguration.Validate()) { healthReporter.ReportProblem($"{nameof(EventSourceInput)}: configuration for one of the sources is invalid", EventFlowContextIdentifiers.Configuration); invalidConfigurationItems.Add(eventSourceConfiguration); } } // eventSources is a collection created by us, so we can modify it as necessary eventSources.RemoveAll(config => invalidConfigurationItems.Contains(config)); // Special case: because of .NET bug https://github.com/dotnet/coreclr/issues/14434, using Microsoft-ApplicationInsights-Data will result in infinite loop. // So we will disable it by default, unless there is explicit configuration for this EventSource bool hasConfigForAppInsightsDataSource = eventSources.Any(config => AppInsightsDataEventSource.Equals(config.ProviderName, StringComparison.Ordinal) || AppInsightsDataEventSource.Equals(config.DisabledProviderNamePrefix, StringComparison.Ordinal)); if (!hasConfigForAppInsightsDataSource) { eventSources.Add(new EventSourceConfiguration() { DisabledProviderNamePrefix = AppInsightsDataEventSource }); } this.EventSources = eventSources; bool haveDisabledSources = this.EventSources.Any(config => !string.IsNullOrWhiteSpace(config.DisabledProviderNamePrefix)); if (haveDisabledSources) { this.disabledSources = new ConcurrentDictionary <string, bool>(); this.OnEventWrittenImpl = BroadcastEventIfSourceNotDisabled; } else { this.OnEventWrittenImpl = BroadcastEvent; } // Make sure the constructor has run to completion before enabling any sources. this.initialization = Task.Run(() => { this.constructed = true; EnableInitialSources(); }); }
private static void ReportItemCreationFailedAndThrow(IHealthReporter healthReporter, string itemType, Exception e = null) { string errMsg = $"{nameof(DiagnosticPipelineFactory)}: item of type '{itemType}' could not be created"; if (e != null) { errMsg += Environment.NewLine + e.ToString(); } healthReporter.ReportProblem(errMsg); throw new Exception(errMsg); }
private static IReadOnlyCollection <DiagnosticSourceConfiguration> GetSources(IConfiguration configuration, IHealthReporter healthReporter) { var sources = new List <DiagnosticSourceConfiguration>(); var sourcesConfiguration = configuration.GetSection("sources"); if (sourcesConfiguration == null) { healthReporter.ReportProblem($"{nameof(DiagnosticSourceInput)}: required configuration section 'sources' is missing"); return(sources); } try { sourcesConfiguration.Bind(sources); } catch { healthReporter.ReportProblem($"{nameof(DiagnosticSourceInput)}: configuration is invalid", EventFlowContextIdentifiers.Configuration); } return(sources); }
private CloudTable CreateTableClient(IConfiguration configuration, IHealthReporter healthReporter) { string accountConnectionString = configuration["StorageAccountConnectionString"]; string sasToken = configuration["StorageAccountSasToken"]; if (string.IsNullOrWhiteSpace(sasToken) && string.IsNullOrWhiteSpace(accountConnectionString)) { healthReporter.ReportProblem($"{nameof(TableStorageSender)}: configuration must specify either the storage account connection string ('StorageAccountConnectionString' parameter) or SAS token ('StorageAccountSasToken' paramteter)"); return(null); } string storageTableName = configuration["StorageTableName"]; if (string.IsNullOrWhiteSpace(storageTableName)) { healthReporter.ReportProblem($"{nameof(TableStorageSender)}: configuration must specify the target storage name ('storageTableName' parameter)"); return(null); } CloudStorageAccount storageAccount = string.IsNullOrWhiteSpace(sasToken) ? CloudStorageAccount.Parse(accountConnectionString) : new CloudStorageAccount(new StorageCredentials(sasToken), useHttps: true); var cloudTable = storageAccount.CreateCloudTableClient().GetTableReference(storageTableName); try { cloudTable.CreateIfNotExists(); } catch (Exception e) { healthReporter.ReportProblem($"{nameof(TableStorageSender)}: could not ensure that destination Azure storage table exists{Environment.NewLine}{e.ToString()}"); throw; } return(cloudTable); }
public SplunkOutputConfiguration Create(IConfiguration configuration, IHealthReporter healthReporter) { var splunkOutputConfiguration = new SplunkOutputConfiguration(); try { configuration.Bind(splunkOutputConfiguration); } catch { healthReporter.ReportProblem($"Invalid {nameof(SplunkOutput)} configuration encountered: '{configuration}'", EventFlowContextIdentifiers.Configuration); throw; } if (string.IsNullOrWhiteSpace(splunkOutputConfiguration.ServiceBaseAddress)) { var errorMessage = $"{nameof(SplunkOutput)}: 'serviceBaseAddress' configuration parameter is not set"; healthReporter.ReportProblem(errorMessage, EventFlowContextIdentifiers.Configuration); throw new Exception(errorMessage); } if (string.IsNullOrWhiteSpace(splunkOutputConfiguration.AuthenticationToken)) { var errorMessage = $"{nameof(SplunkOutput)}: 'authenticationToken' configuration parameter is not set"; healthReporter.ReportProblem(errorMessage, EventFlowContextIdentifiers.Configuration); throw new Exception(errorMessage); } splunkOutputConfiguration.Host = !string.IsNullOrWhiteSpace(splunkOutputConfiguration.Host) ? splunkOutputConfiguration.Host : Environment.MachineName; splunkOutputConfiguration.Index = !string.IsNullOrWhiteSpace(splunkOutputConfiguration.Index) ? splunkOutputConfiguration.Index : null; splunkOutputConfiguration.Source = !string.IsNullOrWhiteSpace(splunkOutputConfiguration.Source) ? splunkOutputConfiguration.Source : null; splunkOutputConfiguration.SourceType = !string.IsNullOrWhiteSpace(splunkOutputConfiguration.SourceType) ? splunkOutputConfiguration.SourceType : null; return(splunkOutputConfiguration); }
private IEnumerable <Uri> GetEsServiceUriList(IHealthReporter healthReporter) { var esServiceUri = ServiceUri .Split(';') .Where(x => Uri.IsWellFormedUriString(x, UriKind.Absolute)) .Select(x => new Uri(x)) .ToList(); if (!esServiceUri.Any()) { //Invalid config string report and throw var errorMessage = $"{nameof(ElasticSearchOutput)}: required 'serviceUri' configuration parameter is invalid"; healthReporter.ReportProblem(errorMessage, EventFlowContextIdentifiers.Configuration); throw new Exception(errorMessage); } return(esServiceUri); }
public SqlTableOutput(IConfiguration configuration, IHealthReporter healthReporter) { _healthReporter = healthReporter; Configuration = new SqlTableOutputConfiguration(); try { configuration.Bind(Configuration); Initialize(); } catch { _healthReporter.ReportProblem($"{nameof(SqlTableOutput)}: Invalid {nameof(SqlTableOutput)} configuration encountered: '{configuration.ToString()}'", EventFlowContextIdentifiers.Configuration); throw; } }
public async Task SendEventsAsync(IReadOnlyCollection <EventData> events, long transmissionSequenceNumber, CancellationToken cancellationToken) { try { await splunkHttpEventCollectorClient.SendEventsAsync(events, cancellationToken); healthReporter.ReportHealthy(); } catch (Exception e) { ErrorHandlingPolicies.HandleOutputTaskError(e, () => { string errorMessage = $"{nameof(SplunkOutput)}: An error occurred while sending data to Splunk. Exception: {e}"; healthReporter.ReportProblem(errorMessage, EventFlowContextIdentifiers.Output); }); } }
private void DoCollection(object state) { float counterValue; lock (this.syncObject) { var collectionStartTime = DateTime.Now; this.processInstanceNameCache.Clear(); foreach (TrackedPerformanceCounter counter in this.trackedPerformanceCounters) { try { if (counter.SampleNextValue(this.processInstanceNameCache, out counterValue)) { EventData d = new EventData(); d.Payload[CounterNameProperty] = counter.Configuration.CounterName; d.Payload[CounterCategoryProperty] = counter.Configuration.CounterCategory; d.Payload[MetricValueProperty] = counterValue; d.Payload[ProcessIdProperty] = this.currentProcessId; d.Payload[ProcessNameProperty] = this.currentProcessName; d.Timestamp = DateTimeOffset.UtcNow; d.Level = LogLevel.Informational; d.ProviderName = PerformanceCounterInputProviderName; this.subject.OnNext(d); } } catch (Exception e) { healthReporter.ReportProblem( $"{nameof(PerformanceCounterInput)}: an error occurred when sampling performance counter {counter.Configuration.CounterName} " + $"in category {counter.Configuration.CounterCategory}{Environment.NewLine}{e.ToString()}"); } } TimeSpan dueTime = this.sampleInterval - (DateTime.Now - collectionStartTime); if (dueTime < MinimumCollectionInterval) { dueTime = MinimumCollectionInterval; } this.collectionTimer.Change(dueTime, TimeSpan.FromDays(1)); } }
private void Initialize(List <EventSourceConfiguration> eventSources, IHealthReporter healthReporter) { this.healthReporter = healthReporter; this.subject = new EventFlowSubject <EventData>(); if (eventSources.Count() == 0) { healthReporter.ReportWarning($"{nameof(EventSourceInput)}: no event sources configured", EventFlowContextIdentifiers.Configuration); } var invalidConfigurationItems = new List <EventSourceConfiguration>(); foreach (var eventSourceConfiguration in eventSources) { if (!eventSourceConfiguration.Validate()) { healthReporter.ReportProblem($"{nameof(EventSourceInput)}: configuration for one of the sources is invalid", EventFlowContextIdentifiers.Configuration); invalidConfigurationItems.Add(eventSourceConfiguration); } } // eventSources is a collection created by us, so we can modify it as necessary eventSources.RemoveAll(config => invalidConfigurationItems.Contains(config)); this.EventSources = eventSources; bool haveDisabledSources = this.EventSources.Any(config => !string.IsNullOrWhiteSpace(config.DisabledProviderNamePrefix)); if (haveDisabledSources) { this.disabledSources = new ConcurrentDictionary <string, bool>(); this.OnEventWrittenImpl = BroadcastEventIfSourceNotDisabled; } else { this.OnEventWrittenImpl = BroadcastEvent; } // Make sure the constructor has run to completion before enabling any sources. this.initialization = Task.Run(() => { this.constructed = true; EnableInitialSources(); }); }
public PerformanceCounterInput(IConfiguration configuration, IHealthReporter healthReporter) { Requires.NotNull(configuration, nameof(configuration)); Requires.NotNull(healthReporter, nameof(healthReporter)); var inputConfiguration = new PerformanceCounterInputConfiguration(); try { configuration.Bind(inputConfiguration); } catch (Exception e) { healthReporter.ReportProblem($"{nameof(PerformanceCounterInput)}: an error occurred when reading configuration{Environment.NewLine}{e.ToString()}"); return; } Initialize(inputConfiguration, healthReporter); }
public DropFilter CreateItem(IConfiguration configuration, IHealthReporter healthReporter) { Requires.NotNull(configuration, nameof(configuration)); Requires.NotNull(healthReporter, nameof(healthReporter)); var filterConfiguration = new IncludeConditionFilterConfiguration(); try { configuration.Bind(filterConfiguration); } catch { healthReporter.ReportProblem($"{nameof(DropFilterFactory)}: configuration is invalid for filter {configuration.ToString()}"); return(null); } return(new DropFilter(filterConfiguration.Include)); }
/// <summary> /// Initializes a new instance of the <see cref="ReflectInsightOutput" /> class. /// </summary> /// <param name="configuration">The configuration.</param> /// <param name="healthReporter">The health reporter.</param> public ReflectInsightOutput(IConfiguration configuration, IHealthReporter healthReporter) { Requires.NotNull(configuration, nameof(configuration)); Requires.NotNull(healthReporter, nameof(healthReporter)); _healthReporter = healthReporter; var riConfig = new ReflectInsightOutputConfiguration(); try { configuration.Bind(riConfig); _reflectInsight = RILogManager.Get(riConfig.InstanceName ?? TraceTag); } catch { healthReporter.ReportProblem($"Invalid {nameof(TraceTag)} configuration encountered: '{configuration.ToString()}'", EventFlowContextIdentifiers.Configuration); throw; } }
public ApplicationInsightsOutput(IConfiguration configuration, IHealthReporter healthReporter) { Requires.NotNull(configuration, nameof(configuration)); Requires.NotNull(healthReporter, nameof(healthReporter)); this.healthReporter = healthReporter; var aiOutputConfiguration = new ApplicationInsightsOutputConfiguration(); try { configuration.Bind(aiOutputConfiguration); } catch { healthReporter.ReportProblem($"Invalid {nameof(ApplicationInsightsOutput)} configuration encountered: '{configuration.ToString()}'", EventFlowContextIdentifiers.Configuration); throw; } Initialize(aiOutputConfiguration); }
public Log4netInput(IConfiguration configuration, IHealthReporter healthReporter) { Requires.NotNull(healthReporter, nameof(healthReporter)); Requires.NotNull(configuration, nameof(configuration)); var log4NetInputConfiguration = new Log4netConfiguration(); try { configuration.Bind(log4NetInputConfiguration); } catch { healthReporter.ReportProblem($"Invalid {nameof(log4NetInputConfiguration)} configuration encountered: '{configuration}'", EventFlowContextIdentifiers.Configuration); throw; } Initialize(log4NetInputConfiguration, healthReporter); }
public OmsOutput(IConfiguration configuration, IHealthReporter healthReporter) { Requires.NotNull(configuration, nameof(configuration)); Requires.NotNull(healthReporter, nameof(healthReporter)); this.healthReporter = healthReporter; var omsOutputConfiguration = new OmsOutputConfiguration(); try { configuration.Bind(omsOutputConfiguration); } catch { healthReporter.ReportProblem($"Invalid {nameof(OmsOutput)} configuration encountered: '{configuration.ToString()}'", EventFlowContextIdentifiers.Configuration); throw; } this.connectionData = CreateConnectionData(omsOutputConfiguration); }
public EventHubOutput(IConfiguration configuration, IHealthReporter healthReporter) { Requires.NotNull(configuration, nameof(configuration)); Requires.NotNull(healthReporter, nameof(healthReporter)); this.healthReporter = healthReporter; this.eventHubClientFactory = this.CreateEventHubClient; this.outputConfiguration = new EventHubOutputConfiguration(); try { configuration.Bind(this.outputConfiguration); } catch { healthReporter.ReportProblem($"Invalid {nameof(EventHubOutput)} configuration encountered: '{configuration.ToString()}'", EventFlowContextIdentifiers.Configuration); throw; } Initialize(); }