-
Notifications
You must be signed in to change notification settings - Fork 206
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4b4b6ec
Rename to TruncateToMaxLengthJsonConverter
russcam ba391e3
Use MaxLength attribute to specify maxLength constraint
russcam db0504d
Rename to SanitizeAttribute
russcam 0881345
Rename to Truncate
russcam 1fdbe58
Reuse serializer in tests
russcam 5c465e4
Move Truncate to StringExtensions
russcam 38b1a6d
Add xml comment
russcam 6f1ac9a
Add RequiredAttribute
russcam 64d0cbe
Check for dictionary type first
russcam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Licensed to Elasticsearch B.V under | ||
// one or more agreements. | ||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||
// See the LICENSE file in the project root for more information | ||
|
||
using System; | ||
|
||
namespace Elastic.Apm.Api.Constraints | ||
{ | ||
/// <summary> | ||
/// Specifies the maximum length of string data allowed in a property, based on the APM server specification. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Property)] | ||
public sealed class MaxLengthAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// The maximum length. | ||
/// </summary> | ||
public int Length { get; } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of <see cref="MaxLengthAttribute"/> | ||
/// with a maximum length of <see cref="Consts.PropertyMaxLength"/> | ||
/// </summary> | ||
public MaxLengthAttribute() : this(Consts.PropertyMaxLength) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of <see cref="MaxLengthAttribute"/> with a given maximum length | ||
/// </summary> | ||
public MaxLengthAttribute(int length) => Length = length; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Licensed to Elasticsearch B.V under | ||
// one or more agreements. | ||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||
// See the LICENSE file in the project root for more information | ||
|
||
using System; | ||
|
||
namespace Elastic.Apm.Api.Constraints | ||
{ | ||
/// <summary> | ||
/// Specifies that a data field value is required. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Property)] | ||
public sealed class RequiredAttribute : Attribute { } | ||
} |
29 changes: 15 additions & 14 deletions
29
...rt/Serialization/SanitizationAttribute.cs → ....Apm/Api/Constraints/SanitizeAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
// Licensed to Elasticsearch B.V under one or more agreements. | ||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||
// See the LICENSE file in the project root for more information | ||
|
||
using System; | ||
|
||
namespace Elastic.Apm.Report.Serialization | ||
{ | ||
/// <summary> | ||
/// An attribute to mark fields for sanitization. This attribute is known to <see cref="ElasticApmContractResolver"/> and it applies a Converter | ||
/// to sanitize field(s) accordingly. | ||
/// </summary> | ||
internal class SanitizationAttribute : Attribute { } | ||
} | ||
// Licensed to Elasticsearch B.V under one or more agreements. | ||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||
// See the LICENSE file in the project root for more information | ||
|
||
using System; | ||
using Elastic.Apm.Report.Serialization; | ||
|
||
namespace Elastic.Apm.Api.Constraints | ||
{ | ||
/// <summary> | ||
/// An attribute to mark fields for sanitization. This attribute is known to <see cref="ElasticApmContractResolver"/> and it applies a Converter | ||
/// to sanitize field(s) accordingly. | ||
/// </summary> | ||
internal sealed class SanitizeAttribute : Attribute { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.