예제 #1
0
 private static async ValueTask WriteOperationHeaderToRemote(AsyncBlittableJsonTextWriter writer, TcpConnectionHeaderMessage.OperationTypes operation, string databaseName)
 {
     writer.WriteStartObject();
     {
         writer.WritePropertyName(nameof(TcpConnectionHeaderMessage.Operation));
         writer.WriteString(operation.ToString());
         writer.WriteComma();
         writer.WritePropertyName(nameof(TcpConnectionHeaderMessage.OperationVersion));
         writer.WriteInteger(TcpConnectionHeaderMessage.GetOperationTcpVersion(operation));
         writer.WriteComma();
         writer.WritePropertyName(nameof(TcpConnectionHeaderMessage.DatabaseName));
         writer.WriteString(databaseName);
     }
     writer.WriteEndObject();
     await writer.FlushAsync();
 }
예제 #2
0
        public DynamicJsonValue GetConnectionStats(JsonOperationContext context)
        {
            var stats = new DynamicJsonValue
            {
                ["Id"]          = Id,
                ["Operation"]   = Operation.ToString(),
                ["ClientUri"]   = TcpClient.Client.RemoteEndPoint.ToString(),
                ["ConnectedAt"] = _connectedAt,
                ["Duration"]    = (DateTime.UtcNow - _connectedAt).ToString()
            };


            _bytesReceivedMetric.SetMinimalHumaneMeterData("Received", stats);
            _bytesSentMetric.SetMinimalHumaneMeterData("Sent", stats);

            _bytesReceivedMetric.SetMinimalMeterData("Received", stats);
            _bytesSentMetric.SetMinimalMeterData("Sent", stats);

            return(stats);
        }