Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing environment variable ORIG_HANDLER #2803

Closed
Warfere opened this issue Aug 16, 2024 · 2 comments
Closed

missing environment variable ORIG_HANDLER #2803

Warfere opened this issue Aug 16, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Warfere
Copy link

Warfere commented Aug 16, 2024

Describe your environment

OS: (e.g, Ubuntu)
Python version: 3.11.2
Package version: latest

What happened?

missing environmnet variable when starting container with
CMD ["opentelemetry-instrument", "--traces_exporter", "console", "--logs_exporter", "console", "--service_name", "dice-server", "fastapi", "run", "app/app.py", "--port", "80"]

Steps to Reproduce

from opentelemetry.instrumentation import aws_lambda
aws_lambda.AwsLambdaInstrumentor()
<opentelemetry.instrumentation.aws_lambda.AwsLambdaInstrumentor object at 0x000001F2DA6ACAD0>
a = aws_lambda.AwsLambdaInstrumentor()
dir(a)
['__abstractmethods__', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__slots__', '__str__', '__subclasshook__', '__weakref__', '_abc_impl', '_check_dependency_conflicts', '_instance', '_instrument', '_is_instrumented_by_opentelemetry', '_uninstrument', 'instrument', 'instrumentation_dependencies', 'is_instrumented_by_opentelemetry', 'uninstrument']
a._instrument
<bound method AwsLambdaInstrumentor._instrument of <opentelemetry.instrumentation.aws_lambda.AwsLambdaInstrumentor object at 0x000001F2DA6ACAD0>>
a._instrument()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "F:\darbeliai\interview\venv\Lib\site-packages\opentelemetry\instrumentation\aws_lambda\__init__.py", line 429, in _instrument
    ) = lambda_handler.rsplit(".", 1)
        ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'rsplit'

#or

FROM python:3.9

# 
WORKDIR /code

# 
COPY ./requirements.txt /code/requirements.txt

# 
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
RUN opentelemetry-bootstrap -a install
# 
COPY ./app /code/app
ENV OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true
# 
CMD ["opentelemetry-instrument", "--traces_exporter", "console", "--logs_exporter", "console", "--metrics_exporter", "console",  "--service_name", "dice-server", "fastapi", "run", "app/app.py", "--port", "80"]

Expected Result

If running locally you should not require env variables. Plus I was not able to find reference in documentation about this variable.

Actual Result

2024-08-16 21:06:30 {
2024-08-16 21:06:30     "body": "Instrumenting of aws-lambda failed",
2024-08-16 21:06:30     "severity_number": "<SeverityNumber.ERROR: 17>",
2024-08-16 21:06:30     "severity_text": "ERROR",
2024-08-16 21:06:30     "attributes": {
2024-08-16 21:06:30         "otelSpanID": "0",
2024-08-16 21:06:30         "otelTraceID": "0",
2024-08-16 21:06:30         "otelTraceSampled": false,
2024-08-16 21:06:30         "otelServiceName": "dice-server",
2024-08-16 21:06:30         "code.filepath": "/usr/local/lib/python3.9/site-packages/opentelemetry/instrumentation/auto_instrumentation/_load.py",
2024-08-16 21:06:30         "code.function": "_load_instrumentors",
2024-08-16 21:06:30         "code.lineno": 90,
2024-08-16 21:06:30         "exception.type": "AttributeError",
2024-08-16 21:06:30         "exception.message": "'NoneType' object has no attribute 'rsplit'",
2024-08-16 21:06:30         "exception.stacktrace": "Traceback (most recent call last):\n  File \"/usr/local/lib/python3.9/site-packages/opentelemetry/instrumentation/auto_instrumentation/_load.py\", line 87, in _load_instrumentors\n    distro.load_instrumentor(entry_point, skip_dep_check=True)\n  File \"/usr/local/lib/python3.9/site-packages/opentelemetry/instrumentation/distro.py\", line 64, in load_instrumentor\n    instrumentor().instrument(**kwargs)\n  File \"/usr/local/lib/python3.9/site-packages/opentelemetry/instrumentation/instrumentor.py\", line 114, in instrument\n    result = self._instrument(  # pylint: disable=assignment-from-no-return\n  File \"/usr/local/lib/python3.9/site-packages/opentelemetry/instrumentation/aws_lambda/__init__.py\", line 430, in _instrument\n    ) = lambda_handler.rsplit(\".\", 1)\nAttributeError: 'NoneType' object has no attribute 'rsplit'\n"
2024-08-16 21:06:30     },
2024-08-16 21:06:30     "dropped_attributes": 0,
2024-08-16 21:06:30     "timestamp": "2024-08-16T18:06:26.902776Z",
2024-08-16 21:06:30     "observed_timestamp": "2024-08-16T18:06:26.903206Z",
2024-08-16 21:06:30     "trace_id": "0x00000000000000000000000000000000",
2024-08-16 21:06:30     "span_id": "0x0000000000000000",
2024-08-16 21:06:30     "trace_flags": 0,
2024-08-16 21:06:30     "resource": {
2024-08-16 21:06:30         "attributes": {
2024-08-16 21:06:30             "telemetry.sdk.language": "python",
2024-08-16 21:06:30             "telemetry.sdk.name": "opentelemetry",
2024-08-16 21:06:30             "telemetry.sdk.version": "1.26.0",
2024-08-16 21:06:30             "service.name": "dice-server",
2024-08-16 21:06:30             "telemetry.auto.version": "0.47b0"
2024-08-16 21:06:30         },
2024-08-16 21:06:30         "schema_url": ""
2024-08-16 21:06:30     }
2024-08-16 21:06:30 }

Additional context

correct me if I do something wrong here :/

@Warfere Warfere added the bug Something isn't working label Aug 16, 2024
@emdneto
Copy link
Member

emdneto commented Aug 16, 2024

You're facing the same issue as here. A fix for this will be part of the next release. In that case, I'm assuming you're not running in an AWS Lambda runtime, so you can disable the AWS Lambda instrumentation or uninstall the aws-lambda instrumentation package.

@Warfere
Copy link
Author

Warfere commented Aug 17, 2024

Hello, sorry for duplicate bug report.
what helpped was CMD ["opentelemetry-instrument", "dice-server", "fastapi", "run", "app/app.py", "--port", "80"]
removing inline exporters' parameters and setting them in docker-compose env.

will close this one. Have a great day

@Warfere Warfere closed this as completed Aug 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants