JaegerOptions.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace Grpc.Extension
  5. {
  6. /// <summary>
  7. /// JaegerOptions
  8. /// </summary>
  9. public class JaegerOptions
  10. {
  11. /// <summary>
  12. /// 是否启用Jaeger
  13. /// </summary>
  14. public bool Enable { get; set; } = true;
  15. /// <summary>
  16. /// 服务名
  17. /// </summary>
  18. public string ServiceName { get; set; }
  19. /// <summary>
  20. /// AgentIp
  21. /// </summary>
  22. public string AgentIp { get; set; }
  23. /// <summary>
  24. /// AgentPort
  25. /// </summary>
  26. public int AgentPort { get; set; }
  27. /// <summary>
  28. /// 检查参数配制
  29. /// </summary>
  30. /// <returns></returns>
  31. public bool CheckConfig()
  32. {
  33. var key = "Jaeger";
  34. if (this.Enable == false) return false;
  35. if (string.IsNullOrWhiteSpace(this.ServiceName))
  36. throw new ArgumentException($"{key}:ServiceName Value cannot be null");
  37. if (string.IsNullOrWhiteSpace(this.AgentIp))
  38. throw new ArgumentException($"{key}:AgentIp Value cannot be null");
  39. if (this.AgentPort == 0)
  40. throw new ArgumentNullException($"{key}:AgentPort Value cannot be null");
  41. return true;
  42. }
  43. }
  44. }