pub struct GcpAuthInterceptor { /* private fields */ }Expand description
A tonic Interceptor that sets the headers of Google credentials on every request:
authorization, and whatever else the credentials add, such as x-goog-user-project
for a quota project.
super::GcpOtlpExporterBuilder authenticates its exporters with one. Pass one to
with_interceptor to authenticate an OTLP exporter built elsewhere, such as a
metrics exporter.
An interceptor runs synchronously while Google tokens are refreshed asynchronously, so a background task polls the credentials and publishes their headers when they change, and each request copies the latest ones. The task runs on the Tokio runtime the interceptor is created on, and ends when the last clone is dropped. A failed refresh keeps the headers published last; a warning is logged when refreshing starts failing and another when it recovers.
Implementations§
Source§impl GcpAuthInterceptor
impl GcpAuthInterceptor
Sourcepub async fn new(
auth_headers: impl Into<Arc<GoogleAuthHeaders>>,
) -> GcloudObservabilityResult<Self>
pub async fn new( auth_headers: impl Into<Arc<GoogleAuthHeaders>>, ) -> GcloudObservabilityResult<Self>
Fetches the first headers of auth_headers and starts the task that keeps them
current.
Fails when called outside a Tokio runtime, or when the credentials serve no headers.
Sourcepub async fn from_adc() -> GcloudObservabilityResult<Self>
pub async fn from_adc() -> GcloudObservabilityResult<Self>
Self::new with the Application Default Credentials and the cloud-platform
scope.
Trait Implementations§
Source§impl Clone for GcpAuthInterceptor
impl Clone for GcpAuthInterceptor
Source§impl Debug for GcpAuthInterceptor
impl Debug for GcpAuthInterceptor
Auto Trait Implementations§
impl Forget for GcpAuthInterceptor
impl Freeze for GcpAuthInterceptor
impl Move for GcpAuthInterceptor
impl RefUnwindSafe for GcpAuthInterceptor
impl Send for GcpAuthInterceptor
impl Sync for GcpAuthInterceptor
impl Unpin for GcpAuthInterceptor
impl UnsafeUnpin for GcpAuthInterceptor
impl UnwindSafe for GcpAuthInterceptor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request