logging: exception.message is the exception's first argument, not its message
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 74/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
Bắt đầu với LoggingHandler._get_attributes trong opentelemetry/instrumentation/logging/handler.py và kiểm tra biểu thức tương tự trong opentelemetry/instrumentation/structlog/__init__.py cũng như handler SDK đã lỗi thời tại opentelemetry/sdk/_logs/_internal/__init__.py. Kiểm tra các bài kiểm thử cho thuộc tính ngoại lệ và so sánh đầu ra log với Span.record_exception cho các ví dụ trong issue. Công việc hoàn tất khi cả ba handler xuất str(exception) nhất quán, kể cả với ngoại lệ có nhiều đối số hoặc không có đối số.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
(Posted by Claude on my behalf)
Describe your environment
OS: Linux
Python version: 3.13
Package version: opentelemetry-instrumentation-logging 0.66b2, opentelemetry-sdk 1.45.2 (the same code is on main)
What happened?
LoggingHandler sets exception.message to str(value.args[0]). For any exception whose message is not its first argument, the exported attribute is wrong, and it disagrees with what Span.record_exception exports for the same exception, which uses str(exception).
| Exception | str(exc) |
log exception.message |
span exception.message |
|---|---|---|---|
OSError(2, "No such file or directory") |
[Errno 2] No such file or directory |
2 |
[Errno 2] No such file or directory |
ValueError("bad value", 42) |
('bad value', 42) |
bad value |
('bad value', 42) |
ValueError() |
(empty) | attribute absent | (empty) |
OSError and its subclasses are the common case: every file and socket error exports its errno as the message.
Steps to Reproduce
import logging
from opentelemetry.instrumentation.logging.handler import LoggingHandler
from opentelemetry.sdk._logs import LoggerProvider
from opentelemetry.sdk._logs.export import InMemoryLogRecordExporter, SimpleLogRecordProcessor
exporter = InMemoryLogRecordExporter()
provider = LoggerProvider()
provider.add_log_record_processor(SimpleLogRecordProcessor(exporter))
log = logging.getLogger("demo")
log.addHandler(LoggingHandler(logger_provider=provider))
try:
raise OSError(2, "No such file or directory")
except OSError:
log.exception("failed")
print(exporter.get_finished_logs()[-1].log_record.attributes["exception.message"])
Expected Result
[Errno 2] No such file or directory, i.e. str(exc), as Span.record_exception exports (EXCEPTION_MESSAGE: str(exception) in opentelemetry/sdk/trace/__init__.py).
Actual Result
2
Additional context
The same expression is in three places:
opentelemetry/instrumentation/logging/handler.py,LoggingHandler._get_attributesopentelemetry/instrumentation/structlog/__init__.py,StructlogProcessor._get_attributesopentelemetry/sdk/_logs/_internal/__init__.py, the SDK's deprecatedLoggingHandler(in opentelemetry-python)
Would you like to implement a fix?
No
- Ngôn ngữ chính
- Python
- Star
- 1.1k
- Fork
- 1.1k
- Merge trung bình
- 3 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 51
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của open-telemetry/opentelemetry-python-contrib
-
jinja2: tracing ignores suppress_instrumentation()Có thể đã có người làm @RichardoMrMu đã nhận 37 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
open-telemetry/opentelemetry-python-contrib#5167 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
opentelemetry-instrumentation-tornado: server metrics recorded twice when a handler raises, http.server.active_requests goes negativeCó thể đã có người làm @sivakumar-mahalingam đã nhận 51 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
open-telemetry/opentelemetry-python-contrib#5113 · 2 bình luận · 2 reaction ·
Maintainer thường phản hồi trong vòng 2 ngày
-
httpx: `http.client.duration` has no `net.peer.name` in the default semconv modeCó thể đã có người làm @jbyers44 đã nhận 53 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
open-telemetry/opentelemetry-python-contrib#5100 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
`LoggingInstrumentor` `log_hook` only runs when there is an active spanCó thể đã có người làm @git-jxj đã nhận 61 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
open-telemetry/opentelemetry-python-contrib#5069 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[grpc] AIO server spans record uncaught exceptions twiceCó thể đã có người làm @somuai đã nhận 60 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
open-telemetry/opentelemetry-python-contrib#5068 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của open-telemetry/opentelemetry-python-contrib
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Deltares/numba_celltree#100 · 1 bình luận ·
-
auto-reported bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
Maintainer thường phản hồi trong vòng 1 ngày
-
soup airgap-bundle --bundle-size-cap nan, inf or a cap above ~1.67e299 GiB stops with an internal ValueError/OverflowError (exit 1) instead of a usage errorCó thể đã có người làm @Keshemir đã nhận hôm nay. Đang mởbug claimed difficulty:2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
MakazhanAlpamys/Soup#3045 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
dagster-io/skills#80 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày