-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expose new EventCounter APIs #23808
Expose new EventCounter APIs #23808
Conversation
src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/DiagnosticCounter.cs
Outdated
Show resolved
Hide resolved
|
|
||
| // arbitrarily we use name as the lock object. | ||
| internal object MyLock { get { return _name; } } | ||
| internal object MyLock { get { return Name; } } |
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.
Is there a need for the second property to access name or could the lock just be on Name? MyLock also feels like a slightly odd name, in collections it would probalby be called SyncLock
src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/CounterPayload.cs
Outdated
Show resolved
Hide resolved
src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/CounterPayload.cs
Show resolved
Hide resolved
src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/DiagnosticCounter.cs
Outdated
Show resolved
Hide resolved
src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventCounter.cs
Outdated
Show resolved
Hide resolved
| CounterPayload payload = new CounterPayload(); | ||
| payload.Count = _count; | ||
| payload.IntervalSec = intervalSec; | ||
| if (0 < _count) |
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 think this condition is correct for computing the Mean, but it should be _count > 1 for standard deviation.
| { | ||
| payload.Mean = _sum / _count; | ||
| payload.StandardDeviation = (float)Math.Sqrt(_sumSquared / _count - _sum * _sum / _count / _count); | ||
| payload.StandardDeviation = Math.Sqrt(_sumSquared / _count - _sum * _sum / _count / _count); |
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.
Should we add a comment here about potential overflow for large values?
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'm not familiar with this formula, could you please add a reference to it?
[Edit] You are using the formula for a finite population with equal probabilities for all points :)
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.
Optionally, it could be:
Math.Sqrt((1.0 / (_count * (_count - 1))) * (_count * _sumSquared - (_sum * _sum)));
noahfalk
left a comment
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.
LGTM - a couple suggestions but nothing critical
|
|
||
| // arbitrarily we use name as the lock object. | ||
| internal object MyLock { get { return _name; } } | ||
| protected object MyLock { get { return Name; } } |
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.
Did we need to change this from internal -> protected? I assume it isn't exposed via the reference assembly, but if we can mark it 'internal' that makes it a little more obvious that we haven't exposed it to customers.
| } | ||
|
|
||
| protected void Enqueue(float value) | ||
| protected void Enqueue(double value) |
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.
Could we make this private? I don't see any type that derives from EventCounter so I assume no code outside of this class uses this member?
* rename BaseCounter to DiagnosticCounter * Change MetaData->Metadata * Make EventSource and Name a property for counter classes * Make the counter APIs public * fix build errors * Change float to double * Few cleanups, fix test * fix GetMetadataString * PR feedback * More PR feedback Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
* rename BaseCounter to DiagnosticCounter * Change MetaData->Metadata * Make EventSource and Name a property for counter classes * Make the counter APIs public * fix build errors * Change float to double * Few cleanups, fix test * fix GetMetadataString * PR feedback * More PR feedback Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
* rename BaseCounter to DiagnosticCounter * Change MetaData->Metadata * Make EventSource and Name a property for counter classes * Make the counter APIs public * fix build errors * Change float to double * Few cleanups, fix test * fix GetMetadataString * PR feedback * More PR feedback Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
* rename BaseCounter to DiagnosticCounter * Change MetaData->Metadata * Make EventSource and Name a property for counter classes * Make the counter APIs public * fix build errors * Change float to double * Few cleanups, fix test * fix GetMetadataString * PR feedback * More PR feedback Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
* rename BaseCounter to DiagnosticCounter * Change MetaData->Metadata * Make EventSource and Name a property for counter classes * Make the counter APIs public * fix build errors * Change float to double * Few cleanups, fix test * fix GetMetadataString * PR feedback * More PR feedback Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
* rename BaseCounter to DiagnosticCounter * Change MetaData->Metadata * Make EventSource and Name a property for counter classes * Make the counter APIs public * fix build errors * Change float to double * Few cleanups, fix test * fix GetMetadataString * PR feedback * More PR feedback Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
|
Do you mean in System.Diagnostics.Tracing.dll? In that case, no. I moved I don't think these changes shipped officially yet because it got merged after the preview 4 snap date. So far I've been testing these by creating them using reflection on System.Private.CoreLib.dll. |
|
Ah! When will it be consumable in a public API? I’d like to see if we can get a requests per second counter going |
|
@sywhang - In order for customers to be able to access the new APIs we need to update the reference assembly in CoreFX and I don't think that happened yet? For example here is one Brian did to expose some other diagnostic APIs. If you can get a PR up tomorrow I'd be glad to review it, the change shouldn't be controversial given the APIs were already approved. |
* rename BaseCounter to DiagnosticCounter * Change MetaData->Metadata * Make EventSource and Name a property for counter classes * Make the counter APIs public * fix build errors * Change float to double * Few cleanups, fix test * fix GetMetadataString * PR feedback * More PR feedback Commit migrated from dotnet/coreclr@95d37e0
This exposes the new EventCounter APIs that were introduced in #23077, along with few changes that were discussed during API review in https://github.com/dotnet/corefx/issues/36129.