@@ -79,7 +79,7 @@ const REPORTING_URL: &str = "https://usage-reporting.api.apollographql.com/api/i
79
79
const TARGET_LOG : & str = "apollo-studio-extension" ;
80
80
const VERSION : & str = env ! ( "CARGO_PKG_VERSION" ) ;
81
81
const RUNTIME_VERSION : & str = "Rust - No runtime version provided yet" ;
82
- const MAX_TRACES_SIZE : i32 = 3_500_000 ;
82
+ const MAX_TRACES : usize = 100 ;
83
83
84
84
/// An ENUM describing the various HTTP Methods existing.
85
85
#[ derive( Debug , Clone ) ]
@@ -175,8 +175,8 @@ impl ApolloTracing {
175
175
/// * graph_ref - <ref>@<variant> Graph reference with variant
176
176
/// * release_name - Your release version or release name from Git for example
177
177
/// * batch_target - The number of traces to batch, it depends on your traffic, if you have.
178
- /// When the accumulated traces are ~4Mb, they are sent event if we did not reach the
179
- /// batch_target limit .
178
+ /// You cannot send batch traces with a size over 4Mb, so we batch every 100 traces even if
179
+ /// your batch_target is set higher .
180
180
pub fn new (
181
181
authorization_token : String ,
182
182
hostname : String ,
@@ -206,7 +206,6 @@ impl ApolloTracing {
206
206
let mut hashmap: HashMap < String , TracesAndStats > =
207
207
HashMap :: with_capacity ( batch_target + 1 ) ;
208
208
let mut count = 0 ;
209
- let mut actual_size: i32 = 0 ;
210
209
while let Some ( ( name, trace) ) = match Runtime :: locate ( ) {
211
210
#[ cfg( feature = "tokio-comp" ) ]
212
211
Runtime :: Tokio => receiver. recv ( ) . await ,
@@ -224,19 +223,15 @@ impl ApolloTracing {
224
223
None => {
225
224
let mut trace_and_stats = TracesAndStats :: new ( ) ;
226
225
trace_and_stats. mut_trace ( ) . push ( trace) ;
227
-
228
- info ! ( target: "size-ext-2" , size = ?size_of_val( & trace_and_stats) ) ;
229
226
hashmap. insert ( name, trace_and_stats) ;
230
227
}
231
228
}
232
229
233
230
count += 1 ;
234
- actual_size += size_of :: < TracesAndStats > ( ) as i32 ;
235
231
236
- if count > batch_target || actual_size > MAX_TRACES_SIZE {
232
+ if count > batch_target || count > MAX_TRACES {
237
233
use tracing:: { field, field:: debug, span, Level } ;
238
234
239
- actual_size = 0 ;
240
235
let span_batch = span ! (
241
236
Level :: DEBUG ,
242
237
"Sending traces by batch to Apollo Studio" ,
@@ -255,18 +250,6 @@ impl ApolloTracing {
255
250
report. set_traces_per_query ( hashmap_to_send) ;
256
251
report. set_header ( ( * header_tokio) . clone ( ) ) ;
257
252
258
- let test = match protobuf:: Message :: write_to_bytes ( & report) {
259
- Ok ( message) => {
260
- info ! ( target: "size-ext-3" , size = ?message. len( ) ) ;
261
- info ! ( target: "size-ext" , size = ?size_of_val( & message) ) ;
262
- } ,
263
- Err ( err) => {
264
- span_batch. in_scope ( || {
265
- error ! ( target: TARGET_LOG , error = ?err, report = ?report) ;
266
- } ) ;
267
- }
268
- } ;
269
-
270
253
let msg = match protobuf:: Message :: write_to_bytes ( & report) {
271
254
Ok ( message) => message,
272
255
Err ( err) => {
0 commit comments