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

Track connection preparation starting time #85

Merged
merged 2 commits into from
Jan 17, 2025
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
6 changes: 4 additions & 2 deletions connect/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ func (h *connectHandler) prepareConnection(ctx context.Context, data connectionE
connectTimeout, cancelConnectTimeout := context.WithTimeout(ctx, 10*time.Second)
defer cancelConnectTimeout()

startTime := time.Now()

startRes, err := h.apiClient.start(ctx, data.hashedSigningKey, &connectproto.StartRequest{
ExcludeGateways: excludeGateways,
})
Expand All @@ -127,11 +129,11 @@ func (h *connectHandler) prepareConnection(ctx context.Context, data connectionE
}

// Connection ID is unique per connection, reconnections should get a new ID
connectionId := ulid.MustNew(ulid.Now(), rand.Reader)
connectionId := ulid.MustNew(ulid.Timestamp(startTime), rand.Reader)

h.logger.Debug("websocket connection established", "gateway_host", gatewayHost)

err = h.performConnectHandshake(ctx, connectionId.String(), ws, startRes, data)
err = h.performConnectHandshake(ctx, connectionId.String(), ws, startRes, data, startTime)
if err != nil {
return connection{}, reconnectError{fmt.Errorf("could not perform connect handshake: %w", err)}
}
Expand Down
4 changes: 3 additions & 1 deletion connect/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/inngest/inngest/pkg/connect/wsproto"
connectproto "github.com/inngest/inngest/proto/gen/connect/v1"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/timestamppb"
"runtime"
"time"
)
Expand All @@ -28,7 +29,7 @@ func shouldReconnect(err error) bool {
return errors.Is(err, reconnectError{})
}

func (h *connectHandler) performConnectHandshake(ctx context.Context, connectionId string, ws *websocket.Conn, startResponse *connectproto.StartResponse, data connectionEstablishData) error {
func (h *connectHandler) performConnectHandshake(ctx context.Context, connectionId string, ws *websocket.Conn, startResponse *connectproto.StartResponse, data connectionEstablishData, startTime time.Time) error {
// Wait for gateway hello message
{
initialMessageTimeout, cancelInitialTimeout := context.WithTimeout(ctx, 5*time.Second)
Expand Down Expand Up @@ -73,6 +74,7 @@ func (h *connectHandler) performConnectHandshake(ctx context.Context, connection
SdkVersion: h.opts.SDKVersion,
SdkLanguage: h.opts.SDKLanguage,
WorkerManualReadinessAck: data.manualReadinessAck,
StartedAt: timestamppb.New(startTime),
})
if err != nil {
return fmt.Errorf("could not serialize sdk connect message: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/google/uuid v1.6.0
github.com/gosimple/slug v1.12.0
github.com/gowebpki/jcs v1.0.0
github.com/inngest/inngest v1.3.4-0.20241218224011-c98e011728d6
github.com/inngest/inngest v1.4.0-beta.1.0.20250117112018-f70307dc1c23
github.com/oklog/ulid/v2 v2.1.0
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58
github.com/sashabaranov/go-openai v1.35.6
Expand Down
10 changes: 4 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,10 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/inngest/expr v0.0.0-20241106234328-863dff7deec0 h1:cqaGD0mx745BYyVGZ3GJsiZETktC64h1r9zdDInmKIs=
github.com/inngest/expr v0.0.0-20241106234328-863dff7deec0/go.mod h1:0Dllw9clwlMWWxfiSsHY9VdE+Zjt/8SVCMxK9r39aKE=
github.com/inngest/inngest v1.3.4-0.20241218201514-632b6fe3c996 h1:vO3bLgmQd/stlTJU/IIRtE+N9D9/LmzC+vfwVyJeNCE=
github.com/inngest/inngest v1.3.4-0.20241218201514-632b6fe3c996/go.mod h1:UfL9PYy1SECtj/vG01UZXPIoEJsamNqRPtz+Uyhli5k=
github.com/inngest/inngest v1.3.4-0.20241218202510-b750c9bf0ba6 h1:znR2kHI/mZhD5RInIanQCVFllzNFhRc8wdL1nOu2umI=
github.com/inngest/inngest v1.3.4-0.20241218202510-b750c9bf0ba6/go.mod h1:UfL9PYy1SECtj/vG01UZXPIoEJsamNqRPtz+Uyhli5k=
github.com/inngest/inngest v1.3.4-0.20241218224011-c98e011728d6 h1:Jyu3YZfUCUBZzub+exw8qtObbZAB3l4ouhfYwvccbbQ=
github.com/inngest/inngest v1.3.4-0.20241218224011-c98e011728d6/go.mod h1:fhroKPLWcj78OST/5TAqTKuks34K7fWGma3L47ZQl7Y=
github.com/inngest/inngest v1.3.4-0.20250109201856-952279204d50 h1:7gsx77EbLE7mfdk9OHn/Qiv6tX1o4RL2vffWoGYYEtY=
github.com/inngest/inngest v1.3.4-0.20250109201856-952279204d50/go.mod h1:HH/i3CFWPqQytJpSL5p4LvYP8xWJFnNywwYV7q852LQ=
github.com/inngest/inngest v1.4.0-beta.1.0.20250117112018-f70307dc1c23 h1:KVnAWaJXblDyAswSMG5tm02ZtzS3ppWbzfwlL2QyPHA=
github.com/inngest/inngest v1.4.0-beta.1.0.20250117112018-f70307dc1c23/go.mod h1:Z1QM6Az04hLLXZjs/h+hTnX5T4tLDMuWSz2vFiZb4OE=
github.com/karlseguin/ccache/v2 v2.0.8 h1:lT38cE//uyf6KcFok0rlgXtGFBWxkI6h/qg4tbFyDnA=
github.com/karlseguin/ccache/v2 v2.0.8/go.mod h1:2BDThcfQMf/c0jnZowt16eW405XIqZPavt+HoYEtcxQ=
github.com/karlseguin/expect v1.0.2-0.20190806010014-778a5f0c6003 h1:vJ0Snvo+SLMY72r5J4sEfkuE7AFbixEP2qRbEcum/wA=
Expand Down
2 changes: 0 additions & 2 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import (
"sync"
"time"

"log/slog"

"github.com/inngest/inngest/pkg/enums"
"github.com/inngest/inngest/pkg/execution/state"
"github.com/inngest/inngest/pkg/inngest"
Expand Down
7 changes: 4 additions & 3 deletions vendor/github.com/inngest/inngest/pkg/consts/consts.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/github.com/inngest/inngest/pkg/consts/otel.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions vendor/github.com/inngest/inngest/pkg/telemetry/metrics/counter.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions vendor/github.com/inngest/inngest/pkg/telemetry/metrics/gauge.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions vendor/github.com/inngest/inngest/pkg/util/hash.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading