Skip to content

Commit c92075a

Browse files
committed
fix: logging stacklevel for ppc64le
Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
1 parent d228a93 commit c92075a

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/instana/instrumentation/logging.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from typing import Any, Tuple, Dict, Callable
1010

1111
from instana.log import logger
12+
from instana.util.runtime import get_runtime_env_info
1213
from instana.util.traceutils import get_tracer_tuple, tracing_is_off
1314

1415

@@ -25,7 +26,7 @@ def log_with_instana(
2526

2627
# We take into consideration if `stacklevel` is already present in `kwargs`.
2728
# This prevents the error `_log() got multiple values for keyword argument 'stacklevel'`
28-
stacklevel_in = kwargs.pop("stacklevel", 1)
29+
stacklevel_in = kwargs.pop("stacklevel", 1 if get_runtime_env_info()[0] != "ppc64le" else 2)
2930
stacklevel = stacklevel_in + 1 + (sys.version_info >= (3, 14))
3031

3132
try:

tests/clients/test_logging.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import pytest
99
from opentelemetry.trace import SpanKind
1010

11+
from instana.util.runtime import get_runtime_env_info
1112
from instana.singletons import agent, tracer
1213

1314

@@ -146,6 +147,9 @@ def test_log_caller_with_stacklevel(
146147
)
147148
self.logger.addHandler(handler)
148149

150+
if get_runtime_env_info()[0] == "ppc64le":
151+
stacklevel += 1
152+
149153
def log_custom_warning():
150154
self.logger.warning("foo %s", "bar", stacklevel=stacklevel)
151155

0 commit comments

Comments
 (0)