Skip to content

Dotnet Counters + Dotnet Monitor Unification - #4254

Merged
kkeirstead merged 18 commits into
dotnet:mainfrom
kkeirstead:kkeirstead/unifyCounters5
Oct 11, 2023
Merged

kkeirstead merged 18 commits into
dotnet:mainfrom
kkeirstead:kkeirstead/unifyCounters5

Conversation

@kkeirstead

@kkeirstead kkeirstead commented Sep 22, 2023 •

Copy link
Copy Markdown
Contributor

This PR was co-developed with @wiktork.

Dotnet-Counters and the metrics functionality within Dotnet-Monitor currently share a lot of common logic, and keeping the code separate has resulted in a lot of duplicated work as new features are added to both tools.

This PR encompasses the unification work that takes place in dotnet-counters (a small amount of changes were also required within the dotnet-monitor repo). If you notice any behavior that seems to be inconsistent with what you'd expect, just let us know and we'll look into it - the intent is for this to not be a breaking change for either tool. I plan to do a final round of manual testing prior to merging in these changes, once all other feedback has been resolved.

Another PR contains functional tests to reduce the likelihood of breaking changes - these changes do not depend on each other.

@tommcdon

Copy link
Copy Markdown
Member

@noahfalk @hoyosjs

@noahfalk noahfalk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was mentally prepared for a lot more churn, this feels not bad at all :) I do think there are a few things to change, comments inline.

<ItemGroup>
<InternalsVisibleTo Include="dotnet-monitor" />
<InternalsVisibleTo Include="dotnet-counters" />
<InternalsVisibleTo Include="DotnetCounters.UnitTests" />

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is likely a bigger discussion we can have outside of this PR, but all this InternalsVisibleTo usage looks like something we should move away from. I'd suggest we declare that M.D.Monitoring.* are implementation details of tools our teams maintain and then we convert all the internal APIs we expect those tools to call to be public. Years back when dotnet-monitor was getting started we had ideas that there might be an ecosystem of tools and we might also host an in-proc version of the monitor. Since then it feels pretty clear that OpenTelemetry.NET is the defacto standard in-proc agent and its unlikely anyone else has a need to build an out-of-proc diagnostic tool around this library other than our teams.

For now I'm not objecting to the IVT existing or that we are adding a new one, just suggesting a direction to move in for the future.


int Series { get; }

bool IsValuePublishedEvent { get => EventType != EventType.BeginInstrumentReporting; }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest enumerating the event types which do qualify rather than those which do not, it makes the intent more clear. The current impl is also incorrectly triaging a bunch of events. For example error payloads shouldn't return true I think.

For consistency I'd add this to the EventType extensions so its less likely to be missed if new events are added.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I misinterpreted the initial ask - since the exceptions were already being filtered out earlier in this conditional I didn't account for them. If I should have included any other EventTypes, just let me know and I'll add them in.

@noahfalk noahfalk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few tiny things still outstanding, but overall I think its in good shape. Double check with @mikem8361 before merging to make sure the timing isn't conflicting with the tools release but I think that already happened and there is no issue there.

@mikem8361

Copy link
Copy Markdown
Contributor

Yes, the recent tools release is done and out. Merging this when it is ready would be just fine.

@kkeirstead
kkeirstead marked this pull request as ready for review October 3, 2023 21:04
@kkeirstead
kkeirstead requested a review from a team as a code owner October 3, 2023 21:04
@kkeirstead

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

try
{
session = await client.StartEventPipeSessionAsync(_sourceConfig.GetProviders(), _sourceConfig.RequestRundown, _sourceConfig.BufferSizeInMB, cancellationToken).ConfigureAwait(false);
if (resumeRuntime)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the concept of runtime resumption should be here at all. Let the caller do that after it gets the stream back. Only have the EventPipeStreamProvider care about providing the event stream, nothing else.

I also don't think this should be a setting on EventSourcePipeline class either. Again, let the caller do that. Only have the pipeline care about collection events from the event source.

Pseudo example of a caller needing to resume the runtime:

DiagnosticsClient client = ...;
EventTracePipeline pipeline = new(client, ...);
await pipeline.StartAsync(...);
await client.ResumeRuntimeAsync(...);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to defer this as there is nothing technically wrong with how it is.

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.

6 participants