Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cqwang opened this issue Feb 26, 2018 · 0 comments
Open

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

cqwang opened this issue Feb 26, 2018 · 0 comments

Comments

@cqwang
Copy link

cqwang commented Feb 26, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant