open-telemetry / open-telemetry/opentelemetry-python

[bug] BatchSpanProcessor missing validation for export_timeout_millis <= 0

Open
#5,648 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
2.6k
Forks
1k
Avg merge
4d 15h
Merged PRs (30d)
19

Description

Describe your environment

OS: macOS / Linux
Python version: 3.10+
SDK version: main

What happened?

In opentelemetry-sdk (opentelemetry.sdk.trace.export.BatchSpanProcessor and BatchLogRecordProcessor), parameters like max_queue_size, schedule_delay_millis, and max_export_batch_size validate that values must be positive integers and raise a ValueError if <= 0.

However, export_timeout_millis is missing validation for values <= 0. Initializing BatchSpanProcessor(ConsoleSpanExporter(), export_timeout_millis=-500) or export_timeout_millis=0 is accepted without raising a ValueError.

Steps to Reproduce

from opentelemetry.sdk.trace.export import BatchSpanProcessor, ConsoleSpanExporter

1. schedule_delay_millis correctly validates <= 0:

try:
BatchSpanProcessor(ConsoleSpanExporter(), schedule_delay_millis=0)
except ValueError as e:
print("schedule_delay_millis validation working:", e)

2. export_timeout_millis is missing validation:

bsp = BatchSpanProcessor(ConsoleSpanExporter(), export_timeout_millis=-500)
print("Accepted without ValueError!")

Expected Result

Initializing BatchSpanProcessor or BatchLogRecordProcessor with export_timeout_millis <= 0 should raise a ValueError("export_timeout_millis must be positive.").

Actual Result

Accepted without raising a ValueError.

Additional context

Location: opentelemetry-sdk/src/opentelemetry/sdk/trace/export/init.py in BatchSpanProcessor._validate_arguments().

I am opening a PR for this fix now!

Would you like to implement a fix?

Yes

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

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 in opentelemetry-sdk/src/opentelemetry/sdk/trace/export/init.py at BatchSpanProcessor._validate_arguments(), and compare the existing positive-value checks for the other parameters. Add matching validation for export_timeout_millis in both BatchSpanProcessor and BatchLogRecordProcessor, then run the relevant processor tests to confirm non-positive values raise the expected ValueError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
observability
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.