public async Task RuntimeConfiguration_HasNoDefaultTelemetryVerbosityConfigured_UsesDefault() { // Arrange var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration() .WithGeneralTelemetry(null) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <ScraperRuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.Telemetry); Assert.Equal(DefaultsCore.Telemetry.DefaultVerbosity, runtimeConfiguration.Telemetry.DefaultVerbosity); }
public async Task RuntimeConfiguration_HasConfiguredEnabledMetricTimestampsInPrometheusEndpoint_UsesConfigured(bool enableMetricsTimestamp) { // Arrange var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration() .WithPrometheusConfiguration(enableMetricsTimestamp: enableMetricsTimestamp) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <RuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.Prometheus); Assert.Equal(enableMetricsTimestamp, runtimeConfiguration.Prometheus.EnableMetricTimestamps); }
public async Task RuntimeConfiguration_HasConfiguredMaxDegreeOfParallelism_UsesConfigured() { // Arrange var bogusMaxDegreeOfParallelism = BogusGenerator.Random.Int(); var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration(maxDegreeOfParallelism : bogusMaxDegreeOfParallelism) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <ScraperRuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.Server); Assert.Equal(bogusMaxDegreeOfParallelism, runtimeConfiguration.Server.MaxDegreeOfParallelism); }
public async Task RuntimeConfiguration_HasNoMetricsConfigurationBasePathConfigured_UsesDefault() { // Arrange var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration() .WithMetricsConfiguration(absolutePath: null) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <ScraperRuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.MetricsConfiguration); Assert.Equal(Defaults.MetricsConfiguration.AbsolutePath, runtimeConfiguration.MetricsConfiguration.AbsolutePath); }
public async Task RuntimeConfiguration_HasConfiguredApplicationInsightsEnabledFlag_UsesConfigured(bool containerLogsEnabled) { // Arrange var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration() .WithApplicationInsightsTelemetry(isEnabled: containerLogsEnabled) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <ScraperRuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.Telemetry.ApplicationInsights); Assert.Equal(containerLogsEnabled, runtimeConfiguration.Telemetry.ApplicationInsights.IsEnabled); }
public async Task RuntimeConfiguration_HasConfiguredHttpPort_UsesConfigured() { // Arrange var bogusHttpPort = BogusGenerator.Random.Int(); var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration(bogusHttpPort) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <ScraperRuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.Server); Assert.Equal(bogusHttpPort, runtimeConfiguration.Server.HttpPort); }
public async Task RuntimeConfiguration_HasNoEnableMetricTimestampsConfigured_UsesDefault() { // Arrange var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration() .WithPrometheusConfiguration(enableMetricsTimestamp: null) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <RuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.Prometheus); Assert.Equal(Defaults.Prometheus.EnableMetricTimestamps, runtimeConfiguration.Prometheus.EnableMetricTimestamps); }
public async Task RuntimeConfiguration_HasConfiguredNoCollectorUriInOpenTelemetryCollectorEndpoint_OpenTelemetryIsIgnored() { // Arrange var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration() .WithOpenTelemetryCollectorMetricSink(collectorUri: null) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <ScraperRuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.MetricSinks); Assert.Null(runtimeConfiguration.MetricSinks.OpenTelemetryCollector); }
public async Task RuntimeConfiguration_HasNoResourceDiscoveryPortConfigured_UsesDefault() { // Arrange var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration() .WithResourceDiscovery(port: null) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <ScraperRuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.ResourceDiscovery); Assert.NotNull(runtimeConfiguration.ResourceDiscovery.Port); }
public async Task RuntimeConfiguration_HasConfiguredAzureMonitorLoggingEnabledFlag_UsesConfigured(bool azureMonitorLogsEnabled) { // Arrange var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration() .WithAzureMonitorLogging(isEnabled: azureMonitorLogsEnabled) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <ScraperRuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.AzureMonitor); Assert.NotNull(runtimeConfiguration.AzureMonitor.Logging); Assert.Equal(azureMonitorLogsEnabled, runtimeConfiguration.AzureMonitor.Logging.IsEnabled); }
public async Task RuntimeConfiguration_HasConfiguredApplicationInsightsVerbosity_UsesConfigured() { // Arrange var verbosity = LogLevel.Error; var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration() .WithApplicationInsightsTelemetry(verbosity: verbosity) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <ScraperRuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.Telemetry.ApplicationInsights); Assert.Equal(verbosity, runtimeConfiguration.Telemetry.ApplicationInsights.Verbosity); }
public async Task RuntimeConfiguration_HasConfiguredContainerLogVerbosity_UsesConfigured() { // Arrange var verbosity = LogLevel.Error; var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration() .WithContainerTelemetry(verbosity) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <RuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.Telemetry.ContainerLogs); Assert.Equal(verbosity, runtimeConfiguration.Telemetry.ContainerLogs.Verbosity); }
public async Task RuntimeConfiguration_HasConfiguredAzureMonitorLoggingInformationLevel_UsesConfigured(HttpLoggingDelegatingHandler.Level informationLevel) { // Arrange var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration() .WithAzureMonitorLogging(informationLevel: informationLevel) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <ScraperRuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.AzureMonitor); Assert.NotNull(runtimeConfiguration.AzureMonitor.Logging); Assert.Equal(informationLevel, runtimeConfiguration.AzureMonitor.Logging.InformationLevel); }
public async Task RuntimeConfiguration_HasConfiguredMetricUnavailableValueInPrometheusEndpoint_UsesConfigured() { // Arrange var metricUnavailableValue = _faker.Random.Double(min: 1); var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration() .WithPrometheusConfiguration(metricUnavailableValue: metricUnavailableValue) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <RuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.Prometheus); Assert.Equal(metricUnavailableValue, runtimeConfiguration.Prometheus.MetricUnavailableValue); }
public async Task RuntimeConfiguration_HasConfiguredApplicationInsightsInstrumentationKey_UsesConfigured() { // Arrange var instrumentationKey = _faker.Random.Guid().ToString(); var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration() .WithApplicationInsightsTelemetry(instrumentationKey) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <RuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.Telemetry.ApplicationInsights); Assert.Equal(instrumentationKey, runtimeConfiguration.Telemetry.ApplicationInsights.InstrumentationKey); }
public async Task RuntimeConfiguration_HasConfiguredDefaultTelemetryVerbosityConfigured_UsesConfigured() { // Arrange var defaultVerbosity = LogLevel.Error; var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration() .WithGeneralTelemetry(defaultVerbosity) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <RuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.Telemetry); Assert.Equal(defaultVerbosity, runtimeConfiguration.Telemetry.DefaultVerbosity); }
public async Task RuntimeConfiguration_HasNoPrometheusScrapeEndpointConfigured_UsesDefault() { // Arrange var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration() .WithPrometheusConfiguration(scrapeEndpointBaseUri: null) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <RuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.Prometheus); Assert.NotNull(runtimeConfiguration.Prometheus.ScrapeEndpoint); Assert.Equal(Defaults.Prometheus.ScrapeEndpointBaseUri, runtimeConfiguration.Prometheus.ScrapeEndpoint.BaseUriPath); Assert.NotEqual(Defaults.Prometheus.MetricUnavailableValue, runtimeConfiguration.Prometheus.MetricUnavailableValue); }
public async Task RuntimeConfiguration_HasNoDefaultContainerLogsConfigured_UsesDefault() { // Arrange var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration() .WithContainerTelemetry(null, null) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <RuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.Telemetry); Assert.NotNull(runtimeConfiguration.Telemetry.ContainerLogs); Assert.Equal(Defaults.Telemetry.ContainerLogs.Verbosity, runtimeConfiguration.Telemetry.ContainerLogs.Verbosity); Assert.Equal(Defaults.Telemetry.ContainerLogs.IsEnabled, runtimeConfiguration.Telemetry.ContainerLogs.IsEnabled); }
public async Task RuntimeConfiguration_HasConfiguredPrometheusScrapeEndpointConfigured_UsesConfigured() { // Arrange var scrapeEndpointBaseUri = _faker.System.DirectoryPath(); var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration() .WithPrometheusConfiguration(scrapeEndpointBaseUri: scrapeEndpointBaseUri) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <RuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.Prometheus); Assert.NotNull(runtimeConfiguration.Prometheus.ScrapeEndpoint); Assert.Equal(scrapeEndpointBaseUri, runtimeConfiguration.Prometheus.ScrapeEndpoint.BaseUriPath); }
public async Task RuntimeConfiguration_HasConfiguredMetricsConfigurationBasePath_UsesConfigured() { // Arrange var metricsDeclarationBasePath = _faker.System.DirectoryPath(); var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration() .WithMetricsConfiguration(absolutePath: metricsDeclarationBasePath) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <RuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.Prometheus); Assert.NotNull(runtimeConfiguration.Prometheus.ScrapeEndpoint); Assert.Equal(metricsDeclarationBasePath, runtimeConfiguration.MetricsConfiguration.AbsolutePath); }
public async Task RuntimeConfiguration_HasNoStartingFromInHoursConfiguredForAzureMonitorIntegration_UsesDefault() { // Arrange var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration() .WithAzureMonitorIntegration(startingFromInHours: null) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <ScraperRuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.AzureMonitor); Assert.NotNull(runtimeConfiguration.AzureMonitor.Integration); Assert.NotNull(runtimeConfiguration.AzureMonitor.Integration.History); Assert.Equal(12, runtimeConfiguration.AzureMonitor.Integration.History.StartingFromInHours); }
public async Task RuntimeConfiguration_HasConfiguredMetricUnavailableValueInPrometheusScrapeEndpointSink_UsesConfigured() { // Arrange var metricUnavailableValue = BogusGenerator.Random.Double(min: 1); var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration() .WithPrometheusMetricSink(metricUnavailableValue: metricUnavailableValue) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <ScraperRuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.MetricSinks); Assert.NotNull(runtimeConfiguration.MetricSinks.PrometheusScrapingEndpoint); Assert.Equal(metricUnavailableValue, runtimeConfiguration.MetricSinks.PrometheusScrapingEndpoint.MetricUnavailableValue); }
public async Task RuntimeConfiguration_HasConfiguredHostInStatsDEndpoint_UsesConfigured() { // Arrange var statsdHost = BogusGenerator.System.DirectoryPath(); var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration() .WithStatsDMetricSink(host: statsdHost) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <ScraperRuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.MetricSinks); Assert.NotNull(runtimeConfiguration.MetricSinks.Statsd); Assert.Equal(statsdHost, runtimeConfiguration.MetricSinks.Statsd.Host); }
public async Task RuntimeConfiguration_HasConfiguredMetricPrefixInStatsDEndpoint_UsesConfigured() { // Arrange var metricPrefix = BogusGenerator.Name.FirstName(); var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration() .WithStatsDMetricSink(metricPrefix: metricPrefix) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <ScraperRuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.MetricSinks); Assert.NotNull(runtimeConfiguration.MetricSinks.Statsd); Assert.Equal(metricPrefix, runtimeConfiguration.MetricSinks.Statsd.MetricPrefix); }
public async Task RuntimeConfiguration_HasConfiguredPortInStatsDEndpoint_UsesConfigured() { // Arrange var port = BogusGenerator.Random.Int(); var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration() .WithStatsDMetricSink(port: port) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <ScraperRuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.MetricSinks); Assert.NotNull(runtimeConfiguration.MetricSinks.Statsd); Assert.Equal(port, runtimeConfiguration.MetricSinks.Statsd.Port); }
public async Task RuntimeConfiguration_HasConfiguredCollectorUriInOpenTelemetryCollectorEndpoint_UsesConfigured() { // Arrange var collectorUri = "https://foo.bar"; var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration() .WithOpenTelemetryCollectorMetricSink(collectorUri: collectorUri) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <ScraperRuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.MetricSinks); Assert.NotNull(runtimeConfiguration.MetricSinks.OpenTelemetryCollector); Assert.Equal(collectorUri, runtimeConfiguration.MetricSinks.OpenTelemetryCollector.CollectorUri); }
public async Task RuntimeConfiguration_HasNoDefaultApplicationInsights_UsesDefault() { // Arrange var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration() .WithApplicationInsightsTelemetry(verbosity: null, isEnabled: null, instrumentationKey: null) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <RuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.Telemetry); Assert.NotNull(runtimeConfiguration.Telemetry.ApplicationInsights); Assert.Null(runtimeConfiguration.Telemetry.ApplicationInsights.InstrumentationKey); Assert.Equal(Defaults.Telemetry.ApplicationInsights.Verbosity, runtimeConfiguration.Telemetry.ApplicationInsights.Verbosity); Assert.Equal(Defaults.Telemetry.ApplicationInsights.IsEnabled, runtimeConfiguration.Telemetry.ApplicationInsights.IsEnabled); }
public async Task RuntimeConfiguration_HasStartingFromInHoursConfiguredForAzureMonitorIntegration_UsesConfigured() { // Arrange var expectedStartingFromInHours = BogusGenerator.Random.Int(min: 1); var configuration = await RuntimeConfigurationGenerator.WithServerConfiguration() .WithAzureMonitorIntegration(startingFromInHours: expectedStartingFromInHours) .GenerateAsync(); // Act var runtimeConfiguration = configuration.Get <ScraperRuntimeConfiguration>(); // Assert Assert.NotNull(runtimeConfiguration); Assert.NotNull(runtimeConfiguration.AzureMonitor); Assert.NotNull(runtimeConfiguration.AzureMonitor.Integration); Assert.NotNull(runtimeConfiguration.AzureMonitor.Integration.History); Assert.Equal(expectedStartingFromInHours, runtimeConfiguration.AzureMonitor.Integration.History.StartingFromInHours); }