Skip to content

Commit

Permalink
rename call.FunctionID() to call.String()
Browse files Browse the repository at this point in the history
  • Loading branch information
asmyasnikov committed Nov 12, 2024
1 parent 6e8ca8f commit 8e04db0
Show file tree
Hide file tree
Showing 14 changed files with 107 additions and 105 deletions.
4 changes: 2 additions & 2 deletions internal/stack/function_id.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package stack

type Caller interface {
FunctionID() string
String() string
}

var _ Caller = functionID("")

type functionID string

func (id functionID) FunctionID() string {
func (id functionID) String() string {
return string(id)
}

Expand Down
8 changes: 4 additions & 4 deletions internal/stack/function_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ type genericType[T any] struct{}
type starType struct{}

func (t genericType[T]) Call() string {
return FunctionID("").FunctionID()
return FunctionID("").String()
}

func staticCall() string {
return FunctionID("").FunctionID()
return FunctionID("").String()
}

func (e *starType) starredCall() string {
return FunctionID("").FunctionID()
return FunctionID("").String()
}

func anonymousFunctionCall() string {
Expand All @@ -30,7 +30,7 @@ func anonymousFunctionCall() string {
go func() {
mu.Lock()
defer mu.Unlock()
result = FunctionID("").FunctionID()
result = FunctionID("").String()
}()
time.Sleep(time.Second)

Expand Down
2 changes: 1 addition & 1 deletion internal/stack/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func buildRecordString(
return buffer.String()
}

func (c call) FunctionID() string {
func (c call) String() string {
return c.Record(Lambda(false), FileName(false))
}

Expand Down
2 changes: 1 addition & 1 deletion internal/stack/record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,6 @@ func BenchmarkCallRecord(b *testing.B) {
func BenchmarkCallFuncionID(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_ = Call(0).FunctionID()
_ = Call(0).String()
}
}
2 changes: 1 addition & 1 deletion retry/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (call callOption) ApplyRetryOption(opts *retryOptions) {
}

type call interface {
FunctionID() string
String() string
}

func withCaller(call call) callOption {
Expand Down
2 changes: 1 addition & 1 deletion spans/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func discovery(adapter Adapter) (t trace.Discovery) {
start := childSpanWithReplaceCtx(
adapter,
info.Context,
info.Call.FunctionID(),
info.Call.String(),
kv.String("address", info.Address),
kv.String("database", info.Database),
)
Expand Down
40 changes: 20 additions & 20 deletions spans/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func driver(adapter Adapter) trace.Driver { //nolint:gocyclo,funlen
start := childSpanWithReplaceCtx(
adapter,
info.Context,
info.Call.FunctionID(),
info.Call.String(),
)

return func(info trace.DriverRepeaterWakeUpDoneInfo) {
Expand All @@ -56,7 +56,7 @@ func driver(adapter Adapter) trace.Driver { //nolint:gocyclo,funlen
start := childSpanWithReplaceCtx(
adapter,
info.Context,
info.Call.FunctionID(),
info.Call.String(),
)

return func(info trace.DriverConnDialDoneInfo) {
Expand All @@ -74,7 +74,7 @@ func driver(adapter Adapter) trace.Driver { //nolint:gocyclo,funlen
start := childSpanWithReplaceCtx(
adapter,
info.Context,
info.Call.FunctionID(),
info.Call.String(),
kv.String("address", safeAddress(info.Endpoint)),
kv.String("method", string(info.Method)),
)
Expand Down Expand Up @@ -114,7 +114,7 @@ func driver(adapter Adapter) trace.Driver { //nolint:gocyclo,funlen
start := childSpanWithReplaceCtx(
adapter,
info.Context,
info.Call.FunctionID(),
info.Call.String(),
kv.String("address", safeAddress(info.Endpoint)),
kv.String("method", string(info.Method)),
)
Expand Down Expand Up @@ -177,7 +177,7 @@ func driver(adapter Adapter) trace.Driver { //nolint:gocyclo,funlen

return func(info trace.DriverConnStreamCloseSendDoneInfo) {
if info.Error != nil {
start.Log(call.FunctionID(), kv.Error(info.Error))
start.Log(call.String(), kv.Error(info.Error))
}
}
},
Expand All @@ -204,7 +204,7 @@ func driver(adapter Adapter) trace.Driver { //nolint:gocyclo,funlen
attributes = append(attributes, kv.Error(info.Error))
}

start.Log(call.FunctionID(), attributes...)
start.Log(call.String(), attributes...)
},
OnConnPark: func(info trace.DriverConnParkStartInfo) func(trace.DriverConnParkDoneInfo) {
if adapter.Details()&trace.DriverConnEvents == 0 {
Expand All @@ -218,9 +218,9 @@ func driver(adapter Adapter) trace.Driver { //nolint:gocyclo,funlen

return func(info trace.DriverConnParkDoneInfo) {
if info.Error != nil {
start.Log(call.FunctionID(), kv.Error(info.Error))
start.Log(call.String(), kv.Error(info.Error))
} else {
start.Log(call.FunctionID())
start.Log(call.String())
}
}
},
Expand All @@ -236,9 +236,9 @@ func driver(adapter Adapter) trace.Driver { //nolint:gocyclo,funlen

return func(info trace.DriverConnCloseDoneInfo) {
if info.Error != nil {
start.Log(call.FunctionID(), kv.Error(info.Error))
start.Log(call.String(), kv.Error(info.Error))
} else {
start.Log(call.FunctionID())
start.Log(call.String())
}
}
},
Expand All @@ -247,7 +247,7 @@ func driver(adapter Adapter) trace.Driver { //nolint:gocyclo,funlen
return nil
}
s := adapter.SpanFromContext(*info.Context)
s.Log(info.Call.FunctionID(),
s.Log(info.Call.String(),
kv.String("cause", safeError(info.Cause)),
)

Expand All @@ -259,7 +259,7 @@ func driver(adapter Adapter) trace.Driver { //nolint:gocyclo,funlen
}
s := adapter.SpanFromContext(*info.Context)
oldState := safeStringer(info.State)
functionID := info.Call.FunctionID()
functionID := info.Call.String()

return func(info trace.DriverConnStateChangeDoneInfo) {
s.Log(functionID,
Expand All @@ -275,7 +275,7 @@ func driver(adapter Adapter) trace.Driver { //nolint:gocyclo,funlen
start := childSpanWithReplaceCtx(
adapter,
info.Context,
info.Call.FunctionID(),
info.Call.String(),
kv.String("name", info.Name),
)

Expand All @@ -292,7 +292,7 @@ func driver(adapter Adapter) trace.Driver { //nolint:gocyclo,funlen
start := childSpanWithReplaceCtx(
adapter,
info.Context,
info.Call.FunctionID(),
info.Call.String(),
kv.String("address", info.Address),
)

Expand All @@ -305,7 +305,7 @@ func driver(adapter Adapter) trace.Driver { //nolint:gocyclo,funlen
return nil
}
start := childSpanWithReplaceCtx(adapter, info.Context,
info.Call.FunctionID(),
info.Call.String(),
kv.String("database", info.Database),
kv.Bool("need_local_dc", info.NeedLocalDC),
)
Expand Down Expand Up @@ -342,7 +342,7 @@ func driver(adapter Adapter) trace.Driver { //nolint:gocyclo,funlen
return nil
}
parent := adapter.SpanFromContext(*info.Context)
functionID := info.Call.FunctionID()
functionID := info.Call.String()

return func(info trace.DriverBalancerChooseEndpointDoneInfo) {
if info.Error != nil {
Expand All @@ -360,7 +360,7 @@ func driver(adapter Adapter) trace.Driver { //nolint:gocyclo,funlen
return nil
}
parent := adapter.SpanFromContext(*info.Context)
functionID := info.Call.FunctionID()
functionID := info.Call.String()

return func(info trace.DriverGetCredentialsDoneInfo) {
if info.Error != nil {
Expand Down Expand Up @@ -388,7 +388,7 @@ func driver(adapter Adapter) trace.Driver { //nolint:gocyclo,funlen
start := childSpanWithReplaceCtx(
adapter,
info.Context,
info.Call.FunctionID(),
info.Call.String(),
kv.String("endpoint", info.Endpoint),
kv.String("database", info.Database),
kv.Bool("secure", info.Secure),
Expand All @@ -405,7 +405,7 @@ func driver(adapter Adapter) trace.Driver { //nolint:gocyclo,funlen
start := childSpanWithReplaceCtx(
adapter,
info.Context,
info.Call.FunctionID(),
info.Call.String(),
)

return func(info trace.DriverCloseDoneInfo) {
Expand All @@ -419,7 +419,7 @@ func driver(adapter Adapter) trace.Driver { //nolint:gocyclo,funlen
start := childSpanWithReplaceCtx(
adapter,
info.Context,
info.Call.FunctionID(),
info.Call.String(),
)

return func(info trace.DriverConnPoolNewDoneInfo) {
Expand Down
Loading

0 comments on commit 8e04db0

Please sign in to comment.