qlog the quic-go version

This only works when quic-go is used as a library.
This commit is contained in:
Marten Seemann
2021-02-07 19:26:12 +08:00
parent 622ca23d4e
commit 218b204e1b
2 changed files with 20 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ import (
"io"
"log"
"net"
"runtime/debug"
"sync"
"time"
@@ -17,6 +18,24 @@ import (
"github.com/francoispqt/gojay"
)
var quicGoVersion = "(devel)"
func init() {
info, ok := debug.ReadBuildInfo()
if !ok { // no build info available. This happens when quic-go is not used as a library.
return
}
for _, d := range info.Deps {
if d.Path == "github.com/lucas-clemente/quic-go" {
quicGoVersion = d.Version
if d.Replace != nil {
quicGoVersion += " (replaced)"
}
break
}
}
}
const eventChanSize = 50
type tracer struct {

View File

@@ -17,6 +17,7 @@ func (l topLevel) MarshalJSONObject(enc *gojay.Encoder) {
enc.StringKey("qlog_format", "NDJSON")
enc.StringKey("qlog_version", "draft-02")
enc.StringKeyOmitEmpty("title", "quic-go qlog")
enc.StringKey("code_version", quicGoVersion)
enc.ObjectKey("trace", l.trace)
}