def set_in_request(cls, r: Optional[Request] = None, metrics: Optional[RequestMetrics] = None) -> None:
        """
        NOTE: this function should only be used in TelemetryMiddleware, and threading edge cases.
        """
        r = r if r is not None else cls._get_request()
        cls._set_request(r)
        cls.METRIC_STORES[r] = metrics if metrics is not None else RequestMetrics()

        NOTE: this function should only be used in TelemetryMiddleware, and threading edge cases.
        
src/marqo/tensor_search/telemetry.py