Class: Foam::Otel::Verdict

Inherits:
Struct
  • Object
show all
Defined in:
lib/foam/otel/classifier.rb

Overview

The coexistence classifier (BASE_PACKAGE_SPEC rule 18). Reads all three global slots and reports FREE (the API's built-in proxy is still installed) or CLAIMED (a real SDK registered first) — reads ONLY, never registers. init() registers into every FREE slot and warns once per CLAIMED slot; it never touches a claimed slot (rule 18, step 2).

The FREE predicate is instance_of? against the API's Proxy provider — the exact check the API's own setters use (opentelemetry-api opentelemetry.rb, metrics-api, logs-api). Real SDK providers are NOT subclasses of the proxies, so instance_of? (not is_a?) is correct. The metrics-/logs-api gems must be required before their slots exist; init() loads the SDK before classifying.

RULE-42 FENCE (GOTCHAS F7): the Internal::Proxy* constants are @api-private — this reach BREAKS IF upstream renames/moves them, so it is (1) isolated to this one file, (2) feature-detected (defined?) degrading to a warned fail-safe no-op (UNCLASSIFIABLE, below), (3+4) documented in GOTCHAS F7 and pinned by spec/classifier_spec.rb's degradation examples, and (5) the upstream need — a public "is the global still the default" predicate — is tracked for filing against open-telemetry/opentelemetry-ruby (see GOTCHAS F7); delete the reach when it ships.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#freeObject

Returns the value of attribute free

Returns:

  • (Object)

    the current value of free



27
28
29
# File 'lib/foam/otel/classifier.rb', line 27

def free
  @free
end

#ownerObject

Returns the value of attribute owner

Returns:

  • (Object)

    the current value of owner



27
28
29
# File 'lib/foam/otel/classifier.rb', line 27

def owner
  @owner
end

Instance Method Details

#claimed?Boolean

Returns:

  • (Boolean)


29
# File 'lib/foam/otel/classifier.rb', line 29

def claimed? = !free

#free?Boolean

Returns:

  • (Boolean)


28
# File 'lib/foam/otel/classifier.rb', line 28

def free? = free

#unclassifiable?Boolean

rule 42 fence: when the API's Internal proxy constant is missing (upstream renamed/removed it), foam cannot PROVE the slot free. The verdict stays fail-safe (claimed → register nothing) but is marked UNCLASSIFIABLE so init warns "foam cannot classify this OTel API version" instead of fabricating a foreign-owner name (GOTCHAS G14).

Returns:

  • (Boolean)


36
# File 'lib/foam/otel/classifier.rb', line 36

def unclassifiable? = !free && owner.equal?(Classifier::UNCLASSIFIABLE)