Skip to content

Commit

Permalink
test: test span
Browse files Browse the repository at this point in the history
  • Loading branch information
andysim3d committed Feb 21, 2025
1 parent 2a978da commit 85aee47
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 21 deletions.
16 changes: 8 additions & 8 deletions bin/rundler/src/cli/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ pub fn configure_logging(config: &LogsArgs) -> anyhow::Result<WorkerGuard> {

let metadata = MetadataMap::new();

// let exporter = opentelemetry_otlp::SpanExporter::builder()
// .with_http()
// .with_endpoint("http://127.0.0.1:4318")
// .with_protocol(opentelemetry_otlp::Protocol::HttpBinary)
// .with_timeout(Duration::from_secs(3))
// // .with_metadata(metadata)
// .build()?;
let exporter = opentelemetry_stdout::SpanExporter::default();
let exporter = opentelemetry_otlp::SpanExporter::builder()
.with_tonic()
.with_endpoint("http://127.0.0.1:4317")
.with_protocol(opentelemetry_otlp::Protocol::HttpBinary)
.with_timeout(Duration::from_secs(3))
.with_metadata(metadata)
.build()?;
// let exporter = opentelemetry_stdout::SpanExporter::default();
let tracer_provider = opentelemetry_sdk::trace::SdkTracerProvider::builder()
.with_batch_exporter(exporter)
.with_resource(Resource::builder().with_service_name("rundler").build())
Expand Down
14 changes: 13 additions & 1 deletion crates/rpc/src/eth/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
// You should have received a copy of the GNU General Public License along with Rundler.
// If not, see https://www.gnu.org/licenses/.

use std::{fmt::Debug, marker::PhantomData, sync::Arc};
use std::{
fmt::{self, Debug},
marker::PhantomData,
sync::Arc,
};

use alloy_primitives::{Address, B256};
use rundler_provider::{EntryPoint, SimulationProvider, StateOverride};
Expand Down Expand Up @@ -85,6 +89,14 @@ pub(crate) struct EntryPointRouter {
v0_7: Option<(Address, Arc<dyn EntryPointRoute>)>,
}

impl fmt::Debug for EntryPointRouter {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("EntryPointRouter")
.field("entry_points", &self.entry_points)
.finish()
}
}

impl EntryPointRouter {
pub(crate) fn entry_points(&self) -> impl Iterator<Item = &Address> {
self.entry_points.iter()
Expand Down
24 changes: 15 additions & 9 deletions crates/rpc/src/rundler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use async_trait::async_trait;
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
use rundler_sim::{gas, FeeEstimator};
use rundler_types::{chain::ChainSpec, pool::Pool, UserOperation, UserOperationVariant};
use tracing::{info, info_span};
use tracing::instrument;

use crate::{
eth::{EntryPointRouter, EthResult, EthRpcError},
Expand Down Expand Up @@ -70,12 +70,15 @@ where
P: Pool + 'static,
F: FeeEstimator + 'static,
{
#[instrument(
name = "RundlerApiServer::max_priority_fee_per_gas",
skip(self),
fields(force_trace_sample = true)
)]
async fn max_priority_fee_per_gas(&self) -> RpcResult<U128> {
let span = info_span!("max_priority_fee_per_gas api");
let x = span.in_scope(|| self);
utils::safe_call_rpc_handler(
"rundler_maxPriorityFeePerGas",
RundlerApi::max_priority_fee_per_gas(x),
RundlerApi::max_priority_fee_per_gas(self),
)
.await
}
Expand Down Expand Up @@ -112,13 +115,11 @@ where
}
}

async fn max_priority_fee_per_gas(&self) -> EthResult<U128> {
let span = info_span!("max_priority_fee_per_gas impl");
let x = span.in_scope(|| None);
info!("here is a log");
#[instrument(skip(self))]
async fn simple_wrapper(&self) -> EthResult<U128> {
let (bundle_fees, _) = self
.fee_estimator
.required_bundle_fees(x)
.required_bundle_fees(None)
.await
.context("should get required fees")?;
Ok(U128::from(
Expand All @@ -128,6 +129,11 @@ where
))
}

#[instrument(name = "RundlerApi::max_priority_fee_per_gas", skip(self))]
async fn max_priority_fee_per_gas(&self) -> EthResult<U128> {
self.simple_wrapper().await
}

async fn drop_local_user_operation(
&self,
user_op: RpcUserOperation,
Expand Down
3 changes: 0 additions & 3 deletions crates/sim/src/gas/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use rundler_provider::{BlockHashOrNumber, DAGasProvider, EvmProvider};
use rundler_types::{chain::ChainSpec, da::DAGasUOData, GasFees, UserOperation};
use rundler_utils::math;
use tokio::try_join;
use tracing::info_span;

use super::oracle::FeeOracle;

Expand Down Expand Up @@ -219,8 +218,6 @@ impl<P: EvmProvider, O: FeeOracle> FeeEstimator for FeeEstimatorImpl<P, O> {
&self,
min_fees: Option<GasFees>,
) -> anyhow::Result<(GasFees, u128)> {
let span = info_span!("max_priority_fee_per_gas innner ");

let (base_fee, priority_fee) =
try_join!(self.get_pending_base_fee(), self.get_priority_fee())?;

Expand Down

0 comments on commit 85aee47

Please sign in to comment.