private static bool TryLoadJsonConfigurationFile(IConfigurationSource configurationSource, out IConfigurationSource jsonConfigurationSource) { try { // if environment variable is not set, look for default file name in the current directory var configurationFileName = configurationSource.GetString(ConfigurationKeys.ConfigurationFileName) ?? configurationSource.GetString("DD_DOTNET_TRACER_CONFIG_FILE") ?? Path.Combine(GetCurrentDirectory(), "datadog.json"); if (string.Equals(Path.GetExtension(configurationFileName), ".JSON", StringComparison.OrdinalIgnoreCase) && File.Exists(configurationFileName)) { jsonConfigurationSource = JsonConfigurationSource.FromFile(configurationFileName); return(true); } } catch (Exception) { // Unable to load the JSON file from disk // The configuration manager should not depend on a logger being bootstrapped yet // so do not do anything } jsonConfigurationSource = default; return(false); }
public CIVisibilitySettings(IConfigurationSource source) { Enabled = source?.GetBool(ConfigurationKeys.CIVisibility.Enabled) ?? false; Agentless = source?.GetBool(ConfigurationKeys.CIVisibility.AgentlessEnabled) ?? false; Logs = source?.GetBool(ConfigurationKeys.CIVisibility.Logs) ?? false; ApiKey = source?.GetString(ConfigurationKeys.ApiKey); Site = source?.GetString(ConfigurationKeys.Site) ?? "datadoghq.com"; // By default intake payloads has a 5MB limit MaximumAgentlessPayloadSize = 5 * 1024 * 1024; ProxyHttps = source?.GetString(ConfigurationKeys.Proxy.ProxyHttps); var proxyNoProxy = source?.GetString(ConfigurationKeys.Proxy.ProxyNoProxy) ?? string.Empty; ProxyNoProxy = proxyNoProxy.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); TracerSettings = new TracerSettings(source); if (Logs) { // Enable the direct log submission TracerSettings.LogSubmissionSettings.DirectLogSubmissionEnabledIntegrations.Add("XUnit"); TracerSettings.LogSubmissionSettings.DirectLogSubmissionBatchPeriod = TimeSpan.FromSeconds(1); } }
public SecuritySettings(IConfigurationSource source) { // both should default to false Enabled = source?.GetBool(ConfigurationKeys.AppSecEnabled) ?? false; Rules = source?.GetString(ConfigurationKeys.AppSecRules); CustomIpHeader = source?.GetString(ConfigurationKeys.AppSecCustomIpHeader); var extraHeaders = source?.GetString(ConfigurationKeys.AppSecExtraHeaders); ExtraHeaders = !string.IsNullOrEmpty(extraHeaders) ? extraHeaders.Split(',') : Array.Empty <string>(); KeepTraces = source?.GetBool(ConfigurationKeys.AppSecKeepTraces) ?? true; // empty or junk values to default to 100, any number is valid, with zero or less meaning limit off TraceRateLimit = source?.GetInt32(ConfigurationKeys.AppSecTraceRateLimit) ?? 100; // Default timeout of 100 ms, only extreme conditions should cause timeout const int defaultWafTimeout = 100_000; var wafTimeout = source?.GetInt32(ConfigurationKeys.AppSecWafTimeout) ?? defaultWafTimeout; if (wafTimeout <= 0) { wafTimeout = defaultWafTimeout; Log.Warning <string, int>("Ignoring '{WafTimeoutKey}' of '{WafTimeout}' because it was zero or less", ConfigurationKeys.AppSecWafTimeout, wafTimeout); } WafTimeoutMicroSeconds = (ulong)wafTimeout; }
/// <summary> /// Initializes a new instance of the <see cref="MeterSettings"/> class /// using the specified <see cref="IConfigurationSource"/> to initialize values. /// </summary> /// <param name="source">The <see cref="IConfigurationSource"/> to use when retrieving configuration values.</param> private MeterSettings(IConfigurationSource source) : base(source) { MetricExporter = ParseMetricExporter(source); ConsoleExporterEnabled = source.GetBool(ConfigurationKeys.Metrics.ConsoleExporterEnabled) ?? false; var instrumentations = new Dictionary <string, MeterInstrumentation>(); var enabledInstrumentations = source.GetString(ConfigurationKeys.Metrics.Instrumentations); if (enabledInstrumentations != null) { foreach (var instrumentation in enabledInstrumentations.Split(Separator)) { if (Enum.TryParse(instrumentation, out MeterInstrumentation parsedType)) { instrumentations[instrumentation] = parsedType; } else { throw new FormatException($"The \"{instrumentation}\" is not recognized as supported metrics instrumentation and cannot be enabled"); } } } var disabledInstrumentations = source.GetString(ConfigurationKeys.Metrics.DisabledInstrumentations); if (disabledInstrumentations != null) { foreach (var instrumentation in disabledInstrumentations.Split(Separator)) { instrumentations.Remove(instrumentation); } } EnabledInstrumentations = instrumentations.Values.ToList(); var providerPlugins = source.GetString(ConfigurationKeys.Metrics.ProviderPlugins); if (providerPlugins != null) { foreach (var pluginAssemblyQualifiedName in providerPlugins.Split(DotNetQualifiedNameSeparator)) { MetricPlugins.Add(pluginAssemblyQualifiedName); } } var additionalSources = source.GetString(ConfigurationKeys.Metrics.AdditionalSources); if (additionalSources != null) { foreach (var sourceName in additionalSources.Split(Separator)) { Meters.Add(sourceName); } } MetricsEnabled = source.GetBool(ConfigurationKeys.Metrics.Enabled) ?? true; LoadMetricsAtStartup = source.GetBool(ConfigurationKeys.Metrics.LoadMeterAtStartup) ?? true; }
private static bool TryLoadJsonConfigurationFile(IConfigurationSource configurationSource, out JsonConfigurationSource jsonConfigurationSource) { // if environment variable is not set, look for default file name in the current directory var configurationFileName = configurationSource.GetString(ConfigurationKeys.ConfigurationFileName) ?? configurationSource.GetString("OTEL_DOTNET_TRACER_CONFIG_FILE"); return(TryLoadJsonConfigurationFile(configurationFileName, out jsonConfigurationSource)); }
public CIVisibilitySettings(IConfigurationSource source) { Enabled = source?.GetBool(ConfigurationKeys.CIVisibility.Enabled) ?? false; Agentless = source?.GetBool(ConfigurationKeys.CIVisibility.AgentlessEnabled) ?? false; ApiKey = source?.GetString(ConfigurationKeys.ApiKey); Site = source?.GetString(ConfigurationKeys.Site) ?? "datadoghq.com"; // By default intake payloads has a 5MB limit MaximumAgentlessPayloadSize = 5 * 1024 * 1024; ProxyHttps = source?.GetString(ConfigurationKeys.Proxy.ProxyHttps); var proxyNoProxy = source?.GetString(ConfigurationKeys.Proxy.ProxyNoProxy) ?? string.Empty; ProxyNoProxy = proxyNoProxy.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); TracerSettings = new TracerSettings(source); }
public DirectLogSubmissionSettings(IConfigurationSource source) { DirectLogSubmissionHost = source?.GetString(ConfigurationKeys.DirectLogSubmission.Host) ?? HostMetadata.Instance.Hostname; DirectLogSubmissionSource = source?.GetString(ConfigurationKeys.DirectLogSubmission.Source) ?? DefaultSource; var overriddenSubmissionUrl = source?.GetString(ConfigurationKeys.DirectLogSubmission.Url); if (!string.IsNullOrEmpty(overriddenSubmissionUrl)) { // if they provide a url, use it DirectLogSubmissionUrl = overriddenSubmissionUrl; } else { // They didn't provide a URL, use the default (With DD_SITE if provided) var specificSite = source?.GetString(ConfigurationKeys.Site); var ddSite = string.IsNullOrEmpty(specificSite) ? DefaultSite : specificSite; DirectLogSubmissionUrl = $"{IntakePrefix}{ddSite}{IntakeSuffix}"; } DirectLogSubmissionMinimumLevel = DirectSubmissionLogLevelExtensions.Parse( source?.GetString(ConfigurationKeys.DirectLogSubmission.MinimumLevel), DefaultMinimumLevel); DirectLogSubmissionGlobalTags = source?.GetDictionary(ConfigurationKeys.DirectLogSubmission.GlobalTags) ?.Where(kvp => !string.IsNullOrWhiteSpace(kvp.Key) && !string.IsNullOrWhiteSpace(kvp.Value)) .ToDictionary(kvp => kvp.Key.Trim(), kvp => kvp.Value.Trim()) ?? new Dictionary <string, string>(); var logSubmissionIntegrations = source?.GetString(ConfigurationKeys.DirectLogSubmission.EnabledIntegrations) ?.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries) ?? Enumerable.Empty <string>(); DirectLogSubmissionEnabledIntegrations = new HashSet <string>(logSubmissionIntegrations, StringComparer.OrdinalIgnoreCase); var batchSizeLimit = source?.GetInt32(ConfigurationKeys.DirectLogSubmission.BatchSizeLimit); DirectLogSubmissionBatchSizeLimit = batchSizeLimit is null or <= 0 ? DefaultBatchSizeLimit : batchSizeLimit.Value; var queueSizeLimit = source?.GetInt32(ConfigurationKeys.DirectLogSubmission.QueueSizeLimit); DirectLogSubmissionQueueSizeLimit = queueSizeLimit is null or <= 0 ? DefaultQueueSizeLimit : queueSizeLimit.Value; var seconds = source?.GetInt32(ConfigurationKeys.DirectLogSubmission.BatchPeriodSeconds); DirectLogSubmissionBatchPeriod = TimeSpan.FromSeconds( seconds is null or <= 0 ? DefaultBatchPeriodSeconds : seconds.Value); ApiKey = source?.GetString(ConfigurationKeys.ApiKey); }
public TelemetrySettings(IConfigurationSource source, ImmutableTracerSettings tracerSettings) { var explicitlyEnabled = source?.GetBool(ConfigurationKeys.Telemetry.Enabled); TelemetryEnabled = explicitlyEnabled ?? false; var apiKey = source?.GetString(ConfigurationKeys.ApiKey); if (explicitlyEnabled != false && !string.IsNullOrEmpty(apiKey)) { // We have an API key, so try to send directly to intake ApiKey = apiKey; TelemetryEnabled = true; var requestedTelemetryUri = source?.GetString(ConfigurationKeys.Telemetry.Uri); if (!string.IsNullOrEmpty(requestedTelemetryUri) && Uri.TryCreate(requestedTelemetryUri, UriKind.Absolute, out var telemetryUri)) { // telemetry URI provided and well-formed TelemetryUri = telemetryUri; } else { // use the default intake. Use DD_SITE if provided, otherwise use default var siteFromEnv = source.GetString(ConfigurationKeys.Site); var ddSite = string.IsNullOrEmpty(siteFromEnv) ? "datadoghq.com" : siteFromEnv; TelemetryUri = new Uri($"{TelemetryConstants.TelemetryIntakePrefix}.{ddSite}/"); } } else if (TelemetryEnabled) { // no API key provided, so send to the agent instead // We only support http at the moment so disable telemetry for now if we're using something else if (tracerSettings.Exporter.TracesTransport == TracesTransportType.Default) { TelemetryUri = new Uri(tracerSettings.Exporter.AgentUri, TelemetryConstants.AgentTelemetryEndpoint); } else { TelemetryEnabled = false; } } }
/// <summary> /// Initializes a new instance of the <see cref="TracerSettings"/> class /// using the specified <see cref="IConfigurationSource"/> to initialize values. /// </summary> /// <param name="source">The <see cref="IConfigurationSource"/> to use when retrieving configuration values.</param> public TracerSettings(IConfigurationSource source) { ConfigurationSource = source; Environment = source?.GetString(ConfigurationKeys.Environment); ServiceName = source?.GetString(ConfigurationKeys.ServiceName) ?? // backwards compatibility for names used in the past source?.GetString("OTEL_SERVICE_NAME"); ServiceVersion = source?.GetString(ConfigurationKeys.ServiceVersion); TraceEnabled = source?.GetBool(ConfigurationKeys.TraceEnabled) ?? // default value true; if (AzureAppServices.Metadata.IsRelevant && AzureAppServices.Metadata.IsUnsafeToTrace) { TraceEnabled = false; } DisabledIntegrationNames = new HashSet <string>(source.GetStrings(ConfigurationKeys.DisabledIntegrations), StringComparer.OrdinalIgnoreCase); AdoNetExcludedTypes = new HashSet <string>(source.GetStrings(ConfigurationKeys.AdoNetExcludedTypes), StringComparer.OrdinalIgnoreCase); Integrations = new IntegrationSettingsCollection(source); var agentHost = source?.GetString(ConfigurationKeys.AgentHost) ?? // backwards compatibility for names used in the past source?.GetString("OTEL_TRACE_AGENT_HOSTNAME") ?? // default value DefaultAgentHost; var agentPort = source?.GetInt32(ConfigurationKeys.AgentPort) ?? // backwards compatibility for names used in the past source?.GetInt32("OTEL_TRACE_AGENT_PORT") ?? // default value DefaultAgentPort; var agentUri = source?.GetString(ConfigurationKeys.AgentUri) ?? // default value $"http://{agentHost}:{agentPort}"; AgentUri = new Uri(agentUri); TracesPipeName = source?.GetString(ConfigurationKeys.TracesPipeName); TracesPipeTimeoutMs = source?.GetInt32(ConfigurationKeys.TracesPipeTimeoutMs) #if DEBUG ?? 20_000;
private static OtlpExportProtocol?GetExporterOtlpProtocol(IConfigurationSource source) { // the default in SDK is grpc. http/protobuf should be default for our purposes var exporterOtlpProtocol = source.GetString(ConfigurationKeys.ExporterOtlpProtocol); if (string.IsNullOrEmpty(exporterOtlpProtocol)) { // override settings only for http/protobuf return(OpenTelemetry.Exporter.OtlpExportProtocol.HttpProtobuf); } // null value here means that it will be handled by OTEL .NET SDK return(null); }
/// <summary> /// Initializes a new instance of the <see cref="TracerSettings"/> class /// using the specified <see cref="IConfigurationSource"/> to initialize values. /// </summary> /// <param name="source">The <see cref="IConfigurationSource"/> to use when retrieving configuration values.</param> public TracerSettings(IConfigurationSource source) { Environment = source?.GetString(ConfigurationKeys.Environment); ServiceName = source?.GetString(ConfigurationKeys.ServiceName); TraceEnabled = source?.GetBool(ConfigurationKeys.TraceEnabled) ?? // default value true; DebugEnabled = source?.GetBool(ConfigurationKeys.DebugEnabled) ?? // default value false; var disabledIntegrationNames = source?.GetString(ConfigurationKeys.DisabledIntegrations) ?.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries) ?? Enumerable.Empty <string>(); DisabledIntegrationNames = new HashSet <string>(disabledIntegrationNames, StringComparer.OrdinalIgnoreCase); var agentHost = source?.GetString(ConfigurationKeys.AgentHost) ?? // backwards compatibility for names used in the past source?.GetString("DD_TRACE_AGENT_HOSTNAME") ?? source?.GetString("DATADOG_TRACE_AGENT_HOSTNAME") ?? DefaultAgentHost; var agentPort = source?.GetInt32(ConfigurationKeys.AgentPort) ?? // backwards compatibility for names used in the past source?.GetInt32("DATADOG_TRACE_AGENT_PORT") ?? DefaultAgentPort; var agentUri = source?.GetString(ConfigurationKeys.AgentUri) ?? $"http://{agentHost}:{agentPort}"; AgentUri = new Uri(agentUri); AnalyticsEnabled = source?.GetBool(ConfigurationKeys.GlobalAnalyticsEnabled) ?? false; LogsInjectionEnabled = source?.GetBool(ConfigurationKeys.LogsInjectionEnabled) ?? false; Integrations = new IntegrationSettingsCollection(source); }
private static MetricsExporter ParseMetricExporter(IConfigurationSource source) { var metricsExporterEnvVar = source.GetString(ConfigurationKeys.Metrics.Exporter) ?? "otlp"; switch (metricsExporterEnvVar) { case null: case "": case "otlp": return(MetricsExporter.Otlp); case "prometheus": return(MetricsExporter.Prometheus); case "none": return(MetricsExporter.None); default: throw new FormatException($"Metric exporter '{metricsExporterEnvVar}' is not supported"); } }
private static TracesExporter ParseTracesExporter(IConfigurationSource source) { var tracesExporterEnvVar = source.GetString(ConfigurationKeys.Traces.Exporter) ?? "otlp"; switch (tracesExporterEnvVar) { case null: case "": case "otlp": return(TracesExporter.Otlp); case "zipkin": return(TracesExporter.Zipkin); case "jaeger": return(TracesExporter.Jaeger); case "none": return(TracesExporter.None); default: throw new FormatException($"Traces exporter '{tracesExporterEnvVar}' is not supported"); } }
/// <summary> /// Tries to read String from configuration source as Uri. In case of: /// Null source default is returned, /// Empty configuration default is returned, /// Invalid configuration error is logged and default is returned. /// </summary> /// <param name="source">Configuration source.</param> /// <param name="key">Configuration key.</param> /// <param name="defaultTo">In case of failure, default to this value.</param> /// <param name="defaultUsed">Indicated is the default was used</param> /// <returns>Config uri or default.</returns> public static Uri SafeReadUri(this IConfigurationSource source, string key, Uri defaultTo, out bool defaultUsed) { defaultUsed = false; string csValue = source?.GetString(key); if (string.IsNullOrWhiteSpace(csValue)) { defaultUsed = true; return(defaultTo); } try { return(new Uri(csValue, UriKind.Absolute)); } catch (Exception ex) { Log.Error(ex, $"[{key}]: Invalid configuration value '{csValue}'. Defaulting to '{defaultTo}'"); } defaultUsed = true; return(defaultTo); }
private static bool TryLoadJsonConfigurationFile(IConfigurationSource configurationSource, out JsonConfigurationSource jsonConfigurationSource) { try { var configurationFileName = configurationSource.GetString(ConfigurationKeys.ConfigurationFileName); if (!string.IsNullOrWhiteSpace(configurationFileName) && string.Equals(Path.GetExtension(configurationFileName), ".JSON", StringComparison.OrdinalIgnoreCase) && File.Exists(configurationFileName)) { jsonConfigurationSource = JsonConfigurationSource.FromFile(configurationFileName); return(true); } } catch (Exception) { // Unable to load the JSON file from disk // The configuration manager should not depend on a logger being bootstrapped yet // so do not do anything } jsonConfigurationSource = default; return(false); }
/// <summary> /// Initializes a new instance of the <see cref="TracerSettings"/> class /// using the specified <see cref="IConfigurationSource"/> to initialize values. /// </summary> /// <param name="source">The <see cref="IConfigurationSource"/> to use when retrieving configuration values.</param> public TracerSettings(IConfigurationSource source) { Environment = source?.GetString(ConfigurationKeys.Environment); ServiceName = source?.GetString(ConfigurationKeys.ServiceName) ?? // backwards compatibility for names used in the past source?.GetString("DD_SERVICE_NAME"); ServiceVersion = source?.GetString(ConfigurationKeys.ServiceVersion); TraceEnabled = source?.GetBool(ConfigurationKeys.TraceEnabled) ?? // default value true; var disabledIntegrationNames = source?.GetString(ConfigurationKeys.DisabledIntegrations) ?.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries) ?? Enumerable.Empty <string>(); DisabledIntegrationNames = new HashSet <string>(disabledIntegrationNames, StringComparer.OrdinalIgnoreCase); var agentHost = source?.GetString(ConfigurationKeys.AgentHost) ?? // backwards compatibility for names used in the past source?.GetString("DD_TRACE_AGENT_HOSTNAME") ?? source?.GetString("DATADOG_TRACE_AGENT_HOSTNAME") ?? // default value DefaultAgentHost; var agentPort = source?.GetInt32(ConfigurationKeys.AgentPort) ?? // backwards compatibility for names used in the past source?.GetInt32("DATADOG_TRACE_AGENT_PORT") ?? // default value DefaultAgentPort; var agentUri = source?.GetString(ConfigurationKeys.AgentUri) ?? // default value $"http://{agentHost}:{agentPort}"; AgentUri = new Uri(agentUri); if (string.Equals(AgentUri.Host, "localhost", StringComparison.OrdinalIgnoreCase)) { // Replace localhost with 127.0.0.1 to avoid DNS resolution. // When ipv6 is enabled, localhost is first resolved to ::1, which fails // because the trace agent is only bound to ipv4. // This causes delays when sending traces. var builder = new UriBuilder(agentUri) { Host = "127.0.0.1" }; AgentUri = builder.Uri; } AnalyticsEnabled = source?.GetBool(ConfigurationKeys.GlobalAnalyticsEnabled) ?? // default value false; LogsInjectionEnabled = source?.GetBool(ConfigurationKeys.LogsInjectionEnabled) ?? // default value false; MaxTracesSubmittedPerSecond = source?.GetInt32(ConfigurationKeys.MaxTracesSubmittedPerSecond) ?? // default value 100; Integrations = new IntegrationSettingsCollection(source); GlobalTags = source?.GetDictionary(ConfigurationKeys.GlobalTags) ?? // backwards compatibility for names used in the past source?.GetDictionary("DD_TRACE_GLOBAL_TAGS") ?? // default value (empty) new ConcurrentDictionary <string, string>(); // Filter out tags with empty keys or empty values, and trim whitespace GlobalTags = GlobalTags.Where(kvp => !string.IsNullOrEmpty(kvp.Key) && !string.IsNullOrEmpty(kvp.Value)) .ToDictionary(kvp => kvp.Key.Trim(), kvp => kvp.Value.Trim()); HeaderTags = source?.GetDictionary(ConfigurationKeys.HeaderTags) ?? // default value (empty) new ConcurrentDictionary <string, string>(); // Filter out tags with empty keys or empty values, and trim whitespace HeaderTags = HeaderTags.Where(kvp => !string.IsNullOrEmpty(kvp.Key) && !string.IsNullOrEmpty(kvp.Value)) .ToDictionary(kvp => kvp.Key.Trim(), kvp => kvp.Value.Trim()); DogStatsdPort = source?.GetInt32(ConfigurationKeys.DogStatsdPort) ?? // default value 8125; TracerMetricsEnabled = source?.GetBool(ConfigurationKeys.TracerMetricsEnabled) ?? // default value false; RuntimeMetricsEnabled = source?.GetBool(ConfigurationKeys.RuntimeMetricsEnabled) ?? false; CustomSamplingRules = source?.GetString(ConfigurationKeys.CustomSamplingRules); GlobalSamplingRate = source?.GetDouble(ConfigurationKeys.GlobalSamplingRate); StartupDiagnosticLogEnabled = source?.GetBool(ConfigurationKeys.StartupDiagnosticLogEnabled) ?? // default value true; TraceQueueSize = source?.GetInt32(ConfigurationKeys.QueueSize) ?? 1000; }
/// <summary> /// Initializes a new instance of the <see cref="ExporterSettings"/> class. /// Direct use in tests only. /// </summary> /// <param name="source">The <see cref="IConfigurationSource"/> to use when retrieving configuration values.</param> public ExporterSettings(IConfigurationSource source) { ValidationWarnings = new List <string>(); // Get values from the config var endpointUrl = source?.GetString(ConfigurationKeys.EndpointUrl); var tracesPipeName = source?.GetString(ConfigurationKeys.TracesPipeName); var tracesPipeTimeoutMs = source?.GetInt32(ConfigurationKeys.TracesPipeTimeoutMs) ?? 0; var agentPort = source?.GetInt32(ConfigurationKeys.AgentPort); var ingestRealm = source?.GetString(ConfigurationKeys.IngestRealm) ?? LocalIngestRealm; var dogStatsdPort = source?.GetInt32(ConfigurationKeys.DogStatsdPort) ?? 0; var metricsPipeName = source?.GetString(ConfigurationKeys.MetricsPipeName); ConfigureTraceTransport(endpointUrl, tracesPipeName, agentPort, ingestRealm); MetricsExporter = source.GetTypedValue <MetricsExporterType>(ConfigurationKeys.MetricsExporter); if (MetricsExporter == MetricsExporterType.SignalFx) { MetricsEndpointUrl = source.SafeReadUri( key: ConfigurationKeys.MetricsEndpointUrl, defaultTo: GetConfiguredMetricsEndpoint(ingestRealm), out _); } else { ConfigureStatsdMetricsTransport(endpointUrl, dogStatsdPort, metricsPipeName); } ConfigureLogsTransport(source); TracesPipeTimeoutMs = tracesPipeTimeoutMs > 0 ? tracesPipeTimeoutMs : 500; PartialFlushEnabled = source?.GetBool(ConfigurationKeys.PartialFlushEnabled) ?? false; PartialFlushMinSpans = source.SafeReadInt32( key: ConfigurationKeys.PartialFlushMinSpans, defaultTo: 500, validators: (val) => val > 0); SyncExport = source?.GetBool(ConfigurationKeys.TraceSyncExport) ?? false; var stringProfileExportFormat = source?.GetString(ConfigurationKeys.AlwaysOnProfiler.ExportFormat); if (string.IsNullOrEmpty(stringProfileExportFormat)) { ProfilerExportFormat = ProfilerExportFormat.Pprof; } else if (Enum.TryParse(stringProfileExportFormat, out ProfilerExportFormat profilerExportFormat)) { ProfilerExportFormat = profilerExportFormat; } else { Log.Logger.Warning("Unknown {0} passed: {1}, using {2} as a default", ConfigurationKeys.AlwaysOnProfiler.ExportFormat, stringProfileExportFormat, ProfilerExportFormat.Pprof); ProfilerExportFormat = ProfilerExportFormat.Pprof; } }
/// <summary> /// Initializes a new instance of the <see cref="TracerSettings"/> class /// using the specified <see cref="IConfigurationSource"/> to initialize values. /// </summary> /// <param name="source">The <see cref="IConfigurationSource"/> to use when retrieving configuration values.</param> public TracerSettings(IConfigurationSource source) { Environment = source?.GetString(ConfigurationKeys.Environment); ServiceName = source?.GetString(ConfigurationKeys.ServiceName); TraceEnabled = source?.GetBool(ConfigurationKeys.TraceEnabled) ?? // default value true; var disabledIntegrationNames = source?.GetString(ConfigurationKeys.DisabledIntegrations) ?.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries) ?? Enumerable.Empty <string>(); DisabledIntegrationNames = new HashSet <string>(disabledIntegrationNames, StringComparer.OrdinalIgnoreCase); var agentHost = source?.GetString(ConfigurationKeys.AgentHost) ?? // backwards compatibility for names used in the past source?.GetString("DD_TRACE_AGENT_HOSTNAME") ?? source?.GetString("DATADOG_TRACE_AGENT_HOSTNAME") ?? // default value DefaultAgentHost; var agentPort = source?.GetInt32(ConfigurationKeys.AgentPort) ?? // backwards compatibility for names used in the past source?.GetInt32("DATADOG_TRACE_AGENT_PORT") ?? // default value DefaultAgentPort; var agentUri = source?.GetString(ConfigurationKeys.AgentUri) ?? // default value $"http://{agentHost}:{agentPort}"; AgentUri = new Uri(agentUri); AnalyticsEnabled = source?.GetBool(ConfigurationKeys.GlobalAnalyticsEnabled) ?? // default value false; LogsInjectionEnabled = source?.GetBool(ConfigurationKeys.LogsInjectionEnabled) ?? // default value false; var maxTracesPerSecond = source?.GetInt32(ConfigurationKeys.MaxTracesSubmittedPerSecond); if (maxTracesPerSecond != null) { // Ensure our flag for the rate limiter is enabled RuleBasedSampler.OptInTracingWithoutLimits(); } else { maxTracesPerSecond = 100; // default } MaxTracesSubmittedPerSecond = maxTracesPerSecond.Value; Integrations = new IntegrationSettingsCollection(source); GlobalTags = source?.GetDictionary(ConfigurationKeys.GlobalTags) ?? // default value (empty) new ConcurrentDictionary <string, string>(); DogStatsdPort = source?.GetInt32(ConfigurationKeys.DogStatsdPort) ?? // default value 8125; TracerMetricsEnabled = source?.GetBool(ConfigurationKeys.TracerMetricsEnabled) ?? // default value false; CustomSamplingRules = source?.GetString(ConfigurationKeys.CustomSamplingRules); GlobalSamplingRate = source?.GetDouble(ConfigurationKeys.GlobalSamplingRate); DiagnosticSourceEnabled = source?.GetBool(ConfigurationKeys.DiagnosticSourceEnabled) ?? // default value true; }
/// <summary> /// Initializes a new instance of the <see cref="TracerSettings"/> class /// using the specified <see cref="IConfigurationSource"/> to initialize values. /// </summary> /// <param name="source">The <see cref="IConfigurationSource"/> to use when retrieving configuration values.</param> public TracerSettings(IConfigurationSource source) { Environment = source?.GetString(ConfigurationKeys.Environment); ServiceName = source?.GetString(ConfigurationKeys.ServiceName); ServiceNamePerSpanEnabled = source?.GetBool(ConfigurationKeys.ServiceNamePerSpan) ?? false; SignalFxAccessToken = source?.GetString(ConfigurationKeys.SignalFxAccessToken); TraceEnabled = source?.GetBool(ConfigurationKeys.TraceEnabled) ?? true; SynchronousSend = source?.GetBool(ConfigurationKeys.SynchronousSend) ?? false; var disabledIntegrationNames = source?.GetString(ConfigurationKeys.DisabledIntegrations) ?.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries) ?? Enumerable.Empty <string>(); DisabledIntegrationNames = new HashSet <string>(disabledIntegrationNames, StringComparer.OrdinalIgnoreCase); var endpointUrl = source?.GetString(ConfigurationKeys.EndpointUrl) ?? DefaultEndpointUrl; EndpointUrl = new Uri(endpointUrl); var agentHost = source?.GetString(ConfigurationKeys.AgentHost) ?? // backwards compatibility for names used in the past source?.GetString("SIGNALFX_TRACE_AGENT_HOSTNAME") ?? source?.GetString("DATADOG_TRACE_AGENT_HOSTNAME") ?? // default value EndpointUrl.Host; var agentPort = source?.GetInt32(ConfigurationKeys.AgentPort) ?? // backwards compatibility for names used in the past source?.GetInt32("DATADOG_TRACE_AGENT_PORT") ?? // default value EndpointUrl.Port; var agentUri = source?.GetString(ConfigurationKeys.AgentUri) ?? // default value $"{EndpointUrl.Scheme}://{agentHost}:{agentPort}"; AgentUri = new Uri(agentUri); var endpointPath = EndpointUrl.PathAndQuery != "/" ? EndpointUrl.PathAndQuery : FallbackUriPath; var agentPath = source?.GetString(ConfigurationKeys.AgentPath) ?? endpointPath; // We still want tests and users to be able to configure Uri elements, so reform Endpoint Url EndpointUrl = new Uri(AgentUri, agentPath); ApiType = source?.GetString(ConfigurationKeys.ApiType) ?? DefaultApiType; AnalyticsEnabled = source?.GetBool(ConfigurationKeys.GlobalAnalyticsEnabled) ?? // default value false; LogsInjectionEnabled = source?.GetBool(ConfigurationKeys.LogsInjectionEnabled) ?? // default value false; var maxTracesPerSecond = source?.GetInt32(ConfigurationKeys.MaxTracesSubmittedPerSecond); if (maxTracesPerSecond != null) { // Ensure our flag for the rate limiter is enabled RuleBasedSampler.OptInTracingWithoutLimits(); } else { maxTracesPerSecond = 100; // default } MaxTracesSubmittedPerSecond = maxTracesPerSecond.Value; Integrations = new IntegrationSettingsCollection(source); GlobalTags = source?.GetDictionary(ConfigurationKeys.GlobalTags); DogStatsdPort = source?.GetInt32(ConfigurationKeys.DogStatsdPort) ?? // default value 8125; TracerMetricsEnabled = source?.GetBool(ConfigurationKeys.TracerMetricsEnabled) ?? // default value false; CustomSamplingRules = source?.GetString(ConfigurationKeys.CustomSamplingRules); GlobalSamplingRate = source?.GetDouble(ConfigurationKeys.GlobalSamplingRate); DiagnosticSourceEnabled = source?.GetBool(ConfigurationKeys.DiagnosticSourceEnabled) ?? // default value true; TagMongoCommands = source?.GetBool(ConfigurationKeys.TagMongoCommands) ?? true; TagElasticsearchQueries = source?.GetBool(ConfigurationKeys.TagElasticsearchQueries) ?? true; TagRedisCommands = source?.GetBool(ConfigurationKeys.TagRedisCommands) ?? true; SanitizeSqlStatements = source?.GetBool(ConfigurationKeys.SanitizeSqlStatements) ?? true; AdditionalDiagnosticListeners = source?.GetString(ConfigurationKeys.AdditionalDiagnosticListeners) ?.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Select(s => s.Trim()).ToArray() ?? new string[0]; AppendUrlPathToName = source?.GetBool(ConfigurationKeys.AppendUrlPathToName) ?? false; UseWebServerResourceAsOperationName = source?.GetBool(ConfigurationKeys.UseWebServerResourceAsOperationName) ?? true; AddClientIpToServerSpans = source?.GetBool(ConfigurationKeys.AddClientIpToServerSpans) ?? false; RecordedValueMaxLength = source?.GetInt32(ConfigurationKeys.RecordedValueMaxLength) ?? DefaultRecordedValueMaxLength; if (RecordedValueMaxLength < 0) { RecordedValueMaxLength = DefaultRecordedValueMaxLength; } }
public static TelemetrySettings FromSource(IConfigurationSource?source) { string?configurationError = null; var apiKey = source?.GetString(ConfigurationKeys.ApiKey); var agentlessExplicitlyEnabled = source?.GetBool(ConfigurationKeys.Telemetry.AgentlessEnabled); var agentlessEnabled = false; if (agentlessExplicitlyEnabled == true) { if (string.IsNullOrEmpty(apiKey)) { configurationError = "Telemetry configuration error: Agentless mode was enabled, but no API key was available."; } else { agentlessEnabled = true; } } else if (agentlessExplicitlyEnabled is null) { // if there's an API key, we use agentless mode, otherwise we use the agent agentlessEnabled = !string.IsNullOrEmpty(apiKey); } // disabled by default unless using agentless var telemetryEnabled = source?.GetBool(ConfigurationKeys.Telemetry.Enabled) ?? agentlessEnabled; AgentlessSettings?agentless = null; if (telemetryEnabled && agentlessEnabled) { // We have an API key, so try to send directly to intake Uri agentlessUri; var requestedTelemetryUri = source?.GetString(ConfigurationKeys.Telemetry.Uri); if (!string.IsNullOrEmpty(requestedTelemetryUri) && Uri.TryCreate(requestedTelemetryUri, UriKind.Absolute, out var telemetryUri)) { // telemetry URI provided and well-formed agentlessUri = UriHelpers.Combine(telemetryUri, "/"); } else { if (!string.IsNullOrEmpty(requestedTelemetryUri)) { // URI parsing failed configurationError = configurationError is null ? $"Telemetry configuration error: The provided telemetry Uri '{requestedTelemetryUri}' was not a valid absolute Uri. Using default intake Uri." : configurationError + ", The provided telemetry Uri '{requestedTelemetryUri}' was not a valid absolute Uri. Using default intake Uri."; } // use the default intake. Use SIGNALFX_SITE if provided, otherwise use default var siteFromEnv = source?.GetString(ConfigurationKeys.Site); var ddSite = string.IsNullOrEmpty(siteFromEnv) ? "datadoghq.com" : siteFromEnv; agentlessUri = new Uri($"{TelemetryConstants.TelemetryIntakePrefix}.{ddSite}/"); } agentless = new AgentlessSettings(agentlessUri, apiKey !); } return(new TelemetrySettings(telemetryEnabled, configurationError, agentless)); }
/// <summary> /// Initializes a new instance of the <see cref="TracerSettings"/> class /// using the specified <see cref="IConfigurationSource"/> to initialize values. /// </summary> /// <param name="source">The <see cref="IConfigurationSource"/> to use when retrieving configuration values.</param> public TracerSettings(IConfigurationSource source) { Environment = source?.GetString(ConfigurationKeys.Environment); ServiceName = source?.GetString(ConfigurationKeys.ServiceName) ?? // backwards compatibility for names used in the past source?.GetString("DD_SERVICE_NAME"); ServiceVersion = source?.GetString(ConfigurationKeys.ServiceVersion); TraceEnabled = source?.GetBool(ConfigurationKeys.TraceEnabled) ?? // default value true; if (AzureAppServices.Metadata.IsRelevant && AzureAppServices.Metadata.IsUnsafeToTrace) { TraceEnabled = false; } var disabledIntegrationNames = source?.GetString(ConfigurationKeys.DisabledIntegrations) ?.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries) ?? Enumerable.Empty <string>(); DisabledIntegrationNames = new HashSet <string>(disabledIntegrationNames, StringComparer.OrdinalIgnoreCase); Integrations = new IntegrationSettingsCollection(source); Exporter = new ExporterSettings(source); #pragma warning disable 618 // App analytics is deprecated, but still used AnalyticsEnabled = source?.GetBool(ConfigurationKeys.GlobalAnalyticsEnabled) ?? // default value false; #pragma warning restore 618 LogsInjectionEnabled = source?.GetBool(ConfigurationKeys.LogsInjectionEnabled) ?? // default value false; MaxTracesSubmittedPerSecond = source?.GetInt32(ConfigurationKeys.TraceRateLimit) ?? #pragma warning disable 618 // this parameter has been replaced but may still be used source?.GetInt32(ConfigurationKeys.MaxTracesSubmittedPerSecond) ?? #pragma warning restore 618 // default value 100; GlobalTags = source?.GetDictionary(ConfigurationKeys.GlobalTags) ?? // backwards compatibility for names used in the past source?.GetDictionary("DD_TRACE_GLOBAL_TAGS") ?? // default value (empty) new ConcurrentDictionary <string, string>(); // Filter out tags with empty keys or empty values, and trim whitespace GlobalTags = GlobalTags.Where(kvp => !string.IsNullOrWhiteSpace(kvp.Key) && !string.IsNullOrWhiteSpace(kvp.Value)) .ToDictionary(kvp => kvp.Key.Trim(), kvp => kvp.Value.Trim()); var inputHeaderTags = source?.GetDictionary(ConfigurationKeys.HeaderTags, allowOptionalMappings: true) ?? // default value (empty) new Dictionary <string, string>(); var headerTagsNormalizationFixEnabled = source?.GetBool(ConfigurationKeys.FeatureFlags.HeaderTagsNormalizationFixEnabled) ?? true; // Filter out tags with empty keys or empty values, and trim whitespaces HeaderTags = InitializeHeaderTags(inputHeaderTags, headerTagsNormalizationFixEnabled); var serviceNameMappings = source?.GetDictionary(ConfigurationKeys.ServiceNameMappings) ?.Where(kvp => !string.IsNullOrWhiteSpace(kvp.Key) && !string.IsNullOrWhiteSpace(kvp.Value)) ?.ToDictionary(kvp => kvp.Key.Trim(), kvp => kvp.Value.Trim()); ServiceNameMappings = new ServiceNames(serviceNameMappings); TracerMetricsEnabled = source?.GetBool(ConfigurationKeys.TracerMetricsEnabled) ?? // default value false; RuntimeMetricsEnabled = source?.GetBool(ConfigurationKeys.RuntimeMetricsEnabled) ?? false; CustomSamplingRules = source?.GetString(ConfigurationKeys.CustomSamplingRules); GlobalSamplingRate = source?.GetDouble(ConfigurationKeys.GlobalSamplingRate); StartupDiagnosticLogEnabled = source?.GetBool(ConfigurationKeys.StartupDiagnosticLogEnabled) ?? // default value true; var urlSubstringSkips = source?.GetString(ConfigurationKeys.HttpClientExcludedUrlSubstrings) ?? // default value (AzureAppServices.Metadata.IsRelevant ? AzureAppServices.Metadata.DefaultHttpClientExclusions : null); if (urlSubstringSkips != null) { HttpClientExcludedUrlSubstrings = TrimSplitString(urlSubstringSkips.ToUpperInvariant(), ',').ToArray(); } var httpServerErrorStatusCodes = source?.GetString(ConfigurationKeys.HttpServerErrorStatusCodes) ?? // Default value "500-599"; HttpServerErrorStatusCodes = ParseHttpCodesToArray(httpServerErrorStatusCodes); var httpClientErrorStatusCodes = source?.GetString(ConfigurationKeys.HttpClientErrorStatusCodes) ?? // Default value "400-499"; HttpClientErrorStatusCodes = ParseHttpCodesToArray(httpClientErrorStatusCodes); TraceBufferSize = source?.GetInt32(ConfigurationKeys.BufferSize) ?? 1024 * 1024 * 10; // 10MB TraceBatchInterval = source?.GetInt32(ConfigurationKeys.SerializationBatchInterval) ?? 100; RouteTemplateResourceNamesEnabled = source?.GetBool(ConfigurationKeys.FeatureFlags.RouteTemplateResourceNamesEnabled) ?? true; ExpandRouteTemplatesEnabled = source?.GetBool(ConfigurationKeys.ExpandRouteTemplatesEnabled) // disabled by default if route template resource names enabled ?? !RouteTemplateResourceNamesEnabled; KafkaCreateConsumerScopeEnabled = source?.GetBool(ConfigurationKeys.KafkaCreateConsumerScopeEnabled) ?? true; // default DelayWcfInstrumentationEnabled = source?.GetBool(ConfigurationKeys.FeatureFlags.DelayWcfInstrumentationEnabled) ?? false; PropagationStyleInject = TrimSplitString(source?.GetString(ConfigurationKeys.PropagationStyleInject) ?? nameof(Propagators.ContextPropagators.Names.Datadog), ',').ToArray(); PropagationStyleExtract = TrimSplitString(source?.GetString(ConfigurationKeys.PropagationStyleExtract) ?? nameof(Propagators.ContextPropagators.Names.Datadog), ',').ToArray(); LogSubmissionSettings = new DirectLogSubmissionSettings(source); }
private static bool TryLoadPluginJsonConfigurationFile(IConfigurationSource configurationSource, out JsonConfigurationSource jsonConfigurationSource) { var configurationFileName = configurationSource?.GetString(ConfigurationKeys.PluginConfigurationFileName); return(TryLoadJsonConfigurationFile(configurationFileName, out jsonConfigurationSource)); }
public static TEnum GetTypedValue <TEnum>(this IConfigurationSource source, string key) where TEnum : struct, IConvertible { Enum.TryParse(source?.GetString(key), ignoreCase: true, out TEnum typedValue); return(typedValue); }
public static IEnumerable <string> GetStrings(this IConfigurationSource source, string key) { return(source?.GetString(key) ?.Split(new[] { Separator }, StringSplitOptions.RemoveEmptyEntries) ?? Enumerable.Empty <string>()); }
/// <summary> /// Initializes a new instance of the <see cref="TracerSettings"/> class /// using the specified <see cref="IConfigurationSource"/> to initialize values. /// </summary> /// <param name="source">The <see cref="IConfigurationSource"/> to use when retrieving configuration values.</param> public TracerSettings(IConfigurationSource source) { Environment = source?.GetString(ConfigurationKeys.Environment); ServiceName = source?.GetString(ConfigurationKeys.ServiceName); ServiceVersion = source?.GetString(ConfigurationKeys.ServiceVersion); SignalFxAccessToken = source?.GetString(ConfigurationKeys.SignalFxAccessToken); TraceEnabled = source?.GetBool(ConfigurationKeys.TraceEnabled) ?? // default value true; if (AzureAppServices.Metadata.IsRelevant && AzureAppServices.Metadata.IsUnsafeToTrace) { TraceEnabled = false; } DisabledIntegrationNames = new HashSet <string>(source.GetStrings(ConfigurationKeys.DisabledIntegrations), StringComparer.OrdinalIgnoreCase); Integrations = new IntegrationSettingsCollection(source); ExporterSettings = new ExporterSettings(source); #pragma warning disable 618 // App analytics is deprecated, but still used AnalyticsEnabled = source?.GetBool(ConfigurationKeys.GlobalAnalyticsEnabled) ?? // default value false; #pragma warning restore 618 MaxTracesSubmittedPerSecond = source?.GetInt32(ConfigurationKeys.TraceRateLimit) ?? // default value 100; GlobalTags = source?.GetDictionary(ConfigurationKeys.GlobalTags) ?? // default value (empty) new ConcurrentDictionary <string, string>(); // Filter out tags with empty keys or empty values, and trim whitespace GlobalTags = GlobalTags.Where(kvp => !string.IsNullOrWhiteSpace(kvp.Key) && !string.IsNullOrWhiteSpace(kvp.Value)) .ToDictionary(kvp => kvp.Key.Trim(), kvp => kvp.Value.Trim()); var inputHeaderTags = source?.GetDictionary(ConfigurationKeys.HeaderTags, allowOptionalMappings: true) ?? // default value (empty) new Dictionary <string, string>(); var headerTagsNormalizationFixEnabled = source?.GetBool(ConfigurationKeys.FeatureFlags.HeaderTagsNormalizationFixEnabled) ?? true; // Filter out tags with empty keys or empty values, and trim whitespaces HeaderTags = InitializeHeaderTags(inputHeaderTags, headerTagsNormalizationFixEnabled); var serviceNameMappings = source?.GetDictionary(ConfigurationKeys.ServiceNameMappings) ?.Where(kvp => !string.IsNullOrWhiteSpace(kvp.Key) && !string.IsNullOrWhiteSpace(kvp.Value)) ?.ToDictionary(kvp => kvp.Key.Trim(), kvp => kvp.Value.Trim()); ServiceNameMappings = new ServiceNames(serviceNameMappings); TracerMetricsEnabled = source?.GetBool(ConfigurationKeys.TracerMetricsEnabled) ?? // default value false; TagRedisCommands = source?.GetBool(ConfigurationKeys.TagRedisCommands) ?? // default value true; RuntimeMetricsEnabled = source?.GetBool(ConfigurationKeys.RuntimeMetricsEnabled) ?? false; CustomSamplingRules = source?.GetString(ConfigurationKeys.CustomSamplingRules); GlobalSamplingRate = source?.GetDouble(ConfigurationKeys.GlobalSamplingRate); StartupDiagnosticLogEnabled = source?.GetBool(ConfigurationKeys.StartupDiagnosticLogEnabled) ?? // default value true; Exporter = source.GetTypedValue <ExporterType>(ConfigurationKeys.Exporter); Convention = source.GetTypedValue <ConventionType>(ConfigurationKeys.Convention); var urlSubstringSkips = source?.GetString(ConfigurationKeys.HttpClientExcludedUrlSubstrings) ?? // default value (AzureAppServices.Metadata.IsRelevant ? AzureAppServices.Metadata.DefaultHttpClientExclusions : null); if (urlSubstringSkips != null) { HttpClientExcludedUrlSubstrings = TrimSplitString(urlSubstringSkips.ToUpperInvariant(), ',').ToArray(); } var httpServerErrorStatusCodes = source?.GetString(ConfigurationKeys.HttpServerErrorStatusCodes) ?? // Default value "500-599"; HttpServerErrorStatusCodes = ParseHttpCodesToArray(httpServerErrorStatusCodes); var httpClientErrorStatusCodes = source?.GetString(ConfigurationKeys.HttpClientErrorStatusCodes) ?? // Default value "400-599"; HttpClientErrorStatusCodes = ParseHttpCodesToArray(httpClientErrorStatusCodes); TraceBufferSize = source?.GetInt32(ConfigurationKeys.BufferSize) ?? 1024 * 1024 * 10; // 10MB TraceBatchInterval = source?.GetInt32(ConfigurationKeys.SerializationBatchInterval) ?? 100; RecordedValueMaxLength = source.SafeReadInt32( key: ConfigurationKeys.RecordedValueMaxLength, defaultTo: DefaultRecordedValueMaxLength, validators: (value) => value >= 0); RouteTemplateResourceNamesEnabled = source?.GetBool(ConfigurationKeys.FeatureFlags.RouteTemplateResourceNamesEnabled) ?? true; TraceResponseHeaderEnabled = source?.GetBool(ConfigurationKeys.TraceResponseHeaderEnabled) ?? true; ExpandRouteTemplatesEnabled = source?.GetBool(ConfigurationKeys.ExpandRouteTemplatesEnabled) // disabled by default if route template resource names enabled ?? !RouteTemplateResourceNamesEnabled; KafkaCreateConsumerScopeEnabled = source?.GetBool(ConfigurationKeys.KafkaCreateConsumerScopeEnabled) ?? true; // default TagMongoCommands = source?.GetBool(ConfigurationKeys.TagMongoCommands) ?? true; DelayWcfInstrumentationEnabled = source?.GetBool(ConfigurationKeys.FeatureFlags.DelayWcfInstrumentationEnabled) ?? false; PropagationStyleInject = TrimSplitString(source?.GetString(ConfigurationKeys.Propagators) ?? $"{nameof(Propagators.ContextPropagators.Names.B3)},{nameof(Propagators.ContextPropagators.Names.W3C)}", ',').ToArray(); PropagationStyleExtract = PropagationStyleInject; TagElasticsearchQueries = source?.GetBool(ConfigurationKeys.TagElasticsearchQueries) ?? true; // If you change this, change environment_variables.h too ThreadSamplingEnabled = source?.GetBool(ConfigurationKeys.AlwaysOnProfiler.Enabled) ?? false; ThreadSamplingPeriod = GetThreadSamplingPeriod(source); LogSubmissionSettings = new DirectLogSubmissionSettings(source); TraceMethods = source?.GetString(ConfigurationKeys.TraceMethods) ?? // Default value string.Empty; var grpcTags = source?.GetDictionary(ConfigurationKeys.GrpcTags, allowOptionalMappings: true) ?? // default value (empty) new Dictionary <string, string>(); // Filter out tags with empty keys or empty values, and trim whitespaces GrpcTags = InitializeHeaderTags(grpcTags, headerTagsNormalizationFixEnabled: true); IsActivityListenerEnabled = source?.GetBool(ConfigurationKeys.FeatureFlags.ActivityListenerEnabled) ?? // default value false; if (IsActivityListenerEnabled) { // If the activities support is activated, we must enable W3C propagators if (!Array.Exists(PropagationStyleExtract, key => string.Equals(key, nameof(Propagators.ContextPropagators.Names.W3C), StringComparison.OrdinalIgnoreCase))) { PropagationStyleExtract = PropagationStyleExtract.Concat(nameof(Propagators.ContextPropagators.Names.W3C)); } if (!Array.Exists(PropagationStyleInject, key => string.Equals(key, nameof(Propagators.ContextPropagators.Names.W3C), StringComparison.OrdinalIgnoreCase))) { PropagationStyleInject = PropagationStyleInject.Concat(nameof(Propagators.ContextPropagators.Names.W3C)); } } }