Skip to content

ValueError when initializing Tracer #4456

@obs-gh-abhishekrao

Description

@obs-gh-abhishekrao

Describe your environment

We have a Python 3.11 app using openllmetry 0.38.8

What happened?

We encountered this bug in openllmetry - traceloop/openllmetry#2699

 File "/code/python/service/ai_agents/.venv/lib/python3.11/site-packages/opentelemetry/sdk/trace/__init__.py", line 713, in _from_env_if_absent
    raise ValueError(err_msg.format(env_var, value))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: cannot switch from manual field specification to automatic field numbering

We still don't know what's causing the original problem, but the error itself is dubious. We should seen a different error that tells us which env var that has the malformed value, but instead run into a ValueError on the error message formatting.

When I checked, it felt like the problem might be on this line -

err_msg = "{0} must be a non-negative integer but got {}"

  1. Unless I've missed something, It feels like the formatting may be the culprit for the ValueError.
  2. It's not clear how _from_env_if_absent is even failing in openllmetry, but I suppose fixing the above bug will help us reach that part. We have a gunicorn FastAPI app backing an LLM service in our setup.

Steps to Reproduce

Even a basic python script like the following reproduces the error:

env_var = "test"
value = -1
err_msg = "{0} must be a non-negative integer but got {}"
raise ValueError(err_msg.format(env_var, value))

Expected Result

Should tell us which env var was supplied an incorrect value

Actual Result

ValueError: cannot switch from manual field specification to automatic field numbering

Additional context

No response

Would you like to implement a fix?

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions