mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Prefer explicit construction to coercion in record initialization
While we support initializing records via coercion from an expression list, e.g., local x: X = [$x1=1, $x2=2]; this can sometimes obscure the code to readers, e.g., when assigning to value declared and typed elsewhere. The language runtime has a similar overhead since instead of just constructing a known type it needs to check at runtime that the coercion from the expression list is valid; this can be slower than just writing the readible code in the first place, see #4559. With this patch we use explicit construction, e.g., local x = X($x1=1, $x2=2);
This commit is contained in:
parent
54f9e45597
commit
d5fd29edcd
139 changed files with 786 additions and 788 deletions
|
@ -5,13 +5,13 @@
|
|||
|
||||
module Cluster;
|
||||
|
||||
global broker_backpressure_disconnects_cf = Telemetry::register_counter_family([
|
||||
global broker_backpressure_disconnects_cf = Telemetry::register_counter_family(Telemetry::MetricOpts(
|
||||
$prefix="zeek",
|
||||
$name="broker-backpressure-disconnects",
|
||||
$unit="",
|
||||
$label_names=vector("peer"),
|
||||
$help_text="Number of Broker peerings dropped due to a neighbor falling behind in message I/O",
|
||||
]);
|
||||
));
|
||||
|
||||
event Broker::peer_removed(endpoint: Broker::EndpointInfo, msg: string)
|
||||
{
|
||||
|
|
|
@ -7,13 +7,13 @@ module Cluster;
|
|||
## This gauge tracks the current number of locally queued messages in each
|
||||
## Broker peering's send buffer. The "peer" label identifies the remote side of
|
||||
## the peering, containing a Zeek cluster node name.
|
||||
global broker_peer_buffer_messages_gf = Telemetry::register_gauge_family([
|
||||
global broker_peer_buffer_messages_gf = Telemetry::register_gauge_family(Telemetry::MetricOpts(
|
||||
$prefix="zeek",
|
||||
$name="broker-peer-buffer-messages",
|
||||
$unit="",
|
||||
$label_names=vector("peer"),
|
||||
$help_text="Number of messages queued in Broker's send buffers",
|
||||
]);
|
||||
));
|
||||
|
||||
## This gauge tracks recent maximum queue lengths for each Broker peering's send
|
||||
## buffer. Most of the time the send buffers are nearly empty, so this gauge
|
||||
|
@ -23,26 +23,26 @@ global broker_peer_buffer_messages_gf = Telemetry::register_gauge_family([
|
|||
## observed message. That is, Zeek keeps a timestamp of when the window started,
|
||||
## and once it notices that the interval has passed, it moves the start of the
|
||||
## window to current time.
|
||||
global broker_peer_buffer_recent_max_messages_gf = Telemetry::register_gauge_family([
|
||||
global broker_peer_buffer_recent_max_messages_gf = Telemetry::register_gauge_family(Telemetry::MetricOpts(
|
||||
$prefix="zeek",
|
||||
$name="broker-peer-buffer-recent-max-messages",
|
||||
$unit="",
|
||||
$label_names=vector("peer"),
|
||||
$help_text="Maximum number of messages recently queued in Broker's send buffers",
|
||||
]);
|
||||
));
|
||||
|
||||
## This counter tracks for each Broker peering the number of times its send
|
||||
## buffer has overflowed. For the "disconnect" policy this can at most be 1,
|
||||
## since Broker stops the peering at this time. For the "drop_oldest" and
|
||||
## "drop_newest" policies (see :zeek:see:`Broker:peer_overflow_policy`) the count
|
||||
## instead reflects the number of messages lost.
|
||||
global broker_peer_buffer_overflows_cf = Telemetry::register_counter_family([
|
||||
global broker_peer_buffer_overflows_cf = Telemetry::register_counter_family(Telemetry::MetricOpts(
|
||||
$prefix="zeek",
|
||||
$name="broker-peer-buffer-overflows",
|
||||
$unit="",
|
||||
$label_names=vector("peer"),
|
||||
$help_text="Number of overflows in Broker's send buffers",
|
||||
]);
|
||||
));
|
||||
|
||||
|
||||
# A helper to track overflow counts over past peerings as well as the current
|
||||
|
|
|
@ -492,7 +492,7 @@ function nodeid_to_node(id: string): NamedNode
|
|||
return NamedNode($name=name, $node=n);
|
||||
}
|
||||
|
||||
return NamedNode($name="", $node=[$node_type=NONE, $ip=0.0.0.0]);
|
||||
return NamedNode($name="", $node=Node($node_type=NONE, $ip=0.0.0.0));
|
||||
}
|
||||
|
||||
event Cluster::hello(name: string, id: string) &priority=10
|
||||
|
@ -572,7 +572,7 @@ event zeek_init() &priority=5
|
|||
terminate();
|
||||
}
|
||||
|
||||
Log::create_stream(Cluster::LOG, [$columns=Info, $path="cluster", $policy=log_policy]);
|
||||
Log::create_stream(Cluster::LOG, Log::Stream($columns=Info, $path="cluster", $policy=log_policy));
|
||||
}
|
||||
|
||||
function create_store(name: string, persistent: bool &default=F): Cluster::StoreInfo
|
||||
|
@ -654,7 +654,7 @@ function create_store(name: string, persistent: bool &default=F): Cluster::Store
|
|||
|
||||
function log(msg: string)
|
||||
{
|
||||
Log::write(Cluster::LOG, [$ts = network_time(), $node = node, $message = msg]);
|
||||
Log::write(Cluster::LOG, Info($ts = network_time(), $node = node, $message = msg));
|
||||
}
|
||||
|
||||
function init(): bool
|
||||
|
|
|
@ -42,7 +42,7 @@ function __init_cluster_nodes(): bool
|
|||
if ( endp$role in rolemap )
|
||||
typ = rolemap[endp$role];
|
||||
|
||||
cnode = [$node_type=typ, $ip=endp$host, $p=endp$p];
|
||||
cnode = Cluster::Node($node_type=typ, $ip=endp$host, $p=endp$p);
|
||||
if ( |manager_name| > 0 && cnode$node_type != Cluster::MANAGER )
|
||||
cnode$manager = manager_name;
|
||||
if ( endp?$metrics_port )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue