-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Naive implementation of http/json collector endpoint
Note this implementation comes with some major concurrency flaws
- Loading branch information
Showing
6 changed files
with
59 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
mod inspect; | ||
mod inspectors; | ||
pub mod otel; | ||
mod requestor; | ||
mod requests; | ||
pub mod spans; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use crate::api::grpc::extract_trace_ids; | ||
use crate::data::models::Span; | ||
use crate::data::Store; | ||
use crate::events::ServerEvents; | ||
use crate::models::SpanAdded; | ||
use axum::extract::State; | ||
use axum::response::IntoResponse; | ||
use axum::Json; | ||
use opentelemetry_proto::tonic::collector::trace::v1::{ | ||
ExportTraceServiceRequest, ExportTraceServiceResponse, | ||
}; | ||
|
||
#[tracing::instrument(skip_all)] | ||
pub async fn trace_collector_handler( | ||
State(store): State<Store>, | ||
State(events): State<ServerEvents>, | ||
Json(payload): Json<ExportTraceServiceRequest>, | ||
) -> impl IntoResponse { | ||
let trace_ids = extract_trace_ids(&payload); | ||
|
||
let tx = store.start_transaction().await.expect("TODO"); | ||
|
||
let spans = Span::from_collector_request(payload); | ||
for span in spans { | ||
store.span_create(&tx, span).await.expect("TODO"); | ||
} | ||
|
||
store.commit_transaction(tx).await.expect("TODO"); | ||
|
||
events.broadcast(SpanAdded::new(trace_ids).into()); | ||
|
||
let message = ExportTraceServiceResponse { | ||
partial_success: None, | ||
}; | ||
|
||
Json(message) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters