Skip to content

Commit

Permalink
Tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeBlanch committed Aug 28, 2023
1 parent cab6189 commit 6a5d89b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ private bool AddFieldToLookupForExtension(
out var fieldInformation))
{
OneCollectorExporterEventSource.Log.AttributeDropped(this.itemType, extensionName, "Extension field name was not specified");
return false;

// Note: Return true here to allow other fields to potentially succeed.
return true;
}

return this.AddFieldToLookupForExtension(ref keyLookup, fieldInformation!, fieldValue);
Expand All @@ -243,6 +245,8 @@ private bool AddFieldToLookupForExtension(
if (keyCount >= MaxNumberOfExtensionValuesPerKey)
{
OneCollectorExporterEventSource.Log.AttributeDropped(this.itemType, fieldInformation.ExtensionName!, "Extension field limit reached");

// Note: Return false here to prevent other fields from being attempted when we know they will also fail.
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ public void AddExtensionAttributeMixedFieldAndPropertyTest()
state.AddExtensionAttribute(new KeyValuePair<string, object?>("ext.foo", new List<KeyValuePair<string, object?>> { new KeyValuePair<string, object?>(" foo.field2 ", 2) }));
state.AddExtensionAttribute(new KeyValuePair<string, object?>("ext.foo .foo_field3 ", 3));

state.AddExtensionAttribute(new KeyValuePair<string, object?>("ext. bar ", new Dictionary<string, object?> { ["bar_field1"] = 1 }));
state.AddExtensionAttribute(new KeyValuePair<string, object?>("ext. bar ", new Dictionary<string, object?>
{
[" "] = 99, // Note: This will be dropped but the second entry will be added.
["bar_field1"] = 1,
}));
state.AddExtensionAttribute(new KeyValuePair<string, object?>("ext. bar .bar.field2", 2));
state.AddExtensionAttribute(new KeyValuePair<string, object?>("ext.bar.bar_field3", 3));

Expand Down

0 comments on commit 6a5d89b

Please sign in to comment.