Skip to content

Commit

Permalink
Fix issue with resuing tags
Browse files Browse the repository at this point in the history
  • Loading branch information
utpilla committed Jan 22, 2022
1 parent e66874e commit b62c0f9
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/OpenTelemetry/Metrics/AggregatorStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,13 @@ private int LookupAggregatorStore(string[] tagKeys, object[] tagValues, int leng
if (!this.sortedTagsDictionary.TryGetValue(givenTags, out var sortedTags))
{
// Note: We are using storage from ThreadStatic, so need to make a deep copy for Dictionary storage.
var seqKey = new string[length];
tagKeys.CopyTo(seqKey, 0);
var givenKeys = new string[length];
tagKeys.CopyTo(givenKeys, 0);

var seqValue = new object[length];
tagValues.CopyTo(seqValue, 0);
var givenValues = new object[length];
tagValues.CopyTo(givenValues, 0);

givenTags = new Tags(givenKeys, givenValues);

string[] sortedTagKeys;
object[] sortedTagValues;
Expand All @@ -214,8 +216,8 @@ private int LookupAggregatorStore(string[] tagKeys, object[] tagValues, int leng
}
else
{
sortedTagKeys = seqKey;
sortedTagValues = seqValue;
sortedTagKeys = givenKeys;
sortedTagValues = givenValues;
}

sortedTags = new Tags(sortedTagKeys, sortedTagValues);
Expand Down

0 comments on commit b62c0f9

Please sign in to comment.