-
Notifications
You must be signed in to change notification settings - Fork 440
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 SDK: View API #1110
Metrics SDK: View API #1110
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1110 +/- ##
==========================================
- Coverage 93.36% 93.26% -0.10%
==========================================
Files 165 173 +8
Lines 6233 6362 +129
==========================================
+ Hits 5819 5933 +114
- Misses 414 429 +15
|
…-cpp into metrics-sdk-views-2
…-cpp into metrics-sdk-views-2
# if HAVE_WORKING_REGEX | ||
return std::regex_match(str.data(), reg_key_); | ||
# else | ||
return false; // not supported |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this should fail in some fashion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this will be supported eventually. For now, we can add the LOG_ERROR to log the error while returning false
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added LOG_ERROR. Let me know if you have a better way to fail. This will eventually return a default View. We don't throw exceptions in sdk. Let me know if you have a better way to fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks great!
- One major comment on default view name/description (the default metric from an instrument with new view is its "natural" aggregation (marked TODO) and the instrument name/description)
- A couple questions/nits that can get resolved as implementation/benchmarking land to think about.
|
||
class DefaultAttributesProcessor : public AttributesProcessor | ||
{ | ||
MetricAttributes process( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC - by necessity, this API will need to take in an Iterator and return a concrete object. It's likely this would get used on the "hot path" of metrics. Does it make sense to have this API work only against AttributeMap
, that way in the event you're just passing it through, there isn't a sort + unique step (I forget the details of attribute map).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, your understanding is correct here. The metrics API takes non-owning KeyValueIterable object as here, and the plan is to make a copy of this only when required in hot-path. Attribute-processor could be one of the places to create a copy in case of passthrough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect this to (commonly) be a passthrough case. Can deal with it after initial implementation :)
public: | ||
PatternPredicate(opentelemetry::nostd::string_view pattern) : reg_key_{pattern.data()} | ||
{ | ||
if (pattern == "*") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to support *
in all your predicates. You could have ONE predicate which is the "star" predicate and then a "predicate factory" that returns either a new PatternPredicate
or MatchEverything
predicate, if you wanted.
Only commenting because I noticed this logic duplicate in the "ExactPredicate" code as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Will change accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is changed now.
// return default view if none found; | ||
if (!found) | ||
{ | ||
static View view(kDefaultViewName, kDefaultViewDescription); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[blocking] The default name and description should come from the instrument descriptor's name/description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we instead return default view ( with empty name and description ) as done in Java here ? This will allow us to return a default static
immutable object always when a view is not found.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have made changes as per my suggestion above. Let me know if that works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see, you're planning to then select the name of the metric by checking for empty description or empty name.
I understand wanting to keep this static. You'll need to either use Java's "MetricDescriptor" trick to figure out what to name the underlying metric, or keep this logic elsewhere.
That's entirely reasonable to do, but remember you'll still be instantiating something to remember the name/description of the resulting metric. For C++ it may be easier to do so view the View object, but you can decide once you work on the "storage" aspect of views :)
// return default view if none found; | ||
if (!found) | ||
{ | ||
static View view(""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this still pull name/description from the instrument?
Fixes #1088
Changes
For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes