public void LoadNumeric_NoValue() { bool actualBool = EnvironmentVariableHelper.LoadNumeric(EnvVar, out int actualValue); Assert.False(actualBool); Assert.Equal(0, actualValue); }
/// <summary> /// Initializes a new instance of the <see cref="OtlpExporterOptions"/> class. /// </summary> public OtlpExporterOptions() { if (EnvironmentVariableHelper.LoadUri(EndpointEnvVarName, out Uri endpoint)) { this.Endpoint = endpoint; } if (EnvironmentVariableHelper.LoadString(HeadersEnvVarName, out string headersEnvVar)) { this.Headers = headersEnvVar; } if (EnvironmentVariableHelper.LoadNumeric(TimeoutEnvVarName, out int timeout)) { this.TimeoutMilliseconds = timeout; } if (EnvironmentVariableHelper.LoadString(ProtocolEnvVarName, out string protocolEnvVar)) { var protocol = protocolEnvVar.ToOtlpExportProtocol(); if (protocol.HasValue) { this.Protocol = protocol.Value; } else { throw new FormatException($"{ProtocolEnvVarName} environment variable has an invalid value: '${protocolEnvVar}'"); } } }
public JaegerExporterOptions() { if (EnvironmentVariableHelper.LoadString(OTelProtocolEnvVarKey, out string protocolEnvVar)) { var protocol = protocolEnvVar.ToJaegerExportProtocol(); if (protocol.HasValue) { this.Protocol = protocol.Value; } else { throw new FormatException($"{OTelProtocolEnvVarKey} environment variable has an invalid value: '{protocolEnvVar}'"); } } if (EnvironmentVariableHelper.LoadString(OTelAgentHostEnvVarKey, out string agentHostEnvVar)) { this.AgentHost = agentHostEnvVar; } if (EnvironmentVariableHelper.LoadNumeric(OTelAgentPortEnvVarKey, out int agentPortEnvVar)) { this.AgentPort = agentPortEnvVar; } if (EnvironmentVariableHelper.LoadString(OTelEndpointEnvVarKey, out string endpointEnvVar) && Uri.TryCreate(endpointEnvVar, UriKind.Absolute, out Uri endpoint)) { this.Endpoint = endpoint; } }
public void LoadNumeric(string value, int expectedValue) { Environment.SetEnvironmentVariable(EnvVar, value); bool actualBool = EnvironmentVariableHelper.LoadNumeric(EnvVar, out int actualValue); Assert.True(actualBool); Assert.Equal(expectedValue, actualValue); }
/// <summary> /// Initializes a new instance of the <see cref="OtlpExporterOptions"/> class. /// </summary> public OtlpExporterOptions() { if (EnvironmentVariableHelper.LoadUri(EndpointEnvVarName, out Uri parsedEndpoint)) { this.endpoint = parsedEndpoint; } if (EnvironmentVariableHelper.LoadString(HeadersEnvVarName, out string headersEnvVar)) { this.Headers = headersEnvVar; } if (EnvironmentVariableHelper.LoadNumeric(TimeoutEnvVarName, out int timeout)) { this.TimeoutMilliseconds = timeout; } if (EnvironmentVariableHelper.LoadString(ProtocolEnvVarName, out string protocolEnvVar)) { var protocol = protocolEnvVar.ToOtlpExportProtocol(); if (protocol.HasValue) { this.Protocol = protocol.Value; } else { throw new FormatException($"{ProtocolEnvVarName} environment variable has an invalid value: '{protocolEnvVar}'"); } } this.HttpClientFactory = this.DefaultHttpClientFactory = () => { return(new HttpClient { Timeout = TimeSpan.FromMilliseconds(this.TimeoutMilliseconds), }); }; }
public JaegerExporterOptions() { if (EnvironmentVariableHelper.LoadString(OtelProtocolEnvVarKey, out string protocolEnvVar) && Enum.TryParse(protocolEnvVar, ignoreCase: true, out JaegerExportProtocol protocol)) { this.Protocol = protocol; } if (EnvironmentVariableHelper.LoadString(OTelAgentHostEnvVarKey, out string agentHostEnvVar)) { this.AgentHost = agentHostEnvVar; } if (EnvironmentVariableHelper.LoadNumeric(OTelAgentPortEnvVarKey, out int agentPortEnvVar)) { this.AgentPort = agentPortEnvVar; } if (EnvironmentVariableHelper.LoadString(OTelEndpointEnvVarKey, out string endpointEnvVar) && Uri.TryCreate(endpointEnvVar, UriKind.Absolute, out Uri endpoint)) { this.Endpoint = endpoint; } }
public BatchExportActivityProcessorOptions() { int value; if (EnvironmentVariableHelper.LoadNumeric(ExporterTimeoutEnvVarKey, out value)) { this.ExporterTimeoutMilliseconds = value; } if (EnvironmentVariableHelper.LoadNumeric(MaxExportBatchSizeEnvVarKey, out value)) { this.MaxExportBatchSize = value; } if (EnvironmentVariableHelper.LoadNumeric(MaxQueueSizeEnvVarKey, out value)) { this.MaxQueueSize = value; } if (EnvironmentVariableHelper.LoadNumeric(ScheduledDelayEnvVarKey, out value)) { this.ScheduledDelayMilliseconds = value; } }
[InlineData("0xFF")] // only decimal number allowed public void LoadNumeric_Invalid(string value) { Environment.SetEnvironmentVariable(EnvVar, value); Assert.Throws <FormatException>(() => EnvironmentVariableHelper.LoadNumeric(EnvVar, out int _)); }