-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.rs
43 lines (39 loc) · 1.03 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use anyhow::Result;
fn main() -> Result<()> {
println!("cargo:rerun-if-changed=protocol/tempo/tempo.proto");
let mut cfg = prost_build::Config::new();
let mut builder = cfg
.type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]")
.type_attribute(".", "#[serde(rename_all = \"camelCase\")]")
.extern_path(
".opentelemetry.proto.trace.v1",
"opentelemetry_proto::tonic::trace::v1",
)
.extern_path(
".opentelemetry.proto.common.v1",
"opentelemetry_proto::tonic::common::v1",
)
.format(true)
.out_dir("src/proto");
let i64_fields = [
"startTimeUnixNano",
"durationNanos",
"inspectedBytes",
"totalBlockBytes",
];
for field in i64_fields {
builder = builder.field_attribute(
field,
"#[serde(with = \"crate::utils::serde::jsonstr\")]",
);
}
let id_fields = ["traceID", "spanID"];
for field in id_fields {
builder = builder.field_attribute(
field,
format!("#[serde(rename = \"{}\")]", field),
);
}
builder.compile_protos(&["protocol/tempo/tempo.proto"], &["protocol"])?;
Ok(())
}