Skip to content

Commit

Permalink
Improve connection error logs (#417)
Browse files Browse the repository at this point in the history
* Improve connection error logs
* Use docker compose 2.x
  • Loading branch information
rsafonseca committed Aug 6, 2024
1 parent 68da1bc commit fa9721e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ setup-protobuf-macos:
@go get github.com/golang/protobuf/protoc-gen-go

run-jaeger-aio:
@docker-compose -f ./examples/testing/docker-compose-jaeger.yml up -d
@docker compose -f ./examples/testing/docker-compose-jaeger.yml up -d
@echo "Access jaeger UI @ http://localhost:16686"

run-chat-example:
@cd examples/testing && docker-compose up -d etcd nats && cd ../demo/chat/ && go run main.go
@cd examples/testing && docker compose up -d etcd nats && cd ../demo/chat/ && go run main.go

run-cluster-example-frontend-tracing:
@PITAYA_METRICS_PROMETHEUS_PORT=9090 JAEGER_SAMPLER_PARAM=1 JAEGER_DISABLED=false JAEGER_SERVICE_NAME=example-frontend JAEGER_AGENT_PORT=6832 go run examples/demo/cluster/main.go
Expand Down Expand Up @@ -98,16 +98,16 @@ ensure-testing-bin:
@[ -f ./examples/testing/server ] || go build -o ./examples/testing/server ./examples/testing/main.go

ensure-testing-deps:
@cd ./examples/testing && docker-compose up -d
@cd ./examples/testing && docker compose up -d

ensure-e2e-deps-grpc:
@cd ./examples/testing && docker-compose up -d etcd
@cd ./examples/testing && docker compose up -d etcd

kill-testing-deps:
@cd ./examples/testing && docker-compose down; true
@cd ./examples/testing && docker compose down; true

kill-jaeger:
@docker-compose -f ./examples/testing/docker-compose-jaeger.yml down; true
@docker compose -f ./examples/testing/docker-compose-jaeger.yml down; true

e2e-test: e2e-test-nats e2e-test-grpc

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Here's one example of running Pitaya:

Start etcd (This command requires docker-compose and will run an etcd container locally. An etcd may be run without docker if preferred.)
```
cd ./examples/testing && docker-compose up -d etcd
cd ./examples/testing && docker compose up -d etcd
```
run the connector frontend server from cluster_grpc example
```
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/chat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ refs: https://github.com/topfreegames/pitaya

## Run
```
docker-compose -f ../../testing/docker-compose.yml up -d etcd nats
docker compose -f ../../testing/docker-compose.yml up -d etcd nats
go run main.go
```

Expand Down
7 changes: 6 additions & 1 deletion service/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,12 @@ func (h *HandlerService) Handle(conn acceptor.PlayerConn) {
} else if err == constants.ErrConnectionClosed {
logger.Log.Debugf("Connection no longer available while reading next available message: %s", err.Error())
} else {
logger.Log.Errorf("Error reading next available message: %s", err.Error())
// Differentiate errors for valid sessions, to avoid noise from load balancer healthchecks and other internet noise
if a.GetStatus() != constants.StatusStart {
logger.Log.Errorf("Error reading next available message for UID: %s, Build: %s, error: %s", a.GetSession().UID(), "a.GetSession().GetHandshakeData().Sys.BuildNumber", err.Error())
} else {
logger.Log.Debugf("Error reading next available message on initial connection: %s", err.Error())
}
}

return
Expand Down
6 changes: 4 additions & 2 deletions service/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,16 +418,18 @@ func TestHandlerServiceHandle(t *testing.T) {
mockAgent.EXPECT().SendHandshakeResponse().Return(nil)

mockSession := mocks.NewMockSession(ctrl)
mockSession.EXPECT().GetHandshakeData().Return(&session.HandshakeData{Sys: session.HandshakeClientData{BuildNumber: "10"}}).AnyTimes()
mockSession.EXPECT().SetHandshakeData(gomock.Any()).Times(1)
mockSession.EXPECT().ValidateHandshake(gomock.Any()).Times(1)
mockSession.EXPECT().UID().Return("uid").Times(1)
mockSession.EXPECT().UID().Return("uid").AnyTimes()
mockSession.EXPECT().ID().Return(int64(1)).Times(2)
mockSession.EXPECT().Set(constants.IPVersionKey, constants.IPv4)
mockSession.EXPECT().Close()

mockAgent.EXPECT().String().Return("")
mockAgent.EXPECT().GetStatus().AnyTimes()
mockAgent.EXPECT().SetStatus(constants.StatusHandshake)
mockAgent.EXPECT().GetSession().Return(mockSession).Times(7)
mockAgent.EXPECT().GetSession().Return(mockSession).AnyTimes()
mockAgent.EXPECT().IPVersion().Return(constants.IPv4)
mockAgent.EXPECT().RemoteAddr().Return(&mockAddr{}).AnyTimes()
mockAgent.EXPECT().SetLastAt().Do(func() {
Expand Down

0 comments on commit fa9721e

Please sign in to comment.