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

Update min go version to 1.21 #898

Merged
merged 3 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: "1.22"
go-version: "1.23"
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # [email protected]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
run: make vet
- name: Check go.mod Tidiness
run: make mod-tidy
if: ${{ matrix.go == '1.20' }}
if: ${{ matrix.go == '1.21' }}
- name: Test
run: make test-coverage
- name: Upload coverage to Codecov
Expand All @@ -64,6 +64,6 @@ jobs:
timeout-minutes: 15
strategy:
matrix:
go: ["1.23", "1.22", "1.21", "1.20", "1.19", "1.18"]
go: ["1.23", "1.22", "1.21"]
os: [ubuntu, windows, macos]
fail-fast: false
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

- Always set Mechanism Type to generic ([#896](https://github.com/getsentry/sentry-go/pull/897))

### Misc

Drop support for Go 1.18, 1.19 and 1.20. The currently supported Go versions are the last 3 stable releases: 1.23, 1.22 and 1.21.

## 0.29.1

The Sentry SDK team is happy to announce the immediate availability of Sentry Go SDK v0.29.1.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ mod-tidy: ## Check go.mod tidiness
for dir in $(ALL_GO_MOD_DIRS); do \
cd "$${dir}"; \
echo ">>> Running 'go mod tidy' for module: $${dir}"; \
go mod tidy -go=1.18 -compat=1.18; \
go mod tidy -go=1.21 -compat=1.21; \
done; \
git diff --exit-code;
.PHONY: mod-tidy
Expand Down
8 changes: 0 additions & 8 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,14 +590,6 @@ func (client *Client) GetSDKIdentifier() string {
return client.sdkIdentifier
}

// reverse reverses the slice a in place.
func reverse(a []Exception) {
for i := len(a)/2 - 1; i >= 0; i-- {
opp := len(a) - 1 - i
a[i], a[opp] = a[opp], a[i]
}
}

func (client *Client) processEvent(event *Event, hint *EventHint, scope EventModifier) *EventID {
if event == nil {
err := usageError{fmt.Errorf("%s called with nil event", callerFunctionName())}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/getsentry/sentry-go

go 1.18
go 1.21

require (
github.com/gin-gonic/gin v1.8.1
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA
github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY=
github.com/nxadm/tail v1.4.11/go.mod h1:OTaG3NK980DZzxbRq6lEuzgU+mug70nY11sMd4JXXHc=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
github.com/onsi/gomega v1.27.1 h1:rfztXRbg6nv/5f+Raen9RcGoSecHIFgBBLQK3Wdj754=
github.com/onsi/gomega v1.27.1/go.mod h1:aHX5xOykVYzWOV4WqQy0sy8BQptgukenXpCXfadcIAw=
github.com/pelletier/go-toml/v2 v2.0.5 h1:ipoSadvV8oGUjnUbMub59IDPPwfxF694nG/jwbMiyQg=
github.com/pelletier/go-toml/v2 v2.0.5/go.mod h1:OMHamSCAODeSsVrwwvcJOaoN0LIUIaFVNZzmWyNfXas=
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
Expand Down Expand Up @@ -212,6 +214,7 @@ github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FB
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M=
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM=
github.com/yudai/pp v2.0.1+incompatible h1:Q4//iY4pNF6yPLZIigmvcl7k/bPgrcTPIFIcmawg5bI=
github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand Down
3 changes: 2 additions & 1 deletion hub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package sentry
import (
"context"
"fmt"
"slices"
"strings"
"sync"
"testing"
Expand Down Expand Up @@ -400,7 +401,7 @@ func TestGetBaggage(t *testing.T) {
t.Run(name, func(t *testing.T) {
result := tt.hub.GetBaggage()
res := strings.Split(result, ",")
sortSlice(res)
slices.Sort(res)
assertEqual(t, strings.Join(res, ","), tt.expected)
})
}
Expand Down
3 changes: 2 additions & 1 deletion interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net"
"net/http"
"reflect"
"slices"
"strings"
"time"
)
Expand Down Expand Up @@ -398,7 +399,7 @@ func (e *Event) SetException(exception error, maxErrorDepth int) {
}

// event.Exception should be sorted such that the most recent error is last.
reverse(e.Exception)
slices.Reverse(e.Exception)

for i := range e.Exception {
e.Exception[i].Mechanism = &Mechanism{
Expand Down
12 changes: 3 additions & 9 deletions metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"hash/crc32"
"math"
"regexp"
"sort"
"slices"
"strings"
)

Expand Down Expand Up @@ -223,7 +223,7 @@ func (am abstractMetric) SerializeTags() string {
for k := range am.tags {
values = append(values, k)
}
sortSlice(values)
slices.Sort(values)

for _, key := range values {
val := sanitizeValue(am.tags[key])
Expand Down Expand Up @@ -375,7 +375,7 @@ func (s SetMetric[T]) SerializeValue() string {
for k := range s.values {
values = append(values, k)
}
sortSlice(values)
slices.Sort(values)

var sb strings.Builder
for _, el := range values {
Expand Down Expand Up @@ -419,9 +419,3 @@ func sanitizeValue(s string) string {
type Ordered interface {
~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64 | ~string
}

func sortSlice[T Ordered](s []T) {
sort.Slice(s, func(i, j int) bool {
return s[i] < s[j]
})
}
2 changes: 0 additions & 2 deletions otel/context.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build go1.18

package sentryotel

// Context keys to be used with context.WithValue(...) and ctx.Value(...)
Expand Down
2 changes: 0 additions & 2 deletions otel/event_processor.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build go1.18

package sentryotel

import (
Expand Down
2 changes: 0 additions & 2 deletions otel/event_processor_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build go1.18

package sentryotel

import (
Expand Down
2 changes: 1 addition & 1 deletion otel/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/getsentry/sentry-go/otel

go 1.18
go 1.21

require (
github.com/getsentry/sentry-go v0.29.1
Expand Down
7 changes: 7 additions & 0 deletions otel/go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
Expand All @@ -8,9 +10,13 @@ github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
go.opentelemetry.io/otel v1.11.0 h1:kfToEGMDq6TrVrJ9Vht84Y8y9enykSZzDDZglV0kIEk=
go.opentelemetry.io/otel v1.11.0/go.mod h1:H2KtuEphyMvlhZ+F7tg9GRhAOe60moNx61Ex+WmiKkk=
go.opentelemetry.io/otel/sdk v1.11.0 h1:ZnKIL9V9Ztaq+ME43IUi/eo22mNsb6a7tGfzaOWB5fo=
Expand All @@ -22,3 +28,4 @@ golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 0 additions & 2 deletions otel/helpers_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build go1.18

package sentryotel

import (
Expand Down
2 changes: 0 additions & 2 deletions otel/internal/utils/mapotelstatus.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build go1.18

package utils

import (
Expand Down
2 changes: 0 additions & 2 deletions otel/internal/utils/sentryrequest.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build go1.18

package utils

import (
Expand Down
2 changes: 0 additions & 2 deletions otel/internal/utils/spanattributes.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build go1.18

package utils

import (
Expand Down
2 changes: 0 additions & 2 deletions otel/propagator.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build go1.18

package sentryotel

import (
Expand Down
2 changes: 0 additions & 2 deletions otel/propagator_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build go1.18

package sentryotel

import (
Expand Down
2 changes: 0 additions & 2 deletions otel/span_map.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build go1.18

package sentryotel

import (
Expand Down
2 changes: 0 additions & 2 deletions otel/span_processor.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build go1.18

package sentryotel

import (
Expand Down
2 changes: 0 additions & 2 deletions otel/span_processor_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build go1.18

package sentryotel

import (
Expand Down
9 changes: 2 additions & 7 deletions profiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package sentry

import (
"container/ring"
"encoding/binary"
"strconv"

"runtime"
Expand Down Expand Up @@ -377,13 +378,7 @@ func (p *profileRecorder) addStackTrace(capturedStack traceparser.Trace) int {

p.stackKeyBuffer = append(p.stackKeyBuffer, 0) // space

// The following code is just like binary.AppendUvarint() which isn't yet available in Go 1.18.
x := uint64(frameIndex) + 1
for x >= 0x80 {
p.stackKeyBuffer = append(p.stackKeyBuffer, byte(x)|0x80)
x >>= 7
}
p.stackKeyBuffer = append(p.stackKeyBuffer, byte(x))
p.stackKeyBuffer = binary.AppendUvarint(p.stackKeyBuffer, uint64(frameIndex)+1)
}
}

Expand Down
37 changes: 31 additions & 6 deletions stacktrace.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"go/build"
"reflect"
"runtime"
"slices"
"strings"
)

Expand Down Expand Up @@ -277,12 +278,7 @@ func extractFrames(pcs []uintptr) []runtime.Frame {
}
}

// TODO don't append and reverse, put in the right place from the start.
// reverse
for i, j := 0, len(frames)-1; i < j; i, j = i+1, j-1 {
frames[i], frames[j] = frames[j], frames[i]
}

slices.Reverse(frames)
return frames
}

Expand Down Expand Up @@ -382,3 +378,32 @@ func baseName(name string) string {
}
return name
}

func isCompilerGeneratedSymbol(name string) bool {
// In versions of Go 1.20 and above a prefix of "type:" and "go:" is a
// compiler-generated symbol that doesn't belong to any package.
// See variable reservedimports in cmd/compile/internal/gc/subr.go
if strings.HasPrefix(name, "go:") || strings.HasPrefix(name, "type:") {
return true
}
return false
}

// Walk backwards through the results and for the current function name
// remove it's parent function's prefix, leaving only it's actual name. This
// fixes issues grouping errors with the new fully qualified function names
// introduced from Go 1.21.
func cleanupFunctionNamePrefix(f []Frame) []Frame {
for i := len(f) - 1; i > 0; i-- {
name := f[i].Function
parentName := f[i-1].Function + "."

if !strings.HasPrefix(name, parentName) {
continue
}

f[i].Function = name[len(parentName):]
}

return f
}
15 changes: 0 additions & 15 deletions stacktrace_below_go1.20.go

This file was deleted.

32 changes: 0 additions & 32 deletions stacktrace_below_go1.20_test.go

This file was deleted.

7 changes: 0 additions & 7 deletions stacktrace_below_go1.21.go

This file was deleted.

Loading
Loading