-
Notifications
You must be signed in to change notification settings - Fork 772
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
MetricPoint public API changes #2633
Comments
This would make things much clearer. I just now wrote an exporter and had to dig in the code to see what they meant. |
yes surely.! A bigger motivation is to hide the implementation from users, so we can optimize MetricPoint in the future, without breaking. |
Just to maybe capture some feedback around this. I'm building an exporter and some things I stumbled across that might be considered:
For example: var lines = new List<string>(metric.PointsCount); // new API
foreach (var metricPoint in metric.GetMetricPoints())
{
lines.add(SerializePoint(metricPoint))
}
for (int i = 0; i < metricPoint.Keys.Length; i++)
{
tagsBuilder.Append(metricPoint.Keys[i]);
tagsBuilder.Append(':');
tagsBuilder.Append(metricPoint.Values[i]);
tagsBuilder.Append(' ');
}
public class MyClass
{
public override string ToString() => "OOPS";
}
// either this or by using `TagList`
var attributes = new KeyValuePair<string, object?>[]
{
new ("key1", new MyClass()),
};
var attributes2 = new TagList
{
{ "my_label", new MyClass() }
};
var counter = meter.CreateCounter<int>("counter");
counter.Add(10, attributes); |
For attributes/tags - this pr #2642 is merged. Regarding the tag value being object - Could you clarify what is the ask? |
It would be nice if it was possible to know how many points a metric holds. --> we should be able to support this. |
It's just that the spec says only primitive values (or lists of primitive values) are allowed, but here I can add whatever value I want. And in this case, I added an instance of a class and it took the |
Closing the overall issue as its covered by several prs, and is part of 1.2.0-rc1 release. Have few additional feedback from @joaopgrassi . Will operate specific issues for tracking them, to add post 1.2.0 |
The numerical values are now retrived using LongValue, DoubleValue etc. These fields have meaning based on the type (eg: For histogram DoubleValue means the SUM, for Long Counter , DoubleValue means nothing and is an error if trrying to access)
Proposal is to make these internal, and instead provide methods like GetHistogramSum etc., so that exporters doesn't have to know any internal details. This will also allow us from changing the MetricPoint structure internally, w/o breaking exporters.
The text was updated successfully, but these errors were encountered: