Skip to content

Commit

Permalink
Merge branch 'main' of github.com:DataDog/lading into lenaic/CONTINT-…
Browse files Browse the repository at this point in the history
…4562
  • Loading branch information
L3n41c committed Jan 31, 2025
2 parents 657129d + e71c224 commit 6dc1509
Show file tree
Hide file tree
Showing 5 changed files with 198 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
type=sha,format=long
- name: Build and push Docker image
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0
uses: docker/build-push-action@ca877d9245402d1537745e0e356eab47c3520991 # v6.13.0
with:
file: Dockerfile
tags: ${{ needs.tagging.outputs.SHA_TAG }}-${{ matrix.arch }}
Expand Down
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]
## Added
- Introduced the ability for users to configure lading's sample rate,
configuration option `sample_period_milliseconds` in `lading.yaml`.
- Introduce a `container` generator able to generate an arbitrary number
of docker containers

## [0.25.5]
## Added
- Introduced the ability for users to configure lading's sample rate,
configuration option `sample_period_milliseconds` in `lading.yaml`.
- Users can now configure expvar scraping on https endpoints, skipping certificate validation.

## [0.25.4]
## Changed
- The `splunk_hec` generator now only requires responses to have an `ackId` when
Expand Down
171 changes: 170 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lading/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lading"
version = "0.25.4"
version = "0.25.5"
authors = [
"Brian L. Troutwine <[email protected]>",
"George Hahn <[email protected]>",
Expand Down Expand Up @@ -58,7 +58,7 @@ rand = { workspace = true, default-features = false, features = [
"std_rng",
] }
regex = { version = "1.11" }
reqwest = { version = "0.12", default-features = false, features = ["json"] }
reqwest = { version = "0.12", default-features = false, features = ["json", "default-tls"] }
rustc-hash = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
Expand Down
28 changes: 19 additions & 9 deletions lading/src/target_metrics/expvar.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Expvar target metrics fetcher
//!
//! This module scrapes Go expvar formatted metrics from the target software.
//! The metrics are formatted as a JSON tree that is fetched over HTTP.
//! The metrics are formatted as a JSON tree that is fetched over HTTP or HTTPS.
use std::time::Duration;

Expand Down Expand Up @@ -80,24 +80,34 @@ impl Expvar {
self.sample_period
);

let client = reqwest::Client::new();
// Disable certificate validation
let client = reqwest::ClientBuilder::new()
.danger_accept_invalid_certs(true)
.build()
.expect("Failed to build http/https client");

let server = async move {
loop {
tokio::time::sleep(self.sample_period).await;
let Ok(resp) = client
let resp = match client
.get(&self.config.uri)
.timeout(self.sample_period)
.send()
.await
else {
info!("failed to get expvar uri");
continue;
{
Ok(resp) => resp, // If successful, return the response
Err(err) => {
info!("Failed to get expvar URI: {}", err);
continue; // Skip the iteration on error
}
};

let Ok(json) = resp.json::<Value>().await else {
info!("failed to parse expvar json");
continue;
let json = match resp.json::<Value>().await {
Ok(json) => json, // Successfully parsed JSON
Err(err) => {
info!("Failed to parse expvar JSON: {}", err);
continue; // Skip the iteration on error
}
};

// Add lading labels including user defined tags for this endpoint
Expand Down

0 comments on commit 6dc1509

Please sign in to comment.