Invalid enum `OTEL_*` values abort initialization instead of falling back

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

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

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

Research direction

The payload names no files, so start by finding where OTEL_TRACES_SAMPLER is read from the environment and where the Unknown sampler error is thrown. Run the reproduction command from the issue with the autoload flag set. Done means an unrecognized enum value logs a warning and the SDK falls back to the default sampler, with the invalid value covered by a test.

Written by the indexing model from the issue text.

Description

bug

https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#enum

For sources accepting an enum value, if the user provides a value the implementation does not recognize, the implementation MUST generate a warning and gracefully ignore the setting.

Steps to reproduce

OTEL_PHP_AUTOLOAD_ENABLED=true OTEL_TRACES_SAMPLER=not-a-sampler php -r 'require "vendor/autoload.php"; \OpenTelemetry\API\Globals::tracerProvider();'

What is the expected behavior?
The invalid setting is gracefully ignored, the SDK is initialized with the default value.

What is the actual behavior?

OpenTelemetry: [warning] Error during opentelemetry initialization: Unknown sampler: not-a-sampler

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.

Dominant language
PHP
Stars
923
Forks
234
Avg merge
1d 20h
Merged PRs (30d)
35

Getting set up

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.

More from open-telemetry/opentelemetry-php

All issues in open-telemetry/opentelemetry-php

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.