open-telemetry / open-telemetry/opentelemetry-python-contrib

[opentelemetry-instrumentation-aws-lambda] No span is automatically created

Open
#1,251 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
1.1k
Forks
1.1k
Avg merge
4d 15h
Merged PRs (30d)
16

Description

Failing to get a lambda span auto generated an awslambdaric docker image.
Seems that metrics are being generated as seen by:

{"resource_metrics": [{"resource": {"attributes": {"telemetry.sdk.language": "python", "telemetry.sdk.name": "opentelemetry", "telemetry.sdk.version": "1.12.0", "service.name": "chook", "telemetry.auto.version": "0.33b0"}, "schema_url": ""}, "scope_metrics": [], "schema_url": ""}]}

Describe your environment
Final image includes the following relevant packages:

awslambdaric-2.0.4.dist-info  
opentelemetry_api-1.12.0.dist-info   
opentelemetry_distro-0.33b0.dist-info  
opentelemetry_exporter_otlp_proto_http-1.12.0.dist-info   
opentelemetry_instrumentation-0.33b0.dist-info  
opentelemetry_instrumentation_aws_lambda-0.33b0.dist-info  
opentelemetry_instrumentation_dbapi-0.33b0.dist-info  
opentelemetry_instrumentation_logging-0.33b0.dist-info  
opentelemetry_instrumentation_requests-0.33b0.dist-info  
opentelemetry_instrumentation_sqlite3-0.33b0.dist-info  
opentelemetry_instrumentation_urllib-0.33b0.dist-info  
opentelemetry_instrumentation_urllib3-0.33b0.dist-info  
opentelemetry_instrumentation_wsgi-0.33b0.dist-info  
opentelemetry_propagator_aws_xray-1.0.1.dist-info  
opentelemetry_proto-1.12.0.dist-info  
opentelemetry_sdk-1.12.0.dist-info
opentelemetry_sdk_extension_aws-2.0.1.dist-info
opentelemetry_semantic_conventions-0.33b0.dist-info
opentelemetry_util_http-0.33b0.dist-info
protobuf-3.20.1.dist-info

Steps to reproduce
The entry.sh is
exec /usr/local/bin/opentelemetry-instrument --service_name=chook--log_level=debug --traces_exporter=console --metrics_exporter=console --logs_exporter=console /usr/local/bin/python -m awslambdaric $1

What is the expected behavior?
Once I run
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'
I expected the lambda to create a span as well.

What is the actual behavior?
No span is generated (also validated with adding trace.get_current_span().get_span_context().span_id and it's 0.

Additional context
Here's the Dockerfile

FROM python:3.9-slim-bullseye

ARG BUILD_DATE
ARG BUILD_REVISION
ARG BUILD_VERSION

RUN grep security /etc/apt/sources.list > /tmp/security.list \
    && apt-get update \
    && apt-get upgrade -y -oDir::Etc::Sourcelist=/tmp/security.list \
    && apt-get upgrade -y \
    && apt-get install -y git --no-install-recommends 
WORKDIR /app

ENV PIP_DISABLE_PIP_VERSION_CHECK=1
ENV PIP_NO_CACHE_DIR=1
ENV PYTHONUNBUFFERED 1

RUN pip install awslambdaric pipenv \
    opentelemetry-instrumentation \
    opentelemetry-distro \
    opentelemetry-instrumentation-aws-lambda \
    opentelemetry-sdk-extension-aws \
    opentelemetry-propagator-aws-xray \
    opentelemetry-exporter-otlp-proto-http

COPY app ./app

ADD entry.sh /entry.sh
ADD https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie /usr/bin/aws-lambda-rie

RUN chmod 755 /usr/bin/aws-lambda-rie /entry.sh

RUN opentelemetry-bootstrap -a install

ENTRYPOINT ["/entry.sh", "app.main.lambda_handler"]

Contributor guide

Open the contributing guide

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.

Research direction

Start with entry.sh and the Dockerfile, especially the opentelemetry-instrument invocation and awslambdaric entry point. Reproduce the report with the AWS Lambda Runtime Interface Emulator and the shown curl request, then trace why no Lambda span is created. Done means the invocation produces the expected automatically generated span and the behavior is covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python
Domain
cloud, observability
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.