Skip to content

Commit

Permalink
ci: "Fix" the downstream anchor build (solana-labs#2208)
Browse files Browse the repository at this point in the history
* ci: "Fix" the downstream anchor build

* Force the CI run to happen

add hostname tag
  • Loading branch information
joncinque authored and vovkman committed Jul 22, 2024
1 parent 6e0e68f commit c7473aa
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/downstream-project-anchor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ on:
- "cargo-build-sbf"
- "cargo-test-sbf"
- "scripts/build-downstream-anchor-projects.sh"
- "scripts/patch-spl-crates-for-anchor.sh"
- ".github/scripts/purge-ubuntu-runner.sh"
- ".github/scripts/downstream-project-spl-install-deps.sh"
- ".github/workflows/downstream-project-anchor.yml"
Expand Down
21 changes: 18 additions & 3 deletions metrics/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,10 @@ impl InfluxDbMetricsWriter {
}
}

pub fn serialize_points(points: &Vec<DataPoint>, host_id: &str) -> String {
pub fn serialize_points(points: &Vec<DataPoint>, host_id: &str, host_name: &str) -> String {
const TIMESTAMP_LEN: usize = 20;
const HOST_ID_LEN: usize = 8; // "host_id=".len()
const HOST_NAME_LEN: usize = 10; // "host_name=".len()
const EXTRA_LEN: usize = 2; // "=,".len()
let mut len = 0;
for point in points {
Expand All @@ -114,10 +115,15 @@ pub fn serialize_points(points: &Vec<DataPoint>, host_id: &str) -> String {
len += point.name.len();
len += TIMESTAMP_LEN;
len += host_id.len() + HOST_ID_LEN;
len += host_name.len() + HOST_NAME_LEN;
}
let mut line = String::with_capacity(len);
for point in points {
let _ = write!(line, "{},host_id={}", &point.name, host_id);
let _ = write!(
line,
"{},host_id={},host_name={}",
&point.name, host_id, host_name
);
for (name, value) in point.tags.iter() {
let _ = write!(line, ",{name}={value}");
}
Expand All @@ -140,8 +146,9 @@ impl MetricsWriter for InfluxDbMetricsWriter {
debug!("submitting {} points", points.len());

let host_id = HOST_ID.read().unwrap();
let host_name = HOST_NAME.read().unwrap();

let line = serialize_points(&points, &host_id);
let line = serialize_points(&points, &host_id, &host_name);

let client = reqwest::blocking::Client::builder()
.timeout(Duration::from_secs(5))
Expand Down Expand Up @@ -405,6 +412,14 @@ lazy_static! {
format!("{}", hash(hostname.as_bytes()))
}))
};
static ref HOST_NAME: Arc<RwLock<String>> = {
Arc::new(RwLock::new({
let hostname: String = gethostname()
.into_string()
.unwrap_or_else(|_| "".to_string());
format!("{}", hash(hostname.as_bytes()))
}))
};
}

pub fn set_host_id(host_id: String) {
Expand Down
5 changes: 4 additions & 1 deletion scripts/patch-spl-crates-for-anchor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ patch_crates_io() {
spl-memo = { path = "$spl_dir/memo/program" }
spl-pod = { path = "$spl_dir/libraries/pod" }
spl-token = { path = "$spl_dir/token/program" }
spl-token-2022 = { path = "$spl_dir/token/program-2022" }
# Avoid patching spl-token-2022 to avoid forcing anchor to use 4.0.1, which
# doesn't work with the monorepo forcing 4.0.0. Allow the patching again once
# the monorepo is on 4.0.1, or relax the dependency in the monorepo.
#spl-token-2022 = { path = "$spl_dir/token/program-2022" }
spl-token-group-interface = { path = "$spl_dir/token-group/interface" }
spl-token-metadata-interface = { path = "$spl_dir/token-metadata/interface" }
spl-tlv-account-resolution = { path = "$spl_dir/libraries/tlv-account-resolution" }
Expand Down

0 comments on commit c7473aa

Please sign in to comment.