Skip to content

Conversation

@aldy505
Copy link
Contributor

@aldy505 aldy505 commented Oct 23, 2025

Important

This will never get merged. This is a proof of concept on my end, and it works. This should be reworked if this (#1107) got merged.

If you want to use this, go set this on your go.mod:

replace github.com/getsentry/sentry-go => github.com/aldy505/sentry-go v0.0.0-20251027094200-132f880a4c16

On your sentry.Init call:

	err := sentry.Init(sentry.ClientOptions{
		ExperimentalEnableTraceMetric: true,
	})

Then use it:

meter := sentry.NewMeter(ctx)
meter.Count("number_of_lines", 1, sentry.MeterOptions{})
meter.Distribution("processing_time_ms", float64(time.Since(startTime).Milliseconds()), sentry.MeterOptions{})

Description

Implement trace metric based on getsentry/sentry-docs#15178

This work is based on the batch logger made by Giannis. Minimal documentation to really emphasize how experimental this is.

Issues

Reminders

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@codecov
Copy link

codecov bot commented Oct 23, 2025

Codecov Report

❌ Patch coverage is 4.62633% with 268 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.91%. Comparing base (c982e6f) to head (132f880).

Files with missing lines Patch % Lines
metrics.go 0.00% 141 Missing ⚠️
batch_metrics.go 0.00% 78 Missing ⚠️
interfaces.go 38.46% 14 Missing and 2 partials ⚠️
transport.go 0.00% 16 Missing ⚠️
internal/protocol/envelope.go 0.00% 10 Missing ⚠️
client.go 16.66% 3 Missing and 2 partials ⚠️
internal/ratelimit/category.go 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1116      +/-   ##
==========================================
- Coverage   86.67%   82.91%   -3.77%     
==========================================
  Files          60       63       +3     
  Lines        6964     5829    -1135     
==========================================
- Hits         6036     4833    -1203     
- Misses        743      806      +63     
- Partials      185      190       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

}
if client.batchMeter != nil {
client.batchMeter.Flush(ctx.Done())
}
Copy link

Choose a reason for hiding this comment

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

Bug: Goroutine Leak in Client Close

The Client.Close() method doesn't call Shutdown() on batchMeter (or batchLogger), causing goroutine leaks. The BatchMeter.run() goroutine will continue running indefinitely even after the client is closed, as it only stops when the context is cancelled. The Shutdown() method should be called to properly cancel the context and wait for the goroutine to finish, similar to how Flush() calls both batchLogger.Flush() and batchMeter.Flush().

Fix in Cursor Fix in Web

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.

1 participant