recordDataEnd takes per RPC measurements derived from information derived from the lifetime of the RPC (RPC attempt client side).
(ctx context.Context, mi *metricsInfo, e *stats.End)
| 180 | // recordDataEnd takes per RPC measurements derived from information derived |
| 181 | // from the lifetime of the RPC (RPC attempt client side). |
| 182 | func recordDataEnd(ctx context.Context, mi *metricsInfo, e *stats.End) { |
| 183 | // latency bounds for distribution data (speced millisecond bounds) have |
| 184 | // fractions, thus need a float. |
| 185 | latency := float64(time.Since(mi.startTime)) / float64(time.Millisecond) |
| 186 | var st string |
| 187 | if e.Error != nil { |
| 188 | s, _ := status.FromError(e.Error) |
| 189 | st = canonicalString(s.Code()) |
| 190 | } else { |
| 191 | st = "OK" |
| 192 | } |
| 193 | |
| 194 | // TODO: Attach trace data through attachments?!?! |
| 195 | |
| 196 | if e.Client { |
| 197 | ocstats.RecordWithOptions(ctx, |
| 198 | ocstats.WithTags( |
| 199 | tag.Upsert(keyClientMethod, removeLeadingSlash(mi.method)), |
| 200 | tag.Upsert(keyClientStatus, st)), |
| 201 | ocstats.WithMeasurements( |
| 202 | clientSentBytesPerRPC.M(atomic.LoadInt64(&mi.sentBytes)), |
| 203 | clientSentCompressedBytesPerRPC.M(atomic.LoadInt64(&mi.sentCompressedBytes)), |
| 204 | clientSentMessagesPerRPC.M(atomic.LoadInt64(&mi.sentMsgs)), |
| 205 | clientReceivedMessagesPerRPC.M(atomic.LoadInt64(&mi.recvMsgs)), |
| 206 | clientReceivedBytesPerRPC.M(atomic.LoadInt64(&mi.recvBytes)), |
| 207 | clientReceivedCompressedBytesPerRPC.M(atomic.LoadInt64(&mi.recvCompressedBytes)), |
| 208 | clientRoundtripLatency.M(latency), |
| 209 | clientServerLatency.M(latency), |
| 210 | )) |
| 211 | return |
| 212 | } |
| 213 | ocstats.RecordWithOptions(ctx, |
| 214 | ocstats.WithTags( |
| 215 | tag.Upsert(keyServerMethod, removeLeadingSlash(mi.method)), |
| 216 | tag.Upsert(keyServerStatus, st), |
| 217 | ), |
| 218 | ocstats.WithMeasurements( |
| 219 | serverSentBytesPerRPC.M(atomic.LoadInt64(&mi.sentBytes)), |
| 220 | serverSentCompressedBytesPerRPC.M(atomic.LoadInt64(&mi.sentCompressedBytes)), |
| 221 | serverSentMessagesPerRPC.M(atomic.LoadInt64(&mi.sentMsgs)), |
| 222 | serverReceivedMessagesPerRPC.M(atomic.LoadInt64(&mi.recvMsgs)), |
| 223 | serverReceivedBytesPerRPC.M(atomic.LoadInt64(&mi.recvBytes)), |
| 224 | serverReceivedCompressedBytesPerRPC.M(atomic.LoadInt64(&mi.recvCompressedBytes)), |
| 225 | serverLatency.M(latency))) |
| 226 | } |
no test coverage detected