-
Notifications
You must be signed in to change notification settings - Fork 775
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
Implement metric identity specification #4222
Conversation
public abstract String getDescription(); | ||
|
||
public abstract String getUnit(); |
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.
No reason for getUnit()
to be a top level field since views can't modify it.
|
||
/** The view that lead to the creation of this metric, if applicable. */ | ||
public abstract Optional<View> getSourceView(); |
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.
No reason for getSourceView()
to be optional. Getting rid of optional simplifies code.
"Failed to register metric.") | ||
.getThrowable()) | ||
.hasMessageContaining("Metric with same name and different descriptor already created."); | ||
logs.assertContains("Found duplicate metric definition"); |
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.
A lot of the tests in this code duplicate the test cases in IdentityTest
, but with less complete validation. I think I should remove the duplicate scenarios to reduce maintenance burden.
Codecov Report
@@ Coverage Diff @@
## main #4222 +/- ##
============================================
- Coverage 90.32% 90.21% -0.11%
- Complexity 4752 4762 +10
============================================
Files 553 555 +2
Lines 14611 14692 +81
Branches 1402 1413 +11
============================================
+ Hits 13197 13254 +57
- Misses 954 982 +28
+ Partials 460 456 -4
Continue to review full report at Codecov.
|
class InstrumentDescriptorTest { | ||
|
||
@Test | ||
void equals() { |
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.
Is it possible to use equalsverifier?
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 can't figure out how to make it work with an abstract class implemented by autovalue.
/** The instrument which lead to the creation of this metric. */ | ||
public abstract InstrumentDescriptor getSourceInstrument(); | ||
|
||
/** The FQCN of the view aggregation. */ |
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.
How about using Class directly instead of String?
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.
Though otherwise if we already have the concept of a human-readable aggregation name for viewconfig, we should try to use that too
...metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/descriptor/MetricDescriptor.java
Outdated
Show resolved
Hide resolved
sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/MeterSharedState.java
Show resolved
Hide resolved
...metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/MetricStorageRegistry.java
Outdated
Show resolved
Hide resolved
...metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/MetricStorageRegistry.java
Show resolved
Hide resolved
...metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/MetricStorageRegistry.java
Show resolved
Hide resolved
…y-java into metric-identity
"Unrecognized aggregation " + aggregation.getClass().getName()); | ||
} | ||
return name; | ||
} |
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.
@anuraaga this is my solution for being able to translate aggregations to / from human readable names. Its in an internal class so we're not obligated to support it, but it provides a central place for the conversion that both the view file config and MetricDescriptor#getAggregationName()
can depend on.
"Unrecognized aggregation " + aggregation.getClass().getName()); | ||
} | ||
return name; | ||
} |
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.
@anuraaga this is my solution for being able to translate aggregations to / from human readable names. Its in an internal class so we're not obligated to support it, but it provides a central place for the conversion that both the view file config and MetricDescriptor#getAggregationName()
can depend on.
Implements changes merged in spec PR #2317.
In summary: