Skip to content

oss_19_periodic_metric_reader_batch_size#25

Open
ocelotl wants to merge 2 commits into
mainfrom
oss_19_periodic_metric_reader_batch_size
Open

oss_19_periodic_metric_reader_batch_size#25
ocelotl wants to merge 2 commits into
mainfrom
oss_19_periodic_metric_reader_batch_size

Conversation

@ocelotl

@ocelotl ocelotl commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Closes #21

Add optional max_export_batch_size to PeriodicExportingMetricReader with data-point chunking under the export lock (Linear OSS-19, finding M4); None = unchanged single export. Validation: metrics suite 309 passed, scope sdk+changelog.

Linear issue: https://linear.app/dash0/issue/OSS-19/m4-periodicexportingmetricreader-lacks-max-export-batch-size

Add an optional max_export_batch_size parameter to
PeriodicExportingMetricReader. When set, collected metrics are split
into batches so that no single exporter.export() call carries more than
the configured number of data points, preserving the
resource/scope/metric grouping. When unset (None), behavior is unchanged
and the full collection is exported in a single call. Batching happens
under the existing export lock.
@ocelotl

ocelotl commented Jul 22, 2026

Copy link
Copy Markdown
Owner Author

🔒 Internal (dash0) — not for upstream.

@ocelotl

ocelotl commented Jul 22, 2026

Copy link
Copy Markdown
Owner Author

📣 Public-facing draft — to be used for the upstream PR in open-telemetry/opentelemetry-python. No internal references; copy verbatim.

Title: Add max_export_batch_size to PeriodicExportingMetricReader

What

Adds an optional max_export_batch_size: int | None = None to PeriodicExportingMetricReader.

  • None (default): unchanged — the full MetricsData is exported in a single export() call.
  • Positive integer: the collected metrics are split into multiple MetricsData batches so no single export() call carries more than that many data points. Each batch reproduces the owning resource and scope, so grouping is preserved and no point is dropped or duplicated. A single metric is never split across the metric boundary; if one metric's own point count exceeds the limit it is emitted whole in its own batch. Batching runs under the existing _export_lock, so export() is still never concurrent.
  • A value <= 0 raises ValueError in the constructor.

Why

The metrics SDK spec defines maxExportBatchSize for the periodic reader and Go implements it (sdk/metric/periodic_reader.go). Python had no way to bound points per export call, which can produce oversized payloads on large cycles.

Spec

Implements the periodic reader maxExportBatchSize from specification/metrics/sdk.md.

Tests

New tests: None/default → one export with all points; small batch size → multiple export calls each within the limit, names present once in order, resource/scope preserved; batch size larger than total → single call; direct _batch_metrics_data coverage on multi-resource/scope/metric input; invalid values (0, -1) → ValueError. All existing metrics tests pass (309).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

oss_19_periodic_metric_reader_batch_size

1 participant