Skip to content

Commit

Permalink
feat: enable otel metrics and traces (#1020)
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
nikhilsinhaparseable authored Dec 8, 2024
1 parent 4af4e6c commit a08e096
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/handlers/http/ingest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ pub async fn ingest_internal_stream(stream_name: String, body: Bytes) -> Result<
// Handler for POST /v1/logs to ingest OTEL logs
// ingests events by extracting stream name from header
// creates if stream does not exist
pub async fn ingest_otel_logs(req: HttpRequest, body: Bytes) -> Result<HttpResponse, PostError> {
pub async fn handle_otel_ingestion(
req: HttpRequest,
body: Bytes,
) -> Result<HttpResponse, PostError> {
if let Some((_, stream_name)) = req
.headers()
.iter()
Expand Down
35 changes: 28 additions & 7 deletions src/handlers/http/modal/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,14 +406,35 @@ impl Server {
}

// /v1/logs endpoint to be used for OTEL log ingestion only
pub fn get_ingest_otel_factory() -> Resource {
web::resource("/v1/logs")
.route(
web::post()
.to(ingest::ingest_otel_logs)
.authorize_for_stream(Action::Ingest),
pub fn get_ingest_otel_factory() -> Scope {
web::scope("/v1")
.service(
web::resource("/logs")
.route(
web::post()
.to(ingest::handle_otel_ingestion)
.authorize_for_stream(Action::Ingest),
)
.app_data(web::PayloadConfig::default().limit(MAX_EVENT_PAYLOAD_SIZE)),
)
.service(
web::resource("/metrics")
.route(
web::post()
.to(ingest::handle_otel_ingestion)
.authorize_for_stream(Action::Ingest),
)
.app_data(web::PayloadConfig::default().limit(MAX_EVENT_PAYLOAD_SIZE)),
)
.service(
web::resource("/traces")
.route(
web::post()
.to(ingest::handle_otel_ingestion)
.authorize_for_stream(Action::Ingest),
)
.app_data(web::PayloadConfig::default().limit(MAX_EVENT_PAYLOAD_SIZE)),
)
.app_data(web::PayloadConfig::default().limit(MAX_EVENT_PAYLOAD_SIZE))
}

// get the oauth webscope
Expand Down

0 comments on commit a08e096

Please sign in to comment.