open-telemetry / open-telemetry/opentelemetry-ruby
Block `Collect`/`Export` after `Shutdown`
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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