Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
d8e13bf
Update Dockerfile
st-omarkhalid Nov 3, 2024
cef518d
Add pprofile in the app
st-omarkhalid Nov 3, 2024
43547fb
nit
st-omarkhalid Nov 3, 2024
10e9a41
update Cargo
st-omarkhalid Nov 3, 2024
3a164e2
nit
st-omarkhalid Nov 3, 2024
1b93c57
nit
st-omarkhalid Nov 3, 2024
52de629
nit
st-omarkhalid Nov 3, 2024
e1194ca
nit
st-omarkhalid Nov 3, 2024
1608ef5
nit
st-omarkhalid Nov 3, 2024
7b7a796
nit
st-omarkhalid Nov 3, 2024
ade460b
nit
st-omarkhalid Nov 3, 2024
ff095d5
nit
st-omarkhalid Nov 3, 2024
d58a7b2
nit
st-omarkhalid Nov 3, 2024
3786d3f
nit
st-omarkhalid Nov 3, 2024
5a1946b
nit
st-omarkhalid Nov 3, 2024
d466ab2
nit
st-omarkhalid Nov 3, 2024
4679d7b
nit
st-omarkhalid Nov 3, 2024
7aba6b1
nit
st-omarkhalid Nov 3, 2024
9462c09
nit
st-omarkhalid Nov 4, 2024
7a6298a
nit
st-omarkhalid Nov 4, 2024
f575b54
nit
st-omarkhalid Nov 4, 2024
bebebe3
nit
st-omarkhalid Nov 4, 2024
37e270b
update app
st-omarkhalid Nov 4, 2024
14e9b9b
update app
st-omarkhalid Nov 4, 2024
d288398
update app
st-omarkhalid Nov 4, 2024
9a925f7
update gen.rs
st-omarkhalid Nov 4, 2024
d3662dc
update exporter.rs
st-omarkhalid Nov 4, 2024
c7f81ac
update exporter.rs
st-omarkhalid Nov 4, 2024
4ce5176
update exporter.rs
st-omarkhalid Nov 4, 2024
382a257
update Cargo
st-omarkhalid Nov 4, 2024
0fdfc97
update Cargo
st-omarkhalid Nov 4, 2024
757810d
update exporter
st-omarkhalid Nov 4, 2024
404b743
update exporter
st-omarkhalid Nov 4, 2024
435d669
update exporter
st-omarkhalid Nov 4, 2024
dd0cc92
update exporter
st-omarkhalid Nov 4, 2024
1e82156
update exporter
st-omarkhalid Nov 4, 2024
b0f5daa
update exporter
st-omarkhalid Nov 4, 2024
8a22c96
update exporter
st-omarkhalid Nov 4, 2024
201e248
update exporter
st-omarkhalid Nov 4, 2024
12eef2d
update exporter
st-omarkhalid Nov 4, 2024
748af7c
update exporter
st-omarkhalid Nov 4, 2024
196222a
update exporter
st-omarkhalid Nov 4, 2024
92b8b7d
update app
st-omarkhalid Nov 4, 2024
8cca762
update app
st-omarkhalid Nov 4, 2024
bd7bfd9
update exporter
st-omarkhalid Nov 4, 2024
6db2ade
update Dockerfile
st-omarkhalid Nov 4, 2024
84f9076
update Cargo
st-omarkhalid Nov 4, 2024
02a8af0
update lib
st-omarkhalid Nov 4, 2024
605d626
update global malloc setting
st-omarkhalid Nov 4, 2024
fabfe47
can only have one global allocator
st-omarkhalid Nov 4, 2024
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
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ socket2 = { version = "0.5.7", default-features = false }
stream-cancel = { version = "0.8.2", default-features = false }
strip-ansi-escapes = { version = "0.2.0", default-features = false }
syslog = { version = "6.1.1", default-features = false, optional = true }
tikv-jemallocator = { version = "0.6.0", default-features = false, features = ["unprefixed_malloc_on_supported_platforms"], optional = true }
tikv-jemallocator = { version = "0.6.0", default-features = false, features = ["unprefixed_malloc_on_supported_platforms", "profiling"], optional = true }
tokio-postgres = { version = "0.7.12", default-features = false, features = ["runtime", "with-chrono-0_4"], optional = true }
tokio-tungstenite = { version = "0.20.1", default-features = false, features = ["connect"], optional = true }
toml.workspace = true
Expand All @@ -370,6 +370,7 @@ heim = { git = "https://github.com/vectordotdev/heim.git", branch = "update-nix"

# make sure to update the external docs when the Lua version changes
mlua = { version = "0.9.9", default-features = false, features = ["lua54", "send", "vendored", "macros"], optional = true }
jemalloc_pprof = "0.6.0"

[target.'cfg(windows)'.dependencies]
windows-service = "0.7.0"
Expand Down
13 changes: 13 additions & 0 deletions release/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ubuntu:latest AS builder
WORKDIR /vector
COPY vector-0.43.0.custom.196222aa1-x86_64-unknown-linux-musl.tar.gz ./
RUN tar -xvf vector-0.43.0.custom.196222aa1-x86_64-unknown-linux-musl.tar.gz --strip-components=2
RUN mkdir -p /var/lib/vector
FROM ubuntu:latest
RUN apt-get update && apt-get install -y ca-certificates tzdata build-essential libc6-dbg libunwind-dev valgrind curl wget net-tools && apt-get clean && rm -rf /var/lib/apt/lists/*
COPY --from=builder /vector/bin/* /usr/local/bin/
COPY --from=builder /vector/config/vector.yaml /etc/vector/vector.yaml
COPY --from=builder /var/lib/vector /var/lib/vector
# Smoke test
RUN ["vector", "--version"]
ENTRYPOINT ["/usr/local/bin/vector"]
28 changes: 20 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,28 @@ extern crate derivative;
#[macro_use]
extern crate vector_lib;

#[cfg(all(feature = "tikv-jemallocator", not(feature = "allocation-tracing")))]
#[global_allocator]
static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
// #[cfg(all(feature = "tikv-jemallocator", not(feature = "allocation-tracing")))]
// #[global_allocator]
// static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;

#[cfg(not(target_env = "msvc"))]
use tikv_jemallocator::Jemalloc;

#[cfg(all(feature = "tikv-jemallocator", feature = "allocation-tracing"))]
#[cfg(not(target_env = "msvc"))]
#[global_allocator]
static ALLOC: self::internal_telemetry::allocations::Allocator<tikv_jemallocator::Jemalloc> =
self::internal_telemetry::allocations::get_grouped_tracing_allocator(
tikv_jemallocator::Jemalloc,
);
static GLOBAL: Jemalloc = Jemalloc;

// #[cfg(all(feature = "tikv-jemallocator", feature = "allocation-tracing"))]
// #[global_allocator]
// static ALLOC: self::internal_telemetry::allocations::Allocator<tikv_jemallocator::Jemalloc> =
// self::internal_telemetry::allocations::get_grouped_tracing_allocator(
// tikv_jemallocator::Jemalloc,
// );

/// Some docs
// #[allow(non_upper_case_globals)]
// #[export_name = "malloc_conf"]
// pub static malloc_conf: &[u8] = b"prof:true,prof_active:true,lg_prof_sample:19\0";

#[allow(unreachable_pub)]
pub mod internal_telemetry;
Expand Down
42 changes: 41 additions & 1 deletion src/sinks/prometheus/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,28 @@ impl PrometheusExporter {
let tls = MaybeTlsSettings::from_config(&tls, true)?;
let listener = tls.bind(&address).await?;


let addr = std::net::SocketAddr::from(([0, 0, 0, 0], 7979));
let pprofile_tls = self.config.tls.clone();
let pp_tls = MaybeTlsSettings::from_config(&pprofile_tls, true)?;
let pprofile_listener = pp_tls.bind(&addr).await?;

tokio::spawn(async move {
// build our application with a route
let app = axum::Router::new()
.route("/debug/pprof/heap", axum::routing::get(handle_get_heap));

info!(message = "Building endpoint for pprofile.", address = %addr);
Server::builder(hyper::server::accept::from_stream(pprofile_listener.accept_stream()))
.serve(app.into_make_service())
.await
.unwrap();

Ok::<(), ()>(())
});

tokio::spawn(async move {
info!(message = "Building HTTP server.", address = %address);
info!(message = "Building HTTP prom exporter server.", address = %address);

Server::builder(hyper::server::accept::from_stream(listener.accept_stream()))
.serve(new_service)
Expand Down Expand Up @@ -1662,3 +1682,23 @@ mod integration_tests {
sink_handle.await.unwrap();
}
}

use axum::response::IntoResponse;

pub async fn handle_get_heap() -> Result<impl IntoResponse, (StatusCode, String)> {
let mut prof_ctl = jemalloc_pprof::PROF_CTL.as_ref().unwrap().lock().await;
require_profiling_activated(&prof_ctl)?;
let pprof = prof_ctl
.dump_pprof()
.map_err(|err| (StatusCode::INTERNAL_SERVER_ERROR, err.to_string()))?;
Ok(pprof)
}

/// Checks whether jemalloc profiling is activated an returns an error response if not.
fn require_profiling_activated(prof_ctl: &jemalloc_pprof::JemallocProfCtl) -> Result<(), (StatusCode, String)> {
if prof_ctl.activated() {
Ok(())
} else {
Err((axum::http::StatusCode::FORBIDDEN, "heap profiling not activated".into()))
}
}