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

Update Python Sample Apps for Upstream 1.3 #110

Merged
merged 3 commits into from
Jul 6, 2021

Conversation

NathanielRN
Copy link
Contributor

@NathanielRN NathanielRN commented Jul 3, 2021

Description

To make our sample apps work with the 1.3 upstream release of OTel Python, we need to make changes to our sample app for the minor breaking changes.

Testing

I was able to get the correct trace both by executing from the Lambda console and by using curl -sS to the API gateway link where my lambda layer was being used.

Upstream PRs that caused changes

@NathanielRN NathanielRN force-pushed the python-apps-1.3-update branch 4 times, most recently from 88dfb00 to 3d17ddf Compare July 5, 2021 17:29
@NathanielRN NathanielRN force-pushed the python-apps-1.3-update branch from 3d17ddf to 6ba9b00 Compare July 5, 2021 17:30
@NathanielRN NathanielRN marked this pull request as ready for review July 5, 2021 17:31
@@ -30,7 +30,7 @@
)

# Enable instrumentation
AwsLambdaInstrumentor().instrument()
AwsLambdaInstrumentor().instrument(skip_dep_check=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use flag skip_dep_check to remove these code ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm I'm not sure what we would replace it with. The _load_distros, _load_instrumentors and _load_configurators all initialize the classes they find. Normally, its important to not skip_dep_check because the classes _load_instrumentors loads requires that the dependencies are installed. Attempting to instrument without the dependencies would cause an import error.

I think it might be possible to use the upstream opentelemetry-instrumentation package as it is today instead of doing this code ourselves, but we don't need that in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge the code first. I feel if is_recording() is essential why it is not integrated inside of start_span. I can raise issue in python repo later.

span.set_attribute("faas.version", function_version)

result = original_func(*args, **kwargs)
if span.is_recording():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure it's necessary. When start the span and sampled, is_recording() is always true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good question! Initially I didn't know why we did this and I just did it because we do it for every other instrumentation as seen in open-telemetry/opentelemetry-python#1057, so I wanted AwsLambdaInstrumentor to be the same.

But now I understand that we need this because we don't know if the Span will be Sampled. It is started like you said but if the Sampler doesn't sample this span then we shouldn't record attributes.

@NathanielRN NathanielRN requested a review from wangzlei July 6, 2021 18:15
@@ -30,7 +30,7 @@
)

# Enable instrumentation
AwsLambdaInstrumentor().instrument()
AwsLambdaInstrumentor().instrument(skip_dep_check=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge the code first. I feel if is_recording() is essential why it is not integrated inside of start_span. I can raise issue in python repo later.

@wangzlei wangzlei merged commit 584edd4 into open-telemetry:main Jul 6, 2021
garrettwegan pushed a commit to garrettwegan/opentelemetry-lambda that referenced this pull request Aug 2, 2021
* Update Python Sample Apps for Upstream 1.3

* Skip dep check lets LambdaInstrumentor get called

* Copy style of contrib instrumentations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants