-
Notifications
You must be signed in to change notification settings - Fork 358
[Exporter.Geneva] Opt in resources #3552
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
Open
mattsains
wants to merge
14
commits into
open-telemetry:main
Choose a base branch
from
mattsains:opt-in-resources
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
1210fc5
add WantedResourceAttributes option
mattsains 536d17a
PR self-reference
mattsains d0577a2
rename to WithResourceAttributes
mattsains 483ac72
update PR number
mattsains 0af3131
seriously...
mattsains d417d80
insane
mattsains 7026e5c
change behaviour to send no resource attributes if WithResourceAttrib…
mattsains 4e66e2b
lint
mattsains ede742b
always allow mapped resource attributes, and fix tests
mattsains e545369
wip
mattsains 1c08198
ready for PR I think
mattsains 5385b5e
change set to init
mattsains b7d1200
fix version
mattsains 5255e5d
fix readme and test
mattsains 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -11,10 +11,7 @@ namespace OpenTelemetry.Exporter.Geneva; | |
| /// </summary> | ||
| public class GenevaExporterOptions | ||
| { | ||
| private IReadOnlyDictionary<string, object> fields = new Dictionary<string, object>(1) | ||
| { | ||
| [Schema.V40.PartA.Ver] = "4.0", | ||
| }; | ||
| private IReadOnlyDictionary<string, object> prepopulatedFields = new Dictionary<string, object>(); | ||
|
|
||
| private IReadOnlyDictionary<string, string>? tableNameMappings; | ||
|
|
||
|
|
@@ -33,6 +30,16 @@ public class GenevaExporterOptions | |
| /// </summary> | ||
| public IEnumerable<string>? CustomFields { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets ResourceFieldNames. | ||
| /// | ||
| /// ResourceFieldNames specifies which resource attribute fields should be sent to Geneva. | ||
| /// | ||
| /// Any resource attributes not in ResourceFieldNames are ignored. | ||
| /// If ResourceFieldNames is not provided, no resource attributes will be sent to Geneva. | ||
| /// </summary> | ||
| public IEnumerable<string>? ResourceFieldNames { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the exception stack trace export mode. | ||
| /// </summary> | ||
|
|
@@ -103,21 +110,14 @@ public IReadOnlyDictionary<string, string>? TableNameMappings | |
| /// </summary> | ||
| public IReadOnlyDictionary<string, object> PrepopulatedFields | ||
| { | ||
| get => this.fields; | ||
| get => this.prepopulatedFields; | ||
| set | ||
| { | ||
| Guard.ThrowIfNull(value); | ||
|
|
||
| var schemaVersion = "4.0"; | ||
|
|
||
| if (value.ContainsKey(Schema.V40.PartA.Ver)) | ||
| if (value.ContainsKey(Schema.V40.PartA.Ver) && value[Schema.V40.PartA.Ver] as string is not "4.0") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cijothomas I asked @mattsains to keep only 4.0 and remove 2.1. Would removing 2.1 here be a breaking change? In your experience, have you seen any customer using 2.1? |
||
| { | ||
| schemaVersion = value[Schema.V40.PartA.Ver] as string; | ||
| } | ||
|
|
||
| if (schemaVersion is not "2.1" and not "4.0") | ||
| { | ||
| throw new ArgumentException("Unsupported schema version, only 2.1 and 4.0 are supported."); | ||
| throw new ArgumentException("Unsupported schema version, only 4.0 is supported."); | ||
| } | ||
|
|
||
| if (value.ContainsKey(Schema.V40.PartA.Name)) | ||
|
|
@@ -130,7 +130,7 @@ public IReadOnlyDictionary<string, object> PrepopulatedFields | |
| throw new ArgumentException("Event timestamp cannot be pre-populated."); | ||
| } | ||
|
|
||
| var copy = new Dictionary<string, object>(value.Count + 1) { [Schema.V40.PartA.Ver] = schemaVersion }; | ||
| var copy = new Dictionary<string, object>(value.Count + 1); | ||
| foreach (var entry in value) | ||
| { | ||
| var val = entry.Value; | ||
|
|
@@ -155,10 +155,16 @@ public IReadOnlyDictionary<string, object> PrepopulatedFields | |
| throw new ArgumentException($"Type `{entry.Value.GetType()}` (key = `{entry.Key}`) is not allowed. Only bool, byte, sbyte, short, ushort, int, uint, long, ulong, float, double, and string are supported."); | ||
| } | ||
|
|
||
| if (entry.Key == Schema.V40.PartA.Ver) | ||
| { | ||
| // This key is now set by the exporters, and is only accepted for legacy reasons. | ||
| continue; | ||
| } | ||
|
|
||
| copy[entry.Key] = val; // shallow copy | ||
| } | ||
|
|
||
| this.fields = copy; | ||
| this.prepopulatedFields = copy; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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.
I recall, asking you to use
init, but let’s switch tosetinstead for API consistency.