Skip to content

Commit a08e096

Browse files
feat: enable otel metrics and traces (#1020)
OTEL metrics endpoint `/v1/metrics` OTEL traces endpoint `/v1/traces` above two endpoints are added to support OTEL metrics and traces ingestion similar to OTEL logs endpoint `/v1/logs`
1 parent 4af4e6c commit a08e096

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

src/handlers/http/ingest.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ pub async fn ingest_internal_stream(stream_name: String, body: Bytes) -> Result<
106106
// Handler for POST /v1/logs to ingest OTEL logs
107107
// ingests events by extracting stream name from header
108108
// creates if stream does not exist
109-
pub async fn ingest_otel_logs(req: HttpRequest, body: Bytes) -> Result<HttpResponse, PostError> {
109+
pub async fn handle_otel_ingestion(
110+
req: HttpRequest,
111+
body: Bytes,
112+
) -> Result<HttpResponse, PostError> {
110113
if let Some((_, stream_name)) = req
111114
.headers()
112115
.iter()

src/handlers/http/modal/server.rs

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -406,14 +406,35 @@ impl Server {
406406
}
407407

408408
// /v1/logs endpoint to be used for OTEL log ingestion only
409-
pub fn get_ingest_otel_factory() -> Resource {
410-
web::resource("/v1/logs")
411-
.route(
412-
web::post()
413-
.to(ingest::ingest_otel_logs)
414-
.authorize_for_stream(Action::Ingest),
409+
pub fn get_ingest_otel_factory() -> Scope {
410+
web::scope("/v1")
411+
.service(
412+
web::resource("/logs")
413+
.route(
414+
web::post()
415+
.to(ingest::handle_otel_ingestion)
416+
.authorize_for_stream(Action::Ingest),
417+
)
418+
.app_data(web::PayloadConfig::default().limit(MAX_EVENT_PAYLOAD_SIZE)),
419+
)
420+
.service(
421+
web::resource("/metrics")
422+
.route(
423+
web::post()
424+
.to(ingest::handle_otel_ingestion)
425+
.authorize_for_stream(Action::Ingest),
426+
)
427+
.app_data(web::PayloadConfig::default().limit(MAX_EVENT_PAYLOAD_SIZE)),
428+
)
429+
.service(
430+
web::resource("/traces")
431+
.route(
432+
web::post()
433+
.to(ingest::handle_otel_ingestion)
434+
.authorize_for_stream(Action::Ingest),
435+
)
436+
.app_data(web::PayloadConfig::default().limit(MAX_EVENT_PAYLOAD_SIZE)),
415437
)
416-
.app_data(web::PayloadConfig::default().limit(MAX_EVENT_PAYLOAD_SIZE))
417438
}
418439

419440
// get the oauth webscope

0 commit comments

Comments
 (0)