lib/aspecto/opentelemetry/configurator.rb in aspecto-opentelemetry-0.1.5 vs lib/aspecto/opentelemetry/configurator.rb in aspecto-opentelemetry-0.1.6
- old
+ new
@@ -2,30 +2,33 @@
module Aspecto
module OpenTelemetry
# Aspecto OpenTelemetry Distro Configurator
class Configurator
+ TRUTHY_VALUES = %w[1 T t true TRUE True].freeze
+
def initialize
# initialize config options from environment variables.
# they can later be overwritten with configurator attribute setters
# that have precedence over env
@override_resource_attributes = {}
self.aspecto_auth = ENV["ASPECTO_AUTH"]
self.log_level = ENV.fetch("OTEL_LOG_LEVEL", Logger::ERROR)
self.env = ENV["ASPECTO_ENV"] if ENV["ASPECTO_ENV"]
self.sampling_ratio = Float(ENV.fetch("ASPECTO_SAMPLING_RATIO", 1.0))
self.otel_exporter_otlp_traces_endpoint = ENV.fetch("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT", "https://otelcol.aspecto.io/v1/trace")
+ self.require_config_for_traces = TRUTHY_VALUES.include?(ENV["ASPECTO_REQUIRE_CONFIG_FOR_TRACES"]&.strip)
end
def service_name=(service_name)
@override_resource_attributes[::OpenTelemetry::SemanticConventions::Resource::SERVICE_NAME] = service_name
end
def env=(env)
@override_resource_attributes[::OpenTelemetry::SemanticConventions::Resource::DEPLOYMENT_ENVIRONMENT] = env
end
- attr_accessor :sampling_ratio, :log_level, :otel_exporter_otlp_traces_endpoint
+ attr_accessor :sampling_ratio, :log_level, :otel_exporter_otlp_traces_endpoint, :require_config_for_traces
attr_reader :aspecto_auth
def aspecto_auth=(aspecto_auth)
@override_resource_attributes["aspecto.token"] = aspecto_auth
@aspecto_auth = aspecto_auth