public void LoadString_NoValue() { bool actualBool = EnvironmentVariableHelper.LoadString(EnvVar, out string actualValue); Assert.False(actualBool); Assert.Null(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 LoadString() { const string value = "something"; Environment.SetEnvironmentVariable(EnvVar, value); bool actualBool = EnvironmentVariableHelper.LoadString(EnvVar, out string actualValue); Assert.True(actualBool); Assert.Equal(value, actualValue); }
public Resource Detect() { var resource = Resource.Empty; if (EnvironmentVariableHelper.LoadString(EnvVarKey, out string envResourceAttributeValue)) { var attributes = ParseResourceAttributes(envResourceAttributeValue); resource = new Resource(attributes); } return(resource); }
public Resource Detect() { var resource = Resource.Empty; if (EnvironmentVariableHelper.LoadString(EnvVarKey, out string envResourceAttributeValue)) { resource = new Resource(new Dictionary <string, object> { [ResourceSemanticConventions.AttributeServiceName] = envResourceAttributeValue, }); } return(resource); }
/// <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; } }