/// <summary>
    /// Initializes a new instance of the <see cref="InfluxObserver"/> by
    /// using the given <paramref name="endpoint"/> and <paramref name="ttl"/>.
    /// </summary>
    /// <param name="endpoint">
    /// The <see cref="ApiEndpoint"/> to be used to send the measures.
    /// </param>
    /// <param name="ttl">
    /// The maximum time that a mesure should be keep in cache, before send it
    /// to influx's.
    /// </param>
    /// <remarks>
    /// The <paramref name="ttl"/> should be greater than or equals to
    /// <see cref="TimeSpan.Zero"/>. If <paramref name="ttl"/> is equals to
    /// <see cref="TimeSpan.Zero"/> the default <paramref name="ttl"/> of
    /// third seconds will be used.
    /// <para>
    /// The application's name will be added as a prefix to all measures
    /// before sending it to influx's endpoint.
    /// </para>
    /// </remarks>
    public InfluxObserver(IApiEndpoint endpoint, TimeSpan ttl) {
      if (ttl < TimeSpan.Zero) {
        throw new ArgumentOutOfRangeException("ttl",
          StringResources.ArgumentOutOfRange_NeedNonNegNum);
      }

      endpoint_ = endpoint;

      measures_ = new ConcurrentQueue<Serie>();

      TimeSpan half_ttl =
        ttl == TimeSpan.Zero
          ? TimeSpan.FromSeconds(15)
          : TimeSpan.FromSeconds(ttl.TotalSeconds/2);
      scheduler_ = NonReentrantSchedule.Every(half_ttl);
      scheduler_.Run(Post);
    }
예제 #2
0
 public PollScheduler(IMetricsPoller poller, TimeSpan interval) {
   poller_ = poller;
   scheduler_ = NonReentrantSchedule.Every(interval);
 }