Skip to content

Commit

Permalink
use binary SocketAddress in access logs
Browse files Browse the repository at this point in the history
use fixed32 for ipv4 addresses
  • Loading branch information
Keksoj committed Feb 5, 2024
1 parent 4d4a0fa commit f01fb8a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions command/src/access_logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rusty_ulid::Ulid;
use time::Duration;

use crate::proto::command::{
BinaryAccessLog, BinaryEndpoint, HttpMethod, RequestUlid, TcpEndpoint, Uint128
BinaryAccessLog, BinaryEndpoint, HttpMethod, RequestUlid, TcpEndpoint, Uint128,
};

/// This uses unsafe to creates a "fake" owner of the underlying data.
Expand Down Expand Up @@ -147,7 +147,7 @@ impl RequestRecord<'_> {
let (first, second) = self.context.request_id.into();
let request_id = RequestUlid { first, second };
let time: Uint128 = time.into();

let endpoint = match self.endpoint {
EndpointRecord::Http {
method,
Expand Down Expand Up @@ -182,7 +182,7 @@ impl RequestRecord<'_> {
};

ManuallyDrop::new(BinaryAccessLog {
backend_address: self.backend_address.map(|a| a.to_string()),
backend_address: self.backend_address.map(Into::into),
backend_id: self.context.backend_id.duplicate(),
bytes_in: *self.bytes_in as u64,
bytes_out: *self.bytes_out as u64,
Expand All @@ -197,7 +197,7 @@ impl RequestRecord<'_> {
response_time: self.response_time.whole_microseconds() as u64,
server_rtt: self.server_rtt.map(|t| t.whole_microseconds() as u64),
service_time: self.service_time.whole_microseconds() as u64,
session_address: self.session_address.map(|a| a.to_string()),
session_address: self.session_address.map(Into::into),
tags: self
.tags
.map(|tags| tags.tags.duplicate())
Expand Down
6 changes: 3 additions & 3 deletions command/src/command.proto
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ message SocketAddress {

message IpAddress {
oneof inner {
uint32 v4 = 1;
fixed32 v4 = 1;
Uint128 v6 = 2;
}
}
Expand All @@ -639,9 +639,9 @@ message BinaryAccessLog {
required RequestUlid request_id = 2;
optional string cluster_id = 3;
optional string backend_id = 4;
optional string session_address = 5;
optional SocketAddress session_address = 5;
// socket address of the backend server
optional string backend_address = 6;
optional SocketAddress backend_address = 6;
// the protocol, with SSL/TLS version, for instance "HTTPS-TLS1.1"
required string protocol = 7;
required BinaryEndpoint endpoint = 8;
Expand Down

0 comments on commit f01fb8a

Please sign in to comment.