mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-05 05:07:36 +03:00
remove the metrics package
Recording every sent and received packet in OpenCensus is quite expensive. Arguably, the metrics needs depend on the application, so that's where the implementation of a metrics collector should live anyway.
This commit is contained in:
parent
622ca23d4e
commit
aa68b3015d
7 changed files with 62 additions and 349 deletions
|
@ -41,8 +41,8 @@ jobs:
|
|||
name: "Run self integration tests with race detector"
|
||||
command: ginkgo -race -v -randomizeAllSpecs -trace integrationtests/self
|
||||
- run:
|
||||
name: "Run self integration tests with qlog and metrics"
|
||||
command: ginkgo -v -randomizeAllSpecs -trace integrationtests/self -- -qlog -metrics
|
||||
name: "Run self integration tests with qlog"
|
||||
command: ginkgo -v -randomizeAllSpecs -trace integrationtests/self -- -qlog
|
||||
go114:
|
||||
<<: *test
|
||||
go115:
|
||||
|
|
2
go.mod
2
go.mod
|
@ -5,7 +5,6 @@ go 1.14
|
|||
require (
|
||||
github.com/cheekybits/genny v1.0.0
|
||||
github.com/francoispqt/gojay v1.2.13
|
||||
github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9 // indirect
|
||||
github.com/golang/mock v1.4.4
|
||||
github.com/marten-seemann/qpack v0.2.1
|
||||
github.com/marten-seemann/qtls v0.10.0
|
||||
|
@ -13,7 +12,6 @@ require (
|
|||
github.com/marten-seemann/qtls-go1-16 v0.1.0-rc.1
|
||||
github.com/onsi/ginkgo v1.14.0
|
||||
github.com/onsi/gomega v1.10.1
|
||||
go.opencensus.io v0.22.2
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
|
||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
|
||||
|
|
16
go.sum
16
go.sum
|
@ -16,7 +16,6 @@ github.com/cheekybits/genny v1.0.0 h1:uGGa4nei+j20rOSeDeP5Of12XVm7TGUd4dJA9RDitf
|
|||
github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
|
@ -32,9 +31,6 @@ github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aev
|
|||
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9 h1:uHTyIjqVhYRhLbJ8nIiOJHkEZZ+5YoOsAbD3sk82NiE=
|
||||
github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.2.0 h1:28o5sBqPkBsMGnC6b4MvE2TzSr5/AT4c/1fLqVGIwlk=
|
||||
|
@ -141,18 +137,13 @@ github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYED
|
|||
github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw=
|
||||
github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:UdhH50NIW0fCiwBSr0co2m7BnFLdv4fQTgdqdJTHFeE=
|
||||
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
|
||||
github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU=
|
||||
github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM=
|
||||
go.opencensus.io v0.18.0 h1:Mk5rgZcggtbvtAun5aJzAtjKKN/t0R3jJPlWILlv938=
|
||||
go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA=
|
||||
go.opencensus.io v0.22.2 h1:75k/FF0Q2YM8QYo07VPddOLBslDt1MZOdEslOHvmzAs=
|
||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE=
|
||||
golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d/go.mod h1:OWs+y06UdEOHN4y+MfF/py+xQ/tYqIWW03b70/CG9Rw=
|
||||
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
|
@ -166,7 +157,6 @@ golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL
|
|||
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
|
@ -178,8 +168,6 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn
|
|||
golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgNrpq9mjcfDemuexIKsU=
|
||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
|
@ -202,7 +190,6 @@ golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5h
|
|||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190316082340-a2f829d7f35f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
|
@ -226,7 +213,6 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
|
|||
golang.org/x/tools v0.0.0-20181030000716-a0a13e073c7b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
@ -242,12 +228,10 @@ google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoA
|
|||
google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg=
|
||||
google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
|
||||
google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio=
|
||||
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
|
|
|
@ -23,7 +23,6 @@ import (
|
|||
"github.com/lucas-clemente/quic-go"
|
||||
"github.com/lucas-clemente/quic-go/internal/utils"
|
||||
"github.com/lucas-clemente/quic-go/logging"
|
||||
"github.com/lucas-clemente/quic-go/metrics"
|
||||
"github.com/lucas-clemente/quic-go/qlog"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
|
@ -88,7 +87,6 @@ var (
|
|||
logBufOnce sync.Once
|
||||
logBuf *syncedBuffer
|
||||
enableQlog bool
|
||||
enableMetrics bool
|
||||
|
||||
tlsConfig *tls.Config
|
||||
tlsConfigLongChain *tls.Config
|
||||
|
@ -101,8 +99,6 @@ var (
|
|||
func init() {
|
||||
flag.StringVar(&logFileName, "logfile", "", "log file")
|
||||
flag.BoolVar(&enableQlog, "qlog", false, "enable qlog")
|
||||
// metrics won't be accessible anywhere, but it's useful to exercise the code
|
||||
flag.BoolVar(&enableMetrics, "metrics", false, "enable metrics")
|
||||
}
|
||||
|
||||
var _ = BeforeSuite(func() {
|
||||
|
@ -136,9 +132,8 @@ var _ = BeforeSuite(func() {
|
|||
NextProtos: []string{alpn},
|
||||
}
|
||||
|
||||
var qlogTracer, metricsTracer logging.Tracer
|
||||
if enableQlog {
|
||||
qlogTracer = qlog.NewTracer(func(p logging.Perspective, connectionID []byte) io.WriteCloser {
|
||||
tracer = qlog.NewTracer(func(p logging.Perspective, connectionID []byte) io.WriteCloser {
|
||||
role := "server"
|
||||
if p == logging.PerspectiveClient {
|
||||
role = "client"
|
||||
|
@ -151,17 +146,6 @@ var _ = BeforeSuite(func() {
|
|||
return utils.NewBufferedWriteCloser(bw, f)
|
||||
})
|
||||
}
|
||||
if enableMetrics {
|
||||
metricsTracer = metrics.NewTracer()
|
||||
}
|
||||
|
||||
if enableQlog && enableMetrics {
|
||||
tracer = logging.NewMultiplexedTracer(qlogTracer, metricsTracer)
|
||||
} else if enableQlog {
|
||||
tracer = qlogTracer
|
||||
} else if enableMetrics {
|
||||
tracer = metricsTracer
|
||||
}
|
||||
})
|
||||
|
||||
func generateCA() (*x509.Certificate, *rsa.PrivateKey, error) {
|
||||
|
|
|
@ -9,24 +9,74 @@ import (
|
|||
"io/ioutil"
|
||||
mrand "math/rand"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
"github.com/lucas-clemente/quic-go/internal/utils"
|
||||
"github.com/lucas-clemente/quic-go/logging"
|
||||
"github.com/lucas-clemente/quic-go/metrics"
|
||||
"github.com/lucas-clemente/quic-go/qlog"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
type customTracer struct{}
|
||||
|
||||
var _ logging.Tracer = &customTracer{}
|
||||
|
||||
func (t *customTracer) TracerForConnection(p logging.Perspective, odcid logging.ConnectionID) logging.ConnectionTracer {
|
||||
return &customConnTracer{}
|
||||
}
|
||||
func (t *customTracer) SentPacket(net.Addr, *logging.Header, logging.ByteCount, []logging.Frame) {}
|
||||
func (t *customTracer) DroppedPacket(net.Addr, logging.PacketType, logging.ByteCount, logging.PacketDropReason) {
|
||||
}
|
||||
|
||||
type customConnTracer struct{}
|
||||
|
||||
var _ logging.ConnectionTracer = &customConnTracer{}
|
||||
|
||||
func (t *customConnTracer) StartedConnection(local, remote net.Addr, version logging.VersionNumber, srcConnID, destConnID logging.ConnectionID) {
|
||||
}
|
||||
func (t *customConnTracer) ClosedConnection(logging.CloseReason) {}
|
||||
func (t *customConnTracer) SentTransportParameters(*logging.TransportParameters) {}
|
||||
func (t *customConnTracer) ReceivedTransportParameters(*logging.TransportParameters) {}
|
||||
func (t *customConnTracer) RestoredTransportParameters(*logging.TransportParameters) {}
|
||||
func (t *customConnTracer) SentPacket(hdr *logging.ExtendedHeader, size logging.ByteCount, ack *logging.AckFrame, frames []logging.Frame) {
|
||||
}
|
||||
|
||||
func (t *customConnTracer) ReceivedVersionNegotiationPacket(*logging.Header, []logging.VersionNumber) {
|
||||
}
|
||||
func (t *customConnTracer) ReceivedRetry(*logging.Header) {}
|
||||
func (t *customConnTracer) ReceivedPacket(hdr *logging.ExtendedHeader, size logging.ByteCount, frames []logging.Frame) {
|
||||
}
|
||||
func (t *customConnTracer) BufferedPacket(logging.PacketType) {}
|
||||
func (t *customConnTracer) DroppedPacket(logging.PacketType, logging.ByteCount, logging.PacketDropReason) {
|
||||
}
|
||||
|
||||
func (t *customConnTracer) UpdatedMetrics(rttStats *logging.RTTStats, cwnd, bytesInFlight logging.ByteCount, packetsInFlight int) {
|
||||
}
|
||||
|
||||
func (t *customConnTracer) LostPacket(logging.EncryptionLevel, logging.PacketNumber, logging.PacketLossReason) {
|
||||
}
|
||||
func (t *customConnTracer) UpdatedCongestionState(logging.CongestionState) {}
|
||||
func (t *customConnTracer) UpdatedPTOCount(value uint32) {}
|
||||
func (t *customConnTracer) UpdatedKeyFromTLS(logging.EncryptionLevel, logging.Perspective) {}
|
||||
func (t *customConnTracer) UpdatedKey(generation logging.KeyPhase, remote bool) {}
|
||||
func (t *customConnTracer) DroppedEncryptionLevel(logging.EncryptionLevel) {}
|
||||
func (t *customConnTracer) DroppedKey(logging.KeyPhase) {}
|
||||
func (t *customConnTracer) SetLossTimer(logging.TimerType, logging.EncryptionLevel, time.Time) {}
|
||||
func (t *customConnTracer) LossTimerExpired(logging.TimerType, logging.EncryptionLevel) {}
|
||||
func (t *customConnTracer) LossTimerCanceled() {}
|
||||
func (t *customConnTracer) Debug(string, string) {}
|
||||
func (t *customConnTracer) Close() {}
|
||||
|
||||
var _ = Describe("Handshake tests", func() {
|
||||
addTracers := func(pers protocol.Perspective, conf *quic.Config) *quic.Config {
|
||||
enableQlog := mrand.Int()%3 != 0
|
||||
enableMetrics := mrand.Int()%3 != 0
|
||||
enableCustomTracer := mrand.Int()%3 != 0
|
||||
|
||||
fmt.Fprintf(GinkgoWriter, "%s using qlog: %t, metrics: %t\n", pers, enableQlog, enableMetrics)
|
||||
fmt.Fprintf(GinkgoWriter, "%s using qlog: %t, custom: %t\n", pers, enableQlog, enableCustomTracer)
|
||||
|
||||
var tracers []logging.Tracer
|
||||
if enableQlog {
|
||||
|
@ -39,8 +89,8 @@ var _ = Describe("Handshake tests", func() {
|
|||
return utils.NewBufferedWriteCloser(bufio.NewWriter(&bytes.Buffer{}), ioutil.NopCloser(nil))
|
||||
}))
|
||||
}
|
||||
if enableMetrics {
|
||||
tracers = append(tracers, metrics.NewTracer())
|
||||
if enableCustomTracer {
|
||||
tracers = append(tracers, &customTracer{})
|
||||
}
|
||||
c := conf.Clone()
|
||||
c.Tracer = logging.NewMultiplexedTracer(tracers...)
|
||||
|
|
|
@ -1,223 +0,0 @@
|
|||
package metrics
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/internal/utils"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
"github.com/lucas-clemente/quic-go/logging"
|
||||
|
||||
"go.opencensus.io/stats"
|
||||
"go.opencensus.io/stats/view"
|
||||
"go.opencensus.io/tag"
|
||||
)
|
||||
|
||||
// Measures
|
||||
var (
|
||||
connections = stats.Int64("quic-go/connections", "number of QUIC connections", stats.UnitDimensionless)
|
||||
lostPackets = stats.Int64("quic-go/lost-packets", "number of packets declared lost", stats.UnitDimensionless)
|
||||
sentPackets = stats.Int64("quic-go/sent-packets", "number of packets sent", stats.UnitDimensionless)
|
||||
ptos = stats.Int64("quic-go/ptos", "number of times the PTO timer fired", stats.UnitDimensionless)
|
||||
closes = stats.Int64("quic-go/close", "number of connections closed", stats.UnitDimensionless)
|
||||
)
|
||||
|
||||
// Tags
|
||||
var (
|
||||
keyPerspective, _ = tag.NewKey("perspective")
|
||||
keyIPVersion, _ = tag.NewKey("ip_version")
|
||||
keyEncryptionLevel, _ = tag.NewKey("encryption_level")
|
||||
keyPacketLossReason, _ = tag.NewKey("packet_loss_reason")
|
||||
keyPacketType, _ = tag.NewKey("packet_type")
|
||||
keyCloseReason, _ = tag.NewKey("close_reason")
|
||||
keyCloseRemote, _ = tag.NewKey("close_remote")
|
||||
keyErrorCode, _ = tag.NewKey("error_code")
|
||||
keyHandshakePhase, _ = tag.NewKey("handshake_phase")
|
||||
)
|
||||
|
||||
// Views
|
||||
var (
|
||||
ConnectionsView = &view.View{
|
||||
Measure: connections,
|
||||
TagKeys: []tag.Key{keyPerspective, keyIPVersion},
|
||||
Aggregation: view.Count(),
|
||||
}
|
||||
LostPacketsView = &view.View{
|
||||
Measure: lostPackets,
|
||||
TagKeys: []tag.Key{keyEncryptionLevel, keyPacketLossReason},
|
||||
Aggregation: view.Count(),
|
||||
}
|
||||
SentPacketsView = &view.View{
|
||||
Measure: sentPackets,
|
||||
TagKeys: []tag.Key{keyPacketType},
|
||||
Aggregation: view.Count(),
|
||||
}
|
||||
PTOView = &view.View{
|
||||
Measure: ptos,
|
||||
TagKeys: []tag.Key{keyHandshakePhase},
|
||||
Aggregation: view.Count(),
|
||||
}
|
||||
CloseView = &view.View{
|
||||
Measure: closes,
|
||||
TagKeys: []tag.Key{keyCloseReason, keyErrorCode},
|
||||
Aggregation: view.Count(),
|
||||
}
|
||||
)
|
||||
|
||||
// DefaultViews collects all OpenCensus views for metric gathering purposes
|
||||
var DefaultViews = []*view.View{
|
||||
ConnectionsView,
|
||||
LostPacketsView,
|
||||
SentPacketsView,
|
||||
CloseView,
|
||||
}
|
||||
|
||||
type tracer struct{}
|
||||
|
||||
var _ logging.Tracer = &tracer{}
|
||||
|
||||
// NewTracer creates a new metrics tracer.
|
||||
func NewTracer() logging.Tracer { return &tracer{} }
|
||||
|
||||
func (t *tracer) TracerForConnection(p logging.Perspective, _ logging.ConnectionID) logging.ConnectionTracer {
|
||||
return newConnTracer(t, p)
|
||||
}
|
||||
|
||||
func (t *tracer) SentPacket(_ net.Addr, hdr *logging.Header, _ protocol.ByteCount, _ []logging.Frame) {
|
||||
stats.RecordWithTags(
|
||||
context.Background(),
|
||||
[]tag.Mutator{
|
||||
tag.Upsert(keyPacketType, packetType(logging.PacketTypeFromHeader(hdr)).String()),
|
||||
},
|
||||
sentPackets.M(1),
|
||||
)
|
||||
}
|
||||
|
||||
func (t *tracer) DroppedPacket(net.Addr, logging.PacketType, logging.ByteCount, logging.PacketDropReason) {
|
||||
}
|
||||
|
||||
type connTracer struct {
|
||||
perspective logging.Perspective
|
||||
tracer logging.Tracer
|
||||
|
||||
handshakeComplete bool
|
||||
}
|
||||
|
||||
func newConnTracer(tracer logging.Tracer, perspective logging.Perspective) logging.ConnectionTracer {
|
||||
return &connTracer{
|
||||
perspective: perspective,
|
||||
tracer: tracer,
|
||||
}
|
||||
}
|
||||
|
||||
var _ logging.ConnectionTracer = &connTracer{}
|
||||
|
||||
func (t *connTracer) StartedConnection(local, _ net.Addr, _ logging.VersionNumber, _, _ logging.ConnectionID) {
|
||||
perspectiveTag := tag.Upsert(keyPerspective, perspective(t.perspective).String())
|
||||
|
||||
var ipVersionTag tag.Mutator
|
||||
if udpAddr, ok := local.(*net.UDPAddr); ok {
|
||||
if utils.IsIPv4(udpAddr.IP) {
|
||||
ipVersionTag = tag.Upsert(keyIPVersion, "IPv4")
|
||||
} else {
|
||||
ipVersionTag = tag.Upsert(keyIPVersion, "IPv6")
|
||||
}
|
||||
} else {
|
||||
ipVersionTag = tag.Upsert(keyIPVersion, "unknown")
|
||||
}
|
||||
|
||||
stats.RecordWithTags(
|
||||
context.Background(),
|
||||
[]tag.Mutator{perspectiveTag, ipVersionTag},
|
||||
connections.M(1),
|
||||
)
|
||||
}
|
||||
|
||||
func (t *connTracer) ClosedConnection(r logging.CloseReason) {
|
||||
var tags []tag.Mutator
|
||||
if timeout, ok := r.Timeout(); ok {
|
||||
tags = []tag.Mutator{
|
||||
tag.Upsert(keyCloseReason, timeoutReason(timeout).String()),
|
||||
tag.Upsert(keyCloseRemote, "false"),
|
||||
}
|
||||
} else if _, ok := r.StatelessReset(); ok {
|
||||
tags = []tag.Mutator{
|
||||
tag.Upsert(keyCloseReason, "stateless_reset"),
|
||||
tag.Upsert(keyCloseRemote, "true"),
|
||||
}
|
||||
} else if errorCode, remote, ok := r.ApplicationError(); ok {
|
||||
tags = []tag.Mutator{
|
||||
tag.Upsert(keyCloseReason, "application_error"),
|
||||
tag.Upsert(keyErrorCode, errorCode.String()),
|
||||
tag.Upsert(keyCloseRemote, fmt.Sprintf("%t", remote)),
|
||||
}
|
||||
} else if errorCode, remote, ok := r.TransportError(); ok {
|
||||
tags = []tag.Mutator{
|
||||
tag.Upsert(keyCloseReason, "transport_error"),
|
||||
tag.Upsert(keyErrorCode, errorCode.String()),
|
||||
tag.Upsert(keyCloseRemote, fmt.Sprintf("%t", remote)),
|
||||
}
|
||||
}
|
||||
stats.RecordWithTags(context.Background(), tags, closes.M(1))
|
||||
}
|
||||
func (t *connTracer) SentTransportParameters(*logging.TransportParameters) {}
|
||||
func (t *connTracer) ReceivedTransportParameters(*logging.TransportParameters) {}
|
||||
func (t *connTracer) RestoredTransportParameters(*logging.TransportParameters) {}
|
||||
func (t *connTracer) SentPacket(hdr *logging.ExtendedHeader, _ logging.ByteCount, _ *logging.AckFrame, _ []logging.Frame) {
|
||||
typ := logging.PacketTypeFromHeader(&hdr.Header)
|
||||
if typ == logging.PacketType1RTT {
|
||||
t.handshakeComplete = true
|
||||
}
|
||||
stats.RecordWithTags(
|
||||
context.Background(),
|
||||
[]tag.Mutator{
|
||||
tag.Upsert(keyPacketType, packetType(typ).String()),
|
||||
},
|
||||
sentPackets.M(1),
|
||||
)
|
||||
}
|
||||
func (t *connTracer) ReceivedVersionNegotiationPacket(*logging.Header, []logging.VersionNumber) {}
|
||||
func (t *connTracer) ReceivedRetry(*logging.Header) {}
|
||||
func (t *connTracer) ReceivedPacket(*logging.ExtendedHeader, logging.ByteCount, []logging.Frame) {
|
||||
}
|
||||
func (t *connTracer) BufferedPacket(logging.PacketType) {}
|
||||
func (t *connTracer) DroppedPacket(logging.PacketType, logging.ByteCount, logging.PacketDropReason) {}
|
||||
func (t *connTracer) UpdatedCongestionState(logging.CongestionState) {}
|
||||
func (t *connTracer) UpdatedMetrics(*logging.RTTStats, logging.ByteCount, logging.ByteCount, int) {}
|
||||
func (t *connTracer) LostPacket(encLevel logging.EncryptionLevel, _ logging.PacketNumber, reason logging.PacketLossReason) {
|
||||
stats.RecordWithTags(
|
||||
context.Background(),
|
||||
[]tag.Mutator{
|
||||
tag.Upsert(keyEncryptionLevel, encryptionLevel(encLevel).String()),
|
||||
tag.Upsert(keyPacketLossReason, packetLossReason(reason).String()),
|
||||
},
|
||||
lostPackets.M(1),
|
||||
)
|
||||
}
|
||||
|
||||
func (t *connTracer) UpdatedPTOCount(value uint32) {
|
||||
if value == 0 {
|
||||
return
|
||||
}
|
||||
phase := "during_handshake"
|
||||
if t.handshakeComplete {
|
||||
phase = "after_handshake"
|
||||
}
|
||||
stats.RecordWithTags(
|
||||
context.Background(),
|
||||
[]tag.Mutator{tag.Upsert(keyHandshakePhase, phase)},
|
||||
ptos.M(1),
|
||||
)
|
||||
}
|
||||
func (t *connTracer) UpdatedKeyFromTLS(logging.EncryptionLevel, logging.Perspective) {}
|
||||
func (t *connTracer) UpdatedKey(logging.KeyPhase, bool) {}
|
||||
func (t *connTracer) DroppedEncryptionLevel(logging.EncryptionLevel) {}
|
||||
func (t *connTracer) DroppedKey(logging.KeyPhase) {}
|
||||
func (t *connTracer) SetLossTimer(logging.TimerType, logging.EncryptionLevel, time.Time) {}
|
||||
func (t *connTracer) LossTimerExpired(logging.TimerType, logging.EncryptionLevel) {}
|
||||
func (t *connTracer) LossTimerCanceled() {}
|
||||
func (t *connTracer) Debug(string, string) {}
|
||||
func (t *connTracer) Close() {}
|
|
@ -1,80 +0,0 @@
|
|||
package metrics
|
||||
|
||||
import "github.com/lucas-clemente/quic-go/logging"
|
||||
|
||||
type perspective logging.Perspective
|
||||
|
||||
func (p perspective) String() string {
|
||||
switch logging.Perspective(p) {
|
||||
case logging.PerspectiveClient:
|
||||
return "client"
|
||||
case logging.PerspectiveServer:
|
||||
return "server"
|
||||
default:
|
||||
return "unknown perspective"
|
||||
}
|
||||
}
|
||||
|
||||
type encryptionLevel logging.EncryptionLevel
|
||||
|
||||
func (e encryptionLevel) String() string {
|
||||
switch logging.EncryptionLevel(e) {
|
||||
case logging.EncryptionInitial:
|
||||
return "initial"
|
||||
case logging.EncryptionHandshake:
|
||||
return "handshake"
|
||||
case logging.Encryption0RTT:
|
||||
return "0-RTT"
|
||||
case logging.Encryption1RTT:
|
||||
return "1-RTT"
|
||||
default:
|
||||
return "unknown encryption level"
|
||||
}
|
||||
}
|
||||
|
||||
type packetLossReason logging.PacketLossReason
|
||||
|
||||
func (r packetLossReason) String() string {
|
||||
switch logging.PacketLossReason(r) {
|
||||
case logging.PacketLossTimeThreshold:
|
||||
return "time_threshold"
|
||||
case logging.PacketLossReorderingThreshold:
|
||||
return "reordering_threshold"
|
||||
default:
|
||||
return "unknown packet loss reason"
|
||||
}
|
||||
}
|
||||
|
||||
type packetType logging.PacketType
|
||||
|
||||
func (t packetType) String() string {
|
||||
switch logging.PacketType(t) {
|
||||
case logging.PacketTypeInitial:
|
||||
return "initial"
|
||||
case logging.PacketTypeHandshake:
|
||||
return "handshake"
|
||||
case logging.PacketTypeVersionNegotiation:
|
||||
return "version_negotiation"
|
||||
case logging.PacketTypeRetry:
|
||||
return "retry"
|
||||
case logging.PacketType0RTT:
|
||||
return "0-RTT"
|
||||
case logging.PacketType1RTT:
|
||||
return "1-RTT"
|
||||
default:
|
||||
return "unknown packet type"
|
||||
}
|
||||
}
|
||||
|
||||
type timeoutReason logging.TimeoutReason
|
||||
|
||||
func (r timeoutReason) String() string {
|
||||
switch logging.TimeoutReason(r) {
|
||||
case logging.TimeoutReasonHandshake:
|
||||
return "handshake_timeout"
|
||||
case logging.TimeoutReasonIdle:
|
||||
return "idle_timeout"
|
||||
default:
|
||||
return "unknown timeout reason"
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue