-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Move the apollo config, update changelog * Split configuration for Apollo so that tracing can go in the tracing module and metrics can go in the metrics module. * Introduce instrument layer Move router_request span to telemetry plugin. There's no way to disable this plugin so it's OK. Add logic for dynamic client name and client version header. * Print errors if config could not be reloaded. * Update test config files * Integration test for jaeger * Fix build for windows and osx. OSX had an issue with max UDP packet size Windows has all sorts of file related issues. On the plus side the special handling for windows in circle has been removed as the root cause of the hang on windows is now known to be: rust-lang/rust#45572 * Add logic to kill node processes on test termination * Remove all piping from external commands, it's not safe unless we read via another thread (which we don't) * Removed instructions for developing without docker compose. It is only going to get more complicated aw we add more integration tests. Docker compose is the way to go. * Router span name moved to constant. Co-authored-by: bryn <bryn@apollographql.com> Co-authored-by: Gary Pennington <gary@apollographql.com>
- Loading branch information
1 parent
a4b78d3
commit 9a62ca1
Showing
72 changed files
with
1,225 additions
and
700 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
//! Instrumentation layer that allows services to be wrapped in a span. | ||
//! | ||
//! See [`Layer`] and [`Service`] for more details. | ||
//! | ||
//! Using ServiceBuilderExt: | ||
//! ```rust | ||
//! # use tower::ServiceBuilder; | ||
//! # use tower_service::Service; | ||
//! # use tracing::info_span; | ||
//! # use apollo_router_core::ServiceBuilderExt; | ||
//! # fn test<T>(service: impl Service<T>) { | ||
//! let instrumented = ServiceBuilder::new() | ||
//! .instrument(|_request| info_span!("query_planning")) | ||
//! .service(service); | ||
//! # } | ||
//! ``` | ||
//! Now calls to the wrapped service will be wrapped in a span. You can attach attributes to the span from the request. | ||
//! | ||
|
||
use futures::future::BoxFuture; | ||
use futures::FutureExt; | ||
use std::marker::PhantomData; | ||
use std::task::{Context, Poll}; | ||
use tower::Layer; | ||
use tower_service::Service; | ||
use tracing::Instrument; | ||
|
||
/// [`Layer`] for instrumentation. | ||
pub struct InstrumentLayer<F, Request> | ||
where | ||
F: Fn(&Request) -> tracing::Span, | ||
{ | ||
span_fn: F, | ||
phantom: PhantomData<Request>, | ||
} | ||
|
||
impl<F, Request> InstrumentLayer<F, Request> | ||
where | ||
F: Fn(&Request) -> tracing::Span, | ||
{ | ||
pub fn new(span_fn: F) -> InstrumentLayer<F, Request> { | ||
Self { | ||
span_fn, | ||
phantom: Default::default(), | ||
} | ||
} | ||
} | ||
|
||
impl<F, S, Request> Layer<S> for InstrumentLayer<F, Request> | ||
where | ||
S: Service<Request>, | ||
F: Fn(&Request) -> tracing::Span + Clone, | ||
{ | ||
type Service = InstrumentService<F, S, Request>; | ||
|
||
fn layer(&self, inner: S) -> Self::Service { | ||
InstrumentService { | ||
inner, | ||
span_fn: self.span_fn.clone(), | ||
phantom: Default::default(), | ||
} | ||
} | ||
} | ||
|
||
/// [`Service`] for instrumentation. | ||
pub struct InstrumentService<F, S, Request> | ||
where | ||
S: Service<Request>, | ||
F: Fn(&Request) -> tracing::Span, | ||
{ | ||
inner: S, | ||
span_fn: F, | ||
phantom: PhantomData<Request>, | ||
} | ||
|
||
impl<F, S, Request> Service<Request> for InstrumentService<F, S, Request> | ||
where | ||
F: Fn(&Request) -> tracing::Span, | ||
S: Service<Request>, | ||
<S as Service<Request>>::Future: Send + 'static, | ||
{ | ||
type Response = S::Response; | ||
type Error = S::Error; | ||
type Future = BoxFuture<'static, Result<Self::Response, Self::Error>>; | ||
|
||
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { | ||
self.inner.poll_ready(cx) | ||
} | ||
|
||
fn call(&mut self, req: Request) -> Self::Future { | ||
let span = (self.span_fn)(&req); | ||
self.inner.call(req).instrument(span).boxed() | ||
} | ||
} |
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
Oops, something went wrong.