@@ -54,7 +54,6 @@ class MetricsMiddleware(BaseHTTPMiddleware):
5454 _send_signal: Sends the metrics signal to the reporting endpoint.
5555 _get_event_signal: Retrieves the metrics signal for the current request.
5656 _get_user: Retrieves the user information from the request.
57- _attach_secret: Attaches the report secret to the metrics data.
5857
5958 """
6059
@@ -149,19 +148,12 @@ def _get_event_signal(
149148 assistant_id = agent_id ,
150149 duration_ms = duration_ms ,
151150 )
152- data = self ._attach_secret (data )
153151 signal = MetricsSignal (signal = data )
154152 return signal
155153 except Exception as e :
156154 logger .warning (event = f"[Metrics] Failed to process event data: { e } " )
157155 return None
158156
159- def _attach_secret (self , data : MetricsData ) -> MetricsData :
160- if not REPORT_SECRET :
161- return data
162- data .secret = REPORT_SECRET
163- return data
164-
165157
166158async def report_metrics (signal : MetricsSignal , ctx : Context ) -> None :
167159 """
@@ -187,7 +179,11 @@ async def report_metrics(signal: MetricsSignal, ctx: Context) -> None:
187179 signal = to_dict (signal )
188180 transport = AsyncHTTPTransport (retries = NUM_RETRIES )
189181 async with AsyncClient (transport = transport ) as client :
190- await client .post (REPORT_ENDPOINT , json = signal )
182+ headers = {
183+ "Authorization" : f"Bearer { REPORT_SECRET } " ,
184+ "Content-Type" : "application/json" ,
185+ }
186+ await client .post (REPORT_ENDPOINT , json = signal , headers = headers )
191187 except Exception as e :
192188 logger .error (event = f"[Metrics] Error posting report: { e } " )
193189
@@ -260,7 +256,6 @@ class MetricsHelper:
260256 def log_signal_curl (signal : MetricsSignal , ctx : Context ) -> None :
261257 logger = ctx .get_logger ()
262258 s = to_dict (signal )
263- s ["signal" ]["secret" ] = "'$SECRET'"
264259 json_signal = json .dumps (s )
265260 # just general curl commands to test the endpoint for now
266261 logger .info (
0 commit comments