diff --git a/distribution/lambda/Makefile b/distribution/lambda/Makefile
index 92b9e04c84a..c133d42223e 100644
--- a/distribution/lambda/Makefile
+++ b/distribution/lambda/Makefile
@@ -108,6 +108,7 @@ bench-index:
done
bench-search-term:
+ export QW_LAMBDA_LOG_SPAN_BOUNDARIES=true
mem_sizes=( 1024 2048 4096 8192 )
for mem_size in "$${mem_sizes[@]}"
do
@@ -117,6 +118,7 @@ bench-search-term:
done
bench-search-histogram:
+ export QW_LAMBDA_LOG_SPAN_BOUNDARIES=true
mem_sizes=( 1024 2048 4096 8192 )
for mem_size in "$${mem_sizes[@]}"
do
diff --git a/distribution/lambda/cdk/stacks/examples/mock_data_stack.py b/distribution/lambda/cdk/stacks/examples/mock_data_stack.py
index a83e4546075..4822e69723a 100644
--- a/distribution/lambda/cdk/stacks/examples/mock_data_stack.py
+++ b/distribution/lambda/cdk/stacks/examples/mock_data_stack.py
@@ -12,7 +12,7 @@
from constructs import Construct
import yaml
-from ..services.quickwit_service import QuickwitService
+from ..services import quickwit_service
SEARCHER_FUNCTION_NAME_EXPORT_NAME = "mock-data-searcher-function-name"
INDEX_STORE_BUCKET_NAME_EXPORT_NAME = "mock-data-index-store-bucket-name"
@@ -28,7 +28,7 @@ def __init__(
scope: Construct,
construct_id: str,
index_id: str,
- qw_svc: QuickwitService,
+ qw_svc: quickwit_service.QuickwitService,
**kwargs,
):
super().__init__(scope, construct_id, **kwargs)
@@ -83,7 +83,7 @@ def __init__(
scope: Construct,
construct_id: str,
index_id: str,
- qw_svc: QuickwitService,
+ qw_svc: quickwit_service.QuickwitService,
api_key: str,
**kwargs,
) -> None:
@@ -149,12 +149,15 @@ def __init__(
"mock-data-index-config",
path=index_config_local_path,
)
- qw_svc = QuickwitService(
+ lambda_env = quickwit_service.extract_local_env()
+ qw_svc = quickwit_service.QuickwitService(
self,
"Quickwit",
index_id=index_id,
index_config_bucket=index_config.s3_bucket_name,
index_config_key=index_config.s3_object_key,
+ indexer_environment=lambda_env,
+ searcher_environment=lambda_env,
indexer_package_location=indexer_package_location,
searcher_package_location=searcher_package_location,
)
diff --git a/distribution/lambda/cdk/stacks/services/indexer_service.py b/distribution/lambda/cdk/stacks/services/indexer_service.py
index 1dee9230e6f..65a32ffb8a6 100644
--- a/distribution/lambda/cdk/stacks/services/indexer_service.py
+++ b/distribution/lambda/cdk/stacks/services/indexer_service.py
@@ -32,7 +32,9 @@ def __init__(
"QW_LAMBDA_INDEX_CONFIG_URI": f"s3://{index_config_bucket}/{index_config_key}",
**environment,
},
- timeout=aws_cdk.Duration.minutes(15),
+ # use a strict timeout and retry policy to avoid unexpected costs
+ timeout=aws_cdk.Duration.minutes(1),
+ retry_attempts=0,
reserved_concurrent_executions=1,
memory_size=memory_size,
ephemeral_storage_size=aws_cdk.Size.gibibytes(10),
diff --git a/distribution/lambda/cdk/stacks/services/quickwit_service.py b/distribution/lambda/cdk/stacks/services/quickwit_service.py
index 2887983f1c1..d0505b63faf 100644
--- a/distribution/lambda/cdk/stacks/services/quickwit_service.py
+++ b/distribution/lambda/cdk/stacks/services/quickwit_service.py
@@ -12,8 +12,12 @@
def extract_local_env() -> dict[str, str]:
- """Extracts local environment variables that start with QW_LAMBDA_"""
- return {k: os.environ[k] for k in os.environ.keys() if k.startswith("QW_LAMBDA_")}
+ """Extracts local environment variables QW_LAMBDA_* and QW_DISABLE_TELEMETRY"""
+ return {
+ k: os.environ[k]
+ for k in os.environ.keys()
+ if (k.startswith("QW_LAMBDA_") or k == "QW_DISABLE_TELEMETRY")
+ }
class QuickwitService(Construct):
diff --git a/quickwit/quickwit-lambda/src/bin/indexer.rs b/quickwit/quickwit-lambda/src/bin/indexer.rs
index a62cccea377..f31196955f1 100644
--- a/quickwit/quickwit-lambda/src/bin/indexer.rs
+++ b/quickwit/quickwit-lambda/src/bin/indexer.rs
@@ -23,7 +23,7 @@ use quickwit_lambda::logger;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
- logger::setup_lambda_tracer(tracing::Level::DEBUG)?;
+ logger::setup_lambda_tracer(tracing::Level::INFO)?;
let func = service_fn(handler);
lambda_runtime::run(func)
.await
diff --git a/quickwit/quickwit-lambda/src/bin/searcher.rs b/quickwit/quickwit-lambda/src/bin/searcher.rs
index 33ee5f16034..564ea4e6653 100644
--- a/quickwit/quickwit-lambda/src/bin/searcher.rs
+++ b/quickwit/quickwit-lambda/src/bin/searcher.rs
@@ -23,7 +23,7 @@ use quickwit_lambda::searcher::handler;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
- logger::setup_lambda_tracer(tracing::Level::DEBUG)?;
+ logger::setup_lambda_tracer(tracing::Level::INFO)?;
let func = service_fn(handler);
run(func).await.map_err(|e| anyhow::anyhow!(e))
}
diff --git a/quickwit/quickwit-lambda/src/environment.rs b/quickwit/quickwit-lambda/src/environment.rs
new file mode 100644
index 00000000000..f279a7bc81b
--- /dev/null
+++ b/quickwit/quickwit-lambda/src/environment.rs
@@ -0,0 +1,34 @@
+// Copyright (C) 2024 Quickwit, Inc.
+//
+// Quickwit is offered under the AGPL v3.0 and as commercial software.
+// For commercial licensing, contact us at hello@quickwit.io.
+//
+// AGPL:
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+use std::env::var;
+
+use once_cell::sync::Lazy;
+
+pub static INDEX_ID: Lazy =
+ Lazy::new(|| var("QW_LAMBDA_INDEX_ID").expect("QW_LAMBDA_INDEX_ID must be set"));
+
+pub static LOG_SPAN_BOUNDARIES: Lazy =
+ Lazy::new(|| var("QW_LAMBDA_LOG_SPAN_BOUNDARIES").is_ok_and(|v| v.as_str() == "true"));
+
+pub static OPENTELEMETRY_URL: Lazy