Skip to content

Commit

Permalink
Encode PeerIsZero in the CloseSocket trace event name.
Browse files Browse the repository at this point in the history
Even simple boolean arguments are privacy-filtered out of trace events,
so put PeerIsZero into the event name instead. Since the name is a
static string in the codebase that can be audited, this does not trigger
privacy filtering.

R=ericorth

Bug: 1194888
Change-Id: I6452a8344f95d983fa35328d57c31c7fce76a6aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3537529
Auto-Submit: Joe Mason <joenotcharles@google.com>
Reviewed-by: Eric Orth <ericorth@chromium.org>
Commit-Queue: Eric Orth <ericorth@chromium.org>
Cr-Commit-Position: refs/heads/main@{#983347}
  • Loading branch information
JoeNotCharlesGoogle authored and Chromium LUCI CQ committed Mar 21, 2022
1 parent 04279f5 commit 4173878
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions net/socket/tcp_socket_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "net/socket/socket_posix.h"
#include "net/socket/socket_tag.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "third_party/perfetto/include/perfetto/tracing/string_helpers.h"

#if BUILDFLAG(IS_ANDROID)
#include "net/android/network_library.h"
Expand Down Expand Up @@ -461,8 +462,9 @@ void TCPSocketPosix::Close() {
// trace event for this case so that it can be correlated with jank in traces.
// Use the "base" category since "net" isn't enabled by default. See
// https://crbug.com/1194888.
TRACE_EVENT("base", "CloseSocketTCP", "connected_to_zero",
PeerIsZeroIPv4(*this));
TRACE_EVENT("base", PeerIsZeroIPv4(*this)
? perfetto::StaticString{"CloseSocketTCP.PeerIsZero"}
: perfetto::StaticString{"CloseSocketTCP"});
#endif // BUILDFLAG(IS_APPLE) && !BUILDFLAG(CRONET_BUILD)
socket_.reset();
tag_ = SocketTag();
Expand Down
6 changes: 4 additions & 2 deletions net/socket/udp_socket_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include "net/socket/socket_tag.h"
#include "net/socket/udp_net_log_parameters.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "third_party/perfetto/include/perfetto/tracing/string_helpers.h"

#if BUILDFLAG(IS_ANDROID)
#include "base/native_library.h"
Expand Down Expand Up @@ -315,8 +316,9 @@ void UDPSocketPosix::Close() {
// trace event for this case so that it can be correlated with jank in traces.
// Use the "base" category since "net" isn't enabled by default. See
// https://crbug.com/1194888.
TRACE_EVENT("base", "CloseSocketUDP", "connected_to_zero",
PeerIsZeroIPv4(*this));
TRACE_EVENT("base", PeerIsZeroIPv4(*this)
? perfetto::StaticString{"CloseSocketUDP.PeerIsZero"}
: perfetto::StaticString{"CloseSocketUDP"});

// Attempt to clear errors on the socket so that they are not returned by
// close(). See https://crbug.com/1151048.
Expand Down

0 comments on commit 4173878

Please sign in to comment.