Skip to content

Commit

Permalink
final_intel: adding response flags
Browse files Browse the repository at this point in the history
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
  • Loading branch information
alyssawilk committed Jan 20, 2022
1 parent d473980 commit 44d8fae
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion library/common/jni/jni_utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jlongArray native_stream_intel_to_array(JNIEnv* env, envoy_stream_intel stream_i

jlongArray native_final_stream_intel_to_array(JNIEnv* env,
envoy_final_stream_intel final_stream_intel) {
jlongArray j_array = env->NewLongArray(14);
jlongArray j_array = env->NewLongArray(15);
jlong* critical_array = static_cast<jlong*>(env->GetPrimitiveArrayCritical(j_array, nullptr));
RELEASE_ASSERT(critical_array != nullptr, "unable to allocate memory in jni_utility");

Expand All @@ -117,6 +117,7 @@ jlongArray native_final_stream_intel_to_array(JNIEnv* env,
critical_array[11] = static_cast<jlong>(final_stream_intel.socket_reused);
critical_array[12] = static_cast<jlong>(final_stream_intel.sent_byte_count);
critical_array[13] = static_cast<jlong>(final_stream_intel.received_byte_count);
critical_array[14] = static_cast<jlong>(final_stream_intel.response_flags);

// Here '0' (for which there is no named constant) indicates we want to commit the changes back
// to the JVM and free the c array, where applicable.
Expand Down
1 change: 1 addition & 0 deletions library/common/stream_info/extra_stream_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ void setFinalStreamIntel(StreamInfo& stream_info, envoy_final_stream_intel& fina
final_intel.sent_byte_count = stream_info.getUpstreamBytesMeter()->wireBytesSent();
final_intel.received_byte_count = stream_info.getUpstreamBytesMeter()->wireBytesReceived();
}
final_intel.response_flags = stream_info.responseFlags();
}

} // namespace StreamInfo
Expand Down
4 changes: 4 additions & 0 deletions library/common/types/c_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ typedef struct {
uint64_t sent_byte_count;
// The number of bytes received from upstream.
uint64_t received_byte_count;
// The final response flags for the stream. See
// https://github.com/envoyproxy/envoy/blob/main/envoy/stream_info/stream_info.h
// for the ResponseFlag enum.
uint64_t response_flags;
} envoy_final_stream_intel;

#ifdef __cplusplus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class EnvoyFinalStreamIntelImpl implements EnvoyFinalStreamIntel {
private boolean socketReused;
private long sentByteCount;
private long receivedByteCount;
private long responseFlags;

EnvoyFinalStreamIntelImpl(long[] values) {
requestStartMs = values[0];
Expand All @@ -33,6 +34,7 @@ class EnvoyFinalStreamIntelImpl implements EnvoyFinalStreamIntel {
socketReused = values[11] != 0;
sentByteCount = values[12];
receivedByteCount = values[13];
responseFlags = values[14];
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion library/kotlin/io/envoyproxy/envoymobile/FinalStreamIntel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import io.envoyproxy.envoymobile.engine.types.EnvoyFinalStreamIntel
* @param socket_reused True if the upstream socket had been used previously.
* @param sentByteCount The number of bytes sent upstream.
* @param receivedByteCount The number of bytes received from upstream.
* @param responseFlags The response flags for the stream.
*/
@Suppress("LongParameterList")
class FinalStreamIntel constructor(
Expand All @@ -43,6 +44,7 @@ class FinalStreamIntel constructor(
val socketReused: Boolean,
val sentByteCount: Long,
val receivedByteCount: Long
val responseFlags: Long
) {
constructor(base: EnvoyFinalStreamIntel) : this(
base.requestStartMs, base.dnsStartMs,
Expand All @@ -52,6 +54,6 @@ class FinalStreamIntel constructor(
base.sendingEndMs,
base.responseStartMs, base.requestEndMs,
base.socketReused, base.sentByteCount,
base.receivedByteCount
base.receivedByteCount, base.responseFlags,
)
}
5 changes: 5 additions & 0 deletions library/swift/FinalStreamIntel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public final class FinalStreamIntel: StreamIntel {
public let sentByteCount: UInt64
/// The number of bytes received from upstream.
public let receivedByteCount: UInt64
/// The response flags for the upstream stream.
public let responseFlags: UInt64

// NOTE(1): These fields may not be set if socket_reused is false.

Expand All @@ -53,6 +55,7 @@ public final class FinalStreamIntel: StreamIntel {
socketReused: Bool,
sentByteCount: UInt64,
receivedByteCount: UInt64
responseFlags: UInt64
) {
self.requestStartMs = requestStartMs
self.dnsStartMs = dnsStartMs
Expand All @@ -68,6 +71,7 @@ public final class FinalStreamIntel: StreamIntel {
self.socketReused = socketReused
self.sentByteCount = sentByteCount
self.receivedByteCount = receivedByteCount
self.responseFlags = responseFlags
super.init(streamId: streamId, connectionId: connectionId, attemptCount: attemptCount)
}
}
Expand All @@ -92,6 +96,7 @@ extension FinalStreamIntel {
socketReused: cFinalIntel.socket_reused != 0,
sentByteCount: cFinalIntel.sent_byte_count,
receivedByteCount: cFinalIntel.received_byte_count
responseFlags: cFinalIntel.response_flags
)
}
}

0 comments on commit 44d8fae

Please sign in to comment.