Skip to content

Commit

Permalink
feat: instrument critical methods in token/token exchange
Browse files Browse the repository at this point in the history
Co-authored-by: Kim Tore Jensen <kimtjen@gmail.com>
  • Loading branch information
tronghn and kimtore committed Nov 18, 2024
1 parent 0dad802 commit 7b718e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/identity_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use std::cmp::PartialEq;
use std::collections::HashMap;
use std::fmt::{Display, Formatter};
use std::marker::PhantomData;
use tracing::instrument;
use utoipa::ToSchema;

/// RFC 6749 token response from section 5.1.
Expand Down Expand Up @@ -301,6 +302,7 @@ where
})
}

#[instrument(skip_all)]
fn create_assertion(&self, target: String) -> Option<String> {
let assertion = A::new(self.token_endpoint.as_ref()?.clone(), self.client_id.clone(), target);
serialize(assertion, self.client_assertion_header.as_ref()?, self.private_jwk.as_ref()?).ok()
Expand Down Expand Up @@ -338,6 +340,7 @@ where
self.upstream_jwks.validate(&token).await.map(IntrospectResponse::new).unwrap_or_else(IntrospectResponse::new_invalid)
}

#[instrument(skip_all)]
async fn get_token_with_config(&self, config: TokenRequestBuilderParams) -> Result<TokenResponse, ApiError> {
let params = R::token_request(config).ok_or(ApiError::Sign)?;

Expand Down
3 changes: 1 addition & 2 deletions src/tracing.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use log::info;
use opentelemetry::trace::TracerProvider;
use opentelemetry::{global, KeyValue};
use opentelemetry_sdk::metrics::reader::DefaultTemporalitySelector;
Expand All @@ -9,7 +8,7 @@ use opentelemetry_semantic_conventions::{
attribute::{DEPLOYMENT_ENVIRONMENT_NAME, SERVICE_NAME, SERVICE_VERSION},
SCHEMA_URL,
};
use tracing::{instrument, span, Level};
use tracing::{Level};
use tracing_opentelemetry::{MetricsLayer, OpenTelemetryLayer};
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
Expand Down

0 comments on commit 7b718e7

Please sign in to comment.