Type warnings in Event and Metrics when OpenTelemetry tracing is unavailable (Elixir 1.20)
Los mantenedores suelen responder en 2 días
Ya se ha fusionado un pull request relacionado.
- #1243 de @whatyouhide — fusionado
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 65/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Área
- observability
Línea de trabajo
Empieza en lib/sentry/event.ex en generate_contexts/0 (alrededor de la línea 505) y en lib/sentry/metrics.ex en record_metric/4 (alrededor de la línea 165), donde current_trace_context/0 se define como nil cuando Sentry.OpenTelemetry.VersionChecker.tracing_compatible?() es falso. Mueve la rama de compilación para que envuelva el código que usa el contexto de traza, como propone quien reportó el problema. Está terminado cuando compilar sin OpenTelemetry en Elixir 1.20 no genera advertencias y mix test sigue pasando.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Elixir
- Estrellas
- 693
- Forks
- 218
- Merge medio
- 2 d 4 h
- PR fusionados (30 d)
- 21
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de getsentry/sentry-elixir
-
Dificultad 3/5 1-2 días Aptitud para principiantes 64/100
getsentry/sentry-elixir#1233 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
Dificultad 4/5 3-5 días Aptitud para principiantes 10/100
getsentry/sentry-elixir#1232 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
traces_sampler example doesn't match the actual context providedQuizá libre de nuevo @solnic la tomó hace 329 días y no hay ningún pull request abierto. AbiertoBug Elixir Traces Waiting for: Product Owner
getsentry/sentry-elixir#945 · 3 comentarios · 1 asignado ·
Los mantenedores suelen responder en 2 días
-
Better oban error groupingQuizá libre de nuevo @solnic la tomó hace 430 días y no hay ningún pull request abierto. AbiertoElixir Errors Improvement
getsentry/sentry-elixir#936 · 1 comentario · 2 reacciones · 1 asignado ·
Los mantenedores suelen responder en 2 días
-
Custom fingerprint added to GenServer call crashes by clientQuizá libre de nuevo @solnic la tomó hace 437 días y no hay ningún pull request abierto. AbiertoBug Elixir Errors
getsentry/sentry-elixir#933 · 3 comentarios · 1 asignado ·
Los mantenedores suelen responder en 2 días
Todos los issues de getsentry/sentry-elixir
Issues similares
-
documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 2 días
-
ci-cd
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
carverauto/serviceradar#5648 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
opentelemetry_bandit: handler is detached when a client disconnects before the request starts (get_peer_data raises :enotconn)Posiblemente ocupada @yordis la tomó hace 1 día. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
open-telemetry/opentelemetry-erlang-contrib#846 ·
Los mantenedores suelen responder en 1 día