scoop:scoop.http.client:0.1.0
src/observability/api.scoop
Selected production source · src/observability/api.scoop
1
package scoop.http.client3
import scoop.http.HttpVersion4
import scoop.time.Instant5
import scoop.time.TimeMark7
/**8
* A suspend observer of immutable call-event snapshots. Callbacks run outside the shared HTTP/29
* driver; callback failures participate in call failure and cleanup.10
*/11
public class HttpObserver public constructor(internal val onEvent: suspend (HttpCallEvent) -> Unit)13
/**14
* The stage or progress change reported to the observer.15
*/16
public enum HttpCallEventKind {17
/**18
* A concrete request attempt has begun.19
*/20
AttemptStarted,21
/**22
* A reusable or newly established connection has been acquired.23
*/24
ConnectionAcquired,25
/**26
* Request headers reached their recorded send point.27
*/28
RequestHeaders,29
/**30
* Outgoing body progress changed.31
*/32
RequestProgress,33
/**34
* Informational, final, or cached response headers were received.35
*/36
ResponseHeaders,37
/**38
* Incoming body progress changed.39
*/40
ResponseProgress,41
/**42
* The attempt and its required cleanup completed or failed.43
*/44
Completed45
}47
/**48
* Stable call identity for observers, with method, a redacted URL display, and a monotonic start49
* mark.50
*/51
public class HttpCallInfo internal constructor(request: HttpRequest,52
/**53
* The monotonic start mark.54
*/55
public val startedAt: TimeMark) {56
/**57
* The case-sensitive request method.58
*/59
public val method: String = request.method60
/**61
* The origin followed by a redacted path marker; query, fragment, and user information are62
* omitted.63
*/64
public val urlDisplay: String = clientObservedUrl(request)65
}67
/**68
* Monotonic phase start and optional finish marks; unfinished phases retain None.69
*/70
public class HttpPhaseTiming internal constructor(71
/**72
* The monotonic start mark.73
*/74
public val startedAt: TimeMark,75
/**76
* The monotonic completion mark, or None while still active.77
*/78
public val finishedAt: TimeMark? = None)80
/**81
* An immutable snapshot of actual attempt phases, connection facts, response status, and body-byte82
* counters. Unperformed phases remain None.83
*/84
public class HttpAttemptMetrics internal constructor(call: ClientCall, observation: ClientObservation) {85
/**86
* The observed attempt number.87
*/88
public val number: Long = observation.number89
/**90
* Why this attempt was made.91
*/92
public val reason: HttpAttemptReason = observation.reason93
/**94
* The case-sensitive request method.95
*/96
public val method: String = call.request.method97
/**98
* The origin followed by a redacted path marker; query, fragment, and user information are99
* omitted.100
*/101
public val urlDisplay: String = clientObservedUrl(call.request)102
/**103
* The monotonic start mark.104
*/105
public val startedAt: TimeMark = observation.startedAt106
/**107
* The wall-clock timestamp sampled at the start of this attempt.108
*/109
public val startedAtUtc: Instant = observation.startedAtUtc110
/**111
* The monotonic completion mark, or None while still active.112
*/113
public val finishedAt: TimeMark? = observation.finishedAt114
/**115
* The wall-clock timestamp sampled at completion, or None while active.116
*/117
public val finishedAtUtc: Instant? = observation.finishedAtUtc118
/**119
* Actual pool-capacity wait timing, when performed.120
*/121
public val queue: HttpPhaseTiming? = observation.queue122
/**123
* Actual name-resolution timing, when performed.124
*/125
public val resolve: HttpPhaseTiming? = observation.resolve126
/**127
* Actual TCP establishment timing, when performed.128
*/129
public val connect: HttpPhaseTiming? = observation.connect130
/**131
* TLS timing for an HTTPS proxy, when performed.132
*/133
public val proxyTls: HttpPhaseTiming? = observation.proxyTls134
/**135
* CONNECT or SOCKS5 handshake timing, when performed.136
*/137
public val proxyHandshake: HttpPhaseTiming? = observation.proxyHandshake138
/**139
* TLS timing for the origin connection, when performed.140
*/141
public val originTls: HttpPhaseTiming? = observation.originTls142
/**143
* The recorded outgoing-header milestone.144
*/145
public val requestHeadersAt: TimeMark? = observation.requestHeadersAt146
/**147
* The wall-clock timestamp sampled when request headers reached the protocol layer.148
*/149
public val requestHeadersAtUtc: Instant? = observation.requestHeadersAtUtc150
/**151
* The most recent informational, final, or cached response-header milestone.152
*/153
public val responseHeadersAt: TimeMark? = observation.responseHeadersAt154
/**155
* The wall-clock timestamp of the most recent response-header milestone.156
*/157
public val responseHeadersAtUtc: Instant? = observation.responseHeadersAtUtc158
/**159
* The network final-response-header milestone, excluding informational and cached heads.160
*/161
public val finalResponseHeadersAt: TimeMark? = observation.finalResponseHeadersAt162
/**163
* The wall-clock timestamp of the network final-response-header milestone.164
*/165
public val finalResponseHeadersAtUtc: Instant? = observation.finalResponseHeadersAtUtc166
/**167
* The first recorded incoming-response-byte milestone. Protocol sampling requires a client168
* observer; request-only observation can leave this None on a shared connection.169
*/170
public val firstResponseByteAt: TimeMark? = observation.firstResponseByteAt171
/**172
* The selected HTTP protocol version, once known.173
*/174
public val version: HttpVersion? = observation.version175
/**176
* Whether an existing connection was reused, once known.177
*/178
public val connectionReused: Boolean? = observation.connectionReused179
/**180
* The most recent informational, final, or cached response status, once available.181
*/182
public val status: UInt? = observation.status183
/**184
* The response's cache/network origin.185
*/186
public val cacheStatus: HttpCacheStatus = call.cacheStatus187
/**188
* Outgoing request body bytes transferred so far.189
*/190
public val requestBodyBytes: Long = call.requestBodyBytes191
/**192
* Incoming body bytes before content decoding.193
*/194
public val encodedResponseBodyBytes: Long = call.encodedResponseBodyBytes195
/**196
* Body bytes delivered after content decoding.197
*/198
public val responseBodyBytes: Long = call.responseBodyBytes199
}201
/**202
* An observer event combining stable call information, an attempt snapshot, and any failure.203
*/204
public class HttpCallEvent internal constructor(205
/**206
* The event's phase or progress category.207
*/208
public val kind: HttpCallEventKind,209
/**210
* Stable information about the logical call.211
*/212
public val call: HttpCallInfo,213
/**214
* The immutable attempt snapshot at this event.215
*/216
public val metrics: HttpAttemptMetrics,217
/**218
* The failure associated with the event, if any.219
*/220
public val failure: Throwable?) {221
/**222
* Formats a compact summary using redacted URL information and observed metrics.223
*/224
public fun formatSummary(): String = formatClientCallEvent(this)225
}