open-telemetry / open-telemetry/opentelemetry-python
[bug] BatchSpanProcessor missing validation for export_timeout_millis <= 0
Nobody has claimed this yet.
- 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
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 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