Skip to content

metrics is always insert into db with last histogram data #95

@cqwang

Description

@cqwang

when I set the interval 5 seconds to sync,always using last histogram data,sush as count, max, min .
I just want to get the latest 1 minute data, not contains the data before.

my init:
`
var host = ConfigurationManager.AppSettings["Metrics.InfluxDb.Host"];
var port = ushort.Parse(ConfigurationManager.AppSettings["Metrics.InfluxDb.Port"]);
var database = ConfigurationManager.AppSettings["Metrics.InfluxDb.DB"];
var userName = ConfigurationManager.AppSettings["Metrics.InfluxDb.UserName"];
var password = ConfigurationManager.AppSettings["Metrics.InfluxDb.Password"];
var intervalSeconds = double.Parse(ConfigurationManager.AppSettings["Metrics.InfluxDb.Interval.Seconds"]);
var environment = ConfigurationManager.AppSettings["Environment"];
var batchSize = int.Parse(ConfigurationManager.AppSettings["Metrics.InfluxDb.BatchSize"]);

        Metric.Config.WithReporting(report => report
            .WithInfluxDbHttp(host, port, database, userName, password, null, null, TimeSpan.FromSeconds(intervalSeconds), null, configFunc => configFunc
            .WithConverter(new DefaultConverter().WithGlobalTags($"env={environment},host={Dns.GetHostName()}"))
            .WithFormatter(new DefaultFormatter().WithLowercase(true))
            .WithWriter(new InfluxdbHttpWriter(configFunc, batchSize))));

`

then , I change the default value in HistogramMetric.cs
public HistogramValue GetValue(bool resetMetric = true) { var value = new HistogramValue(this.last.Value, this.last.UserValue, this.reservoir.GetSnapshot(resetMetric)); if (resetMetric) { this.Reset(); } return value; }

It is ok now, but I cannot believe it Please help me, thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions