Skip to content
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

feat(metrics): add basic metrics type support #789

Merged
merged 28 commits into from
Apr 30, 2024

Conversation

viglia
Copy link
Contributor

@viglia viglia commented Feb 26, 2024

this PR aims at adding metrics type definition and the related serialization logic.

This does not include high-level APIs that will be used by the users (with proper aggregation/bucketing).

Example of how to send metrics through the Transport struct:

package main

import (
	"time"

	"strings"

	"github.com/getsentry/sentry-go"
	"github.com/google/uuid"
)

func main() {
	id := strings.Replace(uuid.New().String(), "-", "", -1)
	e := sentry.NewEvent()
	e.EventID = sentry.EventID(id)

	e.Type = "statsd"
	t := time.Now().Unix()
	release := "1.0"
	env := "dev"
	e.Metrics = []sentry.Metric{
		sentry.NewCounterMetric("test-go-metric", sentry.Second(), map[string]string{"transaction": "go-metrics", "release": release, "env": env, "foo": "bar"}, t, 1.0),
		sentry.NewCounterMetric("test-go-metric", sentry.Second(), map[string]string{"transaction": "go-metrics", "release": release, "env": env, "route": " /foo"}, t, 1.0),
	}
	tr := sentry.NewHTTPSyncTransport()
	tr.Configure(sentry.ClientOptions{
		Dsn:   "<YOUR_DSN_HERE>",
		Debug: true,
	})

	tr.SendEvent(e)

}

Copy link

codecov bot commented Feb 26, 2024

Codecov Report

Attention: Patch coverage is 58.64979% with 98 lines in your changes are missing coverage. Please review.

Project coverage is 81.74%. Comparing base (84427d8) to head (1405211).
Report is 1 commits behind head on master.

Files Patch % Lines
metrics.go 55.67% 86 Missing ⚠️
transport.go 72.09% 6 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #789      +/-   ##
==========================================
- Coverage   83.15%   81.74%   -1.41%     
==========================================
  Files          49       50       +1     
  Lines        4190     4427     +237     
==========================================
+ Hits         3484     3619     +135     
- Misses        565      659      +94     
- Partials      141      149       +8     

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

@viglia viglia marked this pull request as ready for review February 29, 2024 09:58
@viglia viglia requested a review from cleptric February 29, 2024 09:58
Copy link
Member

@cleptric cleptric left a comment

Choose a reason for hiding this comment

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

Please add some usage examples to the PR description. Did you already send some metrics to Sentry?

metrics.go Outdated Show resolved Hide resolved
metrics.go Show resolved Hide resolved
metrics_test.go Outdated Show resolved Hide resolved
metrics.go Outdated Show resolved Hide resolved
@viglia viglia requested a review from cleptric February 29, 2024 17:14
Copy link
Contributor

@aldy505 aldy505 left a comment

Choose a reason for hiding this comment

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

To be honest, this metrics implementation would be so easy if we did #643 first.

metrics.go Outdated Show resolved Hide resolved
metrics.go Outdated Show resolved Hide resolved
metrics.go Show resolved Hide resolved
metrics.go Show resolved Hide resolved
metrics.go Outdated Show resolved Hide resolved
metrics.go Outdated Show resolved Hide resolved
log when the request sent to relay fails with a response code in the
range [400, 599]
log failed requests when relay sends back a response with a status code
in the range [400, 599]
@aldy505
Copy link
Contributor

aldy505 commented Apr 1, 2024

Any updates for this?

@cleptric cleptric enabled auto-merge (squash) April 30, 2024 09:59
@cleptric cleptric merged commit 9a9f285 into master Apr 30, 2024
18 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants