@@ -223,7 +223,7 @@ def _calculate_resource_hash(resource_details: Dict[str, Any]) -> str:
223
223
return sha256_hash (json .dumps (resource_details , sort_keys = True ))
224
224
225
225
def _enqueue_payload (self , payload : UsagePayload ):
226
- logger .debug ("Enqueuing usage payload %s" , payload )
226
+ logger .debug ("Enqueuing usage payload" )
227
227
if not payload :
228
228
return
229
229
with self ._queue_lock :
@@ -347,6 +347,8 @@ def _update_usage_payload(
347
347
inference_test_run : bool = False ,
348
348
fps : float = 0 ,
349
349
execution_duration : float = 0 ,
350
+ roboflow_service_name : Optional [str ] = None ,
351
+ roboflow_internal_secret : Optional [str ] = None ,
350
352
):
351
353
source = str (source ) if source else ""
352
354
try :
@@ -382,7 +384,8 @@ def _update_usage_payload(
382
384
source_usage ["ip_address_hash" ] = ip_address_hash
383
385
source_usage ["is_gpu_available" ] = is_gpu_available
384
386
source_usage ["execution_duration" ] += execution_duration
385
- logger .debug ("Updated usage: %s" , source_usage )
387
+ source_usage ["roboflow_service_name" ] = roboflow_service_name
388
+ source_usage ["roboflow_internal_secret" ] = roboflow_internal_secret
386
389
387
390
def record_usage (
388
391
self ,
@@ -395,6 +398,8 @@ def record_usage(
395
398
inference_test_run : bool = False ,
396
399
fps : float = 0 ,
397
400
execution_duration : float = 0 ,
401
+ roboflow_service_name : Optional [str ] = None ,
402
+ roboflow_internal_secret : Optional [str ] = None ,
398
403
):
399
404
if not api_key :
400
405
return
@@ -417,6 +422,8 @@ def record_usage(
417
422
inference_test_run = inference_test_run ,
418
423
fps = fps ,
419
424
execution_duration = execution_duration ,
425
+ roboflow_service_name = roboflow_service_name ,
426
+ roboflow_internal_secret = roboflow_internal_secret ,
420
427
)
421
428
422
429
async def async_record_usage (
@@ -430,6 +437,8 @@ async def async_record_usage(
430
437
inference_test_run : bool = False ,
431
438
fps : float = 0 ,
432
439
execution_duration : float = 0 ,
440
+ roboflow_service_name : Optional [str ] = None ,
441
+ roboflow_internal_secret : Optional [str ] = None ,
433
442
):
434
443
if self ._async_lock :
435
444
async with self ._async_lock :
@@ -443,6 +452,8 @@ async def async_record_usage(
443
452
inference_test_run = inference_test_run ,
444
453
fps = fps ,
445
454
execution_duration = execution_duration ,
455
+ roboflow_internal_service_name = roboflow_service_name ,
456
+ roboflow_internal_secret = roboflow_internal_secret ,
446
457
)
447
458
else :
448
459
self .record_usage (
@@ -455,6 +466,8 @@ async def async_record_usage(
455
466
inference_test_run = inference_test_run ,
456
467
fps = fps ,
457
468
execution_duration = execution_duration ,
469
+ roboflow_internal_service_name = roboflow_service_name ,
470
+ roboflow_internal_secret = roboflow_internal_secret ,
458
471
)
459
472
460
473
def _usage_collector (self ):
@@ -515,7 +528,6 @@ def _offload_to_api(self, payloads: List[APIKeyUsage]):
515
528
self ._plan_details ._is_enterprise_col_name
516
529
]
517
530
518
- logger .debug ("Sending usage payload %s" , payload )
519
531
api_keys_hashes_failed = send_usage_payload (
520
532
payload = payload ,
521
533
api_usage_endpoint_url = self ._settings .api_usage_endpoint_url ,
@@ -644,6 +656,9 @@ def _extract_usage_params_from_func_kwargs(
644
656
else :
645
657
logger .debug ("Could not obtain API key from func kwargs" )
646
658
659
+ roboflow_service_name = func_kwargs .get ("source_info" )
660
+ roboflow_internal_secret = func_kwargs .get ("service_secret" )
661
+
647
662
return {
648
663
"source" : source ,
649
664
"api_key" : usage_api_key ,
@@ -653,6 +668,8 @@ def _extract_usage_params_from_func_kwargs(
653
668
"inference_test_run" : usage_inference_test_run ,
654
669
"fps" : usage_fps ,
655
670
"execution_duration" : execution_duration ,
671
+ "roboflow_service_name" : roboflow_service_name ,
672
+ "roboflow_internal_secret" : roboflow_internal_secret ,
656
673
}
657
674
658
675
def __call__ (
0 commit comments