Module: Foam::Otel::Resource
- Defined in:
- lib/foam/otel/resource.rb
Overview
Builds the six-attribute resource every foam export carries (BASE_PACKAGE_SPEC section 0, resource identity table). Three come from init arguments (name/environment/version); three the package sets with no customer input (telemetry.distro.name/version, service.instance.id).
service.instance.id is minted per process here; a post-fork re-init mints a fresh one per worker (GOTCHAS R1) so N workers on one SHA are distinguishable rather than reporting as one process.
Class Method Summary collapse
Class Method Details
.build(config) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/foam/otel/resource.rb', line 22 def build(config) # The three customer-supplied identity strings get the value-pattern # secret scan ONCE here (security-fixes-design §V.7: resource # attributes are static, so the layer runs at pipeline construction, # a one-time cost). A normal name/environment/version is untouched; # a token pasted where an identity string belongs is masked. heuristics = Redaction.heuristics_enabled?(config) attrs = { "service.name" => Redaction.scan_value_secrets(config.name, heuristics), "deployment.environment.name" => Redaction.scan_value_secrets(config.environment, heuristics), "telemetry.distro.name" => DISTRO_NAME, "telemetry.distro.version" => Foam::Otel::VERSION, "service.instance.id" => SecureRandom.uuid, } # service.version is optional by design (section 0): not every deploy # has version plumbing on day one, and instrumentation must not block # on it. Present only when supplied. if config.version && !config.version.to_s.empty? attrs["service.version"] = Redaction.scan_value_secrets(config.version.to_s, heuristics) end OpenTelemetry::SDK::Resources::Resource.create(attrs) end |