Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Conversation

@sywhang
Copy link

@sywhang sywhang commented Apr 8, 2019

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.


// arbitrarily we use name as the lock object.
internal object MyLock { get { return _name; } }
internal object MyLock { get { return Name; } }
Copy link

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

@sywhang sywhang requested review from jorive and noahfalk April 8, 2019 21:36
CounterPayload payload = new CounterPayload();
payload.Count = _count;
payload.IntervalSec = intervalSec;
if (0 < _count)
Copy link

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);
Copy link

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?

Copy link

@jorive jorive Apr 9, 2019

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 :)

Copy link

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)));

Copy link
Member

@noahfalk noahfalk left a 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; } }
Copy link
Member

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)
Copy link
Member

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?

@sywhang sywhang merged commit 95d37e0 into dotnet:master Apr 10, 2019
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/corefx that referenced this pull request Apr 10, 2019
* 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>
stephentoub pushed a commit to dotnet/corefx that referenced this pull request Apr 10, 2019
* 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>
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/corert that referenced this pull request Apr 12, 2019
* 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>
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/mono that referenced this pull request Apr 12, 2019
* 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>
marek-safar pushed a commit to mono/mono that referenced this pull request Apr 12, 2019
* 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>
jkotas pushed a commit to dotnet/corert that referenced this pull request Apr 14, 2019
* 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>
@davidfowl
Copy link
Member

@sywhang Did we expose these in a reference assembly?

cc @noahfalk

@sywhang
Copy link
Author

sywhang commented Apr 18, 2019

Do you mean in System.Diagnostics.Tracing.dll? In that case, no. I moved EventCounter out of there to CoreLib and all the new Counter APIs are in CoreLib as well.

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.

@davidfowl
Copy link
Member

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

@noahfalk
Copy link
Member

@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.

@sywhang
Copy link
Author

sywhang commented Apr 18, 2019

dotnet/corefx#36989 :-)

@sywhang sywhang deleted the expose-eventcounter-api branch May 2, 2019 00:46
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* 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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants