-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(spans): Reintroduce OTLP endpoint (#4223)
Restore the OTLP endpoint that was removed in #3973. This PR moves the parsing of the trace data to the processor to ensure fast response times. I also renamed the endpoint from `/spans/` to `/otlp/v1/traces/` to be consistent with https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/#otel_exporter_otlp_endpoint.
- Loading branch information
Showing
20 changed files
with
839 additions
and
39 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use axum::extract::{DefaultBodyLimit, Request}; | ||
use axum::http::StatusCode; | ||
use axum::response::IntoResponse; | ||
use axum::routing::{post, MethodRouter}; | ||
use axum::RequestExt; | ||
use bytes::Bytes; | ||
use relay_config::Config; | ||
use relay_dynamic_config::Feature; | ||
|
||
use crate::endpoints::common; | ||
use crate::envelope::{ContentType, Envelope, Item, ItemType}; | ||
use crate::extractors::{RawContentType, RequestMeta}; | ||
use crate::service::ServiceState; | ||
|
||
async fn handle( | ||
state: ServiceState, | ||
content_type: RawContentType, | ||
meta: RequestMeta, | ||
request: Request, | ||
) -> axum::response::Result<impl IntoResponse> { | ||
let content_type @ (ContentType::Json | ContentType::Protobuf) = | ||
ContentType::from(content_type.as_ref()) | ||
else { | ||
return Ok(StatusCode::UNSUPPORTED_MEDIA_TYPE); | ||
}; | ||
let payload: Bytes = request.extract().await?; | ||
let mut envelope = Envelope::from_request(None, meta); | ||
envelope.require_feature(Feature::OtelEndpoint); | ||
|
||
envelope.add_item({ | ||
let mut item = Item::new(ItemType::OtelTracesData); | ||
item.set_payload(content_type, payload); | ||
item | ||
}); | ||
|
||
common::handle_envelope(&state, envelope).await?; | ||
|
||
Ok(StatusCode::ACCEPTED) | ||
} | ||
|
||
pub fn route(config: &Config) -> MethodRouter<ServiceState> { | ||
post(handle).route_layer(DefaultBodyLimit::max(config.max_envelope_size())) | ||
} |
Oops, something went wrong.