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

Expand allowed versions for jinja2 instrumentation #712

Merged
merged 20 commits into from
Oct 12, 2021

Conversation

andrew-matteson
Copy link
Contributor

Description

The Jinja2 API hasn't changed the functions that have been wrapped in at least 8 years.
The version supported should be much more broad.

Specifically,
jinja2.environment.Template.render jinja2.Template.generate jinja2.Environment.compile jinja2.Environment._load_template
which are the only wrapped functions seem to be appropriate for the instrumentation wrappers without further changes.

I'm not a jinja2 expert, so it's possible I'm missing something. Happy to help with changes if it seems that I am.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

This change produces useful traces in our system.

  • Test A

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

The Jinja2 API hasn't changed the functions that have been wrapped in at least 8 years.
The version supported should be much more broad.
@andrew-matteson andrew-matteson requested a review from a team October 4, 2021 15:52
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 4, 2021

CLA Signed

The committers are authorized under a signed CLA.

@andrew-matteson
Copy link
Contributor Author

@owais Can you let me know if there's anything I need to do to get the checks to run?

Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

I triggered the build just now by updating the branch, it appears to be running.

bootstrap_gen.py Outdated Show resolved Hide resolved
@andrew-matteson
Copy link
Contributor Author

@codeboten Thanks for the pointer. I've created this PR for the bootstrap file.

I'm having some challenges with tests + linting. The tests seem to be running with jinja2==2.11.3. The linting is running with jinja2==3.0.1. The linting fails because the test references, in a version specific way, a variable that stopped existing in 3.0.0. I get the error:

E1101: Module 'jinja2.environment' has no '_spontaneous_environments' member (no-member)

Is # pylint: disable=no-member appropriate in this repo?

@owais owais enabled auto-merge (squash) October 6, 2021 15:19
auto-merge was automatically disabled October 6, 2021 16:56

Head branch was pushed to by a user without write access

@andrew-matteson
Copy link
Contributor Author

@owais @codeboten Could you give me advice on how to proceed?

When I run tox -e generate locally, it generates a bootstrap file that doesn't have the pika section. The jinja2 changes are committed in the core repo. I'm not sure how the comparison between the files works, but if it's just checking that the generated file exactly matches what's in the core repo, I could see a scenario in which both the pika PR and this one are blocked, waiting for each other. Please let me know if there's anything I can do.

The performance regression in the most recent run seems spurious (adding a space to a comment is probably unrelated...)

@lzchen
Copy link
Contributor

lzchen commented Oct 6, 2021

@andrew-matteson
Pika pr is merged (#680) so you just have to rebase and maybe update the SHA

@owais owais enabled auto-merge (squash) October 7, 2021 14:16
@andrew-matteson
Copy link
Contributor Author

@owais Nope. _spontaneous_environments is only referenced in the tests. This logic is used to prevent test drool due to jinja2's caching logic.

I'm also stumped about how to get past the generate check. tox -e generate succeeds on my machine and doesn't generate a bootstrap_gen.py.

@owais
Copy link
Contributor

owais commented Oct 7, 2021

>>> black .
reformatted /tmp/tmp_jl3p0j8/new.py
All done! ✨ 🍰 ✨
1 file reformatted, 1 file left unchanged.
>>> isort --profile black .
INFO:instrumentation_list_generator:generated /tmp/tmp_jl3p0j8/new.py
INFO:instrumentation_list_generator:Generated code is out of date, please run "tox -e generate" and commit bootstrap_gen.py to core repo.
ERROR: InvocationError for command /home/runner/work/opentelemetry-python-contrib/opentelemetry-python-contrib/scripts/generate_instrumentation_bootstrap.py (exited with code 1)
____________

@owais
Copy link
Contributor

owais commented Oct 7, 2021

@andrew-matteson please update .github/workflows/test.yml and set CORE_REPO_SHA to 65528f7534f1f5f2e8adc7520b6e696a84569c7d (latest commit that includes jinja2 bootstrap_gen change). That should resolve the CI failure.

https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/.github/workflows/test.yml#L9


@codeboten we use a specific GIT SHA in CI but use main locally. Ideally we should use the same thing everywhere. Hopefully we can merge #709 soon and this whole requirement issue can be eliminated.

@owais
Copy link
Contributor

owais commented Oct 7, 2021

@owais Nope. _spontaneous_environments is only referenced in the tests. This logic is used to prevent test drool due to jinja2's caching logic.

Yeah, I realized it right after posting the comment :)

auto-merge was automatically disabled October 7, 2021 19:44

Head branch was pushed to by a user without write access

@andrew-matteson
Copy link
Contributor Author

That should do it 🤞

@owais owais enabled auto-merge (squash) October 7, 2021 20:49
@andrew-matteson
Copy link
Contributor Author

The failures seem like sporadic issues unrelated to my changes. If I need to do something, let me know. I won't be able to touch this again until next Wednesday.

Copy link
Contributor

@owais owais left a comment

Choose a reason for hiding this comment

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

LGTM. Will merge if everything else other than docker-tests passes which is known to be broken right now.

Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

LGTM

@owais owais merged commit 36275f3 into open-telemetry:main Oct 12, 2021
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.

5 participants