You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's often not possible to use a static array of tags. Is it possible to recycle an array of tags to multiple calls to service.Increment with different values of the tags, for example as follows ?
// Re-use an array of tags, but change the value of one of the tagspublicvoidDoSomething(){varmyTags=["environment:dev","myTag:A"];
service.Increment("example_metric.increment", tags: _myTags);// Change the value of the second tag
myTags[1]="myTag:B";
service.Increment("example_metric.increment", tags: _myTags);}// Borrow the tags array from a poolpublicvoidDoSomethingElse(){varmyTags=ArrayPool<string>.Shared.Rent(2);
myTags[0]="environment:dev";
myTags[1]="myTag:A";
service.Increment("example_metric.increment", tags: _myTags);ArrayPool<string>.Shared.Return(myTags);}
I'm afraid the tags arrays are processed (serialized) asynchronously, which mean we must ensure the array is not modified after a call to service.Increment.
The text was updated successfully, but these errors were encountered:
Hello,
All documentation instanciate a new string array for tags every time we need to increment a metrics counter. Example:
I'd like to limit the array allocations in order to limit stress to the GC. When possible, I set tags as
static readonly
, for example:It's often not possible to use a static array of tags. Is it possible to recycle an array of tags to multiple calls to
service.Increment
with different values of the tags, for example as follows ?I'm afraid the tags arrays are processed (serialized) asynchronously, which mean we must ensure the array is not modified after a call to
service.Increment
.The text was updated successfully, but these errors were encountered: