Add System.Diagnostics.Metrics for per-connection Zebus monitoring via net10.0 multi-targeting#120
Conversation
…strumentation Agent-Logs-Url: https://github.com/Abc-Arbitrage/Zebus/sessions/8f197dc4-0b8b-4ce0-a40d-97ea7c647727 Co-authored-by: Kuinox <18743295+Kuinox@users.noreply.github.com>
… alive/dead status Agent-Logs-Url: https://github.com/Abc-Arbitrage/Zebus/sessions/8f197dc4-0b8b-4ce0-a40d-97ea7c647727 Co-authored-by: Kuinox <18743295+Kuinox@users.noreply.github.com>
…nsistency Agent-Logs-Url: https://github.com/Abc-Arbitrage/Zebus/sessions/8f197dc4-0b8b-4ce0-a40d-97ea7c647727 Co-authored-by: Kuinox <18743295+Kuinox@users.noreply.github.com>
| var parts = new string[routingMembers.Length]; | ||
| for (var tokenIndex = 0; tokenIndex < routingMembers.Length; ++tokenIndex) | ||
| { | ||
| parts[tokenIndex] = fieldValues.GetValueOrDefault(routingMembers[tokenIndex].Member.Name, BindingKeyPart.StarToken); |
There was a problem hiding this comment.
copilot probably did that due to .NET double targeting.
|
@copilot we may have multiple bus at the same time, having a active bus count metrics isn't very useful, but, we will want to track per bus instance. |
Agent-Logs-Url: https://github.com/Abc-Arbitrage/Zebus/sessions/ca085f25-a9b5-488a-ad33-858646b84131 Co-authored-by: Kuinox <18743295+Kuinox@users.noreply.github.com>
Done in e04af38. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
|
||
| Started?.Invoke(); | ||
| #if NET10_0_OR_GREATER | ||
| ZebusMetrics.BusActive.Add(1, ZebusMetrics.BusTag(_instanceId)); |
There was a problem hiding this comment.
Removed in e1e006b. The zebus.bus.active metric and related instance ID code have been removed from Bus.cs.
|
|
||
| // Directory: peers | ||
| internal static readonly UpDownCounter<int> KnownPeerCount = Meter.CreateUpDownCounter<int>( | ||
| "zebus.directory.known_peers", |
There was a problem hiding this comment.
Make a dedicated metric class for each services, this class should be only for the zebus client.
There was a problem hiding this comment.
Done in e1e006b. Metrics are now split into TransportMetrics (transport instruments), DirectoryMetrics (directory instruments), and ZebusMetrics (shared Meter and tag helpers only).
| { | ||
| outboundSocket.Send(bufferWriter.Buffer, bufferWriter.Position, transportMessage); | ||
| #if NET10_0_OR_GREATER | ||
| ZebusMetrics.MessagesSent.Add(1, ZebusMetrics.PeerTag(target.Id)); |
There was a problem hiding this comment.
Will the metric also have the sender peer id ?
There was a problem hiding this comment.
Yes — the received message metric includes the sender peer ID via transportMessage.Originator.SenderId:
TransportMetrics.MessagesReceived.Add(1, ZebusMetrics.PeerTag(transportMessage.Originator.SenderId));There was a problem hiding this comment.
I'm asking about the metric MessageSent.
There was a problem hiding this comment.
Yes, MessagesSent is tagged with the target peer ID: TransportMetrics.MessagesSent.Add(1, ZebusMetrics.PeerTag(target.Id)) where target is the destination Peer.
There was a problem hiding this comment.
Yes, MessagesSent includes the target peer ID: TransportMetrics.MessagesSent.Add(1, ZebusMetrics.PeerTag(target.Id)) — target.Id is the destination peer.
| #if !NETCOREAPP | ||
| _cryptoServiceProvider.GetBytes(nodeId); | ||
| #else | ||
| RandomNumberGenerator.Fill(nodeId); |
There was a problem hiding this comment.
RNGCryptoServiceProvider is obsolete on .NET Core (SYSLIB0023). RandomNumberGenerator.Fill is the recommended replacement and is available on all NETCOREAPP targets.
| { | ||
| } | ||
|
|
||
| #if !NETCOREAPP |
There was a problem hiding this comment.
The (SerializationInfo, StreamingContext) serialization constructor triggers SYSLIB0051 on .NET Core (binary serialization is obsolete). Excluding it on NETCOREAPP avoids the warning while keeping it for netstandard2.0 consumers.
There was a problem hiding this comment.
@ltrzesniewski i suppose we want to keep this constructor ?
Agent-Logs-Url: https://github.com/Abc-Arbitrage/Zebus/sessions/efc82941-92e3-4ee8-b641-de8cf4c1f8ec Co-authored-by: Kuinox <18743295+Kuinox@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Abc-Arbitrage/Zebus/sessions/efc82941-92e3-4ee8-b641-de8cf4c1f8ec Co-authored-by: Kuinox <18743295+Kuinox@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
| { | ||
| outboundSocket.Send(bufferWriter.Buffer, bufferWriter.Position, transportMessage); | ||
| #if NET10_0_OR_GREATER | ||
| ZebusMetrics.MessagesSent.Add(1, ZebusMetrics.PeerTag(target.Id)); |
There was a problem hiding this comment.
I'm asking about the metric MessageSent.
…ndard, removing #ifdef on usings Agent-Logs-Url: https://github.com/Abc-Arbitrage/Zebus/sessions/81a35d95-9277-416c-9f67-15fb83ff98cf Co-authored-by: Kuinox <18743295+Kuinox@users.noreply.github.com>
The directory has a Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot I also want a byte count per message metric. |
Agent-Logs-Url: https://github.com/Abc-Arbitrage/Zebus/sessions/f0604d23-5c82-4f7f-baaa-b80b93aa52cf Co-authored-by: Kuinox <18743295+Kuinox@users.noreply.github.com>
Added in 4dd924d. Two new counters: Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
Why do we need to create a gauge instance per transport ? @copilot |
The If you'd prefer, I can eliminate the per-instance gauge entirely since we already track socket state via the |
Adds
System.Diagnostics.Metricsinstrumentation to monitor Zebus connection state and messaging, gated behind#if NET10_0_OR_GREATERwith no new NuGet dependencies.Metrics
All per-connection metrics are tagged with
zebus.peer.idfor individual peer filtering:zebus.transport.messages.sentzebus.transport.messages.receivedzebus.transport.bytes.sentzebus.transport.bytes.receivedzebus.transport.messages.send_failureszebus.transport.peer_connectionszebus.transport.peer_disconnectionszebus.transport.peer_connection_failureszebus.transport.connection.alivezebus.transport.outbound_socketszebus.directory.known_peerszebus.directory.peer_updatesMetric class organization
Instruments are split into dedicated classes per service:
ZebusMetrics— sharedMeterinstance andPeerTaghelperTransportMetrics— transport-layer instruments (messages, bytes, connections, sockets)DirectoryMetrics— directory-layer instruments (known peers, peer updates)Multi-targeting
Abc.Zebus.csprojtargetsnetstandard2.0;net10.0#if NET10_0_OR_GREATER; netstandard2.0 output is unchanged.NET 10 compatibility fixes
Polyfill types that now exist in the BCL needed conditional compilation:
#if !NETCOREAPPFormatterServices.GetUninitializedObject→RuntimeHelpers.GetUninitializedObjectRNGCryptoServiceProvider→RandomNumberGenerator.FilloutparameterTryGetValueto avoid ambiguity