Skip to content

Metrics Support - alpha - #2949

Merged
bruno-garcia merged 60 commits into
mainfrom
metrics
Jan 8, 2024
Merged

bruno-garcia merged 60 commits into
mainfrom
metrics

Conversation

@jamescrosswell

@jamescrosswell jamescrosswell commented Dec 6, 2023 •

Copy link
Copy Markdown
Collaborator

Resolves #2880

image

Dogfooding

Once we have a nuget package, we can use the Symbol Collector to dogfood this.

@jamescrosswell jamescrosswell changed the title WIP: Delightful Developer Metrics pilot WIP: Delightful Developer Metrics alpha Dec 7, 2023
@jamescrosswell jamescrosswell changed the title WIP: Delightful Developer Metrics alpha Delightful Developer Metrics alpha Dec 7, 2023
@jamescrosswell
jamescrosswell requested a review from Giorgi December 7, 2023 09:20
Comment thread src/Sentry/DisabledMetricAggregator.cs Resolved
Comment thread src/Sentry/MetricAggregator.cs Resolved
Comment thread src/Sentry/IMetricAggregator.cs Resolved
Comment thread src/Sentry/MetricAggregator.cs Resolved
Comment thread src/Sentry/MetricAggregator.cs Resolved
Comment thread src/Sentry/MetricAggregator.cs Resolved
Comment thread src/Sentry/MetricAggregator.cs Resolved
Comment thread src/Sentry/Protocol/Metrics/Metric.cs Resolved
Comment thread src/Sentry/Protocol/Metrics/Metric.cs Resolved
Comment thread src/Sentry/Protocol/Metrics/Metric.cs Resolved
Comment thread src/Sentry/MetricAggregator.cs Resolved

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

Quick second pass

Comment thread src/Sentry/MetricAggregator.cs Resolved
Comment thread src/Sentry/Protocol/Metrics/Metric.cs Resolved
Comment thread src/Sentry/Internal/Hub.cs Resolved
Comment thread src/Sentry/MetricAggregator.cs Resolved
Comment thread src/Sentry/MetricAggregator.cs Resolved
@bruno-garcia bruno-garcia changed the title Delightful Developer Metrics alpha Metrics Support - alpha Dec 20, 2023
@bruno-garcia

Copy link
Copy Markdown
Member

@jamescrosswell renamed the PR because we dropped the DDM internal name in favor of "Metrics"

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

Ranout of gas, didn't review MetricAggregator really and only did around 30/52 files.

Comment thread CHANGELOG.md Resolved
Comment thread modules/Ben.Demystifier

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.

Comment thread src/Sentry/MetricHelper.cs Resolved
Comment thread src/Sentry/MetricAggregator.cs Resolved

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

Only got as far as 30/52 files and didn't go deep on MetricAggregator and other major pieces but sending some bits as it's what I managed to cover

@jamescrosswell

Copy link
Copy Markdown
Collaborator Author

Only got as far as 30/52 files and didn't go deep on MetricAggregator and other major pieces but sending some bits as it's what I managed to cover

Awesome - thank you! The meat of it is all in the MetricAggregator so that one might take a little while.

@jamescrosswell jamescrosswell self-assigned this Dec 20, 2023

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

Now at 48/52 (only what really matters is left lol)

Maybe on a follow up PR we should rename MeasurementUnit, it's quite verbose

Comment thread src/Sentry/MetricHelper.cs Resolved
Comment thread src/Sentry/MetricHelper.cs Resolved
Comment thread src/Sentry/MetricHelper.cs Resolved
Comment thread src/Sentry/MetricHelper.cs Resolved
Comment thread src/Sentry/Protocol/Metrics/Metric.cs Resolved
Comment thread src/Sentry/Timing.cs Resolved

internal SentryStackFrame? GetCodeLocation(int stackLevel)
{
var stackTrace = new StackTrace(true);

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.

@jamescrosswell jamescrosswell Dec 27, 2023 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I don't see an easy way to do so. There's no way to supply a stackLevel to the CallerMemberName, that I can see. That's the main reason for the _seenLocations cache though... so at least this expensive operation only occurs once per unique metric per day.

_codeLocationLock.Wait();
try
{
var result = _pendingLocations;

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.

You can do this atomically with Interlocked afaik, CompareExchange iirc

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Hm, the _codeLocationLock is used elsewhere in the MetricAggregator to lock on different operations against _pendingLocations though. For example, there's this:

if (!_pendingLocations.ContainsKey(startOfDay))
{
_pendingLocations[startOfDay] = new Dictionary<MetricResourceIdentifier, SentryStackFrame>();
}
_pendingLocations[startOfDay][metaKey] = location;

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

There's a race condition in RecordCodeLocation

Comment thread src/Sentry/MetricHelper.cs Resolved
Comment thread src/Sentry/MetricAggregator.cs Resolved
Comment thread src/Sentry/MetricAggregator.cs Resolved
Comment thread src/Sentry/MetricAggregator.cs Resolved
Comment thread src/Sentry/MetricAggregator.cs Resolved
Comment thread src/Sentry/MetricAggregator.cs Resolved
Comment thread src/Sentry/MetricAggregator.cs Resolved

@bitsandfoxes bitsandfoxes left a comment

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.

This looks amazing!

Comment thread src/Sentry/Timing.cs Resolved
Comment thread src/Sentry/Timing.cs Resolved
Comment thread src/Sentry/IMetricAggregator.cs Resolved
Comment thread src/Sentry/IMetricAggregator.cs Resolved
Comment thread src/Sentry/MetricAggregator.cs Resolved
Comment thread src/Sentry/Internal/Hub.cs Resolved
Comment thread src/Sentry/IMetricAggregator.cs Resolved
Comment thread src/Sentry/SentryClient.cs Resolved

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

There are a few comments that I might have dropped outside a review that are pending. Could you please take a look on the files view: https://github.com/getsentry/sentry-dotnet/pull/2949/files

I don't see any blockers so I'm happy to merge this and ship a beta so we can test. It's just too hard to review this change now and we can do improvements/fixes in follow up PRs now.

Comment thread src/Sentry/Timing.cs Resolved
internal void CaptureCodeLocations(CodeLocations codeLocations)
{
_options.LogDebug($"Capturing code locations for period: {codeLocations.Timestamp}");
CaptureEnvelope(Envelope.FromCodeLocations(codeLocations));

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.

Are code locations not coupled with metrics? In which case they should be on the same envelope ideally

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Metrics API

6 participants