Skip to content

Commit a6fbf34

Browse files
echistyakovfacebook-github-bot
authored andcommitted
Add ConnsTLSAccepted metric
Summary: Reimplement D79220681 using the new `ServerObserver`. Reviewed By: podtserkovskiy Differential Revision: D83169371 fbshipit-source-id: 0f1fc1f9306fdcb00c179c787f0853ec7bae373f
1 parent 58803f1 commit a6fbf34

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

thrift/lib/go/thrift/rocket_server_transport.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ func (r *rocketServerTransport) acceptLoop(ctx context.Context) error {
114114
// Read/Write calls - so that we can access ALPN value and choose the transport.
115115
tlsConn, isTLS := conn.(tlsConnectionStaterHandshaker)
116116
if isTLS {
117+
r.observer.ConnTLSAccepted()
117118
r.stats.ConnsTLS.RecordEvent()
118119

119120
err = tlsConn.HandshakeContext(ctx)

thrift/lib/go/thrift/server_observer.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ import "time"
2222
// for monitoring and troubleshooting purposes.
2323
type ServerObserver interface {
2424
// Connection lifecycle events
25-
ConnDropped() // server-initiated connection close
26-
ConnAccepted() // new connection successfully accepted
25+
ConnDropped() // server-initiated connection close
26+
ConnAccepted() // new connection successfully accepted
27+
ConnTLSAccepted() // new TLS connection successfully accepted
2728

2829
// Request processing events
2930
TaskKilled() // request rejected due to parsing errors or shutdown

thrift/lib/go/thrift/server_observer_noop.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ func newNoopServerObserver() ServerObserver {
3434
// All methods are no-op implementations
3535

3636
// Connection lifecycle events
37-
func (*noopServerObserver) ConnDropped() {}
38-
func (*noopServerObserver) ConnAccepted() {}
37+
func (*noopServerObserver) ConnDropped() {}
38+
func (*noopServerObserver) ConnAccepted() {}
39+
func (*noopServerObserver) ConnTLSAccepted() {}
3940

4041
// Request processing events
4142
func (*noopServerObserver) TaskKilled() {}

thrift/lib/go/thrift/server_observer_noop_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ func TestNoopServerObserver(t *testing.T) {
3131

3232
// Test that all methods can be called without panicking
3333
observer.ConnDropped()
34+
observer.ConnAccepted()
35+
observer.ConnTLSAccepted()
3436
observer.TaskKilled()
3537
observer.TaskTimeout()
3638
observer.DeclaredException()
@@ -39,6 +41,5 @@ func TestNoopServerObserver(t *testing.T) {
3941
observer.ReceivedRequest()
4042
observer.SentReply()
4143
observer.ActiveRequests(10)
42-
observer.ConnAccepted()
4344
observer.ProcessTime(200 * time.Millisecond)
4445
}

0 commit comments

Comments
 (0)