Ejemplo n.º 1
0
 /// <summary>
 /// Records latency recorded during the call
 /// </summary>
 /// <param name="method">Infromation about the call</param>
 /// <param name="value">Value that should be recorded</param>
 public virtual void RecordLatency(GrpcMethodInfo method, double value, string host = "")
 {
     if (EnableLatencyMetrics)
     {
         LatencyHistogram.Labels(method.MethodType, method.ServiceName, method.Name, host).Observe(value);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 服务基本信息
 /// </summary>
 public Task <InfoRS> Info(InfoRQ rq, ServerCallContext context)
 {
     return(Task.Run(() =>
     {
         var methods = MetaModel.Methods.Select(q => q.FullName?.Trim()).ToList();
         if (!string.IsNullOrWhiteSpace(rq.MethodName))
         {
             methods = methods?.Where(q => q.ToLower().Contains(rq.MethodName.Trim().ToLower())).ToList();
         }
         var methodInfos = new List <GrpcMethodInfo>();
         foreach (var m in methods)
         {
             var info = new GrpcMethodInfo {
                 Name = m
             };
             info.IsThrottled = ThrottleManager.Instance.IsThrottled(m);
             info.SaveResponseEnable = MonitorManager.Instance.SaveResponseMethodEnable(m);
             methodInfos.Add(info);
         }
         return new InfoRS
         {
             IpAndPort = $"{MetaModel.Ip}:{MetaModel.Port}",
             StartTime = MetaModel.StartTime.ToUnixTimestamp(),
             MethodInfos = methodInfos
         };
     }));
 }
Ejemplo n.º 3
0
 public AuthorizationInterceptor(ILogger <AuthorizationInterceptor> logger,
                                 IApplicationContext applicationContext,
                                 GrpcMethodInfo grpcMethodInfo)
 {
     _logger             = logger;
     _applicationContext = applicationContext;
     _grpcMethodInfo     = grpcMethodInfo;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Increments <see cref="StreamSentCounter"/>
 /// </summary>
 /// <param name="method">Information about the call</param>
 /// <param name="inc">Indicates by how much counter should be incremented. By default it's set to 1</param>
 public virtual void StreamSentCounterInc(GrpcMethodInfo method, double inc = 1d, string host = "")
 {
     StreamSentCounter.Labels(method.MethodType, method.ServiceName, method.Name, host).Inc(inc);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Increments <see cref="ResponseCounter"/>
 /// </summary>
 /// <param name="method">Information about the call</param>
 /// <param name="code">Response status code</param>
 /// <param name="inc">Indicates by how much counter should be incremented. By default it's set to 1</param>
 public virtual void ResponseCounterInc(GrpcMethodInfo method, StatusCode code, double inc = 1d, string host = "")
 {
     ResponseCounter.Labels(method.MethodType, method.ServiceName, method.Name, code.ToString(), host).Inc(inc);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Increments <see cref="StreamReceivedCounter"/>
 /// </summary>
 /// <param name="method">Information about the call</param>
 /// <param name="inc">Indicates by how much counter should be incremented. By default it's set to 1</param>
 public virtual void StreamReceivedCounterInc(GrpcMethodInfo method, double inc = 1d)
 {
     StreamReceivedCounter.Labels(method.MethodType, method.ServiceName, method.Name).Inc(inc);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Increments <see cref="RequestCounter"/>
 /// </summary>
 /// <param name="method">Information about the call</param>
 /// <param name="inc">Indicates by how much counter should be incremented. By default it's set to 1</param>
 public virtual void RequestCounterInc(GrpcMethodInfo method, double inc = 1d)
 {
     RequestCounter.Labels(method.MethodType, method.ServiceName, method.Name).Inc(inc);
 }