opentelemetry-config 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6920e5ca17ba99ef990626f22fb6d1d5b09fd0f07a02039c48c7fb420e59d2b
4
- data.tar.gz: 3cf56fdd238b6903c3209b150860e5998ad7dbcd26e8e8588b18ea0699115543
3
+ metadata.gz: 17b22f9a07db4efa7182ceefc5d35e2654a69a2222f914be8263ade344c1e7a1
4
+ data.tar.gz: 8bc97d2d66b57afce05ae6e4beb26eeba5c3b4d716485ee783a2ed665bd1ab0b
5
5
  SHA512:
6
- metadata.gz: 677ce312429f98ce5c1555c4d53172ae8ee4fc0c44bff5052844f3afd735d576299306f5d36964afdf1b41d4b115d5c2540a35b7c38d615df33fd8125125e37f
7
- data.tar.gz: 60eb6aa2db9e5efec14a2e6c23c2c9fa93d1f6f02ad22998f064836d0a2532ca8b585c8f2a36072f5d52a20093f1eea1b666b9e29d1aec650eb0ec33189363c2
6
+ metadata.gz: 73a690631b026066700a372a69987670b5de3bb75fa1911ccff8e84eeb7739cdc3ef1bc847c1393ec02c53443e180173a21884d9f404b82763ea5bece743709d
7
+ data.tar.gz: acf18866d0dd78f50ddd4b895f58cfb6267be49428847cd0a3a009f52250cd461d68d82f1f04a3e7992eb652a19d00e079da06563878f21d943d1dd9c01a5e35
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Release History: opentelemetry-config
2
2
 
3
+ ### v0.1.1 / 2026-10-13
4
+
5
+ * FIXED: Ignore SDK env defaults in declarative config (#2429)
6
+
3
7
  ### v0.1.0 / 2026-09-29
4
8
 
5
9
  * ADDED: Declarative configuration for trace_provider (#2161)
data/README.md CHANGED
@@ -22,7 +22,6 @@ This code is still under development and is not a complete implementation of the
22
22
 
23
23
  Some features we still need to implement include:
24
24
 
25
- - Configuration file precedence over environment variables
26
25
  - Using declarative configuration without a call in your code
27
26
  - Declarative configuration instrumentation API and SDK
28
27
 
@@ -65,6 +64,36 @@ If you have a config file path at hand, call `configure_from_file` instead:
65
64
  sdk = OpenTelemetry::Config.configure_from_file('/path/to/otel-config.yaml')
66
65
  ```
67
66
 
67
+ ### Environment variables and SDK-specific settings
68
+
69
+ File-based configuration uses the values in the YAML file and the schema defaults
70
+ for omitted settings. It does not inherit the SDK's `OTEL_*` environment-variable
71
+ defaults.
72
+
73
+ Some Ruby-specific SDK settings have no equivalent in the configuration schema:
74
+
75
+ - `OTEL_RUBY_BSP_START_THREAD_ON_BOOT` is ignored. A configured batch span
76
+ processor starts its worker thread during construction. Applications that need
77
+ to delay worker startup should use programmatic SDK configuration instead.
78
+ - `OTEL_RUBY_EXPORTER_OTLP_SSL_VERIFY_NONE` and
79
+ `OTEL_RUBY_EXPORTER_OTLP_SSL_VERIFY_PEER` are ignored. The OTLP HTTP exporter
80
+ verifies the server certificate. For a private certificate authority, set
81
+ `tls.ca_file` rather than disabling verification. For mutual TLS, also set
82
+ `tls.cert_file` and `tls.key_file`.
83
+
84
+ ```yaml
85
+ tracer_provider:
86
+ processors:
87
+ - batch:
88
+ exporter:
89
+ otlp_http:
90
+ endpoint: https://collector.example.com:4318/v1/traces
91
+ tls:
92
+ ca_file: /path/to/ca.pem
93
+ cert_file: /path/to/client.pem
94
+ key_file: /path/to/client-key.pem
95
+ ```
96
+
68
97
  ### Parse, create, and install
69
98
 
70
99
  `configure` is a convenience wrapper around the three [SDK operations][sdk-operations]. Call them individually when you need to inspect the configuration model or delay installing the global state:
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright The OpenTelemetry Authors
4
+ #
5
+ # SPDX-License-Identifier: Apache-2.0
6
+
7
+ module OpenTelemetry
8
+ module Config
9
+ # Schema defaults for omitted or null properties. Keys use schema names;
10
+ # durations are in milliseconds and are converted by the builders.
11
+ module Defaults
12
+ BATCH_SPAN_PROCESSOR = {
13
+ schedule_delay: 5_000,
14
+ export_timeout: 30_000,
15
+ max_queue_size: 2048,
16
+ max_export_batch_size: 512
17
+ }.freeze
18
+
19
+ SPAN_LIMITS = {
20
+ attribute_count_limit: 128,
21
+ attribute_value_length_limit: nil,
22
+ event_count_limit: 128,
23
+ link_count_limit: 128,
24
+ event_attribute_count_limit: 128,
25
+ link_attribute_count_limit: 128
26
+ }.freeze
27
+
28
+ OTLP_HTTP_EXPORTER = {
29
+ compression: 'none',
30
+ timeout: 10_000
31
+ }.freeze
32
+
33
+ OTLP_HTTP_TRACES_ENDPOINT = 'http://localhost:4318/v1/traces'
34
+ end
35
+
36
+ private_constant :Defaults
37
+ end
38
+ end
@@ -11,7 +11,7 @@ module OpenTelemetry
11
11
 
12
12
  # Priority: attributes > attribute_list > detected > base
13
13
  def build_resource(resource_cfg)
14
- base = OpenTelemetry::SDK::Resources::Resource.default
14
+ base = default_resource
15
15
 
16
16
  return base unless resource_cfg
17
17
 
@@ -38,6 +38,20 @@ module OpenTelemetry
38
38
  base.merge(custom)
39
39
  end
40
40
 
41
+ # Builds the intrinsic SDK resource without consulting OTEL_* environment
42
+ # variables. File-based configuration and environment configuration are
43
+ # intentionally separate sources.
44
+ def default_resource
45
+ resource_class = OpenTelemetry::SDK::Resources::Resource
46
+
47
+ resource_class.create(
48
+ OpenTelemetry::SemanticConventions::Resource::SERVICE_NAME => 'unknown_service',
49
+ OpenTelemetry::SemanticConventions::Resource::TELEMETRY_SDK_NAME => 'opentelemetry',
50
+ OpenTelemetry::SemanticConventions::Resource::TELEMETRY_SDK_LANGUAGE => 'ruby',
51
+ OpenTelemetry::SemanticConventions::Resource::TELEMETRY_SDK_VERSION => OpenTelemetry::SDK::VERSION
52
+ ).merge(resource_class.process)
53
+ end
54
+
41
55
  # type coercion
42
56
  def coerce_attribute_value(value, type)
43
57
  case type
@@ -3,6 +3,8 @@
3
3
  # Copyright The OpenTelemetry Authors
4
4
  # SPDX-License-Identifier: Apache-2.0
5
5
 
6
+ require 'openssl'
7
+
6
8
  module OpenTelemetry
7
9
  module Config
8
10
  # Trace component builder for configuring TracerProvider from declarative config.
@@ -46,15 +48,17 @@ module OpenTelemetry
46
48
  end
47
49
  end
48
50
 
49
- # Builds a BatchSpanProcessor with exporter and optional tuning options.
51
+ # Builds a BatchSpanProcessor with exporter and schema defaults. Passing
52
+ # environment-backed options explicitly prevents it from reading OTEL_*.
50
53
  def build_batch_span_processor(cfg)
51
54
  exporter = build_span_exporter(cfg.exporter)
52
55
  opts = {
53
- schedule_delay: cfg.schedule_delay&.to_f,
54
- exporter_timeout: cfg.export_timeout&.to_f,
55
- max_queue_size: cfg.max_queue_size&.to_i,
56
- max_export_batch_size: cfg.max_export_batch_size&.to_i
57
- }.compact
56
+ schedule_delay: (cfg.schedule_delay || Defaults::BATCH_SPAN_PROCESSOR[:schedule_delay]).to_f,
57
+ exporter_timeout: (cfg.export_timeout || Defaults::BATCH_SPAN_PROCESSOR[:export_timeout]).to_f,
58
+ max_queue_size: (cfg.max_queue_size || Defaults::BATCH_SPAN_PROCESSOR[:max_queue_size]).to_i,
59
+ max_export_batch_size: (cfg.max_export_batch_size || Defaults::BATCH_SPAN_PROCESSOR[:max_export_batch_size]).to_i,
60
+ start_thread_on_boot: true
61
+ }
58
62
 
59
63
  OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(exporter, **opts)
60
64
  end
@@ -88,17 +92,19 @@ module OpenTelemetry
88
92
  exporter
89
93
  end
90
94
 
91
- # Builds an OTLP HTTP span exporter from the given endpoint/headers config.
95
+ # Builds an OTLP HTTP span exporter from declarative values and schema
96
+ # defaults, without falling back to exporter environment variables.
92
97
  def build_otlp_http_span_exporter(cfg)
93
- headers = headers_to_hash(cfg)
94
- opts = {
95
- endpoint: cfg.endpoint,
96
- headers: headers.empty? ? nil : headers,
97
- compression: cfg.compression,
98
- timeout: cfg.timeout && (cfg.timeout / 1000.0) # YAML ms → Ruby seconds
99
- }.compact
100
-
101
- OpenTelemetry::Exporter::OTLP::Exporter.new(**opts)
98
+ OpenTelemetry::Exporter::OTLP::Exporter.new(
99
+ endpoint: cfg.endpoint || Defaults::OTLP_HTTP_TRACES_ENDPOINT,
100
+ certificate_file: cfg.tls&.ca_file,
101
+ client_certificate_file: cfg.tls&.cert_file,
102
+ client_key_file: cfg.tls&.key_file,
103
+ ssl_verify_mode: OpenSSL::SSL::VERIFY_PEER,
104
+ headers: headers_to_hash(cfg),
105
+ compression: cfg.compression || Defaults::OTLP_HTTP_EXPORTER[:compression],
106
+ timeout: (cfg.timeout || Defaults::OTLP_HTTP_EXPORTER[:timeout]) / 1000.0
107
+ )
102
108
  end
103
109
 
104
110
  # Builds a sampler from config; defaults to ParentBased(ALWAYS_ON).
@@ -139,20 +145,17 @@ module OpenTelemetry
139
145
  s.parent_based(**opts)
140
146
  end
141
147
 
142
- # Builds SpanLimits from config; returns the SDK default when config is nil.
148
+ # Builds SpanLimits from declarative values and schema defaults.
143
149
  def build_span_limits(limits_cfg)
144
- return OpenTelemetry::SDK::Trace::SpanLimits::DEFAULT unless limits_cfg
145
-
146
- opts = {
147
- attribute_count_limit: limits_cfg.attribute_count_limit,
148
- attribute_length_limit: limits_cfg.attribute_value_length_limit,
149
- event_count_limit: limits_cfg.event_count_limit,
150
- link_count_limit: limits_cfg.link_count_limit,
151
- event_attribute_count_limit: limits_cfg.event_attribute_count_limit,
152
- link_attribute_count_limit: limits_cfg.link_attribute_count_limit
153
- }.compact
154
-
155
- OpenTelemetry::SDK::Trace::SpanLimits.new(**opts)
150
+ OpenTelemetry::SDK::Trace::SpanLimits.new(
151
+ attribute_count_limit: limits_cfg&.attribute_count_limit || Defaults::SPAN_LIMITS[:attribute_count_limit],
152
+ attribute_length_limit: limits_cfg&.attribute_value_length_limit || Defaults::SPAN_LIMITS[:attribute_value_length_limit],
153
+ event_count_limit: limits_cfg&.event_count_limit || Defaults::SPAN_LIMITS[:event_count_limit],
154
+ link_count_limit: limits_cfg&.link_count_limit || Defaults::SPAN_LIMITS[:link_count_limit],
155
+ event_attribute_count_limit: limits_cfg&.event_attribute_count_limit || Defaults::SPAN_LIMITS[:event_attribute_count_limit],
156
+ event_attribute_length_limit: nil,
157
+ link_attribute_count_limit: limits_cfg&.link_attribute_count_limit || Defaults::SPAN_LIMITS[:link_attribute_count_limit]
158
+ )
156
159
  end
157
160
 
158
161
  # Converts the OTLP exporter headers (array of NameStringValuePair structs)
@@ -5,6 +5,6 @@
5
5
 
6
6
  module OpenTelemetry
7
7
  module Config
8
- VERSION = '0.1.0'
8
+ VERSION = '0.1.1'
9
9
  end
10
10
  end
@@ -6,6 +6,7 @@
6
6
  require 'date'
7
7
  require 'yaml'
8
8
 
9
+ require_relative 'config/defaults'
9
10
  require_relative 'config/propagation'
10
11
  require_relative 'config/resource'
11
12
  require_relative 'config/constants'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentelemetry-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenTelemetry Authors
@@ -78,6 +78,7 @@ files:
78
78
  - lib/opentelemetry-config.rb
79
79
  - lib/opentelemetry/config.rb
80
80
  - lib/opentelemetry/config/constants.rb
81
+ - lib/opentelemetry/config/defaults.rb
81
82
  - lib/opentelemetry/config/generated_constants.rb
82
83
  - lib/opentelemetry/config/propagation.rb
83
84
  - lib/opentelemetry/config/resource.rb
@@ -87,10 +88,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
87
88
  licenses:
88
89
  - Apache-2.0
89
90
  metadata:
90
- changelog_uri: https://rubydoc.info/gems/opentelemetry-config/0.1.0/file/CHANGELOG.md
91
- source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/opentelemetry-config/v0.1.0/config
91
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-config/0.1.1/file/CHANGELOG.md
92
+ source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/opentelemetry-config/v0.1.1/config
92
93
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
93
- documentation_uri: https://rubydoc.info/gems/opentelemetry-config/0.1.0
94
+ documentation_uri: https://rubydoc.info/gems/opentelemetry-config/0.1.1
94
95
  rdoc_options: []
95
96
  require_paths:
96
97
  - lib