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
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/foam/otel/resource.rb', line 21 def build(config) attrs = { "service.name" => config.name, "deployment.environment.name" => config.environment, "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. attrs["service.version"] = config.version if config.version && !config.version.to_s.empty? OpenTelemetry::SDK::Resources::Resource.create(attrs) end |