diff --git a/qlog/qlog.go b/qlog/qlog.go index 993e979bb..a53ceeac9 100644 --- a/qlog/qlog.go +++ b/qlog/qlog.go @@ -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 { diff --git a/qlog/trace.go b/qlog/trace.go index 4c299644a..253ca270f 100644 --- a/qlog/trace.go +++ b/qlog/trace.go @@ -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) }