Class: PlatformSdk::Observability::Langfuse::Configuration
- Inherits:
-
Object
- Object
- PlatformSdk::Observability::Langfuse::Configuration
- Defined in:
- lib/platform_sdk/observability/langfuse/configuration.rb
Constant Summary collapse
- DEFAULT_BASE_URL =
US region; set LANGFUSE_BASE_URL for eu.cloud.langfuse.com, jp.cloud.langfuse.com, etc.
'https://us.cloud.langfuse.com'- DEFAULT_PROMPT_LABEL =
'latest'- DEFAULT_BATCH_INTERVAL_MS =
5_000- OTLP_TRACES_PATH =
'/api/public/otel/v1/traces'
Instance Attribute Summary collapse
-
#app_name ⇒ Object
readonly
Returns the value of attribute app_name.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#exporter ⇒ Object
readonly
Returns the value of attribute exporter.
-
#prompt_label ⇒ Object
readonly
Returns the value of attribute prompt_label.
Instance Method Summary collapse
- #default_resource_attributes ⇒ Object
- #enabled? ⇒ Boolean
- #force_flush_and_shutdown ⇒ Object
-
#initialize(app_name:, environment: nil, prompt_label: nil, exporter: nil) ⇒ Configuration
constructor
A new instance of Configuration.
- #otlp_endpoint ⇒ Object
- #tracer ⇒ Object
- #tracer_provider ⇒ Object
Constructor Details
#initialize(app_name:, environment: nil, prompt_label: nil, exporter: nil) ⇒ Configuration
Returns a new instance of Configuration.
19 20 21 22 23 24 25 |
# File 'lib/platform_sdk/observability/langfuse/configuration.rb', line 19 def initialize(app_name:, environment: nil, prompt_label: nil, exporter: nil) @app_name = coerce_string(app_name) @environment = coerce_string(environment || ENV.fetch('RAILS_ENV', 'development')) @prompt_label = coerce_string(prompt_label || ENV.fetch('LANGFUSE_PROMPT_LABEL', DEFAULT_PROMPT_LABEL)) @exporter = exporter @enabled = compute_enabled end |
Instance Attribute Details
#app_name ⇒ Object (readonly)
Returns the value of attribute app_name.
17 18 19 |
# File 'lib/platform_sdk/observability/langfuse/configuration.rb', line 17 def app_name @app_name end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
17 18 19 |
# File 'lib/platform_sdk/observability/langfuse/configuration.rb', line 17 def environment @environment end |
#exporter ⇒ Object (readonly)
Returns the value of attribute exporter.
17 18 19 |
# File 'lib/platform_sdk/observability/langfuse/configuration.rb', line 17 def exporter @exporter end |
#prompt_label ⇒ Object (readonly)
Returns the value of attribute prompt_label.
17 18 19 |
# File 'lib/platform_sdk/observability/langfuse/configuration.rb', line 17 def prompt_label @prompt_label end |
Instance Method Details
#default_resource_attributes ⇒ Object
35 36 37 38 39 40 |
# File 'lib/platform_sdk/observability/langfuse/configuration.rb', line 35 def default_resource_attributes { 'service.name' => app_name, 'deployment.environment' => environment } end |
#enabled? ⇒ Boolean
27 28 29 |
# File 'lib/platform_sdk/observability/langfuse/configuration.rb', line 27 def enabled? @enabled end |
#force_flush_and_shutdown ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/platform_sdk/observability/langfuse/configuration.rb', line 50 def force_flush_and_shutdown return if @shut_down return unless @tracer_provider @tracer_provider.force_flush(timeout: 5) @tracer_provider.shutdown(timeout: 5) @shut_down = true end |
#otlp_endpoint ⇒ Object
31 32 33 |
# File 'lib/platform_sdk/observability/langfuse/configuration.rb', line 31 def otlp_endpoint "#{base_url}#{OTLP_TRACES_PATH}" end |
#tracer ⇒ Object
42 43 44 |
# File 'lib/platform_sdk/observability/langfuse/configuration.rb', line 42 def tracer @tracer ||= tracer_provider.tracer('platform_sdk.observability.langfuse', PlatformSdk::VERSION) end |
#tracer_provider ⇒ Object
46 47 48 |
# File 'lib/platform_sdk/observability/langfuse/configuration.rb', line 46 def tracer_provider @tracer_provider ||= build_tracer_provider end |