Skip to content

Commit 97c501a

Browse files
Default timestamp to -1 for envoy_final_stream_intel (#2006)
Description: Default timestamp to -1 for envoy_final_stream_intel Risk Level: small Testing: CI Docs Changes: N/A Release Notes: N/A Signed-off-by: Charles Le Borgne <cleborgne@google.com>
1 parent 100a566 commit 97c501a

5 files changed

Lines changed: 41 additions & 38 deletions

File tree

library/common/extensions/filters/http/platform_bridge/filter.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ Http::LocalErrorStatus PlatformBridgeFilter::onLocalReply(const LocalReplyData&
192192
envoy_final_stream_intel PlatformBridgeFilter::finalStreamIntel() {
193193
RELEASE_ASSERT(decoder_callbacks_, "StreamInfo accessed before filter callbacks are set");
194194
// FIXME: Stream handle cannot currently be set from the filter context.
195-
envoy_final_stream_intel final_stream_intel;
196-
memset(&final_stream_intel, 0, sizeof(final_stream_intel));
195+
envoy_final_stream_intel final_stream_intel{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0};
197196
setFinalStreamIntel(decoder_callbacks_->streamInfo(), final_stream_intel);
198197
return final_stream_intel;
199198
}

library/common/http/client.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ class Client : public Logger::Loggable<Logger::Id::http> {
280280
bool explicit_flow_control_ = false;
281281
// Latest intel data retrieved from the StreamInfo.
282282
envoy_stream_intel stream_intel_{-1, -1, 0};
283-
envoy_final_stream_intel envoy_final_stream_intel_;
283+
envoy_final_stream_intel envoy_final_stream_intel_{-1, -1, -1, -1, -1, -1, -1,
284+
-1, -1, -1, -1, 0, 0, 0};
284285
StreamInfo::BytesMeterSharedPtr bytes_meter_;
285286
};
286287

library/common/stream_info/extra_stream_info.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ namespace Envoy {
66
namespace StreamInfo {
77
namespace {
88

9-
void setFromOptional(uint64_t& to_set, const absl::optional<MonotonicTime>& time) {
9+
void setFromOptional(int64_t& to_set, const absl::optional<MonotonicTime>& time) {
1010
if (time.has_value()) {
1111
to_set = std::chrono::duration_cast<std::chrono::milliseconds>(time.value().time_since_epoch())
1212
.count();
1313
}
1414
}
1515

16-
void setFromOptional(uint64_t& to_set, absl::optional<std::chrono::nanoseconds> time, long offset) {
16+
void setFromOptional(int64_t& to_set, absl::optional<std::chrono::nanoseconds> time, long offset) {
1717
if (time.has_value()) {
1818
to_set = offset + std::chrono::duration_cast<std::chrono::milliseconds>(time.value()).count();
1919
}

library/common/types/c_types.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -157,34 +157,36 @@ typedef struct {
157157

158158
/**
159159
* Contains internal HTTP stream metrics which sent at stream end.
160+
*
161+
* Note: for the signed fields, -1 means not present.
160162
*/
161163
typedef struct {
162164
// The time the request started, in ms since the epoch.
163-
uint64_t request_start_ms;
165+
int64_t request_start_ms;
164166
// The time the DNS resolution for this request started, in ms since the epoch.
165-
uint64_t dns_start_ms;
167+
int64_t dns_start_ms;
166168
// The time the DNS resolution for this request completed, in ms since the epoch.
167-
uint64_t dns_end_ms;
169+
int64_t dns_end_ms;
168170
// The time the upstream connection started, in ms since the epoch.
169171
// This may not be set if socket_reused is false.
170-
uint64_t connect_start_ms;
172+
int64_t connect_start_ms;
171173
// The time the upstream connection completed, in ms since the epoch.
172174
// This may not be set if socket_reused is false.
173-
uint64_t connect_end_ms;
175+
int64_t connect_end_ms;
174176
// The time the SSL handshake started, in ms since the epoch.
175177
// This may not be set if socket_reused is false.
176-
uint64_t ssl_start_ms;
178+
int64_t ssl_start_ms;
177179
// The time the SSL handshake completed, in ms since the epoch.
178180
// This may not be set if socket_reused is false.
179-
uint64_t ssl_end_ms;
181+
int64_t ssl_end_ms;
180182
// The time the first byte of the request was sent upstream, in ms since the epoch.
181-
uint64_t sending_start_ms;
183+
int64_t sending_start_ms;
182184
// The time the last byte of the request was sent upstream, in ms since the epoch.
183-
uint64_t sending_end_ms;
185+
int64_t sending_end_ms;
184186
// The time the first byte of the response was received, in ms since the epoch.
185-
uint64_t response_start_ms;
187+
int64_t response_start_ms;
186188
// The time the last byte of the request was received, in ms since the epoch.
187-
uint64_t request_end_ms;
189+
int64_t request_end_ms;
188190
// True if the upstream socket had been used previously.
189191
uint64_t socket_reused;
190192
// The number of bytes sent upstream.

library/swift/FinalStreamIntel.swift

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,31 @@
22
import Foundation
33

44
/// Exposes one time HTTP stream metrics, context, and other details.
5+
/// Note: -1 means "not present" for the fields of type Int64.
56
@objcMembers
67
public final class FinalStreamIntel: StreamIntel {
78
/// The time the request started, in ms since the epoch.
8-
public let requestStartMs: UInt64
9+
public let requestStartMs: Int64
910
/// The time the DNS resolution for this request started, in ms since the epoch.
10-
public let dnsStartMs: UInt64
11+
public let dnsStartMs: Int64
1112
/// The time the DNS resolution for this request completed, in ms since the epoch.
12-
public let dnsEndMs: UInt64
13+
public let dnsEndMs: Int64
1314
/// The time the upstream connection started, in ms since the epoch. (1)
14-
public let connectStartMs: UInt64
15+
public let connectStartMs: Int64
1516
/// The time the upstream connection completed, in ms since the epoch. (1)
16-
public let connectEndMs: UInt64
17+
public let connectEndMs: Int64
1718
/// The time the SSL handshake started, in ms since the epoch. (1)
18-
public let sslStartMs: UInt64
19+
public let sslStartMs: Int64
1920
/// The time the SSL handshake completed, in ms since the epoch. (1)
20-
public let sslEndMs: UInt64
21+
public let sslEndMs: Int64
2122
/// The time the first byte of the request was sent upstream, in ms since the epoch.
22-
public let sendingStartMs: UInt64
23+
public let sendingStartMs: Int64
2324
/// The time the last byte of the request was sent upstream, in ms since the epoch.
24-
public let sendingEndMs: UInt64
25+
public let sendingEndMs: Int64
2526
/// The time the first byte of the response was received, in ms since the epoch.
26-
public let responseStartMs: UInt64
27+
public let responseStartMs: Int64
2728
/// The time the last byte of the request was received, in ms since the epoch.
28-
public let requestEndMs: UInt64
29+
public let requestEndMs: Int64
2930
/// True if the upstream socket had been used previously.
3031
public let socketReused: Bool
3132
/// The number of bytes sent upstream.
@@ -39,17 +40,17 @@ public final class FinalStreamIntel: StreamIntel {
3940
streamId: Int64,
4041
connectionId: Int64,
4142
attemptCount: UInt64,
42-
requestStartMs: UInt64,
43-
dnsStartMs: UInt64,
44-
dnsEndMs: UInt64,
45-
connectStartMs: UInt64,
46-
connectEndMs: UInt64,
47-
sslStartMs: UInt64,
48-
sslEndMs: UInt64,
49-
sendingStartMs: UInt64,
50-
sendingEndMs: UInt64,
51-
responseStartMs: UInt64,
52-
requestEndMs: UInt64,
43+
requestStartMs: Int64,
44+
dnsStartMs: Int64,
45+
dnsEndMs: Int64,
46+
connectStartMs: Int64,
47+
connectEndMs: Int64,
48+
sslStartMs: Int64,
49+
sslEndMs: Int64,
50+
sendingStartMs: Int64,
51+
sendingEndMs: Int64,
52+
responseStartMs: Int64,
53+
requestEndMs: Int64,
5354
socketReused: Bool,
5455
sentByteCount: UInt64,
5556
receivedByteCount: UInt64

0 commit comments

Comments
 (0)