示例#1
0
 /// <summary>
 /// Construct a HeartbeaterService that periodically reports heartbeats for multiple
 /// components.
 /// </summary>
 /// <param name="wavefrontMetricSender">
 /// Sender that handles sending of heartbeat metrics to Wavefront.
 /// </param>
 /// <param name="applicationTags">Application tags.</param>
 /// <param name="components">List of components to send heartbeats for.</param>
 /// <param name="source">The source (or host).</param>
 public HeartbeaterService(
     IWavefrontMetricSender wavefrontMetricSender,
     ApplicationTags applicationTags,
     IList <string> components,
     string source)
     : this(wavefrontMetricSender, applicationTags, components, source, Logging.LoggerFactory)
 {
 }
示例#2
0
 /// <summary>
 /// Construct a HeartbeaterService that periodically reports heartbeats for one component.
 /// </summary>
 /// <param name="wavefrontMetricSender">
 /// Sender that handles sending of heartbeat metrics to Wavefront.
 /// </param>
 /// <param name="applicationTags">Application tags.</param>
 /// <param name="component">The component to send heartbeats for.</param>
 /// <param name="source">The source (or host).</param>
 public HeartbeaterService(
     IWavefrontMetricSender wavefrontMetricSender,
     ApplicationTags applicationTags,
     string component,
     string source)
     : this(wavefrontMetricSender, applicationTags, new List <string> {
     component
 }, source)
 {
 }
示例#3
0
 /// <summary>
 /// Sends the given delta counter to Wavefront. The timestamp for the point on the client
 /// side is null because the final timestamp of the delta counter is assigned when the
 /// point is aggregated on the server side. Do not use this method to send older points
 /// (say around 5 min old) as they will be aggregated on server with the current timestamp
 /// which yields in a wrong final aggregated value.
 /// </summary>
 /// <param name="sender">
 /// The instance that implements <see cref="IWavefrontMetricSender"/>.
 /// </param>
 /// <param name="name">
 /// The name of the delta counter. Name will be prefixed by ∆ if it does not start with
 /// that symbol already. Also, spaces are replaced with '-' (dashes) and quotes will be
 /// automatically escaped.
 /// </param>
 /// <param name="value">
 /// The delta value to be sent. This will be aggregated on the Wavefront server side.
 /// </param>
 /// <param name="source">
 /// The source (or host) that's sending the metric. If null then assigned by Wavefront.
 /// </param>
 /// <param name="tags">The tags associated with this metric.</param>
 public static void SendDeltaCounter(this IWavefrontMetricSender sender,
                                     string name, double value, string source,
                                     IDictionary <string, string> tags)
 {
     if (!name.StartsWith(Constants.DeltaPrefix, StringComparison.Ordinal) &&
         !name.StartsWith(Constants.DeltaPrefix2, StringComparison.Ordinal))
     {
         name = Constants.DeltaPrefix + name;
     }
     sender.SendMetric(name, value, null, source, tags);
 }
示例#4
0
 public HeartbeaterService(
     IWavefrontMetricSender wavefrontMetricSender,
     ApplicationTags applicationTags,
     string component,
     string source)
 {
     this.wavefrontMetricSender = wavefrontMetricSender;
     this.source         = source;
     heartbeatMetricTags = new Dictionary <string, string>
     {
         { Constants.ApplicationTagKey, applicationTags.Application },
         { Constants.ClusterTagKey, applicationTags.Cluster ?? Constants.NullTagValue },
         { Constants.ServiceTagKey, applicationTags.Service },
         { Constants.ShardTagKey, applicationTags.Shard ?? Constants.NullTagValue },
         { Constants.ComponentTagKey, component }
     };
 }
        public static void SendDeltaCounter(this IWavefrontMetricSender sender,
                                            string name, double value, long?timestamp,
                                            string source, IDictionary <string, string> tags)
        {
            if (value <= 0)
            {
                // Delta counters cannot be non-positive
                return;
            }

            if (!name.StartsWith(Constants.DeltaPrefix, StringComparison.Ordinal) &&
                !name.StartsWith(Constants.DeltaPrefix2, StringComparison.Ordinal))
            {
                name = Constants.DeltaPrefix + name;
            }
            sender.SendMetric(name, value, null, source, tags);
        }
示例#6
0
 /// <summary>
 /// Construct a HeartbeaterService that periodically reports heartbeats for multiple
 /// components.
 /// </summary>
 /// <param name="wavefrontMetricSender">
 /// Sender that handles sending of heartbeat metrics to Wavefront.
 /// </param>
 /// <param name="applicationTags">Application tags.</param>
 /// <param name="components">List of components to send heartbeats for.</param>
 /// <param name="source">The source (or host).</param>
 /// <param name="source">The logger factory used to create a logger.</param>
 public HeartbeaterService(
     IWavefrontMetricSender wavefrontMetricSender,
     ApplicationTags applicationTags,
     IList <string> components,
     string source,
     ILoggerFactory loggerFactory)
 {
     this.wavefrontMetricSender = wavefrontMetricSender;
     this.source             = source;
     heartbeatMetricTagsList = new List <IDictionary <string, string> >();
     customTagsSet           = new ConcurrentDictionary <IDictionary <string, string>, bool>(
         new TagsDictionaryComparer());
     logger = loggerFactory.CreateLogger <HeartbeaterService>() ??
              throw new ArgumentNullException(nameof(loggerFactory));
     foreach (string component in components)
     {
         var tags = new Dictionary <string, string>
         {
             { Constants.ApplicationTagKey, applicationTags.Application },
             { Constants.ClusterTagKey, applicationTags.Cluster ?? Constants.NullTagValue },
             { Constants.ServiceTagKey, applicationTags.Service },
             { Constants.ShardTagKey, applicationTags.Shard ?? Constants.NullTagValue },
             { Constants.ComponentTagKey, component }
         };
         if (applicationTags.CustomTags != null)
         {
             foreach (var customTag in applicationTags.CustomTags)
             {
                 if (!tags.ContainsKey(customTag.Key))
                 {
                     tags.Add(customTag.Key, customTag.Value);
                 }
             }
         }
         heartbeatMetricTagsList.Add(tags);
     }
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="wavefrontMetricSender">
 /// The sender instance used to send metrics to Wavefront.
 /// </param>
 public Builder(IWavefrontMetricSender wavefrontMetricSender)
 {
     this.wavefrontMetricSender = wavefrontMetricSender;
     tags = new Dictionary <string, string>();
 }