Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pyramid: Fix which package is the correct caller in _traced_init.
Browse files Browse the repository at this point in the history
Ken Robbins committed Dec 9, 2021

Verified

This commit was signed with the committer’s verified signature.
1 parent 444e0a1 commit c69ae2b
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -134,10 +134,12 @@ def _traced_init(wrapped, instance, args, kwargs):
# to find the calling package. So if we let the original `__init__`
# function call it, our wrapper will mess things up.
if not kwargs.get("package", None):
# Get the package for the third frame up from this one.
# Default is `level=2` which will give us the package from `wrapt`
# instead of the desired package (the caller)
kwargs["package"] = caller_package(level=3)
# Get the package for the 2nd frame up from this one.
# Default is `level=2` one level down (in Configurator.__init__).
# We want the 3rd level from _there_. Since we are already 1 level above,
# we need the 2nd level up from here, which will give us the package from
# `wrapt` instead of the desired package (the caller)
kwargs["package"] = caller_package(level=2)

wrapped(*args, **kwargs)
instance.include("opentelemetry.instrumentation.pyramid.callbacks")

0 comments on commit c69ae2b

Please sign in to comment.