-
Notifications
You must be signed in to change notification settings - Fork 209
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
Introduce annotations on Agent types #990
Conversation
We did also talk about replacing |
/// Specifies that a data field value is required. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Property)] | ||
public sealed class RequiredAttribute : Attribute { } |
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.
Just out of interest - do we already have a test on the other PR that makes sure the usage of this attribute is in-sync with the APM Server schema?
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.
We do not because it's a chicken/egg scenario in that we only know what is required in the schema but not on the types. The schema required fields are validated in #984 in the mock APM server when receiving integration test data.
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.
Nice, thanks!
Failing test
|
This commit adds a RequiredAttribute and sets it on properties that are required according to the spec. Move SpanCount into Api namespace and add as a property on ITransaction.
01c23c5
to
64d0cbe
Compare
Codecov Report
@@ Coverage Diff @@
## master #990 +/- ##
==========================================
+ Coverage 79.86% 80.03% +0.16%
==========================================
Files 136 136
Lines 6307 6325 +18
==========================================
+ Hits 5037 5062 +25
+ Misses 1270 1263 -7
Continue to review full report at Codecov.
|
jenkins run the tests please |
This PR introduces annotations onto the agent types to describe the constraints/properties of the APM server specification:
[JsonConverter(typeof(TrimmedStringJsonConverter))]
with a[MaxLength]
attribute, and assign the JsonConverter inElasticApmContractResolver
.RequiredAttribute
and mark required properties as such.TrimmedStringJsonConverter
toTruncateJsonConverter
Discussed with @gregkalapos about using Data Annotations for this purpose, as it contains some of the attributes that are needed and provides types to validate instances against their attributes, something that may be useful for folks that use the agent API for manual instrumentation.