From c1f971576f2b413de41b035947690640f1a8cd5b Mon Sep 17 00:00:00 2001 From: alexgallotta <5581237+alexgallotta@users.noreply.github.com> Date: Thu, 27 Feb 2025 14:35:42 -0500 Subject: [PATCH 1/6] add start info message --- bottlecap/src/bin/bottlecap/main.rs | 9 +++++---- scripts/build_binary_and_layer_dockerized.sh | 1 - 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bottlecap/src/bin/bottlecap/main.rs b/bottlecap/src/bin/bottlecap/main.rs index 5b65f139d..f6966adcd 100644 --- a/bottlecap/src/bin/bottlecap/main.rs +++ b/bottlecap/src/bin/bottlecap/main.rs @@ -67,7 +67,7 @@ use std::{ use telemetry::listener::TelemetryListenerConfig; use tokio::{sync::mpsc::Sender, sync::Mutex as TokioMutex}; use tokio_util::sync::CancellationToken; -use tracing::{debug, error}; +use tracing::{debug, error, info}; use tracing_subscriber::EnvFilter; #[derive(Clone, Deserialize)] @@ -101,7 +101,7 @@ enum NextEventResponse { }, } -async fn next_event(client: &reqwest::Client, ext_id: &str) -> Result { +async fn next_event(client: &Client, ext_id: &str) -> Result { let base_url = base_url(EXTENSION_ROUTE) .map_err(|e| Error::new(std::io::ErrorKind::InvalidData, e.to_string()))?; let url = format!("{base_url}/event/next"); @@ -136,7 +136,7 @@ async fn next_event(client: &reqwest::Client, ext_id: &str) -> Result Result { +async fn register(client: &Client) -> Result { let mut map = HashMap::new(); let base_url = base_url(EXTENSION_ROUTE) .map_err(|e| Error::new(std::io::ErrorKind::InvalidData, e.to_string()))?; @@ -182,10 +182,11 @@ fn build_function_arn(account_id: &str, region: &str, function_name: &str) -> St #[tokio::main] async fn main() -> Result<()> { + info!(format!("Starting Datadog Extension {EXTENSION_VERSION}")); let (mut aws_config, config) = load_configs(); enable_logging_subsystem(&config); - let client = reqwest::Client::builder().no_proxy().build().map_err(|e| { + let client = Client::builder().no_proxy().build().map_err(|e| { Error::new( std::io::ErrorKind::InvalidData, format!("Failed to create client: {e:?}"), diff --git a/scripts/build_binary_and_layer_dockerized.sh b/scripts/build_binary_and_layer_dockerized.sh index 3f5df53f1..de7a129c4 100755 --- a/scripts/build_binary_and_layer_dockerized.sh +++ b/scripts/build_binary_and_layer_dockerized.sh @@ -67,7 +67,6 @@ function docker_build_zip { arch=$1 suffix=$2 - DOCKER_BUILDKIT=1 docker buildx build --platform linux/${arch} \ -t datadog/build-lambda-extension-${arch}:$VERSION \ -f ./scripts/$BUILD_FILE \ From eb2fc16b4fab0b7568873485c10de4e94a2c465c Mon Sep 17 00:00:00 2001 From: alexgallotta <5581237+alexgallotta@users.noreply.github.com> Date: Thu, 27 Feb 2025 14:46:49 -0500 Subject: [PATCH 2/6] import version properly --- bottlecap/src/bin/bottlecap/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bottlecap/src/bin/bottlecap/main.rs b/bottlecap/src/bin/bottlecap/main.rs index f6966adcd..c154c13eb 100644 --- a/bottlecap/src/bin/bottlecap/main.rs +++ b/bottlecap/src/bin/bottlecap/main.rs @@ -9,6 +9,7 @@ #![deny(missing_copy_implementations)] #![deny(missing_debug_implementations)] +use bottlecap::tags::lambda::tags::EXTENSION_VERSION; use bottlecap::{ base_url, config::{self, get_aws_partition_by_region, AwsConfig, Config}, @@ -67,7 +68,7 @@ use std::{ use telemetry::listener::TelemetryListenerConfig; use tokio::{sync::mpsc::Sender, sync::Mutex as TokioMutex}; use tokio_util::sync::CancellationToken; -use tracing::{debug, error, info}; +use tracing::{debug, error}; use tracing_subscriber::EnvFilter; #[derive(Clone, Deserialize)] @@ -182,7 +183,7 @@ fn build_function_arn(account_id: &str, region: &str, function_name: &str) -> St #[tokio::main] async fn main() -> Result<()> { - info!(format!("Starting Datadog Extension {EXTENSION_VERSION}")); + println!("DD_EXTENSION | Starting Datadog Extension {EXTENSION_VERSION}"); let (mut aws_config, config) = load_configs(); enable_logging_subsystem(&config); From f60e98a214c0d463749aa89340e3513f51cea3ca Mon Sep 17 00:00:00 2001 From: alexgallotta <5581237+alexgallotta@users.noreply.github.com> Date: Thu, 27 Feb 2025 15:08:35 -0500 Subject: [PATCH 3/6] use only version without next, it could fall back to goagent still --- bottlecap/src/bin/bottlecap/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bottlecap/src/bin/bottlecap/main.rs b/bottlecap/src/bin/bottlecap/main.rs index c154c13eb..8f2fed851 100644 --- a/bottlecap/src/bin/bottlecap/main.rs +++ b/bottlecap/src/bin/bottlecap/main.rs @@ -183,7 +183,8 @@ fn build_function_arn(account_id: &str, region: &str, function_name: &str) -> St #[tokio::main] async fn main() -> Result<()> { - println!("DD_EXTENSION | Starting Datadog Extension {EXTENSION_VERSION}"); + let version_without_next = EXTENSION_VERSION.split('-').next().unwrap_or("NA"); + println!("DD_EXTENSION | Starting Datadog Extension {version_without_next}"); let (mut aws_config, config) = load_configs(); enable_logging_subsystem(&config); From 8e3ee20d6c1eb3800871bbdc07fefd14e3e3bd88 Mon Sep 17 00:00:00 2001 From: alexgallotta <5581237+alexgallotta@users.noreply.github.com> Date: Fri, 28 Feb 2025 11:20:44 -0500 Subject: [PATCH 4/6] use info log level for startup message --- bottlecap/src/bin/bottlecap/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bottlecap/src/bin/bottlecap/main.rs b/bottlecap/src/bin/bottlecap/main.rs index 8f2fed851..60899caa8 100644 --- a/bottlecap/src/bin/bottlecap/main.rs +++ b/bottlecap/src/bin/bottlecap/main.rs @@ -68,7 +68,7 @@ use std::{ use telemetry::listener::TelemetryListenerConfig; use tokio::{sync::mpsc::Sender, sync::Mutex as TokioMutex}; use tokio_util::sync::CancellationToken; -use tracing::{debug, error}; +use tracing::{debug, error, info}; use tracing_subscriber::EnvFilter; #[derive(Clone, Deserialize)] @@ -183,11 +183,11 @@ fn build_function_arn(account_id: &str, region: &str, function_name: &str) -> St #[tokio::main] async fn main() -> Result<()> { - let version_without_next = EXTENSION_VERSION.split('-').next().unwrap_or("NA"); - println!("DD_EXTENSION | Starting Datadog Extension {version_without_next}"); let (mut aws_config, config) = load_configs(); enable_logging_subsystem(&config); + let version_without_next = EXTENSION_VERSION.split('-').next().unwrap_or("NA"); + info!("DD_EXTENSION | Starting Datadog Extension {version_without_next}"); let client = Client::builder().no_proxy().build().map_err(|e| { Error::new( std::io::ErrorKind::InvalidData, From 8a4fc53e12e453c02a4b13c4a066e0c8cdcd43d3 Mon Sep 17 00:00:00 2001 From: alexgallotta <5581237+alexgallotta@users.noreply.github.com> Date: Fri, 28 Feb 2025 11:21:46 -0500 Subject: [PATCH 5/6] correct message --- bottlecap/src/bin/bottlecap/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bottlecap/src/bin/bottlecap/main.rs b/bottlecap/src/bin/bottlecap/main.rs index 60899caa8..08609808f 100644 --- a/bottlecap/src/bin/bottlecap/main.rs +++ b/bottlecap/src/bin/bottlecap/main.rs @@ -68,7 +68,7 @@ use std::{ use telemetry::listener::TelemetryListenerConfig; use tokio::{sync::mpsc::Sender, sync::Mutex as TokioMutex}; use tokio_util::sync::CancellationToken; -use tracing::{debug, error, info}; +use tracing::{debug, error}; use tracing_subscriber::EnvFilter; #[derive(Clone, Deserialize)] @@ -187,7 +187,7 @@ async fn main() -> Result<()> { enable_logging_subsystem(&config); let version_without_next = EXTENSION_VERSION.split('-').next().unwrap_or("NA"); - info!("DD_EXTENSION | Starting Datadog Extension {version_without_next}"); + debug!("Starting Datadog Extension {version_without_next}"); let client = Client::builder().no_proxy().build().map_err(|e| { Error::new( std::io::ErrorKind::InvalidData, From 273e1a18b0633d50ed81d9957f7b8eecd416373a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?jordan=20gonz=C3=A1lez?= <30836115+duncanista@users.noreply.github.com> Date: Mon, 3 Mar 2025 06:46:18 -0500 Subject: [PATCH 6/6] make variable public also fixed import --- bottlecap/src/bin/bottlecap/main.rs | 6 ++++-- bottlecap/src/tags/lambda/tags.rs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bottlecap/src/bin/bottlecap/main.rs b/bottlecap/src/bin/bottlecap/main.rs index 08609808f..a111ce9d8 100644 --- a/bottlecap/src/bin/bottlecap/main.rs +++ b/bottlecap/src/bin/bottlecap/main.rs @@ -9,7 +9,6 @@ #![deny(missing_copy_implementations)] #![deny(missing_debug_implementations)] -use bottlecap::tags::lambda::tags::EXTENSION_VERSION; use bottlecap::{ base_url, config::{self, get_aws_partition_by_region, AwsConfig, Config}, @@ -25,7 +24,10 @@ use bottlecap::{ flusher::{build_fqdn_logs, Flusher as LogsFlusher}, }, secrets::decrypt, - tags::{lambda, provider::Provider as TagProvider}, + tags::{ + lambda::{self, tags::EXTENSION_VERSION}, + provider::Provider as TagProvider, + }, telemetry::{ self, client::TelemetryApiClient, diff --git a/bottlecap/src/tags/lambda/tags.rs b/bottlecap/src/tags/lambda/tags.rs index b553a15f9..43cd31c57 100644 --- a/bottlecap/src/tags/lambda/tags.rs +++ b/bottlecap/src/tags/lambda/tags.rs @@ -49,7 +49,7 @@ const FUNCTION_TAGS_KEY: &str = "_dd.tags.function"; // TODO(astuyve) decide what to do with the version const EXTENSION_VERSION_KEY: &str = "dd_extension_version"; // TODO(duncanista) figure out a better way to not hardcode this -const EXTENSION_VERSION: &str = "72-next"; +pub const EXTENSION_VERSION: &str = "72-next"; const REGION_KEY: &str = "region"; const ACCOUNT_ID_KEY: &str = "account_id";