Type warnings in Event and Metrics when OpenTelemetry tracing is unavailable (Elixir 1.20)
Maintainer thường phản hồi trong vòng 2 ngày
Một pull request liên quan đã được merge.
- #1243 của @whatyouhide — đã merge
Đá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
- 65/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- observability
Hướng nghiên cứu
Bắt đầu từ lib/sentry/event.ex tại generate_contexts/0 (khoảng dòng 505) và lib/sentry/metrics.ex tại record_metric/4 (khoảng dòng 165), nơi current_trace_context/0 được định nghĩa là nil khi Sentry.OpenTelemetry.VersionChecker.tracing_compatible?() trả về false. Di chuyển nhánh rẽ tại thời điểm biên dịch để nó bao quanh đoạn mã sử dụng ngữ cảnh trace, như người báo lỗi đề xuất. Hoàn thành khi biên dịch không có OpenTelemetry trên Elixir 1.20 không sinh ra cảnh báo nào và mix test vẫn pass.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Issue Description
When OpenTelemetry tracing isn't available (Sentry.OpenTelemetry.VersionChecker.tracing_compatible?() is false at compile time), compiling sentry as a dependency on Elixir 1.20 emits two type warnings:
warning: the right-hand side of || will always execute:
current_trace_context()
because the left-hand side always evaluates to:
dynamic(nil)
└─ lib/sentry/metrics.ex:165: Sentry.Metrics.record_metric/4
warning: the following clause will never match:
{trace_id, span_id} ->
because it attempts to match on the result of:
current_trace_context()
which has type:
dynamic(nil)
└─ lib/sentry/event.ex:505: Sentry.Event.generate_contexts/0
In that configuration current_trace_context/0 is compiled as defp current_trace_context, do: nil in both modules. The type checker can then prove the callers' tuple branch dead. Line numbers are from master at db03025; 13.5.0 and 14.0.0 warn the same way.
Reproduction Steps
- Create a project on Elixir 1.20.x that depends on
{:sentry, "~> 14.0"}and doesn't include opentelemetry. rm -rf _build && mix compile.
Expected Behavior
sentry compiles without warnings.
Actual Behavior
The two warnings above, on every fresh compile of the dependency.
Elixir Version
1.20.2 and 1.20.4 (OTP 29)
SDK Version
14.0.0 (also 13.5.0 and master at db03025)
Integration and Its Version
None needed. Any app without a tracing-compatible OpenTelemetry setup hits this.
Proposed fix
Put the compile-time branch around the code that uses the trace context, instead of around a function that returns nil:
Sentry.Event:generate_contexts/0callsput_trace_context(contexts). The tracing branch matches onTraceContext.current(); the other branch returnscontextsunchanged.Sentry.Metrics:trace_context/0isTraceContext.current() || {generate_trace_id(), nil}in the tracing branch and{generate_trace_id(), nil}in the other.
Behaviour stays the same on both sides. I have this on a branch: the warnings are gone when compiled without OpenTelemetry, and mix test passes (1186 tests). Happy to open the PR if this approach works for you.
- Ngôn ngữ chính
- Elixir
- Star
- 693
- Fork
- 218
- Merge trung bình
- 2 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 21
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 getsentry/sentry-elixir
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 64/100
getsentry/sentry-elixir#1233 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 10/100
getsentry/sentry-elixir#1232 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
traces_sampler example doesn't match the actual context providedCó thể làm lại được @solnic đã nhận 329 ngày trước và không có pull request nào đang mở. Đang mởBug Elixir Traces Waiting for: Product Owner
getsentry/sentry-elixir#945 · 3 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Better oban error groupingCó thể làm lại được @solnic đã nhận 430 ngày trước và không có pull request nào đang mở. Đang mởElixir Errors Improvement
getsentry/sentry-elixir#936 · 1 bình luận · 2 reaction · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Custom fingerprint added to GenServer call crashes by clientCó thể làm lại được @solnic đã nhận 437 ngày trước và không có pull request nào đang mở. Đang mởBug Elixir Errors
getsentry/sentry-elixir#933 · 3 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của getsentry/sentry-elixir
Issue tương tự
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 2 ngày
-
ci-cd
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
carverauto/serviceradar#5648 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ 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
-
opentelemetry_bandit: handler is detached when a client disconnects before the request starts (get_peer_data raises :enotconn)Có thể đã có người làm @yordis đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
open-telemetry/opentelemetry-erlang-contrib#846 ·
Maintainer thường phản hồi trong vòng 1 ngày