Skip to content

Commit 1276065

Browse files
committed
Merge branch 'main' into duncan-harvey/datadog-trace-utils-bump-hyper-rustls-version
2 parents 417cdc7 + 0a4632a commit 1276065

File tree

19 files changed

+1110
-38
lines changed

19 files changed

+1110
-38
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ serverless @Datadog/serverless
2121
sidecar @Datadog/libdatadog-php @Datadog/libdatadog-apm
2222
sidecar-ffi @Datadog/libdatadog-php @Datadog/libdatadog-apm
2323
data-pipeline*/ @Datadog/libdatadog-apm
24+
ddsketch @Datadog/libdatadog-apm @Datadog/libdatadog-telemetry

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ members = [
2828
"serverless",
2929
"bin_tests",
3030
"data-pipeline",
31-
"data-pipeline-ffi"
31+
"data-pipeline-ffi",
32+
"ddsketch",
3233
]
3334
# https://doc.rust-lang.org/cargo/reference/resolver.html#feature-resolver-version-2
3435
resolver = "2"

LICENSE-3rdparty.yml

Lines changed: 36 additions & 3 deletions
Large diffs are not rendered by default.

ddsketch/Cargo.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[package]
2+
name = "datadog-ddsketch"
3+
description = "Minimal implementation of Datadog's DDSketch"
4+
edition.workspace = true
5+
version.workspace = true
6+
rust-version.workspace = true
7+
license.workspace = true
8+
9+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
10+
11+
[dependencies]
12+
prost = "0.11.6"
13+
14+
[build-dependencies]
15+
prost-build = { version = "0.11.9", optional = true }
16+
protoc-bin-vendored = { version = "3.0.0", optional = true }
17+
18+
[features]
19+
generate-protobuf = ["dep:prost-build", "dep:protoc-bin-vendored"]

ddsketch/build.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright 2023-Present Datadog, Inc. https://www.datadoghq.com/
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
use std::error::Error;
5+
6+
#[cfg(feature = "generate-protobuf")]
7+
use std::{
8+
env,
9+
fs::File,
10+
io::{Read, Write},
11+
path::Path,
12+
};
13+
14+
#[cfg(feature = "generate-protobuf")]
15+
const HEADER: &str = "// Copyright 2023-Present Datadog, Inc. https://www.datadoghq.com/
16+
// SPDX-License-Identifier: Apache-2.0
17+
18+
";
19+
20+
fn main() -> Result<(), Box<dyn Error>> {
21+
#[cfg(feature = "generate-protobuf")]
22+
{
23+
// protoc is required to compile proto files. This uses protobuf_src to compile protoc
24+
// from the source, setting the env var to tell prost_build where to find it.
25+
std::env::set_var("PROTOC", protoc_bin_vendored::protoc_bin_path().unwrap());
26+
27+
let mut config = prost_build::Config::new();
28+
29+
let cur_working_dir = env::var("CARGO_MANIFEST_DIR")?;
30+
let output_path = Path::new(&cur_working_dir).join("src");
31+
32+
config.out_dir(output_path.clone());
33+
34+
println!("cargo:rerun-if-changed=src/pb/DDSketch.proto");
35+
config.compile_protos(&["src/pb/DDSketch.proto"], &["src/"])?;
36+
37+
prepend_to_file(HEADER.as_bytes(), &output_path.join("pb.rs"))?;
38+
}
39+
40+
Ok(())
41+
}
42+
43+
#[cfg(feature = "generate-protobuf")]
44+
fn prepend_to_file(data: &[u8], file_path: &Path) -> Result<(), Box<dyn Error>> {
45+
let mut f = File::open(file_path)?;
46+
let mut content = data.to_owned();
47+
f.read_to_end(&mut content)?;
48+
49+
let mut f = File::create(file_path)?;
50+
f.write_all(content.as_slice())?;
51+
Ok(())
52+
}

0 commit comments

Comments
 (0)