Skip to content

f32/f64 values in structured logs are treated as strings #1231

Closed

Description

@rukai

How do you use Sentry?

Sentry SaaS (sentry.io)

SDK version

0.48.4

Steps to reproduce

let value: f32 = 1.0;
tracing::info!("hi", value)

Expected result

Value should show up as a float in the sentry web UI

Actual result

value does not show up as a float in the sentry web ui

Investigation

I can see here that tracing supports floats in its structured values:
https://docs.rs/tracing/latest/tracing/field/trait.Visit.html#method.record_f64

But sentry's implementation of Visit does not implement record_f64

impl Visit for FieldVisitor {

Activity

  1. added
    Bug
    Rust
    on Jul 7, 2026
  2. linear-code commented on Jul 7, 2026

    @linear-code
  3. szokeasaurusrex commented on Jul 8, 2026

    @szokeasaurusrex
    Member

    Hi @rukai, thank you for reporting this issue.

    Unfortunately, the code snippet you provided does not compile for me; I get the following error:

    error: argument never used
      --> src/main.rs:26:26
       |
    26 |     tracing::info!("hi", value);
       |                    ----  ^^^^^ argument never used
       |                    |
       |                    formatting specifier missing
       |
    help: format specifiers use curly braces, consider adding a format specifier
       |
    26 |     tracing::info!("hi{}", value);
       |                       ++
    

    Even with the compiler's suggested solution of adding the format specifier, I am not noticing any unexpected behavior. With that suggestion, the log looks like this in Sentry:

    Image

    That output is formatted the same way that tracing formats it in the terminal:

    2026-07-08T13:05:09.324159Z  INFO tracing_log_floats: hi1
    

    Could you please clarify more precisely how I can reproduce the issue you are seeing? And, could you also clarify what you mean when you say that the value is "displaying as a string, not a float," because what you mean is not entirely clear.

  4. rukai commented on Jul 8, 2026

    @rukai
    Author

    Sorry, that was poor of me that it didn't even compile.

    I am talking about structured logging:

    fn main() {
        let value: f32 = 1.0;
        tracing::info!(value=value, "hi")
    }

    When filtering by structured logs in the sentry web app, it shows the type of structured value when typing in the field name.
    My understanding is the type then impacts sorting behavior.
    (the field has a different name here because I just grabbed the screenshot from our production application)
    Image

  5. szokeasaurusrex commented on Jul 10, 2026

    @szokeasaurusrex
    Member

    Thanks for the clarification, I was able to reproduce. Definitely seems like a bug or unexpected behavior at a minimum

  6. rukai commented on Aug 3, 2026

    @rukai
    Author

    Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugLogsRust

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions