Skip to content

opentelemetry-instrumentation-aws-lambda: code does not handle lack of expected environment variables #2744

@Kyle-sandeman-mrdfood

Description

@Kyle-sandeman-mrdfood

Describe your environment

OS: Docker (python3.12)
Python version: (e.g., Python 3.12.1)
Package version: (e.g., 0.48.0)

What happened?

Please note that my application is NOT a Lambda or related in any way. I only have this package because it is a default in the bootstrap.

Instrumenting of aws-lambda failed
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/auto_instrumentation/_load.py", line 87, in _load_instrumentors
    distro.load_instrumentor(entry_point, skip_dep_check=True)
  File "/usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/distro.py", line 64, in load_instrumentor
    instrumentor().instrument(**kwargs)
  File "/usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/instrumentor.py", line 114, in instrument
    result = self._instrument(  # pylint: disable=assignment-from-no-return
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/aws_lambda/__init__.py", line 429, in _instrument
    ) = lambda_handler.rsplit(".", 1)
        ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'rsplit'
Failed to auto initialize opentelemetry
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/auto_instrumentation/sitecustomize.py", line 39, in initialize
    _load_instrumentors(distro)
  File "/usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/auto_instrumentation/_load.py", line 91, in _load_instrumentors
    raise exc
  File "/usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/auto_instrumentation/_load.py", line 87, in _load_instrumentors
    distro.load_instrumentor(entry_point, skip_dep_check=True)
  File "/usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/distro.py", line 64, in load_instrumentor
    instrumentor().instrument(**kwargs)
  File "/usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/instrumentor.py", line 114, in instrument
    result = self._instrument(  # pylint: disable=assignment-from-no-return
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/aws_lambda/__init__.py", line 429, in _instrument
    ) = lambda_handler.rsplit(".", 1)
        ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'rsplit'

Steps to Reproduce

pip install opentelemetry-distro opentelemetry-exporter-otlp-proto-grpc opentelemetry-propagator-jaeger opentelemetry-instrumentation-aws-lambda

One could instead run opentelemetry-bootstrap -a install, I presume.

opentelemetry-instrument python -c "print('test')"

Expected Result

test

Actual Result

<error message from description>
test

Additional context

While this does not affect the application itself, it may affect whether tracing gets set up properly.

Would you like to implement a fix?

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions