-
Notifications
You must be signed in to change notification settings - Fork 110
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
Why can I not get the correct value of some custom-defined Tag? #66
Comments
Hello, First of all, your two methods, Secondly, the tags are simply metric-level metadata which can help with the organization of metrics, they do not represent sub-metrics of any kind. Maybe you could use two different histograms to track the two methods? |
@PaulParau Thank you again. |
As far as I know there is currently no way of tracking two different methods with the same metric instance. Regarding metric name/keys, you can have two different metric instances with the same name/key, but they have to be in different contexts. |
Hi,
I custom-defined 5 tags—named as AppID, ServerIP, ProcessName, PageName and FunctionName respectively, and then I passed them to the method named as Metric.Histogram(). My code is as follows.
In the file name as MetricsHelper.cs:
static MetricsHelper()
{
string uri = ConfigurationManager.AppSettings["Metrics.DBUri"];
string user = ConfigurationManager.AppSettings["Metrics.UserName"];
string pass = ConfigurationManager.AppSettings["Metrics.Password"];
string database = ConfigurationManager.AppSettings["Metrics.Database"];
private static Histogram Histogram(string metricsName, Unit unit)
{
return Histogram(metricsName, unit, null);
}
private static Histogram Histogram(string metricsName, Unit unit, params string[] tags)
{
string appIDTag = string.Format("AppID={0}", appID);
string serverIPTag = string.Format("ServerIP={0}", environment["IPAddress"]);
string processNameTag = string.Format("ProcessName={0}", environment["ProcessName"]);
public static Histogram SearchFlightTime(params string[] tags)
{
return Histogram("MetricsDemo.SearchFlightTime", Unit.Custom("ms"), tags);
}
In the file named as Program.cs:
static void SearchFlight1()
{
Stopwatch stopwatch = Stopwatch.StartNew();
Random random = new Random((int)DateTime.Now.Ticks & 0x0000FFFF);
var n = random.Next(1000);
Thread.Sleep(n);
static void SearchFlight2()
{
Stopwatch stopwatch = Stopwatch.StartNew();
Random random = new Random((int)DateTime.Now.Ticks & 0x0000FFFF);
var n = random.Next(1000);
Thread.Sleep(n);
static void Main()
{
SearchFlight1();
I executed the method SearchFlight1() only one time, and then executed the method SearchFlight2() three times. However, all the metric data is added to the tag PageName value Flight1 and the tag FunctionName value GetFlight1Info. Please see the following screenshot.
I think that the correct result is as follows.
Total Count--1, PageName--Flight1, FunctionName--GetFlight1Info;
Total Count--3, PageName--Flight2, FunctionName--GetFlight2Info.
Why can I not get the correct value of some custom-defined Tag? And how to modify my code so that I can get the correct result?
Look forward to your soon reply.
Thanks
The text was updated successfully, but these errors were encountered: