Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors reported through sentry-tracing have unhelpful titles #723

Open
keabarnes opened this issue Jan 27, 2025 · 3 comments
Open

Errors reported through sentry-tracing have unhelpful titles #723

keabarnes opened this issue Jan 27, 2025 · 3 comments

Comments

@keabarnes
Copy link

Environment

Version: 0.36.0

Sentry set up with the sentry-tracing integration.

Steps to Reproduce

  1. Followed instructions in the docs to track errors using the tracing macros: https://docs.rs/sentry-tracing/0.36.0/sentry_tracing/#tracking-errors
  2. Logged an error along the lines of tracing::error!(error = &custom_error as &dyn Error, "my operation failed - ...");
    1. tried with let custom_error = std::io::Error::new(std::io::ErrorKind::Other, "Custom ioErrorKind Other Error");
    2. tried with custom thiserror based error struct
  3. Logged a "control" error using error!("my operation failed - simple error!(\"my operation failed\") has helpful title");

Expected Result

Errors to show up in Sentry with a useful title, either based on the original message, or some version of the error struct name

Actual Result

In the Sentry dashboard, the errors reported using the error = capturing method had titles that had nothing to do with the error but rather referenced the tracing crate. Errors reported without the error = capturing method show up with the message in the title.

Image
@keabarnes
Copy link
Author

Added some debug logging inside before_send on the Sentry client.

The code, roughly:

let custom_error = MyError::MyFirstErrorVariant(format!(
    "Testing Error"
));
error!(
    error = &custom_error as &dyn std::error::Error,
    "my operation failed - tracked error is unhelpful 1"
);

The debug log of event from before_send with some stuff ... truncated for brevity:

Event {
    event_id: 41a06b12-023a-4abb-aef6-f1974f746410,
    level: Error,
    fingerprint: [
        "{{ default }}",
    ],
    culprit: None,
    transaction: None,
    message: None,
    logentry: None,
    logger: Some(
        "utils::testing",
    ),
    modules: {},
    platform: "native",
    timestamp: SystemTime {
        tv_sec: 1737988217,
        tv_nsec: 611486000,
    },
    server_name: Some(
        "a765b20e-91fa-3110-b56f-dd6348032988",
    ),
    release: Some(
        "0.1.0",
    ),
    dist: None,
    environment: Some(
        "dev",
    ),
    user: None,
    request: None,
    contexts: {
        "Rust Tracing Location": Other(
            {
                "file": String("/software/src/utils/testing.rs"),
                "line": Number(30),
                "module_path": String("utils::testing"),
            },
        ),
        "device": Device(),
        "os": Os(),
        "rust": Runtime(),
    },
    breadcrumbs: Values {
        values: [...],
    },
    exception: Values {
        values: [
            Exception {
                ty: "MyFirstErrorVariant",
                value: Some(
                    "MyFirstErrorVairant's error message from #[error = ...] on thiserror stuct: Testing Error",
                ),
                module: None,
                stacktrace: None,
                raw_stacktrace: None,
                thread_id: None,
                mechanism: None,
            },
            Exception {
                ty: "tracing::error!",
                value: Some(
                    "my operation failed - tracked error is unhelpful 1",
                ),
                module: Some(
                    "utils::tesing",
                ),
                stacktrace: None,
                raw_stacktrace: None,
                thread_id: None,
                mechanism: Some(
                    Mechanism {
                        ty: "tracing",
                        description: None,
                        help_link: None,
                        handled: None,
                        synthetic: Some(
                            true,
                        ),
                        data: {},
                        meta: MechanismMeta {
                            errno: None,
                            signal: None,
                            mach_exception: None,
                        },
                    },
                ),
            },
        ],
    },
    stacktrace: None,
    template: None,
    threads: Values {
        values: [...],
    },
    tags: {},
    extra: {},
    debug_meta: DebugMeta {
        sdk_info: None,
        images: [],
    },
    sdk: Some(
        ClientSdkInfo {
            name: "sentry.rust",
            version: "0.36.0",
            integrations: [
                "attach-stacktrace",
                "debug-images",
                "contexts",
                "panic",
                "process-stacktrace",
            ],
            packages: [
                ClientSdkPackage {
                    name: "cargo:sentry",
                    version: "0.36.0",
                },
            ],
        },
    ),
}

@keabarnes
Copy link
Author

My gut says the part below shouldn't be there, and the value string in it should be put into the top-level event message?

exception.values: [
    ...,
    Exception {
      ty: "tracing::error!",
      value: Some(
          "my operation failed - tracked error is unhelpful 1",
      ),
      module: Some(
          "utils::tesing",
      ),
      stacktrace: None,
      raw_stacktrace: None,
      thread_id: None,
      mechanism: Some(
          Mechanism {
              ty: "tracing",
              description: None,
              help_link: None,
              handled: None,
              synthetic: Some(
                  true,
              ),
              data: {},
              meta: MechanismMeta {
                  errno: None,
                  signal: None,
                  mach_exception: None,
              },
          },
      ),
    },
]

@peter-lockhart-pub
Copy link

I also see unhelpful titles <unknown> in 0.36.0. I am running in the context of axum, trying to error trace a handled server error:

event!(
                Level::ERROR,
                error = &self as &dyn Error,
                status = %status,
                "app server error"
            );
Image Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants