入队约两个小时后发送请求

时间:2019-08-06 08:59:06

标签: okhttp3

我正在开发一个HttpEventListener来计算每个调用的计时,但是统计数据表明,在调用排队后很长时间发送了一些请求,并且响应成功,代码为200。

首先,我认为我的代码有错误,但是统计信息有两个时间戳,一个是报告时间,它是由我的自定义Itercepter产生的,另一个是事件时间,是由eventListener callStart方法产生的,它们之间的间隔时间较长

class HttpTimeStatListener(private val statData: HttpTimeStatData, private val onReleaseFunc: (Call, Connection) -> Unit) : EventListener() {
    private var resBStartNS = 0L
    private var resHStartNS = 0L
    private var reqBStartNS = 0L
    private var reqHStartNS = 0L
    private var callStartNS = 0L
    private var connectStartNS = 0L

    override fun callStart(call: Call) {
        callStartNS = System.nanoTime()
        statData.event_ts = System.currentTimeMillis()
    }
}
data class ReportParam(
        @field:SerializedName("context")
        private var context: ReportContext,
        @field:SerializedName("data")
        private var data: BaseApiStatData
) {
    @field:SerializedName("what")
    private val what: String? = "req_stat"
    @field:SerializedName("who")
    private val who: String? = "client"
    @field:SerializedName("when")
    private val `when`: Long = System.currentTimeMillis()
    @field:SerializedName("platform")
    private val platform: String? = "android"
    @field:SerializedName("app")
    private val app: String? = "fordeal"


    @field:SerializedName("ip")
    private var ip: String? = NetUtils.getIpAddressString()
}

ReportParam实例将在响应时创建。

0 个答案:

没有答案