-
Notifications
You must be signed in to change notification settings - Fork 293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Event counter listener #177
Conversation
...OpenTelemetry.Contrib.EventCounterListener/OpenTelemetry.Contrib.EventCounterListener.csproj
Outdated
Show resolved
Hide resolved
src/OpenTelemetry.Contrib.EventCounterListener/EventCounterListener.cs
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,58 @@ | |||
# MySqlData Instrumentation for OpenTelemetry |
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.
nit: typo
{ | ||
if (eventData == null) | ||
{ | ||
throw new ArgumentNullException(nameof(eventData)); |
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.
does anyone catch this?
} | ||
} | ||
``` | ||
|
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.
the usage is not clear... could you describe with an example?
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.
If you are looking for how configuration is done, I havent coded that up yet, just making sure what I have so far is in the ballpark. Using the extension method provided (AddEventCounterListener
) adds the EventListener that then republishes counters via metricsAPI. For example running the program listing in the Readme.md
above produces the following output:
- I assumed all counters will be instrumented as guages
- Since this requires aggregation in the
collect
interval, the appropriate one is last value
Export cpu-usage, Unit: CPU Usage, Meter: OpenTelemetry.Contrib.EventCounterListener/0.0.0.0 (2022-01-20T03:48:23.3248145Z, 2022-01-20T03:48:37.2994387Z] DoubleGauge Value: 0 Export working-set, Unit: Working Set, Meter: OpenTelemetry.Contrib.EventCounterListener/0.0.0.0 (2022-01-20T03:48:23.3275819Z, 2022-01-20T03:48:37.2994398Z] DoubleGauge Value: 31 Export gc-heap-size, Unit: GC Heap Size, Meter: OpenTelemetry.Contrib.EventCounterListener/0.0.0.0 (2022-01-20T03:48:23.3276834Z, 2022-01-20T03:48:37.2994400Z] DoubleGauge Value: 5 Export gen-0-gc-count, Unit: Gen 0 GC Count, Meter: OpenTelemetry.Contrib.EventCounterListener/0.0.0.0 (2022-01-20T03:48:23.3280650Z, 2022-01-20T03:48:37.2994402Z] DoubleGauge Value: 0
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.
without seeing how a user would configure, its hard to comment on it.
Some qns:
What are the inputs provided by the user? Do they pick each and every eventcounter?
Given there are different types of EventCounters, do we let user let us know if they want it treated as counter/gauge/histogram?
(Ofcourse we don't want to solve it in 1st iteration, but want to get a feel of how would the final version look like )
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.
What are the inputs provided by the user? Do they pick each and every eventcounter?
I was thinking they can filter by EventSource, and then get more granular at the particular counter.
Given there are different types of EventCounters, do we let user let us know if they want it treated as counter/gauge/histogram?
I have made a list of well known eventcounters and ran Reiley's "algorithm" for picking an instrument. In each case they made no sense to add them, since the eventCounters themselves are preaggregated, it makes no sense to further aggregate them - let me know if I am wrong about this or a different guide to pick instruments. Dependending on the answer to this, we could also make this the default option while giving users customizability to change this.
If you need to get on a zoom call for 15 mins, I am available today or next week is fine as well.
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 did realize something I had misunderstood about different eventcounter types. I'll rework this.
NuGet.config
Outdated
@@ -4,6 +4,8 @@ | |||
<clear /> | |||
<add key="NuGet" value="https://api.nuget.org/v3/index.json" /> | |||
<add key="MyGet" value="https://www.myget.org/F/opentelemetry/api/v3/index.json" /> | |||
<add key="Dotnet-public" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" /> |
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.
we can remove this, as we won't need any packages from non nuget.org/myget.org
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.
removed ..
@hananiel Can we rename the projects |
Fix metric name
Event source configuration
|
1 similar comment
|
Hi @cijothomas 🙋🏼♂️, |
837be0b
to
cfb4d0f
Compare
} | ||
``` | ||
|
||
Configuration can be done completely using the IConfiguration. |
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.
dont think we need to document the usage of IConfiguration or anything else here. Its not related to this package.
{ | ||
public static void Main(string[] args) | ||
{ | ||
using var meterprovider = Sdk.CreateMeterProviderBuilder() |
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 you describe the overall approach/design used in the PR description? Its a bit hard to figure out the design in a big PR without some writeup.
Event counter listener
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.
Sorry it took me a few days to see the message @cijothomas - looks good, just a minor comment. Think we need to be aware that some EventSource's are available on startup as they are typically created on first use. So this could be before the EventListener has been created depending on the configuration of the app. Code as is will miss this if it's not fully initialized from what I can see. May be worth calling EventSource.GetSources()
just after initialization (in our version we actually call this every 5-10 seconds to see if there's any new event sources that the user has request us track)
src/OpenTelemetry.Contrib.Instrumentation.EventCounters/Implementation/EventCounterListener.cs
Show resolved
Hide resolved
/// Creates a counter instrumentation of long values which is an instrument that reports monotonically | ||
/// increasing values. | ||
/// </summary> | ||
Counter = 0, |
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.
Counter is an sync instrument, so we should not use it from EventCounter.
Only supported instruments should be the ObservableCounter, ObservableGauge, and ObservableUpDownCounter (when that instrument is added)
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.
It's only named "Counter". The publisher creates an ObservableCounter
.
Should we rename the Counter
enum value to ObservableCounter
?
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.
Yes. it's not clear which instrument from Metrics API should be used, so a matching name would help here.
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.
The names were renamed.
Rename instrumentation types to reflect the created instrumentation
@cijothomas Anything else missing? |
@hananiel have you considered receiving diagnostic data via EventPipeSession, as is done by e.g. dotnet counters, instead of subscribing to an EventListener? https://docs.microsoft.com/en-us/dotnet/core/diagnostics/eventpipe |
@ZEXSM EventPipes should be used to retrieve the data for out-proc scenarios. EventListeners can be used for in-proc. Since we're running in-proc the EventListeners are the prefered way. See https://docs.microsoft.com/en-us/dotnet/core/diagnostics/event-counters |
@hananiel @twenzel To unblock and make progress, I'd suggest to break this down into smaller PRs, similar to suggestion for runtime metrics PR (#207 (comment)). For this one, consider following
(its generally very hard to get people to review big PRs, so I'd strongly suggest small PRs, each addressing a specific concern, to constantly make progress, and hopefully attract more reviewers.) |
Closing in lieu of #365 |
Resolves #215
This PR provides the option to use any EventCounter as metric instrumentation, using an EventListener to "subscribe" to all Event sources the developer has specified.
The listener reads the event counter payload and passes it to the MeterTelemetryPublisher.
The publisher creates the instrumentation based on user provided definition or if none is provided, by using the information given by the event counter (see Inferring the Instrument Type).
The configuration is very easy. You can add all event counters of an event source just by
or define each event counter fine grained by