open-telemetry / open-telemetry/opentelemetry-ruby

Block `Collect`/`Export` after `Shutdown`

Open
#2,358 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug metrics spec-compliance spec:stable
Dominant language
Ruby
Stars
606
Forks
301
Avg merge
3d 19h
Merged PRs (30d)
42

Description

Spec requirement

MetricReader#Shutdown MUST be called once; after it, subsequent Collect calls MUST NOT be allowed and SHOULD fail (sdk.md:1524-1539). The same applies to MetricExporter#Shutdown/Export (sdk.md:1757-1769).

Current behavior

export/metric_reader.rb:25-27 (permalink) records no state, so collect remains callable (and functional) after shutdown. Separately, the OTLP MetricsExporter#shutdown (metrics_exporter.rb:387-390 (permalink)) sets @shutdown = true, but that flag is never read elsewhere in the file. export also remains functional after shutdown.

Suggested fix

Track a @stopped flag on the base MetricReader and check it at the top of collect, returning a failure/no-op result once set (mirroring ConsoleMetricPullExporter's existing @stopped pattern). Add the equivalent guard clause to the OTLP exporter's export/send_bytes.

Related rows in SPEC_COMPLIANCE_METRICS.md

SDK-56, OTLP-11

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with export/metric_reader.rb:25-27 and the existing @stopped pattern in ConsoleMetricPullExporter. Then inspect metrics_exporter.rb:387-390 and its export/send_bytes flow. Add shutdown guards so Collect and Export no longer operate after shutdown, and verify the behavior against SDK-56 and OTLP-11 in SPEC_COMPLIANCE_METRICS.md.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
observability-sre
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.