Type warnings in Event and Metrics when OpenTelemetry tracing is unavailable (Elixir 1.20)
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 65/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- observability
Direzione di ricerca
Inizia da lib/sentry/event.ex in generate_contexts/0 (intorno alla riga 505) e da lib/sentry/metrics.ex in record_metric/4 (intorno alla riga 165), dove current_trace_context/0 è definita come nil quando Sentry.OpenTelemetry.VersionChecker.tracing_compatible?() è falso. Sposta il ramo di compilazione in modo che racchiuda il codice che usa il contesto di traccia, come propone chi ha segnalato il problema. Il lavoro è completato quando la compilazione senza OpenTelemetry su Elixir 1.20 non produce avvisi e mix test continua a passare.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Elixir
- Stelle
- 694
- Fork
- 217
- Merge medio
- 2g 6h
- PR unite (30g)
- 20
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di getsentry/sentry-elixir
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 64/100
getsentry/sentry-elixir#1233 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 10/100
getsentry/sentry-elixir#1232 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
traces_sampler example doesn't match the actual context providedForse di nuovo libera @solnic l’ha presa 327 giorni fa e non c’è nessuna pull request aperta. ApertaBug Elixir Traces Waiting for: Product Owner
getsentry/sentry-elixir#945 · 3 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
-
Better oban error groupingForse di nuovo libera @solnic l’ha presa 428 giorni fa e non c’è nessuna pull request aperta. ApertaElixir Errors Improvement
getsentry/sentry-elixir#936 · 1 commento · 2 reazioni · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
-
Custom fingerprint added to GenServer call crashes by clientForse di nuovo libera @solnic l’ha presa 435 giorni fa e non c’è nessuna pull request aperta. ApertaBug Elixir Errors
getsentry/sentry-elixir#933 · 3 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di getsentry/sentry-elixir
Issue simili
-
ci-cd
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
carverauto/serviceradar#5648 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
open-telemetry/opentelemetry-erlang-contrib#846 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
electric-sql/electric#4830 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno