Skip to content

Commit c69ae2b

Browse files
author
Ken Robbins
committed
pyramid: Fix which package is the correct caller in _traced_init.
1 parent 444e0a1 commit c69ae2b

File tree

1 file changed

+6
-4
lines changed
  • instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid

1 file changed

+6
-4
lines changed

Diff for: instrumentation/opentelemetry-instrumentation-pyramid/src/opentelemetry/instrumentation/pyramid/__init__.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,12 @@ def _traced_init(wrapped, instance, args, kwargs):
134134
# to find the calling package. So if we let the original `__init__`
135135
# function call it, our wrapper will mess things up.
136136
if not kwargs.get("package", None):
137-
# Get the package for the third frame up from this one.
138-
# Default is `level=2` which will give us the package from `wrapt`
139-
# instead of the desired package (the caller)
140-
kwargs["package"] = caller_package(level=3)
137+
# Get the package for the 2nd frame up from this one.
138+
# Default is `level=2` one level down (in Configurator.__init__).
139+
# We want the 3rd level from _there_. Since we are already 1 level above,
140+
# we need the 2nd level up from here, which will give us the package from
141+
# `wrapt` instead of the desired package (the caller)
142+
kwargs["package"] = caller_package(level=2)
141143

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

0 commit comments

Comments
 (0)