-
Notifications
You must be signed in to change notification settings - Fork 691
Remove type parameters from go names #2343
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package model | ||
|
||
import ( | ||
"regexp" | ||
"strings" | ||
) | ||
|
||
var goStructTypeParameterRegex = regexp.MustCompile(`\[go\.shape\..*\]`) | ||
|
||
func DropGoTypeParameters(input string) string { | ||
matchesIndices := goStructTypeParameterRegex.FindAllStringIndex(input, -1) | ||
if len(matchesIndices) == 0 { | ||
return input | ||
} | ||
var modified strings.Builder | ||
prevEnd := 0 | ||
for _, indices := range matchesIndices { | ||
start, end := indices[0], indices[1] | ||
modified.WriteString(input[prevEnd:start] + "[...]") | ||
prevEnd = end | ||
} | ||
modified.WriteString(input[prevEnd:]) | ||
return modified.String() | ||
} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package model | ||
|
||
import ( | ||
"bufio" | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_DropGoTypeParameters(t *testing.T) { | ||
ef, err := os.Open("testdata/go_type_parameters.expected.txt") | ||
require.NoError(t, err) | ||
defer ef.Close() | ||
|
||
in, err := os.Open("testdata/go_type_parameters.txt") | ||
require.NoError(t, err) | ||
defer in.Close() | ||
|
||
input := bufio.NewScanner(in) | ||
expected := bufio.NewScanner(ef) | ||
for input.Scan() { | ||
expected.Scan() | ||
require.Equal(t, expected.Text(), DropGoTypeParameters(input.Text())) | ||
} | ||
|
||
require.NoError(t, input.Err()) | ||
require.NoError(t, expected.Err()) | ||
require.False(t, expected.Scan()) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
github.com/bufbuild/connect-go.(*Client[...]).CallUnary | ||
github.com/bufbuild/connect-go.(*Request[...]).setRequestMethod | ||
github.com/bufbuild/connect-go.(*Response[...]).Header | ||
github.com/bufbuild/connect-go.NewClient[...].func2 | ||
github.com/bufbuild/connect-go.NewRequest[...] | ||
github.com/bufbuild/connect-go.NewResponse[...] | ||
github.com/bufbuild/connect-go.NewUnaryHandler[...].func2 | ||
github.com/grafana/pyroscope/pkg/util/loser.(*Tree[...]).Next | ||
runtime/internal/atomic.(*Pointer[...]).Load | ||
sync/atomic.(*Pointer[...]).Store | ||
github.com/grafana/pyroscope/pkg/phlaredb/symdb.(*deduplicatingSlice[...]).ingest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
github.com/bufbuild/connect-go.(*Client[go.shape.struct { github.com/grafana/pyroscope/api/gen/proto/go/push/v1.state google.golang.org/protobuf/internal/impl.MessageState; github.com/grafana/pyroscope/api/gen/proto/go/push/v1.sizeCache int32; github.com/grafana/pyroscope/api/gen/proto/go/push/v1.unknownFields []uint8; Series []*github.com/grafana/pyroscope/api/gen/proto/go/push/v1.RawProfileSeries \"protobuf:\\\"bytes,1,rep,name=series,proto3\\\" json:\\\"series,omitempty\\\"\" },go.shape.struct { github.com/grafana/pyroscope/api/gen/proto/go/push/v1.state google.golang.org/protobuf/internal/impl.MessageState; github.com/grafana/pyroscope/api/gen/proto/go/push/v1.sizeCache int32; github.com/grafana/pyroscope/api/gen/proto/go/push/v1.unknownFields []uint8 }]).CallUnary | ||
github.com/bufbuild/connect-go.(*Request[go.shape.struct { github.com/grafana/pyroscope/api/gen/proto/go/push/v1.state google.golang.org/protobuf/internal/impl.MessageState; github.com/grafana/pyroscope/api/gen/proto/go/push/v1.sizeCache int32; github.com/grafana/pyroscope/api/gen/proto/go/push/v1.unknownFields []uint8; Series []*github.com/grafana/pyroscope/api/gen/proto/go/push/v1.RawProfileSeries \"protobuf:\\\"bytes,1,rep,name=series,proto3\\\" json:\\\"series,omitempty\\\"\" }]).setRequestMethod | ||
github.com/bufbuild/connect-go.(*Response[go.shape.struct { github.com/grafana/pyroscope/api/gen/proto/go/push/v1.state google.golang.org/protobuf/internal/impl.MessageState; github.com/grafana/pyroscope/api/gen/proto/go/push/v1.sizeCache int32; github.com/grafana/pyroscope/api/gen/proto/go/push/v1.unknownFields []uint8 }]).Header | ||
github.com/bufbuild/connect-go.NewClient[go.shape.struct { github.com/grafana/pyroscope/api/gen/proto/go/types/v1.state google.golang.org/protobuf/internal/impl.MessageState; github.com/grafana/pyroscope/api/gen/proto/go/types/v1.sizeCache int32; github.com/grafana/pyroscope/api/gen/proto/go/types/v1.unknownFields []uint8; Matchers []string \"protobuf:\\\"bytes,1,rep,name=matchers,proto3\\\" json:\\\"matchers,omitempty\\\"\" },go.shape.struct { github.com/grafana/pyroscope/api/gen/proto/go/types/v1.state google.golang.org/protobuf/internal/impl.MessageState; github.com/grafana/pyroscope/api/gen/proto/go/types/v1.sizeCache int32; github.com/grafana/pyroscope/api/gen/proto/go/types/v1.unknownFields []uint8; Names []string \"protobuf:\\\"bytes,1,rep,name=names,proto3\\\" json:\\\"names,omitempty\\\"\" }].func2 | ||
github.com/bufbuild/connect-go.NewRequest[go.shape.struct { github.com/grafana/pyroscope/api/gen/proto/go/push/v1.state google.golang.org/protobuf/internal/impl.MessageState; github.com/grafana/pyroscope/api/gen/proto/go/push/v1.sizeCache int32; github.com/grafana/pyroscope/api/gen/proto/go/push/v1.unknownFields []uint8; Series []*github.com/grafana/pyroscope/api/gen/proto/go/push/v1.RawProfileSeries \"protobuf:\\\"bytes,1,rep,name=series,proto3\\\" json:\\\"series,omitempty\\\"\" }] | ||
github.com/bufbuild/connect-go.NewResponse[go.shape.struct { github.com/grafana/pyroscope/api/gen/proto/go/push/v1.state google.golang.org/protobuf/internal/impl.MessageState; github.com/grafana/pyroscope/api/gen/proto/go/push/v1.sizeCache int32; github.com/grafana/pyroscope/api/gen/proto/go/push/v1.unknownFields []uint8 }] | ||
github.com/bufbuild/connect-go.NewUnaryHandler[go.shape.struct { github.com/grafana/pyroscope/api/gen/proto/go/types/v1.state google.golang.org/protobuf/internal/impl.MessageState; github.com/grafana/pyroscope/api/gen/proto/go/types/v1.sizeCache int32; github.com/grafana/pyroscope/api/gen/proto/go/types/v1.unknownFields []uint8; Name string \"protobuf:\\\"bytes,1,opt,name=name,proto3\\\" json:\\\"name,omitempty\\\"\"; Matchers []string \"protobuf:\\\"bytes,2,rep,name=matchers,proto3\\\" json:\\\"matchers,omitempty\\\"\" },go.shape.struct { github.com/grafana/pyroscope/api/gen/proto/go/types/v1.state google.golang.org/protobuf/internal/impl.MessageState; github.com/grafana/pyroscope/api/gen/proto/go/types/v1.sizeCache int32; github.com/grafana/pyroscope/api/gen/proto/go/types/v1.unknownFields []uint8; Names []string \"protobuf:\\\"bytes,1,rep,name=names,proto3\\\" json:\\\"names,omitempty\\\"\" }].func2 | ||
github.com/grafana/pyroscope/pkg/util/loser.(*Tree[go.shape.struct { github.com/grafana/pyroscope/pkg/phlaredb.Profile; Index int },go.shape.interface { At() go.shape.struct { github.com/grafana/pyroscope/pkg/phlaredb.Profile; Index int }; Close() error; Err() error; Next() bool }]).Next | ||
runtime/internal/atomic.(*Pointer[go.shape.struct { runtime.lfnode; runtime.popped runtime/internal/atomic.Uint32; runtime.spans [512]runtime.atomicMSpanPointer }]).Load | ||
sync/atomic.(*Pointer[go.shape.struct { net/http.conn *net/http.conn; net/http.req *net/http.Request; net/http.reqBody io.ReadCloser; net/http.cancelCtx context.CancelFunc; net/http.wroteHeader bool; net/http.wroteContinue bool; net/http.wants10KeepAlive bool; net/http.wantsClose bool; net/http.canWriteContinue sync/atomic.Bool; net/http.writeContinueMu sync.Mutex; net/http.w *bufio.Writer; net/http.cw net/http.chunkWriter; net/http.handlerHeader net/http.Header; net/http.calledHeader bool; net/http.written int64; net/http.contentLength int64; net/http.status int; net/http.closeAfterReply bool; net/http.fullDuplex bool; net/http.requestBodyLimitHit bool; net/http.trailers []string; net/http.handlerDone sync/atomic.Bool; net/http.dateBuf [29]uint8; net/http.clenBuf [10]uint8; net/http.statusBuf [3]uint8; net/http.closeNotifyCh chan bool; net/http.didCloseNotify sync/atomic.Bool }]).Store | ||
github.com/grafana/pyroscope/pkg/phlaredb/symdb.(*deduplicatingSlice[go.shape.*github.com/grafana/pyroscope/pkg/phlaredb/schemas/v1.InMemoryLocation,go.shape.struct { MappingId uint32; Address uint64; LinesHash uint64 },go.shape.*uint8]).ingest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,7 +92,7 @@ func (l *Limits) RegisterFlags(f *flag.FlagSet) { | |
f.IntVar(&l.MaxProfileStacktraceSamples, "validation.max-profile-stacktrace-samples", 16000, "Maximum number of samples in a profile. 0 to disable.") | ||
f.IntVar(&l.MaxProfileStacktraceSampleLabels, "validation.max-profile-stacktrace-sample-labels", 100, "Maximum number of labels in a profile sample. 0 to disable.") | ||
f.IntVar(&l.MaxProfileStacktraceDepth, "validation.max-profile-stacktrace-depth", 1000, "Maximum depth of a profile stacktrace. Profiles are not rejected instead stacktraces are truncated. 0 to disable.") | ||
f.IntVar(&l.MaxProfileSymbolValueLength, "validation.max-profile-symbol-value-length", 1024, "Maximum length of a profile symbol value (labels, function names and filenames, etc...). Profiles are not rejected instead symbol values are truncated. 0 to disable.") | ||
f.IntVar(&l.MaxProfileSymbolValueLength, "validation.max-profile-symbol-value-length", 65535, "Maximum length of a profile symbol value (labels, function names and filenames, etc...). Profiles are not rejected instead symbol values are truncated. 0 to disable.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
|
||
// UnmarshalYAML implements the yaml.Unmarshaler interface. | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that we don't know if it is a Go profile / node, therefore the function is applied to all nodes.
ReplaceAllString
would look better here but it allocates a new string.I'm also not sure if there might be more than one group of type parameters.