@@ -141,6 +141,7 @@ impl UsageAgent {
141141    pub  fn  new ( 
142142        token :  String , 
143143        endpoint :  String , 
144+         target_id :  Option < String > , 
144145        buffer_size :  usize , 
145146        connect_timeout :  u64 , 
146147        request_timeout :  u64 , 
@@ -164,6 +165,14 @@ impl UsageAgent {
164165            . build ( ) ; 
165166        let  buffer = Arc :: new ( Buffer :: new ( ) ) ; 
166167
168+         let  mut  endpoint = endpoint; 
169+ 
170+         if  token. starts_with ( "hvo1/" )  { 
171+             if  let  Some ( target_id)  = target_id { 
172+                 endpoint. push_str ( & format ! ( "/{}" ,  target_id) ) ; 
173+             } 
174+         } 
175+ 
167176        UsageAgent  { 
168177            buffer, 
169178            processor, 
@@ -198,43 +207,51 @@ impl UsageAgent {
198207                    ) ; 
199208                    continue ; 
200209                } 
201-                 Ok ( operation)  => { 
202-                     let  hash = operation. hash ; 
203- 
204-                     let  client_name = non_empty_string ( op. client_name ) ; 
205-                     let  client_version = non_empty_string ( op. client_version ) ; 
206- 
207-                     let  metadata:  Option < Metadata >  =
208-                         if  client_name. is_some ( )  || client_version. is_some ( )  { 
209-                             Some ( Metadata  { 
210-                                 client :  Some ( ClientInfo  { 
211-                                     name :  client_name, 
212-                                     version :  client_version, 
213-                                 } ) , 
214-                             } ) 
215-                         }  else  { 
216-                             None 
217-                         } ; 
218-                     report. operations . push ( Operation  { 
219-                         operationMapKey :  hash. clone ( ) , 
220-                         timestamp :  op. timestamp , 
221-                         execution :  Execution  { 
222-                             ok :  op. ok , 
223-                             duration :  op. duration . as_nanos ( ) , 
224-                             errorsTotal :  op. errors , 
225-                         } , 
226-                         persistedDocumentHash :  op. persisted_document_hash , 
227-                         metadata, 
228-                     } ) ; 
229-                     if  let  std:: collections:: hash_map:: Entry :: Vacant ( e)  = report. map . entry ( hash)  { 
230-                         e. insert ( OperationMapRecord  { 
231-                             operation :  operation. operation , 
232-                             operationName :  non_empty_string ( op. operation_name ) , 
233-                             fields :  operation. coordinates , 
210+                 Ok ( operation)  => match  operation { 
211+                     Some ( operation)  => { 
212+                         let  hash = operation. hash ; 
213+ 
214+                         let  client_name = non_empty_string ( op. client_name ) ; 
215+                         let  client_version = non_empty_string ( op. client_version ) ; 
216+ 
217+                         let  metadata:  Option < Metadata >  =
218+                             if  client_name. is_some ( )  || client_version. is_some ( )  { 
219+                                 Some ( Metadata  { 
220+                                     client :  Some ( ClientInfo  { 
221+                                         name :  client_name, 
222+                                         version :  client_version, 
223+                                     } ) , 
224+                                 } ) 
225+                             }  else  { 
226+                                 None 
227+                             } ; 
228+                         report. operations . push ( Operation  { 
229+                             operationMapKey :  hash. clone ( ) , 
230+                             timestamp :  op. timestamp , 
231+                             execution :  Execution  { 
232+                                 ok :  op. ok , 
233+                                 duration :  op. duration . as_nanos ( ) , 
234+                                 errorsTotal :  op. errors , 
235+                             } , 
236+                             persistedDocumentHash :  op. persisted_document_hash , 
237+                             metadata, 
234238                        } ) ; 
239+                         if  let  std:: collections:: hash_map:: Entry :: Vacant ( e)  = report. map . entry ( hash) 
240+                         { 
241+                             e. insert ( OperationMapRecord  { 
242+                                 operation :  operation. operation , 
243+                                 operationName :  non_empty_string ( op. operation_name ) , 
244+                                 fields :  operation. coordinates , 
245+                             } ) ; 
246+                         } 
247+                         report. size  += 1 ; 
235248                    } 
236-                     report. size  += 1 ; 
237-                 } 
249+                     None  => { 
250+                         tracing:: debug!( 
251+                             "Dropping operation (phase: PROCESSING): probably introspection query" 
252+                         ) ; 
253+                     } 
254+                 } , 
238255            } 
239256        } 
240257
0 commit comments