Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions libdd-crashtracker/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ fn build_cpp_file() {

#[cfg(unix)]
fn main() {
println!(
"cargo:rustc-env=TARGET={}",
std::env::var("TARGET").unwrap()
);

cc::Build::new()
.file("src/crash_info/emit_sicodes.c")
.compile("emit_sicodes");
Expand All @@ -139,6 +144,11 @@ fn main() {

#[cfg(not(unix))]
fn main() {
println!(
"cargo:rustc-env=TARGET={}",
std::env::var("TARGET").unwrap()
);

// Build CXX bridge if feature is enabled
#[cfg(feature = "cxx")]
build_cxx_bridge();
Expand Down
10 changes: 9 additions & 1 deletion libdd-crashtracker/src/crash_info/errors_intake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ use std::time::SystemTime;

use crate::{OsInfo, SigInfo};

use super::{build_crash_ping_message, CrashInfo, Experimental, Metadata, StackTrace};
use super::{
build_crash_ping_message, CrashInfo, Experimental, Metadata, StackTrace, TARGET_TRIPLE,
};
use anyhow::Context;
use chrono::{DateTime, Utc};
use http::{uri::PathAndQuery, Uri};
Expand Down Expand Up @@ -363,6 +365,7 @@ fn build_crash_info_tags(crash_info: &CrashInfo) -> String {
append_signal_tags(&mut tags, siginfo);
}

tags.push_str(&format!(",target_triple:{TARGET_TRIPLE}"));
tags
}

Expand Down Expand Up @@ -456,6 +459,8 @@ impl ErrorsIntakePayload {
append_signal_tags(&mut ddtags, sig_info);
}

ddtags.push_str(&format!(",target_triple:{TARGET_TRIPLE}"));

let (error_type, message) = if let Some(sig_info) = sig_info {
(
Some(format!("{:?}", sig_info.si_signo_human_readable)),
Expand Down Expand Up @@ -689,6 +694,7 @@ mod tests {
"si_code_human_readable:SEGV_BNDERR",
"si_signo:11",
"si_signo_human_readable:SIGSEGV",
&format!("target_triple:{}", super::super::TARGET_TRIPLE),
];

let expected_metadata_tags = ["service:foo", "version:bar", "language_name:native"];
Expand Down Expand Up @@ -726,8 +732,10 @@ mod tests {
"si_code_human_readable:SEGV_BNDERR",
"si_signo:11",
"si_signo_human_readable:SIGSEGV",
&format!("target_triple:{}", super::super::TARGET_TRIPLE),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For profiling, we call this runtime_platform -- should we maybe adopt the same naming here, for consistency? See #954 for when we originally added TARGET_TRIPLE

];

println!("payload.ddtags: {}", payload.ddtags);
for tag in expected_tags {
assert!(
payload.ddtags.contains(tag),
Expand Down
3 changes: 3 additions & 0 deletions libdd-crashtracker/src/crash_info/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ mod telemetry;
mod test_utils;
mod unknown_value;

// This is set compile time
pub(crate) const TARGET_TRIPLE: &str = env!("TARGET");

pub use builder::*;
pub use error_data::*;
pub use errors_intake::*;
Expand Down
5 changes: 4 additions & 1 deletion libdd-crashtracker/src/crash_info/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{fmt::Write, time::SystemTime};

use crate::{ErrorKind, SigInfo};

use super::{CrashInfo, Metadata};
use super::{CrashInfo, Metadata, TARGET_TRIPLE};
use anyhow::Context;
use chrono::{DateTime, Utc};
use libdd_common::Endpoint;
Expand Down Expand Up @@ -396,6 +396,7 @@ impl TelemetryCrashUploader {
));
}

write!(tags, ",target_triple:{TARGET_TRIPLE}").ok();
self.append_optional_tags(&mut tags);
tags
}
Expand Down Expand Up @@ -448,6 +449,7 @@ fn extract_crash_info_tags(crash_info: &CrashInfo) -> anyhow::Result<String> {
siginfo.si_signo_human_readable
)?;
}
write!(&mut tags, ",target_triple:{TARGET_TRIPLE}")?;
Ok(tags)
}

Expand Down Expand Up @@ -556,6 +558,7 @@ mod tests {
"si_signo_human_readable:SIGSEGV",
"si_signo:11",
"uuid:1d6b97cb-968c-40c9-af6e-e4b4d71e8781",
&format!("target_triple:{}", super::super::TARGET_TRIPLE),
]),
tags
);
Expand Down
Loading