Class: Foam::Ruby::Configuration
- Inherits:
-
Object
- Object
- Foam::Ruby::Configuration
- Defined in:
- lib/foam/ruby/configuration.rb
Constant Summary collapse
- FOAM_OTEL_ENDPOINT =
"https://otel.api.foam.ai"
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#service_name ⇒ Object
Returns the value of attribute service_name.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #logs_endpoint ⇒ Object
- #otel_headers ⇒ Object
- #traces_endpoint ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
10 11 12 13 14 |
# File 'lib/foam/ruby/configuration.rb', line 10 def initialize @token = ENV["FOAM_API_TOKEN"] @service_name = ENV.fetch("OTEL_SERVICE_NAME", "rails-app") @endpoint = ENV.fetch("FOAM_OTEL_ENDPOINT", FOAM_OTEL_ENDPOINT) end |
Instance Attribute Details
#endpoint ⇒ Object
Returns the value of attribute endpoint.
8 9 10 |
# File 'lib/foam/ruby/configuration.rb', line 8 def endpoint @endpoint end |
#service_name ⇒ Object
Returns the value of attribute service_name.
8 9 10 |
# File 'lib/foam/ruby/configuration.rb', line 8 def service_name @service_name end |
#token ⇒ Object
Returns the value of attribute token.
8 9 10 |
# File 'lib/foam/ruby/configuration.rb', line 8 def token @token end |
Instance Method Details
#logs_endpoint ⇒ Object
24 25 26 |
# File 'lib/foam/ruby/configuration.rb', line 24 def logs_endpoint "#{endpoint}/v1/logs" end |
#otel_headers ⇒ Object
16 17 18 |
# File 'lib/foam/ruby/configuration.rb', line 16 def otel_headers { "Authorization" => "Bearer #{token}" } end |
#traces_endpoint ⇒ Object
20 21 22 |
# File 'lib/foam/ruby/configuration.rb', line 20 def traces_endpoint "#{endpoint}/v1/traces" end |
#valid? ⇒ Boolean
28 29 30 |
# File 'lib/foam/ruby/configuration.rb', line 28 def valid? !token.nil? && !token.empty? end |