@@ -7,16 +7,19 @@ use crate::cloud::CloudConfig;
77use crate :: frame:: types:: LegacyConsistency ;
88use crate :: history;
99use crate :: history:: HistoryListener ;
10+ use crate :: prepared_statement:: PartitionKeyDecoder ;
1011use crate :: retry_policy:: RetryPolicy ;
12+ use crate :: utils:: pretty:: { CommaSeparatedDisplayer , CqlValueDisplayer } ;
1113use arc_swap:: ArcSwapOption ;
1214use async_trait:: async_trait;
1315use bytes:: BufMut ;
1416use bytes:: Bytes ;
1517use bytes:: BytesMut ;
1618use futures:: future:: join_all;
1719use futures:: future:: try_join_all;
20+ use itertools:: Either ;
1821pub use scylla_cql:: errors:: TranslationError ;
19- use scylla_cql:: frame:: response:: result:: Rows ;
22+ use scylla_cql:: frame:: response:: result:: { PreparedMetadata , Rows } ;
2023use scylla_cql:: frame:: response:: NonErrorResponse ;
2124use std:: borrow:: Borrow ;
2225use std:: collections:: HashMap ;
@@ -952,8 +955,12 @@ impl Session {
952955 is_confirmed_lwt : prepared. is_confirmed_lwt ( ) ,
953956 } ;
954957
955- let span =
956- RequestSpan :: new_prepared ( partition_key. as_ref ( ) , token, serialized_values. size ( ) ) ;
958+ let span = RequestSpan :: new_prepared (
959+ prepared. get_prepared_metadata ( ) ,
960+ partition_key. as_ref ( ) ,
961+ token,
962+ serialized_values. size ( ) ,
963+ ) ;
957964
958965 if !span. span ( ) . is_disabled ( ) {
959966 if let ( Some ( keyspace) , Some ( token) ) = ( statement_info. keyspace . as_ref ( ) , token) {
@@ -2063,11 +2070,11 @@ impl RequestSpan {
20632070 }
20642071
20652072 pub ( crate ) fn new_prepared (
2073+ prepared_metadata : & PreparedMetadata ,
20662074 partition_key : Option < & Bytes > ,
20672075 token : Option < Token > ,
20682076 request_size : usize ,
20692077 ) -> Self {
2070- use crate :: utils:: pretty:: HexBytes ;
20712078 use tracing:: field:: Empty ;
20722079
20732080 let span = trace_span ! (
@@ -2087,7 +2094,10 @@ impl RequestSpan {
20872094 if let Some ( partition_key) = partition_key {
20882095 span. record (
20892096 "partition_key" ,
2090- tracing:: field:: display ( format_args ! ( "{:x}" , HexBytes ( partition_key) ) ) ,
2097+ tracing:: field:: display ( format_args ! (
2098+ "{}" ,
2099+ partition_key_displayer( prepared_metadata, partition_key) ,
2100+ ) ) ,
20912101 ) ;
20922102 }
20932103 if let Some ( token) = token {
@@ -2185,3 +2195,15 @@ impl Drop for RequestSpan {
21852195 ) ;
21862196 }
21872197}
2198+
2199+ fn partition_key_displayer < ' pk > (
2200+ prepared_metadata : & ' pk PreparedMetadata ,
2201+ partition_key : & ' pk [ u8 ] ,
2202+ ) -> impl Display + ' pk {
2203+ CommaSeparatedDisplayer (
2204+ PartitionKeyDecoder :: new ( prepared_metadata, partition_key) . map ( |c| match c {
2205+ Ok ( c) => Either :: Left ( CqlValueDisplayer ( c) ) ,
2206+ Err ( _) => Either :: Right ( "<decoding error>" ) ,
2207+ } ) ,
2208+ )
2209+ }
0 commit comments