Upgrade versions of vendored libs
This commit is contained in:
32
go.mod
32
go.mod
@@ -1,10 +1,12 @@
|
|||||||
module aleesa-irc-go
|
module aleesa-irc-go
|
||||||
|
|
||||||
go 1.22
|
go 1.22.0
|
||||||
|
|
||||||
|
toolchain go1.23.4
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/cockroachdb/errors v1.11.3
|
github.com/cockroachdb/errors v1.11.3
|
||||||
github.com/cockroachdb/pebble v1.1.1
|
github.com/cockroachdb/pebble v1.1.4
|
||||||
github.com/go-redis/redis/v8 v8.11.5
|
github.com/go-redis/redis/v8 v8.11.5
|
||||||
github.com/hjson/hjson-go v3.3.0+incompatible
|
github.com/hjson/hjson-go v3.3.0+incompatible
|
||||||
github.com/sirupsen/logrus v1.9.3
|
github.com/sirupsen/logrus v1.9.3
|
||||||
@@ -15,27 +17,27 @@ require (
|
|||||||
github.com/DataDog/zstd v1.5.6 // indirect
|
github.com/DataDog/zstd v1.5.6 // indirect
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
github.com/cockroachdb/fifo v0.0.0-20240616162244-4768e80dfb9a // indirect
|
github.com/cockroachdb/fifo v0.0.0-20240816210425-c5d0cb0b6fc0 // indirect
|
||||||
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
|
github.com/cockroachdb/logtags v0.0.0-20241215232642-bb51bb14a506 // indirect
|
||||||
github.com/cockroachdb/redact v1.1.5 // indirect
|
github.com/cockroachdb/redact v1.1.6 // indirect
|
||||||
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
|
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||||
github.com/getsentry/sentry-go v0.28.1 // indirect
|
github.com/getsentry/sentry-go v0.31.1 // indirect
|
||||||
github.com/gogo/protobuf v1.3.2 // indirect
|
github.com/gogo/protobuf v1.3.2 // indirect
|
||||||
github.com/golang/snappy v0.0.4 // indirect
|
github.com/golang/snappy v0.0.4 // indirect
|
||||||
github.com/klauspost/compress v1.17.9 // indirect
|
github.com/klauspost/compress v1.17.11 // indirect
|
||||||
github.com/kr/pretty v0.3.1 // indirect
|
github.com/kr/pretty v0.3.1 // indirect
|
||||||
github.com/kr/text v0.2.0 // indirect
|
github.com/kr/text v0.2.0 // indirect
|
||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/prometheus/client_golang v1.19.1 // indirect
|
github.com/prometheus/client_golang v1.20.5 // indirect
|
||||||
github.com/prometheus/client_model v0.6.1 // indirect
|
github.com/prometheus/client_model v0.6.1 // indirect
|
||||||
github.com/prometheus/common v0.55.0 // indirect
|
github.com/prometheus/common v0.62.0 // indirect
|
||||||
github.com/prometheus/procfs v0.15.1 // indirect
|
github.com/prometheus/procfs v0.15.1 // indirect
|
||||||
github.com/rogpeppe/go-internal v1.12.0 // indirect
|
github.com/rogpeppe/go-internal v1.13.1 // indirect
|
||||||
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
|
golang.org/x/exp v0.0.0-20250207012021-f9890c6ad9f3 // indirect
|
||||||
golang.org/x/net v0.27.0 // indirect
|
golang.org/x/net v0.34.0 // indirect
|
||||||
golang.org/x/sys v0.22.0 // indirect
|
golang.org/x/sys v0.30.0 // indirect
|
||||||
golang.org/x/text v0.16.0 // indirect
|
golang.org/x/text v0.22.0 // indirect
|
||||||
google.golang.org/protobuf v1.34.2 // indirect
|
google.golang.org/protobuf v1.36.5 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
70
go.sum
70
go.sum
@@ -8,14 +8,14 @@ github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaY
|
|||||||
github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU=
|
github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU=
|
||||||
github.com/cockroachdb/errors v1.11.3 h1:5bA+k2Y6r+oz/6Z/RFlNeVCesGARKuC6YymtcDrbC/I=
|
github.com/cockroachdb/errors v1.11.3 h1:5bA+k2Y6r+oz/6Z/RFlNeVCesGARKuC6YymtcDrbC/I=
|
||||||
github.com/cockroachdb/errors v1.11.3/go.mod h1:m4UIW4CDjx+R5cybPsNrRbreomiFqt8o1h1wUVazSd8=
|
github.com/cockroachdb/errors v1.11.3/go.mod h1:m4UIW4CDjx+R5cybPsNrRbreomiFqt8o1h1wUVazSd8=
|
||||||
github.com/cockroachdb/fifo v0.0.0-20240616162244-4768e80dfb9a h1:f52TdbU4D5nozMAhO9TvTJ2ZMCXtN4VIAmfrrZ0JXQ4=
|
github.com/cockroachdb/fifo v0.0.0-20240816210425-c5d0cb0b6fc0 h1:pU88SPhIFid6/k0egdR5V6eALQYq2qbSmukrkgIh/0A=
|
||||||
github.com/cockroachdb/fifo v0.0.0-20240616162244-4768e80dfb9a/go.mod h1:9/y3cnZ5GKakj/H4y9r9GTjCvAFta7KLgSHPJJYc52M=
|
github.com/cockroachdb/fifo v0.0.0-20240816210425-c5d0cb0b6fc0/go.mod h1:9/y3cnZ5GKakj/H4y9r9GTjCvAFta7KLgSHPJJYc52M=
|
||||||
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE=
|
github.com/cockroachdb/logtags v0.0.0-20241215232642-bb51bb14a506 h1:ASDL+UJcILMqgNeV5jiqR4j+sTuvQNHdf2chuKj1M5k=
|
||||||
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs=
|
github.com/cockroachdb/logtags v0.0.0-20241215232642-bb51bb14a506/go.mod h1:Mw7HqKr2kdtu6aYGn3tPmAftiP3QPX63LdK/zcariIo=
|
||||||
github.com/cockroachdb/pebble v1.1.1 h1:XnKU22oiCLy2Xn8vp1re67cXg4SAasg/WDt1NtcRFaw=
|
github.com/cockroachdb/pebble v1.1.4 h1:5II1uEP4MyHLDnsrbv/EZ36arcb9Mxg3n+owhZ3GrG8=
|
||||||
github.com/cockroachdb/pebble v1.1.1/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU=
|
github.com/cockroachdb/pebble v1.1.4/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU=
|
||||||
github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30=
|
github.com/cockroachdb/redact v1.1.6 h1:zXJBwDZ84xJNlHl1rMyCojqyIxv+7YUpQiJLQ7n4314=
|
||||||
github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
|
github.com/cockroachdb/redact v1.1.6/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
|
||||||
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo=
|
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo=
|
||||||
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ=
|
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ=
|
||||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
@@ -26,8 +26,8 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r
|
|||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||||
github.com/getsentry/sentry-go v0.28.1 h1:zzaSm/vHmGllRM6Tpx1492r0YDzauArdBfkJRtY6P5k=
|
github.com/getsentry/sentry-go v0.31.1 h1:ELVc0h7gwyhnXHDouXkhqTFSO5oslsRDk0++eyE0KJ4=
|
||||||
github.com/getsentry/sentry-go v0.28.1/go.mod h1:1fQZ+7l7eeJ3wYi82q5Hg8GqAPgefRq+FP/QhafYVgg=
|
github.com/getsentry/sentry-go v0.31.1/go.mod h1:CYNcMMz73YigoHljQRG+qPF+eMq8gG72XcGN/p71BAY=
|
||||||
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
|
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
|
||||||
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
|
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
|
||||||
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
|
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
|
||||||
@@ -42,16 +42,16 @@ github.com/hjson/hjson-go v3.3.0+incompatible h1:Rqr+Ya+0aCJMjaE4s8E9YKvuJLuLVpE
|
|||||||
github.com/hjson/hjson-go v3.3.0+incompatible/go.mod h1:qsetwF8NlsTsOTwZTApNlTCerV+b2GjYRRcIk4JMFio=
|
github.com/hjson/hjson-go v3.3.0+incompatible/go.mod h1:qsetwF8NlsTsOTwZTApNlTCerV+b2GjYRRcIk4JMFio=
|
||||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
|
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
|
||||||
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
|
||||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||||
github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY=
|
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||||
github.com/nxadm/tail v1.4.11/go.mod h1:OTaG3NK980DZzxbRq6lEuzgU+mug70nY11sMd4JXXHc=
|
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
||||||
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||||
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
|
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
|
||||||
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
||||||
@@ -63,32 +63,34 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
|||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE=
|
github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
|
||||||
github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho=
|
github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
|
||||||
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
|
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
|
||||||
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
||||||
github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc=
|
github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io=
|
||||||
github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8=
|
github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I=
|
||||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
||||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
||||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||||
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
|
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
|
||||||
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
|
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
|
||||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
github.com/thoj/go-ircevent v0.0.0-20210723090443-73e444401d64 h1:l/T7dYuJEQZOwVOpjIXr1180aM9PZL/d1MnMVIxefX4=
|
github.com/thoj/go-ircevent v0.0.0-20210723090443-73e444401d64 h1:l/T7dYuJEQZOwVOpjIXr1180aM9PZL/d1MnMVIxefX4=
|
||||||
github.com/thoj/go-ircevent v0.0.0-20210723090443-73e444401d64/go.mod h1:Q1NAJOuRdQCqN/VIWdnaaEhV8LpeO2rtlBP7/iDJNII=
|
github.com/thoj/go-ircevent v0.0.0-20210723090443-73e444401d64/go.mod h1:Q1NAJOuRdQCqN/VIWdnaaEhV8LpeO2rtlBP7/iDJNII=
|
||||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
|
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||||
|
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8=
|
golang.org/x/exp v0.0.0-20250207012021-f9890c6ad9f3 h1:qNgPs5exUA+G0C96DrPwNrvLSj7GT/9D+3WMWUcUg34=
|
||||||
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
|
golang.org/x/exp v0.0.0-20250207012021-f9890c6ad9f3/go.mod h1:tujkw807nyEEAamNbDrEGzRav+ilXA7PCRAd6xsmwiU=
|
||||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
@@ -96,27 +98,27 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
|
|||||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
|
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
|
||||||
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
|
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
|
||||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
|
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
|
||||||
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
|
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
|
||||||
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||||
@@ -125,8 +127,8 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
|
|||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
|
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
|
||||||
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
|
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||||
|
|||||||
3
vendor/github.com/cockroachdb/fifo/README.md
generated
vendored
Normal file
3
vendor/github.com/cockroachdb/fifo/README.md
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
DEPRECATED
|
||||||
|
|
||||||
|
Moved to [github.com/cockroachdb/crlib](https://github.com/cockroachdb/crlib/tree/main/fifo)
|
||||||
40
vendor/github.com/cockroachdb/logtags/buffer.go
generated
vendored
40
vendor/github.com/cockroachdb/logtags/buffer.go
generated
vendored
@@ -26,13 +26,47 @@ type Buffer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SingleTagBuffer returns a Buffer with a single tag.
|
// SingleTagBuffer returns a Buffer with a single tag.
|
||||||
func SingleTagBuffer(key string, value interface{}) *Buffer {
|
func SingleTagBuffer(key string, value any) *Buffer {
|
||||||
b := &Buffer{}
|
b := &Buffer{}
|
||||||
b.init(1, 1)
|
b.init(1, 1)
|
||||||
b.tags[0] = Tag{key: key, value: value}
|
b.tags[0] = Tag{key: key, value: value}
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BuildBuffer is used to build a *Buffer that contains an arbitrary number
|
||||||
|
// of tags. Sample usage:
|
||||||
|
//
|
||||||
|
// bld := BuildBuffer()
|
||||||
|
// bld.Add("a", 1)
|
||||||
|
// bld.Add("b", 2)
|
||||||
|
// buf := bld.Finish()
|
||||||
|
//
|
||||||
|
// It is equivalent to using SingleTagBuffer() followed by Buffer.Add() calls,
|
||||||
|
// but avoids allocating each intermediate buffer.
|
||||||
|
func BuildBuffer() BufferBuilder {
|
||||||
|
bld := BufferBuilder{b: &Buffer{}}
|
||||||
|
bld.b.init(0, 0)
|
||||||
|
return bld
|
||||||
|
}
|
||||||
|
|
||||||
|
// BufferBuilder is returned by BuildBuffer.
|
||||||
|
type BufferBuilder struct {
|
||||||
|
b *Buffer
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add a log tag to the buffer. If the key was added already, the value is
|
||||||
|
// replaced.
|
||||||
|
func (bld *BufferBuilder) Add(key string, value any) {
|
||||||
|
bld.b.addOrReplace(key, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finish returns the buffer with the tags that were added to the builder.
|
||||||
|
func (bld *BufferBuilder) Finish() *Buffer {
|
||||||
|
b := bld.b
|
||||||
|
bld.b = nil
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
// Get returns the tags, as a slice. This slice must not be modified.
|
// Get returns the tags, as a slice. This slice must not be modified.
|
||||||
func (b *Buffer) Get() []Tag {
|
func (b *Buffer) Get() []Tag {
|
||||||
return b.tags
|
return b.tags
|
||||||
@@ -55,7 +89,7 @@ func (b *Buffer) GetTag(key string) (Tag, bool) {
|
|||||||
// Add returns a new buffer with one more tag. If the tag has the same key as an
|
// Add returns a new buffer with one more tag. If the tag has the same key as an
|
||||||
// earlier tag, that tag is overwritten.
|
// earlier tag, that tag is overwritten.
|
||||||
// The receiver can be nil.
|
// The receiver can be nil.
|
||||||
func (b *Buffer) Add(key string, value interface{}) *Buffer {
|
func (b *Buffer) Add(key string, value any) *Buffer {
|
||||||
if b == nil {
|
if b == nil {
|
||||||
return SingleTagBuffer(key, value)
|
return SingleTagBuffer(key, value)
|
||||||
}
|
}
|
||||||
@@ -191,7 +225,7 @@ func (b *Buffer) init(length, capacityHint int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Buffer) addOrReplace(key string, value interface{}) {
|
func (b *Buffer) addOrReplace(key string, value any) {
|
||||||
for i := range b.tags {
|
for i := range b.tags {
|
||||||
if b.tags[i].key == key {
|
if b.tags[i].key == key {
|
||||||
b.tags[i].value = value
|
b.tags[i].value = value
|
||||||
|
|||||||
22
vendor/github.com/cockroachdb/logtags/context.go
generated
vendored
22
vendor/github.com/cockroachdb/logtags/context.go
generated
vendored
@@ -21,6 +21,9 @@ type contextLogTagsKey struct{}
|
|||||||
// FromContext returns the tags stored in the context (by WithTags, AddTag, or
|
// FromContext returns the tags stored in the context (by WithTags, AddTag, or
|
||||||
// AddTags).
|
// AddTags).
|
||||||
func FromContext(ctx context.Context) *Buffer {
|
func FromContext(ctx context.Context) *Buffer {
|
||||||
|
if fromContextFn != nil {
|
||||||
|
return fromContextFn(ctx)
|
||||||
|
}
|
||||||
val := ctx.Value(contextLogTagsKey{})
|
val := ctx.Value(contextLogTagsKey{})
|
||||||
if val == nil {
|
if val == nil {
|
||||||
return nil
|
return nil
|
||||||
@@ -31,6 +34,9 @@ func FromContext(ctx context.Context) *Buffer {
|
|||||||
// WithTags returns a context with the given tags. Any existing tags are
|
// WithTags returns a context with the given tags. Any existing tags are
|
||||||
// ignored.
|
// ignored.
|
||||||
func WithTags(ctx context.Context, tags *Buffer) context.Context {
|
func WithTags(ctx context.Context, tags *Buffer) context.Context {
|
||||||
|
if withTagsFn != nil {
|
||||||
|
return withTagsFn(ctx, tags)
|
||||||
|
}
|
||||||
return context.WithValue(ctx, contextLogTagsKey{}, tags)
|
return context.WithValue(ctx, contextLogTagsKey{}, tags)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,3 +69,19 @@ func AddTags(ctx context.Context, tags *Buffer) context.Context {
|
|||||||
}
|
}
|
||||||
return WithTags(ctx, newB)
|
return WithTags(ctx, newB)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OverrideContextFuncs can be used to override the implementation of
|
||||||
|
// FromContext and WithTags. This is useful if we have a more efficient
|
||||||
|
// implementation of context-associated values.
|
||||||
|
//
|
||||||
|
// Must be called before WithTags or FromContext are called.
|
||||||
|
func OverrideContextFuncs(
|
||||||
|
fromContext func(ctx context.Context) *Buffer,
|
||||||
|
withTags func(ctx context.Context, tags *Buffer) context.Context,
|
||||||
|
) {
|
||||||
|
fromContextFn = fromContext
|
||||||
|
withTagsFn = withTags
|
||||||
|
}
|
||||||
|
|
||||||
|
var fromContextFn func(ctx context.Context) *Buffer
|
||||||
|
var withTagsFn func(ctx context.Context, tags *Buffer) context.Context
|
||||||
|
|||||||
11
vendor/github.com/cockroachdb/pebble/checkpoint.go
generated
vendored
11
vendor/github.com/cockroachdb/pebble/checkpoint.go
generated
vendored
@@ -88,23 +88,20 @@ func mkdirAllAndSyncParents(fs vfs.FS, destDir string) (vfs.File, error) {
|
|||||||
// Collect paths for all directories between destDir (excluded) and its
|
// Collect paths for all directories between destDir (excluded) and its
|
||||||
// closest existing ancestor (included).
|
// closest existing ancestor (included).
|
||||||
var parentPaths []string
|
var parentPaths []string
|
||||||
foundExistingAncestor := false
|
for parentPath := fs.PathDir(destDir); ; parentPath = fs.PathDir(parentPath) {
|
||||||
for parentPath := fs.PathDir(destDir); parentPath != "."; parentPath = fs.PathDir(parentPath) {
|
|
||||||
parentPaths = append(parentPaths, parentPath)
|
parentPaths = append(parentPaths, parentPath)
|
||||||
|
if fs.PathDir(parentPath) == parentPath {
|
||||||
|
break
|
||||||
|
}
|
||||||
_, err := fs.Stat(parentPath)
|
_, err := fs.Stat(parentPath)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// Exit loop at the closest existing ancestor.
|
// Exit loop at the closest existing ancestor.
|
||||||
foundExistingAncestor = true
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if !oserror.IsNotExist(err) {
|
if !oserror.IsNotExist(err) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Handle empty filesystem edge case.
|
|
||||||
if !foundExistingAncestor {
|
|
||||||
parentPaths = append(parentPaths, "")
|
|
||||||
}
|
|
||||||
// Create destDir and any of its missing parents.
|
// Create destDir and any of its missing parents.
|
||||||
if err := fs.MkdirAll(destDir, 0755); err != nil {
|
if err := fs.MkdirAll(destDir, 0755); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
4
vendor/github.com/cockroachdb/pebble/internal/manual/manual_32bit.go
generated
vendored
4
vendor/github.com/cockroachdb/pebble/internal/manual/manual_32bit.go
generated
vendored
@@ -2,8 +2,8 @@
|
|||||||
// of this source code is governed by a BSD-style license that can be found in
|
// of this source code is governed by a BSD-style license that can be found in
|
||||||
// the LICENSE file.
|
// the LICENSE file.
|
||||||
|
|
||||||
//go:build 386 || amd64p32 || arm || armbe || mips || mipsle || mips64p32 || mips64p32le || ppc || sparc
|
//go:build 386 || amd64p32 || arm || armbe || ppc || sparc
|
||||||
// +build 386 amd64p32 arm armbe mips mipsle mips64p32 mips64p32le ppc sparc
|
// +build 386 amd64p32 arm armbe ppc sparc
|
||||||
|
|
||||||
package manual
|
package manual
|
||||||
|
|
||||||
|
|||||||
4
vendor/github.com/cockroachdb/pebble/internal/manual/manual_64bit.go
generated
vendored
4
vendor/github.com/cockroachdb/pebble/internal/manual/manual_64bit.go
generated
vendored
@@ -2,8 +2,8 @@
|
|||||||
// of this source code is governed by a BSD-style license that can be found in
|
// of this source code is governed by a BSD-style license that can be found in
|
||||||
// the LICENSE file.
|
// the LICENSE file.
|
||||||
|
|
||||||
//go:build amd64 || arm64 || arm64be || ppc64 || ppc64le || mips64 || mips64le || s390x || sparc64 || riscv64
|
//go:build amd64 || arm64 || arm64be || ppc64 || ppc64le || mips64 || mips64le || s390x || sparc64 || riscv64 || loong64
|
||||||
// +build amd64 arm64 arm64be ppc64 ppc64le mips64 mips64le s390x sparc64 riscv64
|
// +build amd64 arm64 arm64be ppc64 ppc64le mips64 mips64le s390x sparc64 riscv64 loong64
|
||||||
|
|
||||||
package manual
|
package manual
|
||||||
|
|
||||||
|
|||||||
13
vendor/github.com/cockroachdb/pebble/internal/manual/manual_mips.go
generated
vendored
Normal file
13
vendor/github.com/cockroachdb/pebble/internal/manual/manual_mips.go
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
// Copyright 2020 The LevelDB-Go and Pebble Authors. All rights reserved. Use
|
||||||
|
// of this source code is governed by a BSD-style license that can be found in
|
||||||
|
// the LICENSE file.
|
||||||
|
|
||||||
|
//go:build mips || mipsle || mips64p32 || mips64p32le
|
||||||
|
// +build mips mipsle mips64p32 mips64p32le
|
||||||
|
|
||||||
|
package manual
|
||||||
|
|
||||||
|
const (
|
||||||
|
// MaxArrayLen is a safe maximum length for slices on this architecture.
|
||||||
|
MaxArrayLen = 1 << 30
|
||||||
|
)
|
||||||
4
vendor/github.com/cockroachdb/pebble/internal/rawalloc/rawalloc_32bit.go
generated
vendored
4
vendor/github.com/cockroachdb/pebble/internal/rawalloc/rawalloc_32bit.go
generated
vendored
@@ -12,8 +12,8 @@
|
|||||||
// implied. See the License for the specific language governing
|
// implied. See the License for the specific language governing
|
||||||
// permissions and limitations under the License.
|
// permissions and limitations under the License.
|
||||||
|
|
||||||
//go:build 386 || amd64p32 || arm || armbe || mips || mipsle || mips64p32 || mips64p32le || ppc || sparc
|
//go:build 386 || amd64p32 || arm || armbe || ppc || sparc
|
||||||
// +build 386 amd64p32 arm armbe mips mipsle mips64p32 mips64p32le ppc sparc
|
// +build 386 amd64p32 arm armbe ppc sparc
|
||||||
|
|
||||||
package rawalloc
|
package rawalloc
|
||||||
|
|
||||||
|
|||||||
4
vendor/github.com/cockroachdb/pebble/internal/rawalloc/rawalloc_64bit.go
generated
vendored
4
vendor/github.com/cockroachdb/pebble/internal/rawalloc/rawalloc_64bit.go
generated
vendored
@@ -12,8 +12,8 @@
|
|||||||
// implied. See the License for the specific language governing
|
// implied. See the License for the specific language governing
|
||||||
// permissions and limitations under the License.
|
// permissions and limitations under the License.
|
||||||
|
|
||||||
//go:build amd64 || arm64 || arm64be || ppc64 || ppc64le || mips64 || mips64le || s390x || sparc64 || riscv64
|
//go:build amd64 || arm64 || arm64be || ppc64 || ppc64le || mips64 || mips64le || s390x || sparc64 || riscv64 || loong64
|
||||||
// +build amd64 arm64 arm64be ppc64 ppc64le mips64 mips64le s390x sparc64 riscv64
|
// +build amd64 arm64 arm64be ppc64 ppc64le mips64 mips64le s390x sparc64 riscv64 loong64
|
||||||
|
|
||||||
package rawalloc
|
package rawalloc
|
||||||
|
|
||||||
|
|||||||
22
vendor/github.com/cockroachdb/pebble/internal/rawalloc/rawalloc_mips.go
generated
vendored
Normal file
22
vendor/github.com/cockroachdb/pebble/internal/rawalloc/rawalloc_mips.go
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
// Copyright 2014 The Cockroach Authors.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
// implied. See the License for the specific language governing
|
||||||
|
// permissions and limitations under the License.
|
||||||
|
|
||||||
|
//go:build mips || mipsle || mips64p32 || mips64p32le
|
||||||
|
// +build mips mipsle mips64p32 mips64p32le
|
||||||
|
|
||||||
|
package rawalloc
|
||||||
|
|
||||||
|
const (
|
||||||
|
maxArrayLen = 1 << 30
|
||||||
|
)
|
||||||
3
vendor/github.com/cockroachdb/pebble/vfs/mem_fs.go
generated
vendored
3
vendor/github.com/cockroachdb/pebble/vfs/mem_fs.go
generated
vendored
@@ -164,6 +164,9 @@ func (y *MemFS) walk(fullname string, f func(dir *memNode, frag string, final bo
|
|||||||
for len(fullname) > 0 && fullname[0] == sep[0] {
|
for len(fullname) > 0 && fullname[0] == sep[0] {
|
||||||
fullname = fullname[1:]
|
fullname = fullname[1:]
|
||||||
}
|
}
|
||||||
|
if fullname == "." {
|
||||||
|
fullname = ""
|
||||||
|
}
|
||||||
dir := y.root
|
dir := y.root
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
|||||||
10
vendor/github.com/cockroachdb/redact/builder/builder.go
generated
vendored
10
vendor/github.com/cockroachdb/redact/builder/builder.go
generated
vendored
@@ -130,6 +130,16 @@ func (b *StringBuilder) SafeRune(s i.SafeRune) {
|
|||||||
_ = b.Buffer.WriteRune(rune(s))
|
_ = b.Buffer.WriteRune(rune(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *StringBuilder) SafeByte(s i.SafeByte) {
|
||||||
|
b.SetMode(ib.SafeEscaped)
|
||||||
|
_ = b.Buffer.WriteByte(byte(s))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *StringBuilder) SafeBytes(s i.SafeBytes) {
|
||||||
|
b.SetMode(ib.SafeEscaped)
|
||||||
|
_, _ = b.Buffer.Write([]byte(s))
|
||||||
|
}
|
||||||
|
|
||||||
// UnsafeString is part of the SafeWriter interface.
|
// UnsafeString is part of the SafeWriter interface.
|
||||||
func (b *StringBuilder) UnsafeString(s string) {
|
func (b *StringBuilder) UnsafeString(s string) {
|
||||||
b.SetMode(ib.UnsafeEscaped)
|
b.SetMode(ib.UnsafeEscaped)
|
||||||
|
|||||||
18
vendor/github.com/cockroachdb/redact/interfaces/interfaces.go
generated
vendored
18
vendor/github.com/cockroachdb/redact/interfaces/interfaces.go
generated
vendored
@@ -65,6 +65,12 @@ type SafeWriter interface {
|
|||||||
// SafeRune emits a safe rune.
|
// SafeRune emits a safe rune.
|
||||||
SafeRune(SafeRune)
|
SafeRune(SafeRune)
|
||||||
|
|
||||||
|
// SafeByte emits a safe byte.
|
||||||
|
SafeByte(SafeByte)
|
||||||
|
|
||||||
|
// SafeBytes emits a safe byte slice.
|
||||||
|
SafeBytes(SafeBytes)
|
||||||
|
|
||||||
// Print emits its arguments separated by spaces.
|
// Print emits its arguments separated by spaces.
|
||||||
// For each argument it dynamically checks for the SafeFormatter or
|
// For each argument it dynamically checks for the SafeFormatter or
|
||||||
// SafeValue interface and either use that, or mark the argument
|
// SafeValue interface and either use that, or mark the argument
|
||||||
@@ -119,6 +125,18 @@ type SafeRune rune
|
|||||||
// SafeValue makes SafeRune a SafeValue.
|
// SafeValue makes SafeRune a SafeValue.
|
||||||
func (SafeRune) SafeValue() {}
|
func (SafeRune) SafeValue() {}
|
||||||
|
|
||||||
|
// SafeByte represents a byte that is not a sensitive value.
|
||||||
|
type SafeByte byte
|
||||||
|
|
||||||
|
// SafeValue makes SafeByte a SafeValue.
|
||||||
|
func (SafeByte) SafeValue() {}
|
||||||
|
|
||||||
|
// SafeBytes represents a byte slice that is not a sensitive value.
|
||||||
|
type SafeBytes []byte
|
||||||
|
|
||||||
|
// SafeValue makes SafeBytes a SafeValue.
|
||||||
|
func (SafeBytes) SafeValue() {}
|
||||||
|
|
||||||
// SafeValue is a marker interface to be implemented by types that
|
// SafeValue is a marker interface to be implemented by types that
|
||||||
// alias base Go types and whose natural representation via Printf is
|
// alias base Go types and whose natural representation via Printf is
|
||||||
// always safe for reporting.
|
// always safe for reporting.
|
||||||
|
|||||||
12
vendor/github.com/cockroachdb/redact/internal/rfmt/printer_adapter.go
generated
vendored
12
vendor/github.com/cockroachdb/redact/internal/rfmt/printer_adapter.go
generated
vendored
@@ -46,6 +46,18 @@ func (p *pp) SafeRune(r i.SafeRune) {
|
|||||||
p.buf.WriteRune(rune(r))
|
p.buf.WriteRune(rune(r))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SafeByte implements SafePrinter.
|
||||||
|
func (p *pp) SafeByte(r i.SafeByte) {
|
||||||
|
defer p.startSafeOverride().restore()
|
||||||
|
p.buf.WriteByte(byte(r))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SafeBytes implements SafePrinter.
|
||||||
|
func (p *pp) SafeBytes(r i.SafeBytes) {
|
||||||
|
defer p.startSafeOverride().restore()
|
||||||
|
p.buf.Write(r)
|
||||||
|
}
|
||||||
|
|
||||||
func (p *pp) Print(args ...interface{}) {
|
func (p *pp) Print(args ...interface{}) {
|
||||||
defer p.buf.SetMode(p.buf.GetMode())
|
defer p.buf.SetMode(p.buf.GetMode())
|
||||||
np := newPrinter()
|
np := newPrinter()
|
||||||
|
|||||||
27
vendor/github.com/getsentry/sentry-go/.craft.yml
generated
vendored
27
vendor/github.com/getsentry/sentry-go/.craft.yml
generated
vendored
@@ -8,6 +8,33 @@ targets:
|
|||||||
- name: github
|
- name: github
|
||||||
tagPrefix: otel/v
|
tagPrefix: otel/v
|
||||||
tagOnly: true
|
tagOnly: true
|
||||||
|
- name: github
|
||||||
|
tagPrefix: echo/v
|
||||||
|
tagOnly: true
|
||||||
|
- name: github
|
||||||
|
tagPrefix: fasthttp/v
|
||||||
|
tagOnly: true
|
||||||
|
- name: github
|
||||||
|
tagPrefix: fiber/v
|
||||||
|
tagOnly: true
|
||||||
|
- name: github
|
||||||
|
tagPrefix: gin/v
|
||||||
|
tagOnly: true
|
||||||
|
- name: github
|
||||||
|
tagPrefix: iris/v
|
||||||
|
tagOnly: true
|
||||||
|
- name: github
|
||||||
|
tagPrefix: negroni/v
|
||||||
|
tagOnly: true
|
||||||
|
- name: github
|
||||||
|
tagPrefix: logrus/v
|
||||||
|
tagOnly: true
|
||||||
|
- name: github
|
||||||
|
tagPrefix: slog/v
|
||||||
|
tagOnly: true
|
||||||
|
- name: github
|
||||||
|
tagPrefix: zerolog/v
|
||||||
|
tagOnly: true
|
||||||
- name: registry
|
- name: registry
|
||||||
sdks:
|
sdks:
|
||||||
github:getsentry/sentry-go:
|
github:getsentry/sentry-go:
|
||||||
|
|||||||
138
vendor/github.com/getsentry/sentry-go/CHANGELOG.md
generated
vendored
138
vendor/github.com/getsentry/sentry-go/CHANGELOG.md
generated
vendored
@@ -1,5 +1,143 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.31.1
|
||||||
|
|
||||||
|
The Sentry SDK team is happy to announce the immediate availability of Sentry Go SDK v0.31.1.
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
- Correct wrong module name for `sentry-go/logrus` ([#950](https://github.com/getsentry/sentry-go/pull/950))
|
||||||
|
|
||||||
|
## 0.31.0
|
||||||
|
|
||||||
|
The Sentry SDK team is happy to announce the immediate availability of Sentry Go SDK v0.31.0.
|
||||||
|
|
||||||
|
### Breaking Changes
|
||||||
|
|
||||||
|
- Remove support for metrics. Read more about the end of the Metrics beta [here](https://sentry.zendesk.com/hc/en-us/articles/26369339769883-Metrics-Beta-Ended-on-October-7th). ([#914](https://github.com/getsentry/sentry-go/pull/914))
|
||||||
|
|
||||||
|
- Remove support for profiling. ([#915](https://github.com/getsentry/sentry-go/pull/915))
|
||||||
|
|
||||||
|
- Remove `Segment` field from the `User` struct. This field is no longer used in the Sentry product. ([#928](https://github.com/getsentry/sentry-go/pull/928))
|
||||||
|
|
||||||
|
- Every integration is now a separate module, reducing the binary size and number of dependencies. Once you update `sentry-go` to latest version, you'll need to `go get` the integration you want to use. For example, if you want to use the `echo` integration, you'll need to run `go get github.com/getsentry/sentry-go/echo` ([#919](github.com/getsentry/sentry-go/pull/919)).
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
Add the ability to override `hub` in `context` for integrations that use custom context. ([#931](https://github.com/getsentry/sentry-go/pull/931))
|
||||||
|
|
||||||
|
- Add `HubProvider` Hook for `sentrylogrus`, enabling dynamic Sentry hub allocation for each log entry or goroutine. ([#936](https://github.com/getsentry/sentry-go/pull/936))
|
||||||
|
|
||||||
|
This change enhances compatibility with Sentry's recommendation of using separate hubs per goroutine. To ensure a separate Sentry hub for each goroutine, configure the `HubProvider` like this:
|
||||||
|
|
||||||
|
```go
|
||||||
|
hook, err := sentrylogrus.New(nil, sentry.ClientOptions{})
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Failed to initialize Sentry hook: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set a custom HubProvider to generate a new hub for each goroutine or log entry
|
||||||
|
hook.SetHubProvider(func() *sentry.Hub {
|
||||||
|
client, _ := sentry.NewClient(sentry.ClientOptions{})
|
||||||
|
return sentry.NewHub(client, sentry.NewScope())
|
||||||
|
})
|
||||||
|
|
||||||
|
logrus.AddHook(hook)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
- Add support for closing worker goroutines started by the `HTTPTranport` to prevent goroutine leaks. ([#894](https://github.com/getsentry/sentry-go/pull/894))
|
||||||
|
|
||||||
|
```go
|
||||||
|
client, _ := sentry.NewClient()
|
||||||
|
defer client.Close()
|
||||||
|
```
|
||||||
|
|
||||||
|
Worker can be also closed by calling `Close()` method on the `HTTPTransport` instance. `Close` should be called after `Flush` and before terminating the program otherwise some events may be lost.
|
||||||
|
|
||||||
|
```go
|
||||||
|
transport := sentry.NewHTTPTransport()
|
||||||
|
defer transport.Close()
|
||||||
|
```
|
||||||
|
|
||||||
|
### Misc
|
||||||
|
|
||||||
|
- Bump [gin-gonic/gin](https://github.com/gin-gonic/gin) to v1.9.1. ([#946](https://github.com/getsentry/sentry-go/pull/946))
|
||||||
|
|
||||||
|
## 0.30.0
|
||||||
|
|
||||||
|
The Sentry SDK team is happy to announce the immediate availability of Sentry Go SDK v0.30.0.
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- Add `sentryzerolog` integration ([#857](https://github.com/getsentry/sentry-go/pull/857))
|
||||||
|
- Add `sentryslog` integration ([#865](https://github.com/getsentry/sentry-go/pull/865))
|
||||||
|
- Always set Mechanism Type to generic ([#896](https://github.com/getsentry/sentry-go/pull/897))
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
- Prevent panic in `fasthttp` and `fiber` integration in case a malformed URL has to be parsed ([#912](https://github.com/getsentry/sentry-go/pull/912))
|
||||||
|
|
||||||
|
### Misc
|
||||||
|
|
||||||
|
Drop support for Go 1.18, 1.19 and 1.20. The currently supported Go versions are the last 3 stable releases: 1.23, 1.22 and 1.21.
|
||||||
|
|
||||||
|
## 0.29.1
|
||||||
|
|
||||||
|
The Sentry SDK team is happy to announce the immediate availability of Sentry Go SDK v0.29.1.
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
- Correlate errors to the current trace ([#886](https://github.com/getsentry/sentry-go/pull/886))
|
||||||
|
- Set the trace context when the transaction finishes ([#888](https://github.com/getsentry/sentry-go/pull/888))
|
||||||
|
|
||||||
|
### Misc
|
||||||
|
|
||||||
|
- Update the `sentrynegroni` integration to use the latest (v3.1.1) version of Negroni ([#885](https://github.com/getsentry/sentry-go/pull/885))
|
||||||
|
|
||||||
|
## 0.29.0
|
||||||
|
|
||||||
|
The Sentry SDK team is happy to announce the immediate availability of Sentry Go SDK v0.29.0.
|
||||||
|
|
||||||
|
### Breaking Changes
|
||||||
|
|
||||||
|
- Remove the `sentrymartini` integration ([#861](https://github.com/getsentry/sentry-go/pull/861))
|
||||||
|
- The `WrapResponseWriter` has been moved from the `sentryhttp` package to the `internal/httputils` package. If you've imported it previosuly, you'll need to copy the implementation in your project. ([#871](https://github.com/getsentry/sentry-go/pull/871))
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- Add new convenience methods to continue a trace and propagate tracing headers for error-only use cases. ([#862](https://github.com/getsentry/sentry-go/pull/862))
|
||||||
|
|
||||||
|
If you are not using one of our integrations, you can manually continue an incoming trace by using `sentry.ContinueTrace()` by providing the `sentry-trace` and `baggage` header received from a downstream SDK.
|
||||||
|
|
||||||
|
```go
|
||||||
|
hub := sentry.CurrentHub()
|
||||||
|
sentry.ContinueTrace(hub, r.Header.Get(sentry.SentryTraceHeader), r.Header.Get(sentry.SentryBaggageHeader)),
|
||||||
|
```
|
||||||
|
|
||||||
|
You can use `hub.GetTraceparent()` and `hub.GetBaggage()` to fetch the necessary header values for outgoing HTTP requests.
|
||||||
|
|
||||||
|
```go
|
||||||
|
hub := sentry.GetHubFromContext(ctx)
|
||||||
|
req, _ := http.NewRequest("GET", "http://localhost:3000", nil)
|
||||||
|
req.Header.Add(sentry.SentryTraceHeader, hub.GetTraceparent())
|
||||||
|
req.Header.Add(sentry.SentryBaggageHeader, hub.GetBaggage())
|
||||||
|
```
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
- Initialize `HTTPTransport.limit` if `nil` ([#844](https://github.com/getsentry/sentry-go/pull/844))
|
||||||
|
- Fix `sentry.StartTransaction()` returning a transaction with an outdated context on existing transactions ([#854](https://github.com/getsentry/sentry-go/pull/854))
|
||||||
|
- Treat `Proxy-Authorization` as a sensitive header ([#859](https://github.com/getsentry/sentry-go/pull/859))
|
||||||
|
- Add support for the `http.Hijacker` interface to the `sentrynegroni` package ([#871](https://github.com/getsentry/sentry-go/pull/871))
|
||||||
|
- Go version >= 1.23: Use value from `http.Request.Pattern` for HTTP transaction names when using `sentryhttp` & `sentrynegroni` ([#875](https://github.com/getsentry/sentry-go/pull/875))
|
||||||
|
- Go version >= 1.21: Fix closure functions name grouping ([#877](https://github.com/getsentry/sentry-go/pull/877))
|
||||||
|
|
||||||
|
### Misc
|
||||||
|
|
||||||
|
- Collect `span` origins ([#849](https://github.com/getsentry/sentry-go/pull/849))
|
||||||
|
|
||||||
## 0.28.1
|
## 0.28.1
|
||||||
|
|
||||||
The Sentry SDK team is happy to announce the immediate availability of Sentry Go SDK v0.28.1.
|
The Sentry SDK team is happy to announce the immediate availability of Sentry Go SDK v0.28.1.
|
||||||
|
|||||||
7
vendor/github.com/getsentry/sentry-go/Makefile
generated
vendored
7
vendor/github.com/getsentry/sentry-go/Makefile
generated
vendored
@@ -58,9 +58,8 @@ test-coverage: $(COVERAGE_REPORT_DIR) clean-report-dir ## Test with coverage en
|
|||||||
mod-tidy: ## Check go.mod tidiness
|
mod-tidy: ## Check go.mod tidiness
|
||||||
set -e ; \
|
set -e ; \
|
||||||
for dir in $(ALL_GO_MOD_DIRS); do \
|
for dir in $(ALL_GO_MOD_DIRS); do \
|
||||||
cd "$${dir}"; \
|
|
||||||
echo ">>> Running 'go mod tidy' for module: $${dir}"; \
|
echo ">>> Running 'go mod tidy' for module: $${dir}"; \
|
||||||
go mod tidy -go=1.18 -compat=1.18; \
|
(cd "$${dir}" && go mod tidy -go=1.21 -compat=1.21); \
|
||||||
done; \
|
done; \
|
||||||
git diff --exit-code;
|
git diff --exit-code;
|
||||||
.PHONY: mod-tidy
|
.PHONY: mod-tidy
|
||||||
@@ -68,12 +67,12 @@ mod-tidy: ## Check go.mod tidiness
|
|||||||
vet: ## Run "go vet"
|
vet: ## Run "go vet"
|
||||||
set -e ; \
|
set -e ; \
|
||||||
for dir in $(ALL_GO_MOD_DIRS); do \
|
for dir in $(ALL_GO_MOD_DIRS); do \
|
||||||
cd "$${dir}"; \
|
|
||||||
echo ">>> Running 'go vet' for module: $${dir}"; \
|
echo ">>> Running 'go vet' for module: $${dir}"; \
|
||||||
go vet ./...; \
|
(cd "$${dir}" && go vet ./...); \
|
||||||
done;
|
done;
|
||||||
.PHONY: vet
|
.PHONY: vet
|
||||||
|
|
||||||
|
|
||||||
lint: ## Lint (using "golangci-lint")
|
lint: ## Lint (using "golangci-lint")
|
||||||
golangci-lint run
|
golangci-lint run
|
||||||
.PHONY: lint
|
.PHONY: lint
|
||||||
|
|||||||
9
vendor/github.com/getsentry/sentry-go/README.md
generated
vendored
9
vendor/github.com/getsentry/sentry-go/README.md
generated
vendored
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
# Official Sentry SDK for Go
|
# Official Sentry SDK for Go
|
||||||
|
|
||||||
[](https://github.com/getsentry/sentry-go/actions?query=workflow%3Ago-workflow)
|
[](https://github.com/getsentry/sentry-go/actions/workflows/test.yml)
|
||||||
[](https://goreportcard.com/report/github.com/getsentry/sentry-go)
|
[](https://goreportcard.com/report/github.com/getsentry/sentry-go)
|
||||||
[](https://discord.gg/Ww9hbqr)
|
[](https://discord.gg/Ww9hbqr)
|
||||||
[](https://pkg.go.dev/github.com/getsentry/sentry-go)
|
[](https://pkg.go.dev/github.com/getsentry/sentry-go)
|
||||||
@@ -68,17 +68,20 @@ To get started, have a look at one of our [examples](_examples/):
|
|||||||
We also provide a [complete API reference](https://pkg.go.dev/github.com/getsentry/sentry-go).
|
We also provide a [complete API reference](https://pkg.go.dev/github.com/getsentry/sentry-go).
|
||||||
|
|
||||||
For more detailed information about how to get the most out of `sentry-go`,
|
For more detailed information about how to get the most out of `sentry-go`,
|
||||||
checkout the official documentation:
|
check out the official documentation:
|
||||||
|
|
||||||
- [Sentry Go SDK documentation](https://docs.sentry.io/platforms/go/)
|
- [Sentry Go SDK documentation](https://docs.sentry.io/platforms/go/)
|
||||||
- Guides:
|
- Guides:
|
||||||
- [net/http](https://docs.sentry.io/platforms/go/guides/http/)
|
- [net/http](https://docs.sentry.io/platforms/go/guides/http/)
|
||||||
- [echo](https://docs.sentry.io/platforms/go/guides/echo/)
|
- [echo](https://docs.sentry.io/platforms/go/guides/echo/)
|
||||||
- [fasthttp](https://docs.sentry.io/platforms/go/guides/fasthttp/)
|
- [fasthttp](https://docs.sentry.io/platforms/go/guides/fasthttp/)
|
||||||
|
- [fiber](https://docs.sentry.io/platforms/go/guides/fiber/)
|
||||||
- [gin](https://docs.sentry.io/platforms/go/guides/gin/)
|
- [gin](https://docs.sentry.io/platforms/go/guides/gin/)
|
||||||
- [iris](https://docs.sentry.io/platforms/go/guides/iris/)
|
- [iris](https://docs.sentry.io/platforms/go/guides/iris/)
|
||||||
- [martini](https://docs.sentry.io/platforms/go/guides/martini/)
|
- [logrus](https://docs.sentry.io/platforms/go/guides/logrus/)
|
||||||
- [negroni](https://docs.sentry.io/platforms/go/guides/negroni/)
|
- [negroni](https://docs.sentry.io/platforms/go/guides/negroni/)
|
||||||
|
- [slog](https://docs.sentry.io/platforms/go/guides/slog/)
|
||||||
|
- [zerolog](https://docs.sentry.io/platforms/go/guides/zerolog/)
|
||||||
|
|
||||||
## Resources
|
## Resources
|
||||||
|
|
||||||
|
|||||||
27
vendor/github.com/getsentry/sentry-go/client.go
generated
vendored
27
vendor/github.com/getsentry/sentry-go/client.go
generated
vendored
@@ -90,7 +90,7 @@ type EventProcessor func(event *Event, hint *EventHint) *Event
|
|||||||
// ApplyToEvent changes an event based on external data and/or
|
// ApplyToEvent changes an event based on external data and/or
|
||||||
// an event hint.
|
// an event hint.
|
||||||
type EventModifier interface {
|
type EventModifier interface {
|
||||||
ApplyToEvent(event *Event, hint *EventHint) *Event
|
ApplyToEvent(event *Event, hint *EventHint, client *Client) *Event
|
||||||
}
|
}
|
||||||
|
|
||||||
var globalEventProcessors []EventProcessor
|
var globalEventProcessors []EventProcessor
|
||||||
@@ -133,9 +133,6 @@ type ClientOptions struct {
|
|||||||
TracesSampleRate float64
|
TracesSampleRate float64
|
||||||
// Used to customize the sampling of traces, overrides TracesSampleRate.
|
// Used to customize the sampling of traces, overrides TracesSampleRate.
|
||||||
TracesSampler TracesSampler
|
TracesSampler TracesSampler
|
||||||
// The sample rate for profiling traces in the range [0.0, 1.0].
|
|
||||||
// This is relative to TracesSampleRate - it is a ratio of profiled traces out of all sampled traces.
|
|
||||||
ProfilesSampleRate float64
|
|
||||||
// List of regexp strings that will be used to match against event's message
|
// List of regexp strings that will be used to match against event's message
|
||||||
// and if applicable, caught errors type and value.
|
// and if applicable, caught errors type and value.
|
||||||
// If the match is found, then a whole event will be dropped.
|
// If the match is found, then a whole event will be dropped.
|
||||||
@@ -513,6 +510,14 @@ func (client *Client) Flush(timeout time.Duration) bool {
|
|||||||
return client.Transport.Flush(timeout)
|
return client.Transport.Flush(timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close clean up underlying Transport resources.
|
||||||
|
//
|
||||||
|
// Close should be called after Flush and before terminating the program
|
||||||
|
// otherwise some events may be lost.
|
||||||
|
func (client *Client) Close() {
|
||||||
|
client.Transport.Close()
|
||||||
|
}
|
||||||
|
|
||||||
// EventFromMessage creates an event from the given message string.
|
// EventFromMessage creates an event from the given message string.
|
||||||
func (client *Client) EventFromMessage(message string, level Level) *Event {
|
func (client *Client) EventFromMessage(message string, level Level) *Event {
|
||||||
if message == "" {
|
if message == "" {
|
||||||
@@ -590,14 +595,6 @@ func (client *Client) GetSDKIdentifier() string {
|
|||||||
return client.sdkIdentifier
|
return client.sdkIdentifier
|
||||||
}
|
}
|
||||||
|
|
||||||
// reverse reverses the slice a in place.
|
|
||||||
func reverse(a []Exception) {
|
|
||||||
for i := len(a)/2 - 1; i >= 0; i-- {
|
|
||||||
opp := len(a) - 1 - i
|
|
||||||
a[i], a[opp] = a[opp], a[i]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (client *Client) processEvent(event *Event, hint *EventHint, scope EventModifier) *EventID {
|
func (client *Client) processEvent(event *Event, hint *EventHint, scope EventModifier) *EventID {
|
||||||
if event == nil {
|
if event == nil {
|
||||||
err := usageError{fmt.Errorf("%s called with nil event", callerFunctionName())}
|
err := usageError{fmt.Errorf("%s called with nil event", callerFunctionName())}
|
||||||
@@ -685,7 +682,7 @@ func (client *Client) prepareEvent(event *Event, hint *EventHint, scope EventMod
|
|||||||
}
|
}
|
||||||
|
|
||||||
if scope != nil {
|
if scope != nil {
|
||||||
event = scope.ApplyToEvent(event, hint)
|
event = scope.ApplyToEvent(event, hint, client)
|
||||||
if event == nil {
|
if event == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -709,10 +706,6 @@ func (client *Client) prepareEvent(event *Event, hint *EventHint, scope EventMod
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if event.sdkMetaData.transactionProfile != nil {
|
|
||||||
event.sdkMetaData.transactionProfile.UpdateFromEvent(event)
|
|
||||||
}
|
|
||||||
|
|
||||||
return event
|
return event
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
vendor/github.com/getsentry/sentry-go/dsn.go
generated
vendored
4
vendor/github.com/getsentry/sentry-go/dsn.go
generated
vendored
@@ -89,8 +89,8 @@ func NewDsn(rawURL string) (*Dsn, error) {
|
|||||||
|
|
||||||
// Port
|
// Port
|
||||||
var port int
|
var port int
|
||||||
if parsedURL.Port() != "" {
|
if p := parsedURL.Port(); p != "" {
|
||||||
port, err = strconv.Atoi(parsedURL.Port())
|
port, err = strconv.Atoi(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, &DsnParseError{"invalid port"}
|
return nil, &DsnParseError{"invalid port"}
|
||||||
}
|
}
|
||||||
|
|||||||
75
vendor/github.com/getsentry/sentry-go/dynamic_sampling_context.go
generated
vendored
75
vendor/github.com/getsentry/sentry-go/dynamic_sampling_context.go
generated
vendored
@@ -39,8 +39,6 @@ func DynamicSamplingContextFromHeader(header []byte) (DynamicSamplingContext, er
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DynamicSamplingContextFromTransaction(span *Span) DynamicSamplingContext {
|
func DynamicSamplingContextFromTransaction(span *Span) DynamicSamplingContext {
|
||||||
entries := map[string]string{}
|
|
||||||
|
|
||||||
hub := hubFromContext(span.Context())
|
hub := hubFromContext(span.Context())
|
||||||
scope := hub.Scope()
|
scope := hub.Scope()
|
||||||
client := hub.Client()
|
client := hub.Client()
|
||||||
@@ -52,6 +50,8 @@ func DynamicSamplingContextFromTransaction(span *Span) DynamicSamplingContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
entries := make(map[string]string)
|
||||||
|
|
||||||
if traceID := span.TraceID.String(); traceID != "" {
|
if traceID := span.TraceID.String(); traceID != "" {
|
||||||
entries["trace_id"] = traceID
|
entries["trace_id"] = traceID
|
||||||
}
|
}
|
||||||
@@ -78,20 +78,9 @@ func DynamicSamplingContextFromTransaction(span *Span) DynamicSamplingContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if userSegment := scope.user.Segment; userSegment != "" {
|
entries["sampled"] = strconv.FormatBool(span.Sampled.Bool())
|
||||||
entries["user_segment"] = userSegment
|
|
||||||
}
|
|
||||||
|
|
||||||
if span.Sampled.Bool() {
|
return DynamicSamplingContext{Entries: entries, Frozen: true}
|
||||||
entries["sampled"] = "true"
|
|
||||||
} else {
|
|
||||||
entries["sampled"] = "false"
|
|
||||||
}
|
|
||||||
|
|
||||||
return DynamicSamplingContext{
|
|
||||||
Entries: entries,
|
|
||||||
Frozen: true,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d DynamicSamplingContext) HasEntries() bool {
|
func (d DynamicSamplingContext) HasEntries() bool {
|
||||||
@@ -111,13 +100,55 @@ func (d DynamicSamplingContext) String() string {
|
|||||||
}
|
}
|
||||||
members = append(members, member)
|
members = append(members, member)
|
||||||
}
|
}
|
||||||
if len(members) > 0 {
|
|
||||||
baggage, err := baggage.New(members...)
|
if len(members) == 0 {
|
||||||
if err != nil {
|
return ""
|
||||||
return ""
|
|
||||||
}
|
|
||||||
return baggage.String()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ""
|
baggage, err := baggage.New(members...)
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return baggage.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Constructs a new DynamicSamplingContext using a scope and client. Accessing
|
||||||
|
// fields on the scope are not thread safe, and this function should only be
|
||||||
|
// called within scope methods.
|
||||||
|
func DynamicSamplingContextFromScope(scope *Scope, client *Client) DynamicSamplingContext {
|
||||||
|
entries := map[string]string{}
|
||||||
|
|
||||||
|
if client == nil || scope == nil {
|
||||||
|
return DynamicSamplingContext{
|
||||||
|
Entries: entries,
|
||||||
|
Frozen: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
propagationContext := scope.propagationContext
|
||||||
|
|
||||||
|
if traceID := propagationContext.TraceID.String(); traceID != "" {
|
||||||
|
entries["trace_id"] = traceID
|
||||||
|
}
|
||||||
|
if sampleRate := client.options.TracesSampleRate; sampleRate != 0 {
|
||||||
|
entries["sample_rate"] = strconv.FormatFloat(sampleRate, 'f', -1, 64)
|
||||||
|
}
|
||||||
|
|
||||||
|
if dsn := client.dsn; dsn != nil {
|
||||||
|
if publicKey := dsn.publicKey; publicKey != "" {
|
||||||
|
entries["public_key"] = publicKey
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if release := client.options.Release; release != "" {
|
||||||
|
entries["release"] = release
|
||||||
|
}
|
||||||
|
if environment := client.options.Environment; environment != "" {
|
||||||
|
entries["environment"] = environment
|
||||||
|
}
|
||||||
|
|
||||||
|
return DynamicSamplingContext{
|
||||||
|
Entries: entries,
|
||||||
|
Frozen: true,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
42
vendor/github.com/getsentry/sentry-go/hub.go
generated
vendored
42
vendor/github.com/getsentry/sentry-go/hub.go
generated
vendored
@@ -2,6 +2,7 @@ package sentry
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -293,8 +294,13 @@ func (hub *Hub) AddBreadcrumb(breadcrumb *Breadcrumb, hint *BreadcrumbHint) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
max := client.options.MaxBreadcrumbs
|
max := client.options.MaxBreadcrumbs
|
||||||
if max < 0 {
|
switch {
|
||||||
|
case max < 0:
|
||||||
return
|
return
|
||||||
|
case max == 0:
|
||||||
|
max = defaultMaxBreadcrumbs
|
||||||
|
case max > maxBreadcrumbs:
|
||||||
|
max = maxBreadcrumbs
|
||||||
}
|
}
|
||||||
|
|
||||||
if client.options.BeforeBreadcrumb != nil {
|
if client.options.BeforeBreadcrumb != nil {
|
||||||
@@ -307,12 +313,6 @@ func (hub *Hub) AddBreadcrumb(breadcrumb *Breadcrumb, hint *BreadcrumbHint) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if max == 0 {
|
|
||||||
max = defaultMaxBreadcrumbs
|
|
||||||
} else if max > maxBreadcrumbs {
|
|
||||||
max = maxBreadcrumbs
|
|
||||||
}
|
|
||||||
|
|
||||||
hub.Scope().AddBreadcrumb(breadcrumb, max)
|
hub.Scope().AddBreadcrumb(breadcrumb, max)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,6 +365,34 @@ func (hub *Hub) Flush(timeout time.Duration) bool {
|
|||||||
return client.Flush(timeout)
|
return client.Flush(timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetTraceparent returns the current Sentry traceparent string, to be used as a HTTP header value
|
||||||
|
// or HTML meta tag value.
|
||||||
|
// This function is context aware, as in it either returns the traceparent based
|
||||||
|
// on the current span, or the scope's propagation context.
|
||||||
|
func (hub *Hub) GetTraceparent() string {
|
||||||
|
scope := hub.Scope()
|
||||||
|
|
||||||
|
if scope.span != nil {
|
||||||
|
return scope.span.ToSentryTrace()
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf("%s-%s", scope.propagationContext.TraceID, scope.propagationContext.SpanID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetBaggage returns the current Sentry baggage string, to be used as a HTTP header value
|
||||||
|
// or HTML meta tag value.
|
||||||
|
// This function is context aware, as in it either returns the baggage based
|
||||||
|
// on the current span or the scope's propagation context.
|
||||||
|
func (hub *Hub) GetBaggage() string {
|
||||||
|
scope := hub.Scope()
|
||||||
|
|
||||||
|
if scope.span != nil {
|
||||||
|
return scope.span.ToBaggage()
|
||||||
|
}
|
||||||
|
|
||||||
|
return scope.propagationContext.DynamicSamplingContext.String()
|
||||||
|
}
|
||||||
|
|
||||||
// HasHubOnContext checks whether Hub instance is bound to a given Context struct.
|
// HasHubOnContext checks whether Hub instance is bound to a given Context struct.
|
||||||
func HasHubOnContext(ctx context.Context) bool {
|
func HasHubOnContext(ctx context.Context) bool {
|
||||||
_, ok := ctx.Value(HubContextKey).(*Hub)
|
_, ok := ctx.Value(HubContextKey).(*Hub)
|
||||||
|
|||||||
47
vendor/github.com/getsentry/sentry-go/interfaces.go
generated
vendored
47
vendor/github.com/getsentry/sentry-go/interfaces.go
generated
vendored
@@ -8,6 +8,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -18,16 +19,9 @@ const eventType = "event"
|
|||||||
// transactionType is the type of a transaction event.
|
// transactionType is the type of a transaction event.
|
||||||
const transactionType = "transaction"
|
const transactionType = "transaction"
|
||||||
|
|
||||||
// profileType is the type of a profile event.
|
|
||||||
// currently, profiles are always sent as part of a transaction event.
|
|
||||||
const profileType = "profile"
|
|
||||||
|
|
||||||
// checkInType is the type of a check in event.
|
// checkInType is the type of a check in event.
|
||||||
const checkInType = "check_in"
|
const checkInType = "check_in"
|
||||||
|
|
||||||
// metricType is the type of a metric event.
|
|
||||||
const metricType = "statsd"
|
|
||||||
|
|
||||||
// Level marks the severity of the event.
|
// Level marks the severity of the event.
|
||||||
type Level string
|
type Level string
|
||||||
|
|
||||||
@@ -118,32 +112,27 @@ type User struct {
|
|||||||
IPAddress string `json:"ip_address,omitempty"`
|
IPAddress string `json:"ip_address,omitempty"`
|
||||||
Username string `json:"username,omitempty"`
|
Username string `json:"username,omitempty"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
Segment string `json:"segment,omitempty"`
|
|
||||||
Data map[string]string `json:"data,omitempty"`
|
Data map[string]string `json:"data,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u User) IsEmpty() bool {
|
func (u User) IsEmpty() bool {
|
||||||
if len(u.ID) > 0 {
|
if u.ID != "" {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(u.Email) > 0 {
|
if u.Email != "" {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(u.IPAddress) > 0 {
|
if u.IPAddress != "" {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(u.Username) > 0 {
|
if u.Username != "" {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(u.Name) > 0 {
|
if u.Name != "" {
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(u.Segment) > 0 {
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,10 +155,11 @@ type Request struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var sensitiveHeaders = map[string]struct{}{
|
var sensitiveHeaders = map[string]struct{}{
|
||||||
"Authorization": {},
|
"Authorization": {},
|
||||||
"Cookie": {},
|
"Proxy-Authorization": {},
|
||||||
"X-Forwarded-For": {},
|
"Cookie": {},
|
||||||
"X-Real-Ip": {},
|
"X-Forwarded-For": {},
|
||||||
|
"X-Real-Ip": {},
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRequest returns a new Sentry Request from the given http.Request.
|
// NewRequest returns a new Sentry Request from the given http.Request.
|
||||||
@@ -194,6 +184,7 @@ func NewRequest(r *http.Request) *Request {
|
|||||||
// attach more than one Cookie header field.
|
// attach more than one Cookie header field.
|
||||||
cookies = r.Header.Get("Cookie")
|
cookies = r.Header.Get("Cookie")
|
||||||
|
|
||||||
|
headers = make(map[string]string, len(r.Header))
|
||||||
for k, v := range r.Header {
|
for k, v := range r.Header {
|
||||||
headers[k] = strings.Join(v, ",")
|
headers[k] = strings.Join(v, ",")
|
||||||
}
|
}
|
||||||
@@ -237,8 +228,7 @@ type Mechanism struct {
|
|||||||
// SetUnhandled indicates that the exception is an unhandled exception, i.e.
|
// SetUnhandled indicates that the exception is an unhandled exception, i.e.
|
||||||
// from a panic.
|
// from a panic.
|
||||||
func (m *Mechanism) SetUnhandled() {
|
func (m *Mechanism) SetUnhandled() {
|
||||||
h := false
|
m.Handled = Pointer(false)
|
||||||
m.Handled = &h
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exception specifies an error that occurred.
|
// Exception specifies an error that occurred.
|
||||||
@@ -254,8 +244,7 @@ type Exception struct {
|
|||||||
// SDKMetaData is a struct to stash data which is needed at some point in the SDK's event processing pipeline
|
// SDKMetaData is a struct to stash data which is needed at some point in the SDK's event processing pipeline
|
||||||
// but which shouldn't get send to Sentry.
|
// but which shouldn't get send to Sentry.
|
||||||
type SDKMetaData struct {
|
type SDKMetaData struct {
|
||||||
dsc DynamicSamplingContext
|
dsc DynamicSamplingContext
|
||||||
transactionProfile *profileInfo
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Contains information about how the name of the transaction was determined.
|
// Contains information about how the name of the transaction was determined.
|
||||||
@@ -323,7 +312,6 @@ type Event struct {
|
|||||||
Exception []Exception `json:"exception,omitempty"`
|
Exception []Exception `json:"exception,omitempty"`
|
||||||
DebugMeta *DebugMeta `json:"debug_meta,omitempty"`
|
DebugMeta *DebugMeta `json:"debug_meta,omitempty"`
|
||||||
Attachments []*Attachment `json:"-"`
|
Attachments []*Attachment `json:"-"`
|
||||||
Metrics []Metric `json:"-"`
|
|
||||||
|
|
||||||
// The fields below are only relevant for transactions.
|
// The fields below are only relevant for transactions.
|
||||||
|
|
||||||
@@ -397,12 +385,13 @@ func (e *Event) SetException(exception error, maxErrorDepth int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// event.Exception should be sorted such that the most recent error is last.
|
// event.Exception should be sorted such that the most recent error is last.
|
||||||
reverse(e.Exception)
|
slices.Reverse(e.Exception)
|
||||||
|
|
||||||
for i := range e.Exception {
|
for i := range e.Exception {
|
||||||
e.Exception[i].Mechanism = &Mechanism{
|
e.Exception[i].Mechanism = &Mechanism{
|
||||||
IsExceptionGroup: true,
|
IsExceptionGroup: true,
|
||||||
ExceptionID: i,
|
ExceptionID: i,
|
||||||
|
Type: "generic",
|
||||||
}
|
}
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
continue
|
continue
|
||||||
@@ -428,7 +417,9 @@ func (e *Event) MarshalJSON() ([]byte, error) {
|
|||||||
// and a few type tricks.
|
// and a few type tricks.
|
||||||
if e.Type == transactionType {
|
if e.Type == transactionType {
|
||||||
return e.transactionMarshalJSON()
|
return e.transactionMarshalJSON()
|
||||||
} else if e.Type == checkInType {
|
}
|
||||||
|
|
||||||
|
if e.Type == checkInType {
|
||||||
return e.checkInMarshalJSON()
|
return e.checkInMarshalJSON()
|
||||||
}
|
}
|
||||||
return e.defaultMarshalJSON()
|
return e.defaultMarshalJSON()
|
||||||
|
|||||||
15
vendor/github.com/getsentry/sentry-go/internal/traceparser/README.md
generated
vendored
15
vendor/github.com/getsentry/sentry-go/internal/traceparser/README.md
generated
vendored
@@ -1,15 +0,0 @@
|
|||||||
## Benchmark results
|
|
||||||
|
|
||||||
```
|
|
||||||
goos: windows
|
|
||||||
goarch: amd64
|
|
||||||
pkg: github.com/getsentry/sentry-go/internal/trace
|
|
||||||
cpu: 12th Gen Intel(R) Core(TM) i7-12700K
|
|
||||||
BenchmarkEqualBytes-20 44323621 26.08 ns/op
|
|
||||||
BenchmarkStringEqual-20 60980257 18.27 ns/op
|
|
||||||
BenchmarkEqualPrefix-20 41369181 31.12 ns/op
|
|
||||||
BenchmarkFullParse-20 702012 1507 ns/op 1353.42 MB/s 1024 B/op 6 allocs/op
|
|
||||||
BenchmarkFramesIterator-20 1229971 969.3 ns/op 896 B/op 5 allocs/op
|
|
||||||
BenchmarkFramesReversedIterator-20 1271061 944.5 ns/op 896 B/op 5 allocs/op
|
|
||||||
BenchmarkSplitOnly-20 2250800 534.0 ns/op 3818.23 MB/s 128 B/op 1 allocs/op
|
|
||||||
```
|
|
||||||
217
vendor/github.com/getsentry/sentry-go/internal/traceparser/parser.go
generated
vendored
217
vendor/github.com/getsentry/sentry-go/internal/traceparser/parser.go
generated
vendored
@@ -1,217 +0,0 @@
|
|||||||
package traceparser
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"strconv"
|
|
||||||
)
|
|
||||||
|
|
||||||
var blockSeparator = []byte("\n\n")
|
|
||||||
var lineSeparator = []byte("\n")
|
|
||||||
|
|
||||||
// Parses multi-stacktrace text dump produced by runtime.Stack([]byte, all=true).
|
|
||||||
// The parser prioritizes performance but requires the input to be well-formed in order to return correct data.
|
|
||||||
// See https://github.com/golang/go/blob/go1.20.4/src/runtime/mprof.go#L1191
|
|
||||||
func Parse(data []byte) TraceCollection {
|
|
||||||
var it = TraceCollection{}
|
|
||||||
if len(data) > 0 {
|
|
||||||
it.blocks = bytes.Split(data, blockSeparator)
|
|
||||||
}
|
|
||||||
return it
|
|
||||||
}
|
|
||||||
|
|
||||||
type TraceCollection struct {
|
|
||||||
blocks [][]byte
|
|
||||||
}
|
|
||||||
|
|
||||||
func (it TraceCollection) Length() int {
|
|
||||||
return len(it.blocks)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns the stacktrace item at the given index.
|
|
||||||
func (it *TraceCollection) Item(i int) Trace {
|
|
||||||
// The first item may have a leading data separator and the last one may have a trailing one.
|
|
||||||
// Note: Trim() doesn't make a copy for single-character cutset under 0x80. It will just slice the original.
|
|
||||||
var data []byte
|
|
||||||
switch {
|
|
||||||
case i == 0:
|
|
||||||
data = bytes.TrimLeft(it.blocks[i], "\n")
|
|
||||||
case i == len(it.blocks)-1:
|
|
||||||
data = bytes.TrimRight(it.blocks[i], "\n")
|
|
||||||
default:
|
|
||||||
data = it.blocks[i]
|
|
||||||
}
|
|
||||||
|
|
||||||
var splitAt = bytes.IndexByte(data, '\n')
|
|
||||||
if splitAt < 0 {
|
|
||||||
return Trace{header: data}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Trace{
|
|
||||||
header: data[:splitAt],
|
|
||||||
data: data[splitAt+1:],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Trace represents a single stacktrace block, identified by a Goroutine ID and a sequence of Frames.
|
|
||||||
type Trace struct {
|
|
||||||
header []byte
|
|
||||||
data []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
var goroutinePrefix = []byte("goroutine ")
|
|
||||||
|
|
||||||
// GoID parses the Goroutine ID from the header.
|
|
||||||
func (t *Trace) GoID() (id uint64) {
|
|
||||||
if bytes.HasPrefix(t.header, goroutinePrefix) {
|
|
||||||
var line = t.header[len(goroutinePrefix):]
|
|
||||||
var splitAt = bytes.IndexByte(line, ' ')
|
|
||||||
if splitAt >= 0 {
|
|
||||||
id, _ = strconv.ParseUint(string(line[:splitAt]), 10, 64)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return id
|
|
||||||
}
|
|
||||||
|
|
||||||
// UniqueIdentifier can be used as a map key to identify the trace.
|
|
||||||
func (t *Trace) UniqueIdentifier() []byte {
|
|
||||||
return t.data
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *Trace) Frames() FrameIterator {
|
|
||||||
var lines = bytes.Split(t.data, lineSeparator)
|
|
||||||
return FrameIterator{lines: lines, i: 0, len: len(lines)}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *Trace) FramesReversed() ReverseFrameIterator {
|
|
||||||
var lines = bytes.Split(t.data, lineSeparator)
|
|
||||||
return ReverseFrameIterator{lines: lines, i: len(lines)}
|
|
||||||
}
|
|
||||||
|
|
||||||
const framesElided = "...additional frames elided..."
|
|
||||||
|
|
||||||
// FrameIterator iterates over stack frames.
|
|
||||||
type FrameIterator struct {
|
|
||||||
lines [][]byte
|
|
||||||
i int
|
|
||||||
len int
|
|
||||||
}
|
|
||||||
|
|
||||||
// Next returns the next frame, or nil if there are none.
|
|
||||||
func (it *FrameIterator) Next() Frame {
|
|
||||||
return Frame{it.popLine(), it.popLine()}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (it *FrameIterator) popLine() []byte {
|
|
||||||
switch {
|
|
||||||
case it.i >= it.len:
|
|
||||||
return nil
|
|
||||||
case string(it.lines[it.i]) == framesElided:
|
|
||||||
it.i++
|
|
||||||
return it.popLine()
|
|
||||||
default:
|
|
||||||
it.i++
|
|
||||||
return it.lines[it.i-1]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// HasNext return true if there are values to be read.
|
|
||||||
func (it *FrameIterator) HasNext() bool {
|
|
||||||
return it.i < it.len
|
|
||||||
}
|
|
||||||
|
|
||||||
// LengthUpperBound returns the maximum number of elements this stacks may contain.
|
|
||||||
// The actual number may be lower because of elided frames. As such, the returned value
|
|
||||||
// cannot be used to iterate over the frames but may be used to reserve capacity.
|
|
||||||
func (it *FrameIterator) LengthUpperBound() int {
|
|
||||||
return it.len / 2
|
|
||||||
}
|
|
||||||
|
|
||||||
// ReverseFrameIterator iterates over stack frames in reverse order.
|
|
||||||
type ReverseFrameIterator struct {
|
|
||||||
lines [][]byte
|
|
||||||
i int
|
|
||||||
}
|
|
||||||
|
|
||||||
// Next returns the next frame, or nil if there are none.
|
|
||||||
func (it *ReverseFrameIterator) Next() Frame {
|
|
||||||
var line2 = it.popLine()
|
|
||||||
return Frame{it.popLine(), line2}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (it *ReverseFrameIterator) popLine() []byte {
|
|
||||||
it.i--
|
|
||||||
switch {
|
|
||||||
case it.i < 0:
|
|
||||||
return nil
|
|
||||||
case string(it.lines[it.i]) == framesElided:
|
|
||||||
return it.popLine()
|
|
||||||
default:
|
|
||||||
return it.lines[it.i]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// HasNext return true if there are values to be read.
|
|
||||||
func (it *ReverseFrameIterator) HasNext() bool {
|
|
||||||
return it.i > 1
|
|
||||||
}
|
|
||||||
|
|
||||||
// LengthUpperBound returns the maximum number of elements this stacks may contain.
|
|
||||||
// The actual number may be lower because of elided frames. As such, the returned value
|
|
||||||
// cannot be used to iterate over the frames but may be used to reserve capacity.
|
|
||||||
func (it *ReverseFrameIterator) LengthUpperBound() int {
|
|
||||||
return len(it.lines) / 2
|
|
||||||
}
|
|
||||||
|
|
||||||
type Frame struct {
|
|
||||||
line1 []byte
|
|
||||||
line2 []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
// UniqueIdentifier can be used as a map key to identify the frame.
|
|
||||||
func (f *Frame) UniqueIdentifier() []byte {
|
|
||||||
// line2 contains file path, line number and program-counter offset from the beginning of a function
|
|
||||||
// e.g. C:/Users/name/scoop/apps/go/current/src/testing/testing.go:1906 +0x63a
|
|
||||||
return f.line2
|
|
||||||
}
|
|
||||||
|
|
||||||
var createdByPrefix = []byte("created by ")
|
|
||||||
|
|
||||||
func (f *Frame) Func() []byte {
|
|
||||||
if bytes.HasPrefix(f.line1, createdByPrefix) {
|
|
||||||
// Since go1.21, the line ends with " in goroutine X", saying which goroutine created this one.
|
|
||||||
// We currently don't have use for that so just remove it.
|
|
||||||
var line = f.line1[len(createdByPrefix):]
|
|
||||||
var spaceAt = bytes.IndexByte(line, ' ')
|
|
||||||
if spaceAt < 0 {
|
|
||||||
return line
|
|
||||||
}
|
|
||||||
return line[:spaceAt]
|
|
||||||
}
|
|
||||||
|
|
||||||
var end = bytes.LastIndexByte(f.line1, '(')
|
|
||||||
if end >= 0 {
|
|
||||||
return f.line1[:end]
|
|
||||||
}
|
|
||||||
|
|
||||||
return f.line1
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *Frame) File() (path []byte, lineNumber int) {
|
|
||||||
var line = f.line2
|
|
||||||
if len(line) > 0 && line[0] == '\t' {
|
|
||||||
line = line[1:]
|
|
||||||
}
|
|
||||||
|
|
||||||
var splitAt = bytes.IndexByte(line, ' ')
|
|
||||||
if splitAt >= 0 {
|
|
||||||
line = line[:splitAt]
|
|
||||||
}
|
|
||||||
|
|
||||||
splitAt = bytes.LastIndexByte(line, ':')
|
|
||||||
if splitAt < 0 {
|
|
||||||
return line, 0
|
|
||||||
}
|
|
||||||
|
|
||||||
lineNumber, _ = strconv.Atoi(string(line[splitAt+1:]))
|
|
||||||
return line[:splitAt], lineNumber
|
|
||||||
}
|
|
||||||
427
vendor/github.com/getsentry/sentry-go/metrics.go
generated
vendored
427
vendor/github.com/getsentry/sentry-go/metrics.go
generated
vendored
@@ -1,427 +0,0 @@
|
|||||||
package sentry
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"hash/crc32"
|
|
||||||
"math"
|
|
||||||
"regexp"
|
|
||||||
"sort"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
type (
|
|
||||||
NumberOrString interface {
|
|
||||||
int | string
|
|
||||||
}
|
|
||||||
|
|
||||||
void struct{}
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
member void
|
|
||||||
keyRegex = regexp.MustCompile(`[^a-zA-Z0-9_/.-]+`)
|
|
||||||
valueRegex = regexp.MustCompile(`[^\w\d\s_:/@\.{}\[\]$-]+`)
|
|
||||||
unitRegex = regexp.MustCompile(`[^a-z]+`)
|
|
||||||
)
|
|
||||||
|
|
||||||
type MetricUnit struct {
|
|
||||||
unit string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m MetricUnit) toString() string {
|
|
||||||
return m.unit
|
|
||||||
}
|
|
||||||
|
|
||||||
func NanoSecond() MetricUnit {
|
|
||||||
return MetricUnit{
|
|
||||||
"nanosecond",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func MicroSecond() MetricUnit {
|
|
||||||
return MetricUnit{
|
|
||||||
"microsecond",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func MilliSecond() MetricUnit {
|
|
||||||
return MetricUnit{
|
|
||||||
"millisecond",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Second() MetricUnit {
|
|
||||||
return MetricUnit{
|
|
||||||
"second",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Minute() MetricUnit {
|
|
||||||
return MetricUnit{
|
|
||||||
"minute",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Hour() MetricUnit {
|
|
||||||
return MetricUnit{
|
|
||||||
"hour",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Day() MetricUnit {
|
|
||||||
return MetricUnit{
|
|
||||||
"day",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Week() MetricUnit {
|
|
||||||
return MetricUnit{
|
|
||||||
"week",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Bit() MetricUnit {
|
|
||||||
return MetricUnit{
|
|
||||||
"bit",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Byte() MetricUnit {
|
|
||||||
return MetricUnit{
|
|
||||||
"byte",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func KiloByte() MetricUnit {
|
|
||||||
return MetricUnit{
|
|
||||||
"kilobyte",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func KibiByte() MetricUnit {
|
|
||||||
return MetricUnit{
|
|
||||||
"kibibyte",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func MegaByte() MetricUnit {
|
|
||||||
return MetricUnit{
|
|
||||||
"megabyte",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func MebiByte() MetricUnit {
|
|
||||||
return MetricUnit{
|
|
||||||
"mebibyte",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func GigaByte() MetricUnit {
|
|
||||||
return MetricUnit{
|
|
||||||
"gigabyte",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func GibiByte() MetricUnit {
|
|
||||||
return MetricUnit{
|
|
||||||
"gibibyte",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TeraByte() MetricUnit {
|
|
||||||
return MetricUnit{
|
|
||||||
"terabyte",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TebiByte() MetricUnit {
|
|
||||||
return MetricUnit{
|
|
||||||
"tebibyte",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func PetaByte() MetricUnit {
|
|
||||||
return MetricUnit{
|
|
||||||
"petabyte",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func PebiByte() MetricUnit {
|
|
||||||
return MetricUnit{
|
|
||||||
"pebibyte",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func ExaByte() MetricUnit {
|
|
||||||
return MetricUnit{
|
|
||||||
"exabyte",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func ExbiByte() MetricUnit {
|
|
||||||
return MetricUnit{
|
|
||||||
"exbibyte",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Ratio() MetricUnit {
|
|
||||||
return MetricUnit{
|
|
||||||
"ratio",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Percent() MetricUnit {
|
|
||||||
return MetricUnit{
|
|
||||||
"percent",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func CustomUnit(unit string) MetricUnit {
|
|
||||||
return MetricUnit{
|
|
||||||
unitRegex.ReplaceAllString(unit, ""),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type Metric interface {
|
|
||||||
GetType() string
|
|
||||||
GetTags() map[string]string
|
|
||||||
GetKey() string
|
|
||||||
GetUnit() string
|
|
||||||
GetTimestamp() int64
|
|
||||||
SerializeValue() string
|
|
||||||
SerializeTags() string
|
|
||||||
}
|
|
||||||
|
|
||||||
type abstractMetric struct {
|
|
||||||
key string
|
|
||||||
unit MetricUnit
|
|
||||||
tags map[string]string
|
|
||||||
// A unix timestamp (full seconds elapsed since 1970-01-01 00:00 UTC).
|
|
||||||
timestamp int64
|
|
||||||
}
|
|
||||||
|
|
||||||
func (am abstractMetric) GetTags() map[string]string {
|
|
||||||
return am.tags
|
|
||||||
}
|
|
||||||
|
|
||||||
func (am abstractMetric) GetKey() string {
|
|
||||||
return am.key
|
|
||||||
}
|
|
||||||
|
|
||||||
func (am abstractMetric) GetUnit() string {
|
|
||||||
return am.unit.toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (am abstractMetric) GetTimestamp() int64 {
|
|
||||||
return am.timestamp
|
|
||||||
}
|
|
||||||
|
|
||||||
func (am abstractMetric) SerializeTags() string {
|
|
||||||
var sb strings.Builder
|
|
||||||
|
|
||||||
values := make([]string, 0, len(am.tags))
|
|
||||||
for k := range am.tags {
|
|
||||||
values = append(values, k)
|
|
||||||
}
|
|
||||||
sortSlice(values)
|
|
||||||
|
|
||||||
for _, key := range values {
|
|
||||||
val := sanitizeValue(am.tags[key])
|
|
||||||
key = sanitizeKey(key)
|
|
||||||
sb.WriteString(fmt.Sprintf("%s:%s,", key, val))
|
|
||||||
}
|
|
||||||
s := sb.String()
|
|
||||||
if len(s) > 0 {
|
|
||||||
s = s[:len(s)-1]
|
|
||||||
}
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
|
|
||||||
// Counter Metric.
|
|
||||||
type CounterMetric struct {
|
|
||||||
value float64
|
|
||||||
abstractMetric
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *CounterMetric) Add(value float64) {
|
|
||||||
c.value += value
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c CounterMetric) GetType() string {
|
|
||||||
return "c"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c CounterMetric) SerializeValue() string {
|
|
||||||
return fmt.Sprintf(":%v", c.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
// timestamp: A unix timestamp (full seconds elapsed since 1970-01-01 00:00 UTC).
|
|
||||||
func NewCounterMetric(key string, unit MetricUnit, tags map[string]string, timestamp int64, value float64) CounterMetric {
|
|
||||||
am := abstractMetric{
|
|
||||||
key,
|
|
||||||
unit,
|
|
||||||
tags,
|
|
||||||
timestamp,
|
|
||||||
}
|
|
||||||
|
|
||||||
return CounterMetric{
|
|
||||||
value,
|
|
||||||
am,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Distribution Metric.
|
|
||||||
type DistributionMetric struct {
|
|
||||||
values []float64
|
|
||||||
abstractMetric
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *DistributionMetric) Add(value float64) {
|
|
||||||
d.values = append(d.values, value)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d DistributionMetric) GetType() string {
|
|
||||||
return "d"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d DistributionMetric) SerializeValue() string {
|
|
||||||
var sb strings.Builder
|
|
||||||
for _, el := range d.values {
|
|
||||||
sb.WriteString(fmt.Sprintf(":%v", el))
|
|
||||||
}
|
|
||||||
return sb.String()
|
|
||||||
}
|
|
||||||
|
|
||||||
// timestamp: A unix timestamp (full seconds elapsed since 1970-01-01 00:00 UTC).
|
|
||||||
func NewDistributionMetric(key string, unit MetricUnit, tags map[string]string, timestamp int64, value float64) DistributionMetric {
|
|
||||||
am := abstractMetric{
|
|
||||||
key,
|
|
||||||
unit,
|
|
||||||
tags,
|
|
||||||
timestamp,
|
|
||||||
}
|
|
||||||
|
|
||||||
return DistributionMetric{
|
|
||||||
[]float64{value},
|
|
||||||
am,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Gauge Metric.
|
|
||||||
type GaugeMetric struct {
|
|
||||||
last float64
|
|
||||||
min float64
|
|
||||||
max float64
|
|
||||||
sum float64
|
|
||||||
count float64
|
|
||||||
abstractMetric
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *GaugeMetric) Add(value float64) {
|
|
||||||
g.last = value
|
|
||||||
g.min = math.Min(g.min, value)
|
|
||||||
g.max = math.Max(g.max, value)
|
|
||||||
g.sum += value
|
|
||||||
g.count++
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g GaugeMetric) GetType() string {
|
|
||||||
return "g"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g GaugeMetric) SerializeValue() string {
|
|
||||||
return fmt.Sprintf(":%v:%v:%v:%v:%v", g.last, g.min, g.max, g.sum, g.count)
|
|
||||||
}
|
|
||||||
|
|
||||||
// timestamp: A unix timestamp (full seconds elapsed since 1970-01-01 00:00 UTC).
|
|
||||||
func NewGaugeMetric(key string, unit MetricUnit, tags map[string]string, timestamp int64, value float64) GaugeMetric {
|
|
||||||
am := abstractMetric{
|
|
||||||
key,
|
|
||||||
unit,
|
|
||||||
tags,
|
|
||||||
timestamp,
|
|
||||||
}
|
|
||||||
|
|
||||||
return GaugeMetric{
|
|
||||||
value, // last
|
|
||||||
value, // min
|
|
||||||
value, // max
|
|
||||||
value, // sum
|
|
||||||
value, // count
|
|
||||||
am,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set Metric.
|
|
||||||
type SetMetric[T NumberOrString] struct {
|
|
||||||
values map[T]void
|
|
||||||
abstractMetric
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *SetMetric[T]) Add(value T) {
|
|
||||||
s.values[value] = member
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s SetMetric[T]) GetType() string {
|
|
||||||
return "s"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s SetMetric[T]) SerializeValue() string {
|
|
||||||
_hash := func(s string) uint32 {
|
|
||||||
return crc32.ChecksumIEEE([]byte(s))
|
|
||||||
}
|
|
||||||
|
|
||||||
values := make([]T, 0, len(s.values))
|
|
||||||
for k := range s.values {
|
|
||||||
values = append(values, k)
|
|
||||||
}
|
|
||||||
sortSlice(values)
|
|
||||||
|
|
||||||
var sb strings.Builder
|
|
||||||
for _, el := range values {
|
|
||||||
switch any(el).(type) {
|
|
||||||
case int:
|
|
||||||
sb.WriteString(fmt.Sprintf(":%v", el))
|
|
||||||
case string:
|
|
||||||
s := fmt.Sprintf("%v", el)
|
|
||||||
sb.WriteString(fmt.Sprintf(":%d", _hash(s)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb.String()
|
|
||||||
}
|
|
||||||
|
|
||||||
// timestamp: A unix timestamp (full seconds elapsed since 1970-01-01 00:00 UTC).
|
|
||||||
func NewSetMetric[T NumberOrString](key string, unit MetricUnit, tags map[string]string, timestamp int64, value T) SetMetric[T] {
|
|
||||||
am := abstractMetric{
|
|
||||||
key,
|
|
||||||
unit,
|
|
||||||
tags,
|
|
||||||
timestamp,
|
|
||||||
}
|
|
||||||
|
|
||||||
return SetMetric[T]{
|
|
||||||
map[T]void{
|
|
||||||
value: member,
|
|
||||||
},
|
|
||||||
am,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func sanitizeKey(s string) string {
|
|
||||||
return keyRegex.ReplaceAllString(s, "_")
|
|
||||||
}
|
|
||||||
|
|
||||||
func sanitizeValue(s string) string {
|
|
||||||
return valueRegex.ReplaceAllString(s, "")
|
|
||||||
}
|
|
||||||
|
|
||||||
type Ordered interface {
|
|
||||||
~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64 | ~string
|
|
||||||
}
|
|
||||||
|
|
||||||
func sortSlice[T Ordered](s []T) {
|
|
||||||
sort.Slice(s, func(i, j int) bool {
|
|
||||||
return s[i] < s[j]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
73
vendor/github.com/getsentry/sentry-go/profile_sample.go
generated
vendored
73
vendor/github.com/getsentry/sentry-go/profile_sample.go
generated
vendored
@@ -1,73 +0,0 @@
|
|||||||
package sentry
|
|
||||||
|
|
||||||
// Based on https://github.com/getsentry/vroom/blob/d11c26063e802d66b9a592c4010261746ca3dfa4/internal/sample/sample.go
|
|
||||||
|
|
||||||
import (
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type (
|
|
||||||
profileDevice struct {
|
|
||||||
Architecture string `json:"architecture"`
|
|
||||||
Classification string `json:"classification"`
|
|
||||||
Locale string `json:"locale"`
|
|
||||||
Manufacturer string `json:"manufacturer"`
|
|
||||||
Model string `json:"model"`
|
|
||||||
}
|
|
||||||
|
|
||||||
profileOS struct {
|
|
||||||
BuildNumber string `json:"build_number"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
Version string `json:"version"`
|
|
||||||
}
|
|
||||||
|
|
||||||
profileRuntime struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
Version string `json:"version"`
|
|
||||||
}
|
|
||||||
|
|
||||||
profileSample struct {
|
|
||||||
ElapsedSinceStartNS uint64 `json:"elapsed_since_start_ns"`
|
|
||||||
StackID int `json:"stack_id"`
|
|
||||||
ThreadID uint64 `json:"thread_id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
profileThreadMetadata struct {
|
|
||||||
Name string `json:"name,omitempty"`
|
|
||||||
Priority int `json:"priority,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
profileStack []int
|
|
||||||
|
|
||||||
profileTrace struct {
|
|
||||||
Frames []*Frame `json:"frames"`
|
|
||||||
Samples []profileSample `json:"samples"`
|
|
||||||
Stacks []profileStack `json:"stacks"`
|
|
||||||
ThreadMetadata map[uint64]*profileThreadMetadata `json:"thread_metadata"`
|
|
||||||
}
|
|
||||||
|
|
||||||
profileInfo struct {
|
|
||||||
DebugMeta *DebugMeta `json:"debug_meta,omitempty"`
|
|
||||||
Device profileDevice `json:"device"`
|
|
||||||
Environment string `json:"environment,omitempty"`
|
|
||||||
EventID string `json:"event_id"`
|
|
||||||
OS profileOS `json:"os"`
|
|
||||||
Platform string `json:"platform"`
|
|
||||||
Release string `json:"release"`
|
|
||||||
Dist string `json:"dist"`
|
|
||||||
Runtime profileRuntime `json:"runtime"`
|
|
||||||
Timestamp time.Time `json:"timestamp"`
|
|
||||||
Trace *profileTrace `json:"profile"`
|
|
||||||
Transaction profileTransaction `json:"transaction"`
|
|
||||||
Version string `json:"version"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// see https://github.com/getsentry/vroom/blob/a91e39416723ec44fc54010257020eeaf9a77cbd/internal/transaction/transaction.go
|
|
||||||
profileTransaction struct {
|
|
||||||
ActiveThreadID uint64 `json:"active_thread_id"`
|
|
||||||
DurationNS uint64 `json:"duration_ns,omitempty"`
|
|
||||||
ID EventID `json:"id"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
TraceID string `json:"trace_id"`
|
|
||||||
}
|
|
||||||
)
|
|
||||||
451
vendor/github.com/getsentry/sentry-go/profiler.go
generated
vendored
451
vendor/github.com/getsentry/sentry-go/profiler.go
generated
vendored
@@ -1,451 +0,0 @@
|
|||||||
package sentry
|
|
||||||
|
|
||||||
import (
|
|
||||||
"container/ring"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"runtime"
|
|
||||||
"sync"
|
|
||||||
"sync/atomic"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/getsentry/sentry-go/internal/traceparser"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Start a profiler that collects samples continuously, with a buffer of up to 30 seconds.
|
|
||||||
// Later, you can collect a slice from this buffer, producing a Trace.
|
|
||||||
func startProfiling(startTime time.Time) profiler {
|
|
||||||
onProfilerStart()
|
|
||||||
|
|
||||||
p := newProfiler(startTime)
|
|
||||||
|
|
||||||
// Wait for the profiler to finish setting up before returning to the caller.
|
|
||||||
started := make(chan struct{})
|
|
||||||
go p.run(started)
|
|
||||||
|
|
||||||
if _, ok := <-started; ok {
|
|
||||||
return p
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type profiler interface {
|
|
||||||
// GetSlice returns a slice of the profiled data between the given times.
|
|
||||||
GetSlice(startTime, endTime time.Time) *profilerResult
|
|
||||||
Stop(wait bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
type profilerResult struct {
|
|
||||||
callerGoID uint64
|
|
||||||
trace *profileTrace
|
|
||||||
}
|
|
||||||
|
|
||||||
func getCurrentGoID() uint64 {
|
|
||||||
// We shouldn't panic but let's be super safe.
|
|
||||||
defer func() {
|
|
||||||
if err := recover(); err != nil {
|
|
||||||
Logger.Printf("Profiler panic in getCurrentGoID(): %v\n", err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Buffer to read the stack trace into. We should be good with a small buffer because we only need the first line.
|
|
||||||
var stacksBuffer = make([]byte, 100)
|
|
||||||
var n = runtime.Stack(stacksBuffer, false)
|
|
||||||
if n > 0 {
|
|
||||||
var traces = traceparser.Parse(stacksBuffer[0:n])
|
|
||||||
if traces.Length() > 0 {
|
|
||||||
var trace = traces.Item(0)
|
|
||||||
return trace.GoID()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
const profilerSamplingRateHz = 101 // 101 Hz; not 100 Hz because of the lockstep sampling (https://stackoverflow.com/a/45471031/1181370)
|
|
||||||
const profilerSamplingRate = time.Second / profilerSamplingRateHz
|
|
||||||
const stackBufferMaxGrowth = 512 * 1024
|
|
||||||
const stackBufferLimit = 10 * 1024 * 1024
|
|
||||||
const profilerRuntimeLimit = 30 // seconds
|
|
||||||
|
|
||||||
type profileRecorder struct {
|
|
||||||
startTime time.Time
|
|
||||||
stopSignal chan struct{}
|
|
||||||
stopped int64
|
|
||||||
mutex sync.RWMutex
|
|
||||||
testProfilerPanic int64
|
|
||||||
|
|
||||||
// Map from runtime.StackRecord.Stack0 to an index in stacks.
|
|
||||||
stackIndexes map[string]int
|
|
||||||
stacks []profileStack
|
|
||||||
newStacks []profileStack // New stacks created in the current interation.
|
|
||||||
stackKeyBuffer []byte
|
|
||||||
|
|
||||||
// Map from runtime.Frame.PC to an index in frames.
|
|
||||||
frameIndexes map[string]int
|
|
||||||
frames []*Frame
|
|
||||||
newFrames []*Frame // New frames created in the current interation.
|
|
||||||
|
|
||||||
// We keep a ring buffer of 30 seconds worth of samples, so that we can later slice it.
|
|
||||||
// Each bucket is a slice of samples all taken at the same time.
|
|
||||||
samplesBucketsHead *ring.Ring
|
|
||||||
|
|
||||||
// Buffer to read current stacks - will grow automatically up to stackBufferLimit.
|
|
||||||
stacksBuffer []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
func newProfiler(startTime time.Time) *profileRecorder {
|
|
||||||
// Pre-allocate the profile trace for the currently active number of routines & 100 ms worth of samples.
|
|
||||||
// Other coefficients are just guesses of what might be a good starting point to avoid allocs on short runs.
|
|
||||||
return &profileRecorder{
|
|
||||||
startTime: startTime,
|
|
||||||
stopSignal: make(chan struct{}, 1),
|
|
||||||
|
|
||||||
stackIndexes: make(map[string]int, 32),
|
|
||||||
stacks: make([]profileStack, 0, 32),
|
|
||||||
newStacks: make([]profileStack, 0, 32),
|
|
||||||
|
|
||||||
frameIndexes: make(map[string]int, 128),
|
|
||||||
frames: make([]*Frame, 0, 128),
|
|
||||||
newFrames: make([]*Frame, 0, 128),
|
|
||||||
|
|
||||||
samplesBucketsHead: ring.New(profilerRuntimeLimit * profilerSamplingRateHz),
|
|
||||||
|
|
||||||
// A buffer of 2 KiB per goroutine stack looks like a good starting point (empirically determined).
|
|
||||||
stacksBuffer: make([]byte, runtime.NumGoroutine()*2048),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// This allows us to test whether panic during profiling are handled correctly and don't block execution.
|
|
||||||
// If the number is lower than 0, profilerGoroutine() will panic immedately.
|
|
||||||
// If the number is higher than 0, profiler.onTick() will panic when the given samples-set index is being collected.
|
|
||||||
var testProfilerPanic int64
|
|
||||||
var profilerRunning int64
|
|
||||||
|
|
||||||
func (p *profileRecorder) run(started chan struct{}) {
|
|
||||||
// Code backup for manual test debugging:
|
|
||||||
// if !atomic.CompareAndSwapInt64(&profilerRunning, 0, 1) {
|
|
||||||
// panic("Only one profiler can be running at a time")
|
|
||||||
// }
|
|
||||||
|
|
||||||
// We shouldn't panic but let's be super safe.
|
|
||||||
defer func() {
|
|
||||||
if err := recover(); err != nil {
|
|
||||||
Logger.Printf("Profiler panic in run(): %v\n", err)
|
|
||||||
}
|
|
||||||
atomic.StoreInt64(&testProfilerPanic, 0)
|
|
||||||
close(started)
|
|
||||||
p.stopSignal <- struct{}{}
|
|
||||||
atomic.StoreInt64(&p.stopped, 1)
|
|
||||||
atomic.StoreInt64(&profilerRunning, 0)
|
|
||||||
}()
|
|
||||||
|
|
||||||
p.testProfilerPanic = atomic.LoadInt64(&testProfilerPanic)
|
|
||||||
if p.testProfilerPanic < 0 {
|
|
||||||
Logger.Printf("Profiler panicking during startup because testProfilerPanic == %v\n", p.testProfilerPanic)
|
|
||||||
panic("This is an expected panic in profilerGoroutine() during tests")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Collect the first sample immediately.
|
|
||||||
p.onTick()
|
|
||||||
|
|
||||||
// Periodically collect stacks, starting after profilerSamplingRate has passed.
|
|
||||||
collectTicker := profilerTickerFactory(profilerSamplingRate)
|
|
||||||
defer collectTicker.Stop()
|
|
||||||
var tickerChannel = collectTicker.TickSource()
|
|
||||||
|
|
||||||
started <- struct{}{}
|
|
||||||
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-tickerChannel:
|
|
||||||
p.onTick()
|
|
||||||
collectTicker.Ticked()
|
|
||||||
case <-p.stopSignal:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *profileRecorder) Stop(wait bool) {
|
|
||||||
if atomic.LoadInt64(&p.stopped) == 1 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
p.stopSignal <- struct{}{}
|
|
||||||
if wait {
|
|
||||||
<-p.stopSignal
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *profileRecorder) GetSlice(startTime, endTime time.Time) *profilerResult {
|
|
||||||
// Unlikely edge cases - profiler wasn't running at all or the given times are invalid in relation to each other.
|
|
||||||
if p.startTime.After(endTime) || startTime.After(endTime) {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var relativeStartNS = uint64(0)
|
|
||||||
if p.startTime.Before(startTime) {
|
|
||||||
relativeStartNS = uint64(startTime.Sub(p.startTime).Nanoseconds())
|
|
||||||
}
|
|
||||||
var relativeEndNS = uint64(endTime.Sub(p.startTime).Nanoseconds())
|
|
||||||
|
|
||||||
samplesCount, bucketsReversed, trace := p.getBuckets(relativeStartNS, relativeEndNS)
|
|
||||||
if samplesCount == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var result = &profilerResult{
|
|
||||||
callerGoID: getCurrentGoID(),
|
|
||||||
trace: trace,
|
|
||||||
}
|
|
||||||
|
|
||||||
trace.Samples = make([]profileSample, samplesCount)
|
|
||||||
trace.ThreadMetadata = make(map[uint64]*profileThreadMetadata, len(bucketsReversed[0].goIDs))
|
|
||||||
var s = samplesCount - 1
|
|
||||||
for _, bucket := range bucketsReversed {
|
|
||||||
var elapsedSinceStartNS = bucket.relativeTimeNS - relativeStartNS
|
|
||||||
for i, goID := range bucket.goIDs {
|
|
||||||
trace.Samples[s].ElapsedSinceStartNS = elapsedSinceStartNS
|
|
||||||
trace.Samples[s].ThreadID = goID
|
|
||||||
trace.Samples[s].StackID = bucket.stackIDs[i]
|
|
||||||
s--
|
|
||||||
|
|
||||||
if _, goroutineExists := trace.ThreadMetadata[goID]; !goroutineExists {
|
|
||||||
trace.ThreadMetadata[goID] = &profileThreadMetadata{
|
|
||||||
Name: "Goroutine " + strconv.FormatUint(goID, 10),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
// Collect all buckets of samples in the given time range while holding a read lock.
|
|
||||||
func (p *profileRecorder) getBuckets(relativeStartNS, relativeEndNS uint64) (samplesCount int, buckets []*profileSamplesBucket, trace *profileTrace) {
|
|
||||||
p.mutex.RLock()
|
|
||||||
defer p.mutex.RUnlock()
|
|
||||||
|
|
||||||
// sampleBucketsHead points at the last stored bucket so it's a good starting point to search backwards for the end.
|
|
||||||
var end = p.samplesBucketsHead
|
|
||||||
for end.Value != nil && end.Value.(*profileSamplesBucket).relativeTimeNS > relativeEndNS {
|
|
||||||
end = end.Prev()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Edge case - no items stored before the given endTime.
|
|
||||||
if end.Value == nil {
|
|
||||||
return 0, nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
{ // Find the first item after the given startTime.
|
|
||||||
var start = end
|
|
||||||
var prevBucket *profileSamplesBucket
|
|
||||||
samplesCount = 0
|
|
||||||
buckets = make([]*profileSamplesBucket, 0, int64((relativeEndNS-relativeStartNS)/uint64(profilerSamplingRate.Nanoseconds()))+1)
|
|
||||||
for start.Value != nil {
|
|
||||||
var bucket = start.Value.(*profileSamplesBucket)
|
|
||||||
|
|
||||||
// If this bucket's time is before the requests start time, don't collect it (and stop iterating further).
|
|
||||||
if bucket.relativeTimeNS < relativeStartNS {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
// If this bucket time is greater than previous the bucket's time, we have exhausted the whole ring buffer
|
|
||||||
// before we were able to find the start time. That means the start time is not present and we must break.
|
|
||||||
// This happens if the slice duration exceeds the ring buffer capacity.
|
|
||||||
if prevBucket != nil && bucket.relativeTimeNS > prevBucket.relativeTimeNS {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
samplesCount += len(bucket.goIDs)
|
|
||||||
buckets = append(buckets, bucket)
|
|
||||||
|
|
||||||
start = start.Prev()
|
|
||||||
prevBucket = bucket
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Edge case - if the period requested was too short and we haven't collected enough samples.
|
|
||||||
if len(buckets) < 2 {
|
|
||||||
return 0, nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
trace = &profileTrace{
|
|
||||||
Frames: p.frames,
|
|
||||||
Stacks: p.stacks,
|
|
||||||
}
|
|
||||||
return samplesCount, buckets, trace
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *profileRecorder) onTick() {
|
|
||||||
elapsedNs := time.Since(p.startTime).Nanoseconds()
|
|
||||||
|
|
||||||
if p.testProfilerPanic > 0 {
|
|
||||||
Logger.Printf("Profiler testProfilerPanic == %v\n", p.testProfilerPanic)
|
|
||||||
if p.testProfilerPanic == 1 {
|
|
||||||
Logger.Println("Profiler panicking onTick()")
|
|
||||||
panic("This is an expected panic in Profiler.OnTick() during tests")
|
|
||||||
}
|
|
||||||
p.testProfilerPanic--
|
|
||||||
}
|
|
||||||
|
|
||||||
records := p.collectRecords()
|
|
||||||
p.processRecords(uint64(elapsedNs), records)
|
|
||||||
|
|
||||||
// Free up some memory if we don't need such a large buffer anymore.
|
|
||||||
if len(p.stacksBuffer) > len(records)*3 {
|
|
||||||
p.stacksBuffer = make([]byte, len(records)*3)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *profileRecorder) collectRecords() []byte {
|
|
||||||
for {
|
|
||||||
// Capture stacks for all existing goroutines.
|
|
||||||
// Note: runtime.GoroutineProfile() would be better but we can't use it at the moment because
|
|
||||||
// it doesn't give us `gid` for each routine, see https://github.com/golang/go/issues/59663
|
|
||||||
n := runtime.Stack(p.stacksBuffer, true)
|
|
||||||
|
|
||||||
// If we couldn't read everything, increase the buffer and try again.
|
|
||||||
if n >= len(p.stacksBuffer) && n < stackBufferLimit {
|
|
||||||
var newSize = n * 2
|
|
||||||
if newSize > n+stackBufferMaxGrowth {
|
|
||||||
newSize = n + stackBufferMaxGrowth
|
|
||||||
}
|
|
||||||
if newSize > stackBufferLimit {
|
|
||||||
newSize = stackBufferLimit
|
|
||||||
}
|
|
||||||
p.stacksBuffer = make([]byte, newSize)
|
|
||||||
} else {
|
|
||||||
return p.stacksBuffer[0:n]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *profileRecorder) processRecords(elapsedNs uint64, stacksBuffer []byte) {
|
|
||||||
var traces = traceparser.Parse(stacksBuffer)
|
|
||||||
var length = traces.Length()
|
|
||||||
|
|
||||||
// Shouldn't happen but let's be safe and don't store empty buckets.
|
|
||||||
if length == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var bucket = &profileSamplesBucket{
|
|
||||||
relativeTimeNS: elapsedNs,
|
|
||||||
stackIDs: make([]int, length),
|
|
||||||
goIDs: make([]uint64, length),
|
|
||||||
}
|
|
||||||
|
|
||||||
// reset buffers
|
|
||||||
p.newFrames = p.newFrames[:0]
|
|
||||||
p.newStacks = p.newStacks[:0]
|
|
||||||
|
|
||||||
for i := 0; i < length; i++ {
|
|
||||||
var stack = traces.Item(i)
|
|
||||||
bucket.stackIDs[i] = p.addStackTrace(stack)
|
|
||||||
bucket.goIDs[i] = stack.GoID()
|
|
||||||
}
|
|
||||||
|
|
||||||
p.mutex.Lock()
|
|
||||||
defer p.mutex.Unlock()
|
|
||||||
|
|
||||||
p.stacks = append(p.stacks, p.newStacks...)
|
|
||||||
p.frames = append(p.frames, p.newFrames...)
|
|
||||||
|
|
||||||
p.samplesBucketsHead = p.samplesBucketsHead.Next()
|
|
||||||
p.samplesBucketsHead.Value = bucket
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *profileRecorder) addStackTrace(capturedStack traceparser.Trace) int {
|
|
||||||
iter := capturedStack.Frames()
|
|
||||||
stack := make(profileStack, 0, iter.LengthUpperBound())
|
|
||||||
|
|
||||||
// Originally, we've used `capturedStack.UniqueIdentifier()` as a key but that was incorrect because it also
|
|
||||||
// contains function arguments and we want to group stacks by function name and file/line only.
|
|
||||||
// Instead, we need to parse frames and we use a list of their indexes as a key.
|
|
||||||
// We reuse the same buffer for each stack to avoid allocations; this is a hot spot.
|
|
||||||
var expectedBufferLen = cap(stack) * 5 // 4 bytes per frame + 1 byte for space
|
|
||||||
if cap(p.stackKeyBuffer) < expectedBufferLen {
|
|
||||||
p.stackKeyBuffer = make([]byte, 0, expectedBufferLen)
|
|
||||||
} else {
|
|
||||||
p.stackKeyBuffer = p.stackKeyBuffer[:0]
|
|
||||||
}
|
|
||||||
|
|
||||||
for iter.HasNext() {
|
|
||||||
var frame = iter.Next()
|
|
||||||
if frameIndex := p.addFrame(frame); frameIndex >= 0 {
|
|
||||||
stack = append(stack, frameIndex)
|
|
||||||
|
|
||||||
p.stackKeyBuffer = append(p.stackKeyBuffer, 0) // space
|
|
||||||
|
|
||||||
// The following code is just like binary.AppendUvarint() which isn't yet available in Go 1.18.
|
|
||||||
x := uint64(frameIndex) + 1
|
|
||||||
for x >= 0x80 {
|
|
||||||
p.stackKeyBuffer = append(p.stackKeyBuffer, byte(x)|0x80)
|
|
||||||
x >>= 7
|
|
||||||
}
|
|
||||||
p.stackKeyBuffer = append(p.stackKeyBuffer, byte(x))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stackIndex, exists := p.stackIndexes[string(p.stackKeyBuffer)]
|
|
||||||
if !exists {
|
|
||||||
stackIndex = len(p.stacks) + len(p.newStacks)
|
|
||||||
p.newStacks = append(p.newStacks, stack)
|
|
||||||
p.stackIndexes[string(p.stackKeyBuffer)] = stackIndex
|
|
||||||
}
|
|
||||||
|
|
||||||
return stackIndex
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *profileRecorder) addFrame(capturedFrame traceparser.Frame) int {
|
|
||||||
// NOTE: Don't convert to string yet, it's expensive and compiler can avoid it when
|
|
||||||
// indexing into a map (only needs a copy when adding a new key to the map).
|
|
||||||
var key = capturedFrame.UniqueIdentifier()
|
|
||||||
|
|
||||||
frameIndex, exists := p.frameIndexes[string(key)]
|
|
||||||
if !exists {
|
|
||||||
module, function := splitQualifiedFunctionName(string(capturedFrame.Func()))
|
|
||||||
file, line := capturedFrame.File()
|
|
||||||
frame := newFrame(module, function, string(file), line)
|
|
||||||
frameIndex = len(p.frames) + len(p.newFrames)
|
|
||||||
p.newFrames = append(p.newFrames, &frame)
|
|
||||||
p.frameIndexes[string(key)] = frameIndex
|
|
||||||
}
|
|
||||||
return frameIndex
|
|
||||||
}
|
|
||||||
|
|
||||||
type profileSamplesBucket struct {
|
|
||||||
relativeTimeNS uint64
|
|
||||||
stackIDs []int
|
|
||||||
goIDs []uint64
|
|
||||||
}
|
|
||||||
|
|
||||||
// A Ticker holds a channel that delivers “ticks” of a clock at intervals.
|
|
||||||
type profilerTicker interface {
|
|
||||||
// Stop turns off a ticker. After Stop, no more ticks will be sent.
|
|
||||||
Stop()
|
|
||||||
|
|
||||||
// TickSource returns a read-only channel of ticks.
|
|
||||||
TickSource() <-chan time.Time
|
|
||||||
|
|
||||||
// Ticked is called by the Profiler after a tick is processed to notify the ticker. Used for testing.
|
|
||||||
Ticked()
|
|
||||||
}
|
|
||||||
|
|
||||||
type timeTicker struct {
|
|
||||||
*time.Ticker
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *timeTicker) TickSource() <-chan time.Time {
|
|
||||||
return t.C
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *timeTicker) Ticked() {}
|
|
||||||
|
|
||||||
func profilerTickerFactoryDefault(d time.Duration) profilerTicker {
|
|
||||||
return &timeTicker{time.NewTicker(d)}
|
|
||||||
}
|
|
||||||
|
|
||||||
// We allow overriding the ticker for tests. CI is terribly flaky
|
|
||||||
// because the time.Ticker doesn't guarantee regular ticks - they may come (a lot) later than the given interval.
|
|
||||||
var profilerTickerFactory = profilerTickerFactoryDefault
|
|
||||||
5
vendor/github.com/getsentry/sentry-go/profiler_other.go
generated
vendored
5
vendor/github.com/getsentry/sentry-go/profiler_other.go
generated
vendored
@@ -1,5 +0,0 @@
|
|||||||
//go:build !windows
|
|
||||||
|
|
||||||
package sentry
|
|
||||||
|
|
||||||
func onProfilerStart() {}
|
|
||||||
24
vendor/github.com/getsentry/sentry-go/profiler_windows.go
generated
vendored
24
vendor/github.com/getsentry/sentry-go/profiler_windows.go
generated
vendored
@@ -1,24 +0,0 @@
|
|||||||
package sentry
|
|
||||||
|
|
||||||
import (
|
|
||||||
"sync"
|
|
||||||
"syscall"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This works around the ticker resolution on Windows being ~15ms by default.
|
|
||||||
// See https://github.com/golang/go/issues/44343
|
|
||||||
func setTimeTickerResolution() {
|
|
||||||
var winmmDLL = syscall.NewLazyDLL("winmm.dll")
|
|
||||||
if winmmDLL != nil {
|
|
||||||
var timeBeginPeriod = winmmDLL.NewProc("timeBeginPeriod")
|
|
||||||
if timeBeginPeriod != nil {
|
|
||||||
timeBeginPeriod.Call(uintptr(1))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var setupTickerResolutionOnce sync.Once
|
|
||||||
|
|
||||||
func onProfilerStart() {
|
|
||||||
setupTickerResolutionOnce.Do(setTimeTickerResolution)
|
|
||||||
}
|
|
||||||
90
vendor/github.com/getsentry/sentry-go/propagation_context.go
generated
vendored
Normal file
90
vendor/github.com/getsentry/sentry-go/propagation_context.go
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
package sentry
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/rand"
|
||||||
|
"encoding/json"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PropagationContext struct {
|
||||||
|
TraceID TraceID `json:"trace_id"`
|
||||||
|
SpanID SpanID `json:"span_id"`
|
||||||
|
ParentSpanID SpanID `json:"parent_span_id"`
|
||||||
|
DynamicSamplingContext DynamicSamplingContext `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p PropagationContext) MarshalJSON() ([]byte, error) {
|
||||||
|
type propagationContext PropagationContext
|
||||||
|
var parentSpanID string
|
||||||
|
if p.ParentSpanID != zeroSpanID {
|
||||||
|
parentSpanID = p.ParentSpanID.String()
|
||||||
|
}
|
||||||
|
return json.Marshal(struct {
|
||||||
|
*propagationContext
|
||||||
|
ParentSpanID string `json:"parent_span_id,omitempty"`
|
||||||
|
}{
|
||||||
|
propagationContext: (*propagationContext)(&p),
|
||||||
|
ParentSpanID: parentSpanID,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p PropagationContext) Map() map[string]interface{} {
|
||||||
|
m := map[string]interface{}{
|
||||||
|
"trace_id": p.TraceID,
|
||||||
|
"span_id": p.SpanID,
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.ParentSpanID != zeroSpanID {
|
||||||
|
m["parent_span_id"] = p.ParentSpanID
|
||||||
|
}
|
||||||
|
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewPropagationContext() PropagationContext {
|
||||||
|
p := PropagationContext{}
|
||||||
|
|
||||||
|
if _, err := rand.Read(p.TraceID[:]); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := rand.Read(p.SpanID[:]); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func PropagationContextFromHeaders(trace, baggage string) (PropagationContext, error) {
|
||||||
|
p := NewPropagationContext()
|
||||||
|
|
||||||
|
if _, err := rand.Read(p.SpanID[:]); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
hasTrace := false
|
||||||
|
if trace != "" {
|
||||||
|
if tpc, valid := ParseTraceParentContext([]byte(trace)); valid {
|
||||||
|
hasTrace = true
|
||||||
|
p.TraceID = tpc.TraceID
|
||||||
|
p.ParentSpanID = tpc.ParentSpanID
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if baggage != "" {
|
||||||
|
dsc, err := DynamicSamplingContextFromHeader([]byte(baggage))
|
||||||
|
if err != nil {
|
||||||
|
return PropagationContext{}, err
|
||||||
|
}
|
||||||
|
p.DynamicSamplingContext = dsc
|
||||||
|
}
|
||||||
|
|
||||||
|
// In case a sentry-trace header is present but there are no sentry-related
|
||||||
|
// values in the baggage, create an empty, frozen DynamicSamplingContext.
|
||||||
|
if hasTrace && !p.DynamicSamplingContext.HasEntries() {
|
||||||
|
p.DynamicSamplingContext = DynamicSamplingContext{
|
||||||
|
Frozen: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return p, nil
|
||||||
|
}
|
||||||
65
vendor/github.com/getsentry/sentry-go/scope.go
generated
vendored
65
vendor/github.com/getsentry/sentry-go/scope.go
generated
vendored
@@ -43,20 +43,22 @@ type Scope struct {
|
|||||||
Overflow() bool
|
Overflow() bool
|
||||||
}
|
}
|
||||||
eventProcessors []EventProcessor
|
eventProcessors []EventProcessor
|
||||||
|
|
||||||
|
propagationContext PropagationContext
|
||||||
|
span *Span
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewScope creates a new Scope.
|
// NewScope creates a new Scope.
|
||||||
func NewScope() *Scope {
|
func NewScope() *Scope {
|
||||||
scope := Scope{
|
return &Scope{
|
||||||
breadcrumbs: make([]*Breadcrumb, 0),
|
breadcrumbs: make([]*Breadcrumb, 0),
|
||||||
attachments: make([]*Attachment, 0),
|
attachments: make([]*Attachment, 0),
|
||||||
tags: make(map[string]string),
|
tags: make(map[string]string),
|
||||||
contexts: make(map[string]Context),
|
contexts: make(map[string]Context),
|
||||||
extra: make(map[string]interface{}),
|
extra: make(map[string]interface{}),
|
||||||
fingerprint: make([]string, 0),
|
fingerprint: make([]string, 0),
|
||||||
|
propagationContext: NewPropagationContext(),
|
||||||
}
|
}
|
||||||
|
|
||||||
return &scope
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddBreadcrumb adds new breadcrumb to the current scope
|
// AddBreadcrumb adds new breadcrumb to the current scope
|
||||||
@@ -292,6 +294,22 @@ func (scope *Scope) SetLevel(level Level) {
|
|||||||
scope.level = level
|
scope.level = level
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetPropagationContext sets the propagation context for the current scope.
|
||||||
|
func (scope *Scope) SetPropagationContext(propagationContext PropagationContext) {
|
||||||
|
scope.mu.Lock()
|
||||||
|
defer scope.mu.Unlock()
|
||||||
|
|
||||||
|
scope.propagationContext = propagationContext
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetSpan sets a span for the current scope.
|
||||||
|
func (scope *Scope) SetSpan(span *Span) {
|
||||||
|
scope.mu.Lock()
|
||||||
|
defer scope.mu.Unlock()
|
||||||
|
|
||||||
|
scope.span = span
|
||||||
|
}
|
||||||
|
|
||||||
// Clone returns a copy of the current scope with all data copied over.
|
// Clone returns a copy of the current scope with all data copied over.
|
||||||
func (scope *Scope) Clone() *Scope {
|
func (scope *Scope) Clone() *Scope {
|
||||||
scope.mu.RLock()
|
scope.mu.RLock()
|
||||||
@@ -318,6 +336,8 @@ func (scope *Scope) Clone() *Scope {
|
|||||||
clone.request = scope.request
|
clone.request = scope.request
|
||||||
clone.requestBody = scope.requestBody
|
clone.requestBody = scope.requestBody
|
||||||
clone.eventProcessors = scope.eventProcessors
|
clone.eventProcessors = scope.eventProcessors
|
||||||
|
clone.propagationContext = scope.propagationContext
|
||||||
|
clone.span = scope.span
|
||||||
return clone
|
return clone
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,7 +355,7 @@ func (scope *Scope) AddEventProcessor(processor EventProcessor) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ApplyToEvent takes the data from the current scope and attaches it to the event.
|
// ApplyToEvent takes the data from the current scope and attaches it to the event.
|
||||||
func (scope *Scope) ApplyToEvent(event *Event, hint *EventHint) *Event {
|
func (scope *Scope) ApplyToEvent(event *Event, hint *EventHint, client *Client) *Event {
|
||||||
scope.mu.RLock()
|
scope.mu.RLock()
|
||||||
defer scope.mu.RUnlock()
|
defer scope.mu.RUnlock()
|
||||||
|
|
||||||
@@ -379,6 +399,29 @@ func (scope *Scope) ApplyToEvent(event *Event, hint *EventHint) *Event {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if event.Contexts == nil {
|
||||||
|
event.Contexts = make(map[string]Context)
|
||||||
|
}
|
||||||
|
|
||||||
|
if scope.span != nil {
|
||||||
|
if _, ok := event.Contexts["trace"]; !ok {
|
||||||
|
event.Contexts["trace"] = scope.span.traceContext().Map()
|
||||||
|
}
|
||||||
|
|
||||||
|
transaction := scope.span.GetTransaction()
|
||||||
|
if transaction != nil {
|
||||||
|
event.sdkMetaData.dsc = DynamicSamplingContextFromTransaction(transaction)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
event.Contexts["trace"] = scope.propagationContext.Map()
|
||||||
|
|
||||||
|
dsc := scope.propagationContext.DynamicSamplingContext
|
||||||
|
if !dsc.HasEntries() && client != nil {
|
||||||
|
dsc = DynamicSamplingContextFromScope(scope, client)
|
||||||
|
}
|
||||||
|
event.sdkMetaData.dsc = dsc
|
||||||
|
}
|
||||||
|
|
||||||
if len(scope.extra) > 0 {
|
if len(scope.extra) > 0 {
|
||||||
if event.Extra == nil {
|
if event.Extra == nil {
|
||||||
event.Extra = make(map[string]interface{}, len(scope.extra))
|
event.Extra = make(map[string]interface{}, len(scope.extra))
|
||||||
@@ -435,7 +478,7 @@ func (scope *Scope) ApplyToEvent(event *Event, hint *EventHint) *Event {
|
|||||||
// a proper deep copy: if some context values are pointer types (e.g. maps),
|
// a proper deep copy: if some context values are pointer types (e.g. maps),
|
||||||
// they won't be properly copied.
|
// they won't be properly copied.
|
||||||
func cloneContext(c Context) Context {
|
func cloneContext(c Context) Context {
|
||||||
res := Context{}
|
res := make(Context, len(c))
|
||||||
for k, v := range c {
|
for k, v := range c {
|
||||||
res[k] = v
|
res[k] = v
|
||||||
}
|
}
|
||||||
|
|||||||
2
vendor/github.com/getsentry/sentry-go/sentry.go
generated
vendored
2
vendor/github.com/getsentry/sentry-go/sentry.go
generated
vendored
@@ -6,7 +6,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// The version of the SDK.
|
// The version of the SDK.
|
||||||
const SDKVersion = "0.28.1"
|
const SDKVersion = "0.31.1"
|
||||||
|
|
||||||
// apiVersion is the minimum version of the Sentry API compatible with the
|
// apiVersion is the minimum version of the Sentry API compatible with the
|
||||||
// sentry-go SDK.
|
// sentry-go SDK.
|
||||||
|
|||||||
46
vendor/github.com/getsentry/sentry-go/stacktrace.go
generated
vendored
46
vendor/github.com/getsentry/sentry-go/stacktrace.go
generated
vendored
@@ -4,6 +4,7 @@ import (
|
|||||||
"go/build"
|
"go/build"
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -277,12 +278,7 @@ func extractFrames(pcs []uintptr) []runtime.Frame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO don't append and reverse, put in the right place from the start.
|
slices.Reverse(frames)
|
||||||
// reverse
|
|
||||||
for i, j := 0, len(frames)-1; i < j; i, j = i+1, j-1 {
|
|
||||||
frames[i], frames[j] = frames[j], frames[i]
|
|
||||||
}
|
|
||||||
|
|
||||||
return frames
|
return frames
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,6 +303,9 @@ func createFrames(frames []runtime.Frame) []Frame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fix issues grouping errors with the new fully qualified function names
|
||||||
|
// introduced from Go 1.21
|
||||||
|
result = cleanupFunctionNamePrefix(result)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,12 +332,10 @@ func shouldSkipFrame(module string) bool {
|
|||||||
var goRoot = strings.ReplaceAll(build.Default.GOROOT, "\\", "/")
|
var goRoot = strings.ReplaceAll(build.Default.GOROOT, "\\", "/")
|
||||||
|
|
||||||
func setInAppFrame(frame *Frame) {
|
func setInAppFrame(frame *Frame) {
|
||||||
if strings.HasPrefix(frame.AbsPath, goRoot) ||
|
frame.InApp = true
|
||||||
strings.Contains(frame.Module, "vendor") ||
|
if strings.HasPrefix(frame.AbsPath, goRoot) || strings.Contains(frame.Module, "vendor") ||
|
||||||
strings.Contains(frame.Module, "third_party") {
|
strings.Contains(frame.Module, "third_party") {
|
||||||
frame.InApp = false
|
frame.InApp = false
|
||||||
} else {
|
|
||||||
frame.InApp = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -379,3 +376,32 @@ func baseName(name string) string {
|
|||||||
}
|
}
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isCompilerGeneratedSymbol(name string) bool {
|
||||||
|
// In versions of Go 1.20 and above a prefix of "type:" and "go:" is a
|
||||||
|
// compiler-generated symbol that doesn't belong to any package.
|
||||||
|
// See variable reservedimports in cmd/compile/internal/gc/subr.go
|
||||||
|
if strings.HasPrefix(name, "go:") || strings.HasPrefix(name, "type:") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Walk backwards through the results and for the current function name
|
||||||
|
// remove it's parent function's prefix, leaving only it's actual name. This
|
||||||
|
// fixes issues grouping errors with the new fully qualified function names
|
||||||
|
// introduced from Go 1.21.
|
||||||
|
func cleanupFunctionNamePrefix(f []Frame) []Frame {
|
||||||
|
for i := len(f) - 1; i > 0; i-- {
|
||||||
|
name := f[i].Function
|
||||||
|
parentName := f[i-1].Function + "."
|
||||||
|
|
||||||
|
if !strings.HasPrefix(name, parentName) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
f[i].Function = name[len(parentName):]
|
||||||
|
}
|
||||||
|
|
||||||
|
return f
|
||||||
|
}
|
||||||
|
|||||||
15
vendor/github.com/getsentry/sentry-go/stacktrace_below_go1.20.go
generated
vendored
15
vendor/github.com/getsentry/sentry-go/stacktrace_below_go1.20.go
generated
vendored
@@ -1,15 +0,0 @@
|
|||||||
//go:build !go1.20
|
|
||||||
|
|
||||||
package sentry
|
|
||||||
|
|
||||||
import "strings"
|
|
||||||
|
|
||||||
func isCompilerGeneratedSymbol(name string) bool {
|
|
||||||
// In versions of Go below 1.20 a prefix of "type." and "go." is a
|
|
||||||
// compiler-generated symbol that doesn't belong to any package.
|
|
||||||
// See variable reservedimports in cmd/compile/internal/gc/subr.go
|
|
||||||
if strings.HasPrefix(name, "go.") || strings.HasPrefix(name, "type.") {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
15
vendor/github.com/getsentry/sentry-go/stacktrace_go1.20.go
generated
vendored
15
vendor/github.com/getsentry/sentry-go/stacktrace_go1.20.go
generated
vendored
@@ -1,15 +0,0 @@
|
|||||||
//go:build go1.20
|
|
||||||
|
|
||||||
package sentry
|
|
||||||
|
|
||||||
import "strings"
|
|
||||||
|
|
||||||
func isCompilerGeneratedSymbol(name string) bool {
|
|
||||||
// In versions of Go 1.20 and above a prefix of "type:" and "go:" is a
|
|
||||||
// compiler-generated symbol that doesn't belong to any package.
|
|
||||||
// See variable reservedimports in cmd/compile/internal/gc/subr.go
|
|
||||||
if strings.HasPrefix(name, "go:") || strings.HasPrefix(name, "type:") {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
95
vendor/github.com/getsentry/sentry-go/traces_profiler.go
generated
vendored
95
vendor/github.com/getsentry/sentry-go/traces_profiler.go
generated
vendored
@@ -1,95 +0,0 @@
|
|||||||
package sentry
|
|
||||||
|
|
||||||
import (
|
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Checks whether the transaction should be profiled (according to ProfilesSampleRate)
|
|
||||||
// and starts a profiler if so.
|
|
||||||
func (s *Span) sampleTransactionProfile() {
|
|
||||||
var sampleRate = s.clientOptions().ProfilesSampleRate
|
|
||||||
switch {
|
|
||||||
case sampleRate < 0.0 || sampleRate > 1.0:
|
|
||||||
Logger.Printf("Skipping transaction profiling: ProfilesSampleRate out of range [0.0, 1.0]: %f\n", sampleRate)
|
|
||||||
case sampleRate == 0.0 || rng.Float64() >= sampleRate:
|
|
||||||
Logger.Printf("Skipping transaction profiling: ProfilesSampleRate is: %f\n", sampleRate)
|
|
||||||
default:
|
|
||||||
startProfilerOnce.Do(startGlobalProfiler)
|
|
||||||
if globalProfiler == nil {
|
|
||||||
Logger.Println("Skipping transaction profiling: the profiler couldn't be started")
|
|
||||||
} else {
|
|
||||||
s.collectProfile = collectTransactionProfile
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// transactionProfiler collects a profile for a given span.
|
|
||||||
type transactionProfiler func(span *Span) *profileInfo
|
|
||||||
|
|
||||||
var startProfilerOnce sync.Once
|
|
||||||
var globalProfiler profiler
|
|
||||||
|
|
||||||
func startGlobalProfiler() {
|
|
||||||
globalProfiler = startProfiling(time.Now())
|
|
||||||
}
|
|
||||||
|
|
||||||
func collectTransactionProfile(span *Span) *profileInfo {
|
|
||||||
result := globalProfiler.GetSlice(span.StartTime, span.EndTime)
|
|
||||||
if result == nil || result.trace == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
info := &profileInfo{
|
|
||||||
Version: "1",
|
|
||||||
EventID: uuid(),
|
|
||||||
// See https://github.com/getsentry/sentry-go/pull/626#discussion_r1204870340 for explanation why we use the Transaction time.
|
|
||||||
Timestamp: span.StartTime,
|
|
||||||
Trace: result.trace,
|
|
||||||
Transaction: profileTransaction{
|
|
||||||
DurationNS: uint64(span.EndTime.Sub(span.StartTime).Nanoseconds()),
|
|
||||||
Name: span.Name,
|
|
||||||
TraceID: span.TraceID.String(),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
if len(info.Transaction.Name) == 0 {
|
|
||||||
// Name is required by Relay so use the operation name if the span name is empty.
|
|
||||||
info.Transaction.Name = span.Op
|
|
||||||
}
|
|
||||||
if result.callerGoID > 0 {
|
|
||||||
info.Transaction.ActiveThreadID = result.callerGoID
|
|
||||||
}
|
|
||||||
return info
|
|
||||||
}
|
|
||||||
|
|
||||||
func (info *profileInfo) UpdateFromEvent(event *Event) {
|
|
||||||
info.Environment = event.Environment
|
|
||||||
info.Platform = event.Platform
|
|
||||||
info.Release = event.Release
|
|
||||||
info.Dist = event.Dist
|
|
||||||
info.Transaction.ID = event.EventID
|
|
||||||
|
|
||||||
getStringFromContext := func(context map[string]interface{}, originalValue, key string) string {
|
|
||||||
v, ok := context[key]
|
|
||||||
if !ok {
|
|
||||||
return originalValue
|
|
||||||
}
|
|
||||||
|
|
||||||
if s, ok := v.(string); ok {
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
|
|
||||||
return originalValue
|
|
||||||
}
|
|
||||||
|
|
||||||
if runtimeContext, ok := event.Contexts["runtime"]; ok {
|
|
||||||
info.Runtime.Name = getStringFromContext(runtimeContext, info.Runtime.Name, "name")
|
|
||||||
info.Runtime.Version = getStringFromContext(runtimeContext, info.Runtime.Version, "version")
|
|
||||||
}
|
|
||||||
if osContext, ok := event.Contexts["os"]; ok {
|
|
||||||
info.OS.Name = getStringFromContext(osContext, info.OS.Name, "name")
|
|
||||||
}
|
|
||||||
if deviceContext, ok := event.Contexts["device"]; ok {
|
|
||||||
info.Device.Architecture = getStringFromContext(deviceContext, info.Device.Architecture, "arch")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
149
vendor/github.com/getsentry/sentry-go/tracing.go
generated
vendored
149
vendor/github.com/getsentry/sentry-go/tracing.go
generated
vendored
@@ -18,6 +18,20 @@ const (
|
|||||||
SentryBaggageHeader = "baggage"
|
SentryBaggageHeader = "baggage"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// SpanOrigin indicates what created a trace or a span. See: https://develop.sentry.dev/sdk/performance/trace-origin/
|
||||||
|
type SpanOrigin string
|
||||||
|
|
||||||
|
const (
|
||||||
|
SpanOriginManual = "manual"
|
||||||
|
SpanOriginEcho = "auto.http.echo"
|
||||||
|
SpanOriginFastHTTP = "auto.http.fasthttp"
|
||||||
|
SpanOriginFiber = "auto.http.fiber"
|
||||||
|
SpanOriginGin = "auto.http.gin"
|
||||||
|
SpanOriginStdLib = "auto.http.stdlib"
|
||||||
|
SpanOriginIris = "auto.http.iris"
|
||||||
|
SpanOriginNegroni = "auto.http.negroni"
|
||||||
|
)
|
||||||
|
|
||||||
// A Span is the building block of a Sentry transaction. Spans build up a tree
|
// A Span is the building block of a Sentry transaction. Spans build up a tree
|
||||||
// structure of timed operations. The span tree makes up a transaction event
|
// structure of timed operations. The span tree makes up a transaction event
|
||||||
// that is sent to Sentry when the root span is finished.
|
// that is sent to Sentry when the root span is finished.
|
||||||
@@ -37,6 +51,7 @@ type Span struct { //nolint: maligned // prefer readability over optimal memory
|
|||||||
Data map[string]interface{} `json:"data,omitempty"`
|
Data map[string]interface{} `json:"data,omitempty"`
|
||||||
Sampled Sampled `json:"-"`
|
Sampled Sampled `json:"-"`
|
||||||
Source TransactionSource `json:"-"`
|
Source TransactionSource `json:"-"`
|
||||||
|
Origin SpanOrigin `json:"origin,omitempty"`
|
||||||
|
|
||||||
// mu protects concurrent writes to map fields
|
// mu protects concurrent writes to map fields
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
@@ -53,8 +68,6 @@ type Span struct { //nolint: maligned // prefer readability over optimal memory
|
|||||||
recorder *spanRecorder
|
recorder *spanRecorder
|
||||||
// span context, can only be set on transactions
|
// span context, can only be set on transactions
|
||||||
contexts map[string]Context
|
contexts map[string]Context
|
||||||
// collectProfile is a function that collects a profile of the current transaction. May be nil.
|
|
||||||
collectProfile transactionProfiler
|
|
||||||
// a Once instance to make sure that Finish() is only called once.
|
// a Once instance to make sure that Finish() is only called once.
|
||||||
finishOnce sync.Once
|
finishOnce sync.Once
|
||||||
}
|
}
|
||||||
@@ -113,11 +126,19 @@ func StartSpan(ctx context.Context, operation string, options ...SpanOption) *Sp
|
|||||||
parent: parent,
|
parent: parent,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, err := rand.Read(span.SpanID[:])
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
if hasParent {
|
if hasParent {
|
||||||
span.TraceID = parent.TraceID
|
span.TraceID = parent.TraceID
|
||||||
|
span.ParentSpanID = parent.SpanID
|
||||||
|
span.Origin = parent.Origin
|
||||||
} else {
|
} else {
|
||||||
// Only set the Source if this is a transaction
|
// Only set the Source if this is a transaction
|
||||||
span.Source = SourceCustom
|
span.Source = SourceCustom
|
||||||
|
span.Origin = SpanOriginManual
|
||||||
|
|
||||||
// Implementation note:
|
// Implementation note:
|
||||||
//
|
//
|
||||||
@@ -154,13 +175,6 @@ func StartSpan(ctx context.Context, operation string, options ...SpanOption) *Sp
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_, err := rand.Read(span.SpanID[:])
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
if hasParent {
|
|
||||||
span.ParentSpanID = parent.SpanID
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply options to override defaults.
|
// Apply options to override defaults.
|
||||||
for _, option := range options {
|
for _, option := range options {
|
||||||
@@ -176,15 +190,14 @@ func StartSpan(ctx context.Context, operation string, options ...SpanOption) *Sp
|
|||||||
|
|
||||||
span.recorder.record(&span)
|
span.recorder.record(&span)
|
||||||
|
|
||||||
hub := hubFromContext(ctx)
|
clientOptions := span.clientOptions()
|
||||||
|
if clientOptions.EnableTracing {
|
||||||
// Update scope so that all events include a trace context, allowing
|
hub := hubFromContext(ctx)
|
||||||
// Sentry to correlate errors to transactions/spans.
|
if !span.IsTransaction() {
|
||||||
hub.Scope().SetContext("trace", span.traceContext().Map())
|
// Push a new scope to stack for non transaction span
|
||||||
|
hub.PushScope()
|
||||||
// Start profiling only if it's a sampled root transaction.
|
}
|
||||||
if span.IsTransaction() && span.Sampled.Bool() {
|
hub.Scope().SetSpan(&span)
|
||||||
span.sampleTransactionProfile()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return &span
|
return &span
|
||||||
@@ -308,17 +321,21 @@ func (s *Span) ToSentryTrace() string {
|
|||||||
// Use this function to propagate the DynamicSamplingContext to a downstream SDK,
|
// Use this function to propagate the DynamicSamplingContext to a downstream SDK,
|
||||||
// either as the value of the "baggage" HTTP header, or as an html "baggage" meta tag.
|
// either as the value of the "baggage" HTTP header, or as an html "baggage" meta tag.
|
||||||
func (s *Span) ToBaggage() string {
|
func (s *Span) ToBaggage() string {
|
||||||
if containingTransaction := s.GetTransaction(); containingTransaction != nil {
|
t := s.GetTransaction()
|
||||||
// In case there is currently no frozen DynamicSamplingContext attached to the transaction,
|
if t == nil {
|
||||||
// create one from the properties of the transaction.
|
return ""
|
||||||
if !s.dynamicSamplingContext.IsFrozen() {
|
|
||||||
// This will return a frozen DynamicSamplingContext.
|
|
||||||
s.dynamicSamplingContext = DynamicSamplingContextFromTransaction(containingTransaction)
|
|
||||||
}
|
|
||||||
|
|
||||||
return containingTransaction.dynamicSamplingContext.String()
|
|
||||||
}
|
}
|
||||||
return ""
|
|
||||||
|
// In case there is currently no frozen DynamicSamplingContext attached to the transaction,
|
||||||
|
// create one from the properties of the transaction.
|
||||||
|
if !s.dynamicSamplingContext.IsFrozen() {
|
||||||
|
// This will return a frozen DynamicSamplingContext.
|
||||||
|
if dsc := DynamicSamplingContextFromTransaction(t); dsc.HasEntries() {
|
||||||
|
t.dynamicSamplingContext = dsc
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return t.dynamicSamplingContext.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDynamicSamplingContext sets the given dynamic sampling context on the
|
// SetDynamicSamplingContext sets the given dynamic sampling context on the
|
||||||
@@ -335,6 +352,12 @@ func (s *Span) doFinish() {
|
|||||||
s.EndTime = monotonicTimeSince(s.StartTime)
|
s.EndTime = monotonicTimeSince(s.StartTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hub := hubFromContext(s.ctx)
|
||||||
|
if !s.IsTransaction() {
|
||||||
|
// Referenced to StartSpan function that pushes current non-transaction span to scope stack
|
||||||
|
defer hub.PopScope()
|
||||||
|
}
|
||||||
|
|
||||||
if !s.Sampled.Bool() {
|
if !s.Sampled.Bool() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -343,14 +366,9 @@ func (s *Span) doFinish() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.collectProfile != nil {
|
|
||||||
event.sdkMetaData.transactionProfile = s.collectProfile(s)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(tracing): add breadcrumbs
|
// TODO(tracing): add breadcrumbs
|
||||||
// (see https://github.com/getsentry/sentry-python/blob/f6f3525f8812f609/sentry_sdk/tracing.py#L372)
|
// (see https://github.com/getsentry/sentry-python/blob/f6f3525f8812f609/sentry_sdk/tracing.py#L372)
|
||||||
|
|
||||||
hub := hubFromContext(s.ctx)
|
|
||||||
hub.CaptureEvent(event)
|
hub.CaptureEvent(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -534,7 +552,7 @@ func (s *Span) toEvent() *Event {
|
|||||||
s.dynamicSamplingContext = DynamicSamplingContextFromTransaction(s)
|
s.dynamicSamplingContext = DynamicSamplingContextFromTransaction(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
contexts := map[string]Context{}
|
contexts := make(map[string]Context, len(s.contexts)+1)
|
||||||
for k, v := range s.contexts {
|
for k, v := range s.contexts {
|
||||||
contexts[k] = cloneContext(v)
|
contexts[k] = cloneContext(v)
|
||||||
}
|
}
|
||||||
@@ -706,31 +724,32 @@ const (
|
|||||||
maxSpanStatus
|
maxSpanStatus
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var spanStatuses = [maxSpanStatus]string{
|
||||||
|
"",
|
||||||
|
"ok",
|
||||||
|
"cancelled", // [sic]
|
||||||
|
"unknown",
|
||||||
|
"invalid_argument",
|
||||||
|
"deadline_exceeded",
|
||||||
|
"not_found",
|
||||||
|
"already_exists",
|
||||||
|
"permission_denied",
|
||||||
|
"resource_exhausted",
|
||||||
|
"failed_precondition",
|
||||||
|
"aborted",
|
||||||
|
"out_of_range",
|
||||||
|
"unimplemented",
|
||||||
|
"internal_error",
|
||||||
|
"unavailable",
|
||||||
|
"data_loss",
|
||||||
|
"unauthenticated",
|
||||||
|
}
|
||||||
|
|
||||||
func (ss SpanStatus) String() string {
|
func (ss SpanStatus) String() string {
|
||||||
if ss >= maxSpanStatus {
|
if ss >= maxSpanStatus {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
m := [maxSpanStatus]string{
|
return spanStatuses[ss]
|
||||||
"",
|
|
||||||
"ok",
|
|
||||||
"cancelled", // [sic]
|
|
||||||
"unknown",
|
|
||||||
"invalid_argument",
|
|
||||||
"deadline_exceeded",
|
|
||||||
"not_found",
|
|
||||||
"already_exists",
|
|
||||||
"permission_denied",
|
|
||||||
"resource_exhausted",
|
|
||||||
"failed_precondition",
|
|
||||||
"aborted",
|
|
||||||
"out_of_range",
|
|
||||||
"unimplemented",
|
|
||||||
"internal_error",
|
|
||||||
"unavailable",
|
|
||||||
"data_loss",
|
|
||||||
"unauthenticated",
|
|
||||||
}
|
|
||||||
return m[ss]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ss SpanStatus) MarshalJSON() ([]byte, error) {
|
func (ss SpanStatus) MarshalJSON() ([]byte, error) {
|
||||||
@@ -870,6 +889,25 @@ func WithSpanSampled(sampled Sampled) SpanOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithSpanOrigin sets the origin of the span.
|
||||||
|
func WithSpanOrigin(origin SpanOrigin) SpanOption {
|
||||||
|
return func(s *Span) {
|
||||||
|
s.Origin = origin
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Continue a trace based on traceparent and bagge values.
|
||||||
|
// If the SDK is configured with tracing enabled,
|
||||||
|
// this function returns populated SpanOption.
|
||||||
|
// In any other cases, it populates the propagation context on the scope.
|
||||||
|
func ContinueTrace(hub *Hub, traceparent, baggage string) SpanOption {
|
||||||
|
scope := hub.Scope()
|
||||||
|
propagationContext, _ := PropagationContextFromHeaders(traceparent, baggage)
|
||||||
|
scope.SetPropagationContext(propagationContext)
|
||||||
|
|
||||||
|
return ContinueFromHeaders(traceparent, baggage)
|
||||||
|
}
|
||||||
|
|
||||||
// ContinueFromRequest returns a span option that updates the span to continue
|
// ContinueFromRequest returns a span option that updates the span to continue
|
||||||
// an existing trace. If it cannot detect an existing trace in the request, the
|
// an existing trace. If it cannot detect an existing trace in the request, the
|
||||||
// span will be left unchanged.
|
// span will be left unchanged.
|
||||||
@@ -939,6 +977,7 @@ func SpanFromContext(ctx context.Context) *Span {
|
|||||||
func StartTransaction(ctx context.Context, name string, options ...SpanOption) *Span {
|
func StartTransaction(ctx context.Context, name string, options ...SpanOption) *Span {
|
||||||
currentTransaction, exists := ctx.Value(spanContextKey{}).(*Span)
|
currentTransaction, exists := ctx.Value(spanContextKey{}).(*Span)
|
||||||
if exists {
|
if exists {
|
||||||
|
currentTransaction.ctx = ctx
|
||||||
return currentTransaction
|
return currentTransaction
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
148
vendor/github.com/getsentry/sentry-go/transport.go
generated
vendored
148
vendor/github.com/getsentry/sentry-go/transport.go
generated
vendored
@@ -35,6 +35,7 @@ type Transport interface {
|
|||||||
Flush(timeout time.Duration) bool
|
Flush(timeout time.Duration) bool
|
||||||
Configure(options ClientOptions)
|
Configure(options ClientOptions)
|
||||||
SendEvent(event *Event)
|
SendEvent(event *Event)
|
||||||
|
Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func getProxyConfig(options ClientOptions) func(*http.Request) (*url.URL, error) {
|
func getProxyConfig(options ClientOptions) func(*http.Request) (*url.URL, error) {
|
||||||
@@ -95,55 +96,6 @@ func getRequestBodyFromEvent(event *Event) []byte {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func marshalMetrics(metrics []Metric) []byte {
|
|
||||||
var b bytes.Buffer
|
|
||||||
for i, metric := range metrics {
|
|
||||||
b.WriteString(metric.GetKey())
|
|
||||||
if unit := metric.GetUnit(); unit != "" {
|
|
||||||
b.WriteString(fmt.Sprintf("@%s", unit))
|
|
||||||
}
|
|
||||||
b.WriteString(fmt.Sprintf("%s|%s", metric.SerializeValue(), metric.GetType()))
|
|
||||||
if serializedTags := metric.SerializeTags(); serializedTags != "" {
|
|
||||||
b.WriteString(fmt.Sprintf("|#%s", serializedTags))
|
|
||||||
}
|
|
||||||
b.WriteString(fmt.Sprintf("|T%d", metric.GetTimestamp()))
|
|
||||||
|
|
||||||
if i < len(metrics)-1 {
|
|
||||||
b.WriteString("\n")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return b.Bytes()
|
|
||||||
}
|
|
||||||
|
|
||||||
func encodeMetric(enc *json.Encoder, b io.Writer, metrics []Metric) error {
|
|
||||||
body := marshalMetrics(metrics)
|
|
||||||
// Item header
|
|
||||||
err := enc.Encode(struct {
|
|
||||||
Type string `json:"type"`
|
|
||||||
Length int `json:"length"`
|
|
||||||
}{
|
|
||||||
Type: metricType,
|
|
||||||
Length: len(body),
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// metric payload
|
|
||||||
if _, err = b.Write(body); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// "Envelopes should be terminated with a trailing newline."
|
|
||||||
//
|
|
||||||
// [1]: https://develop.sentry.dev/sdk/envelopes/#envelopes
|
|
||||||
if _, err := b.Write([]byte("\n")); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func encodeAttachment(enc *json.Encoder, b io.Writer, attachment *Attachment) error {
|
func encodeAttachment(enc *json.Encoder, b io.Writer, attachment *Attachment) error {
|
||||||
// Attachment header
|
// Attachment header
|
||||||
err := enc.Encode(struct {
|
err := enc.Encode(struct {
|
||||||
@@ -228,8 +180,6 @@ func envelopeFromBody(event *Event, dsn *Dsn, sentAt time.Time, body json.RawMes
|
|||||||
switch event.Type {
|
switch event.Type {
|
||||||
case transactionType, checkInType:
|
case transactionType, checkInType:
|
||||||
err = encodeEnvelopeItem(enc, event.Type, body)
|
err = encodeEnvelopeItem(enc, event.Type, body)
|
||||||
case metricType:
|
|
||||||
err = encodeMetric(enc, &b, event.Metrics)
|
|
||||||
default:
|
default:
|
||||||
err = encodeEnvelopeItem(enc, eventType, body)
|
err = encodeEnvelopeItem(enc, eventType, body)
|
||||||
}
|
}
|
||||||
@@ -245,18 +195,6 @@ func envelopeFromBody(event *Event, dsn *Dsn, sentAt time.Time, body json.RawMes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Profile data
|
|
||||||
if event.sdkMetaData.transactionProfile != nil {
|
|
||||||
body, err = json.Marshal(event.sdkMetaData.transactionProfile)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
err = encodeEnvelopeItem(enc, profileType, body)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return &b, nil
|
return &b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,10 +217,12 @@ func getRequestFromEvent(ctx context.Context, event *Event, dsn *Dsn) (r *http.R
|
|||||||
r.Header.Set("X-Sentry-Auth", auth)
|
r.Header.Set("X-Sentry-Auth", auth)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
body := getRequestBodyFromEvent(event)
|
body := getRequestBodyFromEvent(event)
|
||||||
if body == nil {
|
if body == nil {
|
||||||
return nil, errors.New("event could not be marshaled")
|
return nil, errors.New("event could not be marshaled")
|
||||||
}
|
}
|
||||||
|
|
||||||
envelope, err := envelopeFromBody(event, dsn, time.Now(), body)
|
envelope, err := envelopeFromBody(event, dsn, time.Now(), body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -350,6 +290,9 @@ type HTTPTransport struct {
|
|||||||
|
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
limits ratelimit.Map
|
limits ratelimit.Map
|
||||||
|
|
||||||
|
// receiving signal will terminate worker.
|
||||||
|
done chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewHTTPTransport returns a new pre-configured instance of HTTPTransport.
|
// NewHTTPTransport returns a new pre-configured instance of HTTPTransport.
|
||||||
@@ -357,7 +300,7 @@ func NewHTTPTransport() *HTTPTransport {
|
|||||||
transport := HTTPTransport{
|
transport := HTTPTransport{
|
||||||
BufferSize: defaultBufferSize,
|
BufferSize: defaultBufferSize,
|
||||||
Timeout: defaultTimeout,
|
Timeout: defaultTimeout,
|
||||||
limits: make(ratelimit.Map),
|
done: make(chan struct{}),
|
||||||
}
|
}
|
||||||
return &transport
|
return &transport
|
||||||
}
|
}
|
||||||
@@ -523,6 +466,15 @@ fail:
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close will terminate events sending loop.
|
||||||
|
// It useful to prevent goroutines leak in case of multiple HTTPTransport instances initiated.
|
||||||
|
//
|
||||||
|
// Close should be called after Flush and before terminating the program
|
||||||
|
// otherwise some events may be lost.
|
||||||
|
func (t *HTTPTransport) Close() {
|
||||||
|
close(t.done)
|
||||||
|
}
|
||||||
|
|
||||||
func (t *HTTPTransport) worker() {
|
func (t *HTTPTransport) worker() {
|
||||||
for b := range t.buffer {
|
for b := range t.buffer {
|
||||||
// Signal that processing of the current batch has started.
|
// Signal that processing of the current batch has started.
|
||||||
@@ -533,30 +485,44 @@ func (t *HTTPTransport) worker() {
|
|||||||
t.buffer <- b
|
t.buffer <- b
|
||||||
|
|
||||||
// Process all batch items.
|
// Process all batch items.
|
||||||
for item := range b.items {
|
loop:
|
||||||
if t.disabled(item.category) {
|
for {
|
||||||
continue
|
select {
|
||||||
}
|
case <-t.done:
|
||||||
|
return
|
||||||
response, err := t.client.Do(item.request)
|
case item, open := <-b.items:
|
||||||
if err != nil {
|
if !open {
|
||||||
Logger.Printf("There was an issue with sending an event: %v", err)
|
break loop
|
||||||
continue
|
|
||||||
}
|
|
||||||
if response.StatusCode >= 400 && response.StatusCode <= 599 {
|
|
||||||
b, err := io.ReadAll(response.Body)
|
|
||||||
if err != nil {
|
|
||||||
Logger.Printf("Error while reading response code: %v", err)
|
|
||||||
}
|
}
|
||||||
Logger.Printf("Sending %s failed with the following error: %s", eventType, string(b))
|
if t.disabled(item.category) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := t.client.Do(item.request)
|
||||||
|
if err != nil {
|
||||||
|
Logger.Printf("There was an issue with sending an event: %v", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if response.StatusCode >= 400 && response.StatusCode <= 599 {
|
||||||
|
b, err := io.ReadAll(response.Body)
|
||||||
|
if err != nil {
|
||||||
|
Logger.Printf("Error while reading response code: %v", err)
|
||||||
|
}
|
||||||
|
Logger.Printf("Sending %s failed with the following error: %s", eventType, string(b))
|
||||||
|
}
|
||||||
|
|
||||||
|
t.mu.Lock()
|
||||||
|
if t.limits == nil {
|
||||||
|
t.limits = make(ratelimit.Map)
|
||||||
|
}
|
||||||
|
t.limits.Merge(ratelimit.FromResponse(response))
|
||||||
|
t.mu.Unlock()
|
||||||
|
|
||||||
|
// Drain body up to a limit and close it, allowing the
|
||||||
|
// transport to reuse TCP connections.
|
||||||
|
_, _ = io.CopyN(io.Discard, response.Body, maxDrainResponseBytes)
|
||||||
|
response.Body.Close()
|
||||||
}
|
}
|
||||||
t.mu.Lock()
|
|
||||||
t.limits.Merge(ratelimit.FromResponse(response))
|
|
||||||
t.mu.Unlock()
|
|
||||||
// Drain body up to a limit and close it, allowing the
|
|
||||||
// transport to reuse TCP connections.
|
|
||||||
_, _ = io.CopyN(io.Discard, response.Body, maxDrainResponseBytes)
|
|
||||||
response.Body.Close()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Signal that processing of the batch is done.
|
// Signal that processing of the batch is done.
|
||||||
@@ -644,6 +610,8 @@ func (t *HTTPSyncTransport) SendEvent(event *Event) {
|
|||||||
t.SendEventWithContext(context.Background(), event)
|
t.SendEventWithContext(context.Background(), event)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *HTTPSyncTransport) Close() {}
|
||||||
|
|
||||||
// SendEventWithContext assembles a new packet out of Event and sends it to the remote server.
|
// SendEventWithContext assembles a new packet out of Event and sends it to the remote server.
|
||||||
func (t *HTTPSyncTransport) SendEventWithContext(ctx context.Context, event *Event) {
|
func (t *HTTPSyncTransport) SendEventWithContext(ctx context.Context, event *Event) {
|
||||||
if t.dsn == nil {
|
if t.dsn == nil {
|
||||||
@@ -663,8 +631,6 @@ func (t *HTTPSyncTransport) SendEventWithContext(ctx context.Context, event *Eve
|
|||||||
switch {
|
switch {
|
||||||
case event.Type == transactionType:
|
case event.Type == transactionType:
|
||||||
eventType = "transaction"
|
eventType = "transaction"
|
||||||
case event.Type == metricType:
|
|
||||||
eventType = metricType
|
|
||||||
default:
|
default:
|
||||||
eventType = fmt.Sprintf("%s event", event.Level)
|
eventType = fmt.Sprintf("%s event", event.Level)
|
||||||
}
|
}
|
||||||
@@ -690,6 +656,10 @@ func (t *HTTPSyncTransport) SendEventWithContext(ctx context.Context, event *Eve
|
|||||||
}
|
}
|
||||||
|
|
||||||
t.mu.Lock()
|
t.mu.Lock()
|
||||||
|
if t.limits == nil {
|
||||||
|
t.limits = make(ratelimit.Map)
|
||||||
|
}
|
||||||
|
|
||||||
t.limits.Merge(ratelimit.FromResponse(response))
|
t.limits.Merge(ratelimit.FromResponse(response))
|
||||||
t.mu.Unlock()
|
t.mu.Unlock()
|
||||||
|
|
||||||
@@ -735,3 +705,5 @@ func (noopTransport) SendEvent(*Event) {
|
|||||||
func (noopTransport) Flush(time.Duration) bool {
|
func (noopTransport) Flush(time.Duration) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (noopTransport) Close() {}
|
||||||
|
|||||||
6
vendor/github.com/klauspost/compress/.goreleaser.yml
generated
vendored
6
vendor/github.com/klauspost/compress/.goreleaser.yml
generated
vendored
@@ -1,5 +1,5 @@
|
|||||||
# This is an example goreleaser.yaml file with some sane defaults.
|
version: 2
|
||||||
# Make sure to check the documentation at http://goreleaser.com
|
|
||||||
before:
|
before:
|
||||||
hooks:
|
hooks:
|
||||||
- ./gen.sh
|
- ./gen.sh
|
||||||
@@ -99,7 +99,7 @@ archives:
|
|||||||
checksum:
|
checksum:
|
||||||
name_template: 'checksums.txt'
|
name_template: 'checksums.txt'
|
||||||
snapshot:
|
snapshot:
|
||||||
name_template: "{{ .Tag }}-next"
|
version_template: "{{ .Tag }}-next"
|
||||||
changelog:
|
changelog:
|
||||||
sort: asc
|
sort: asc
|
||||||
filters:
|
filters:
|
||||||
|
|||||||
29
vendor/github.com/klauspost/compress/README.md
generated
vendored
29
vendor/github.com/klauspost/compress/README.md
generated
vendored
@@ -16,6 +16,27 @@ This package provides various compression algorithms.
|
|||||||
|
|
||||||
# changelog
|
# changelog
|
||||||
|
|
||||||
|
* Sep 23rd, 2024 - [1.17.10](https://github.com/klauspost/compress/releases/tag/v1.17.10)
|
||||||
|
* gzhttp: Add TransportAlwaysDecompress option. https://github.com/klauspost/compress/pull/978
|
||||||
|
* gzhttp: Add supported decompress request body by @mirecl in https://github.com/klauspost/compress/pull/1002
|
||||||
|
* s2: Add EncodeBuffer buffer recycling callback https://github.com/klauspost/compress/pull/982
|
||||||
|
* zstd: Improve memory usage on small streaming encodes https://github.com/klauspost/compress/pull/1007
|
||||||
|
* flate: read data written with partial flush by @vajexal in https://github.com/klauspost/compress/pull/996
|
||||||
|
|
||||||
|
* Jun 12th, 2024 - [1.17.9](https://github.com/klauspost/compress/releases/tag/v1.17.9)
|
||||||
|
* s2: Reduce ReadFrom temporary allocations https://github.com/klauspost/compress/pull/949
|
||||||
|
* flate, zstd: Shave some bytes off amd64 matchLen by @greatroar in https://github.com/klauspost/compress/pull/963
|
||||||
|
* Upgrade zip/zlib to 1.22.4 upstream https://github.com/klauspost/compress/pull/970 https://github.com/klauspost/compress/pull/971
|
||||||
|
* zstd: BuildDict fails with RLE table https://github.com/klauspost/compress/pull/951
|
||||||
|
|
||||||
|
* Apr 9th, 2024 - [1.17.8](https://github.com/klauspost/compress/releases/tag/v1.17.8)
|
||||||
|
* zstd: Reject blocks where reserved values are not 0 https://github.com/klauspost/compress/pull/885
|
||||||
|
* zstd: Add RLE detection+encoding https://github.com/klauspost/compress/pull/938
|
||||||
|
|
||||||
|
* Feb 21st, 2024 - [1.17.7](https://github.com/klauspost/compress/releases/tag/v1.17.7)
|
||||||
|
* s2: Add AsyncFlush method: Complete the block without flushing by @Jille in https://github.com/klauspost/compress/pull/927
|
||||||
|
* s2: Fix literal+repeat exceeds dst crash https://github.com/klauspost/compress/pull/930
|
||||||
|
|
||||||
* Feb 5th, 2024 - [1.17.6](https://github.com/klauspost/compress/releases/tag/v1.17.6)
|
* Feb 5th, 2024 - [1.17.6](https://github.com/klauspost/compress/releases/tag/v1.17.6)
|
||||||
* zstd: Fix incorrect repeat coding in best mode https://github.com/klauspost/compress/pull/923
|
* zstd: Fix incorrect repeat coding in best mode https://github.com/klauspost/compress/pull/923
|
||||||
* s2: Fix DecodeConcurrent deadlock on errors https://github.com/klauspost/compress/pull/925
|
* s2: Fix DecodeConcurrent deadlock on errors https://github.com/klauspost/compress/pull/925
|
||||||
@@ -81,7 +102,7 @@ https://github.com/klauspost/compress/pull/919 https://github.com/klauspost/comp
|
|||||||
* zstd: Various minor improvements by @greatroar in https://github.com/klauspost/compress/pull/788 https://github.com/klauspost/compress/pull/794 https://github.com/klauspost/compress/pull/795
|
* zstd: Various minor improvements by @greatroar in https://github.com/klauspost/compress/pull/788 https://github.com/klauspost/compress/pull/794 https://github.com/klauspost/compress/pull/795
|
||||||
* s2: Fix huge block overflow https://github.com/klauspost/compress/pull/779
|
* s2: Fix huge block overflow https://github.com/klauspost/compress/pull/779
|
||||||
* s2: Allow CustomEncoder fallback https://github.com/klauspost/compress/pull/780
|
* s2: Allow CustomEncoder fallback https://github.com/klauspost/compress/pull/780
|
||||||
* gzhttp: Suppport ResponseWriter Unwrap() in gzhttp handler by @jgimenez in https://github.com/klauspost/compress/pull/799
|
* gzhttp: Support ResponseWriter Unwrap() in gzhttp handler by @jgimenez in https://github.com/klauspost/compress/pull/799
|
||||||
|
|
||||||
* Mar 13, 2023 - [v1.16.1](https://github.com/klauspost/compress/releases/tag/v1.16.1)
|
* Mar 13, 2023 - [v1.16.1](https://github.com/klauspost/compress/releases/tag/v1.16.1)
|
||||||
* zstd: Speed up + improve best encoder by @greatroar in https://github.com/klauspost/compress/pull/776
|
* zstd: Speed up + improve best encoder by @greatroar in https://github.com/klauspost/compress/pull/776
|
||||||
@@ -136,7 +157,7 @@ https://github.com/klauspost/compress/pull/919 https://github.com/klauspost/comp
|
|||||||
* zstd: Add [WithDecodeAllCapLimit](https://pkg.go.dev/github.com/klauspost/compress@v1.15.10/zstd#WithDecodeAllCapLimit) https://github.com/klauspost/compress/pull/649
|
* zstd: Add [WithDecodeAllCapLimit](https://pkg.go.dev/github.com/klauspost/compress@v1.15.10/zstd#WithDecodeAllCapLimit) https://github.com/klauspost/compress/pull/649
|
||||||
* Add Go 1.19 - deprecate Go 1.16 https://github.com/klauspost/compress/pull/651
|
* Add Go 1.19 - deprecate Go 1.16 https://github.com/klauspost/compress/pull/651
|
||||||
* flate: Improve level 5+6 compression https://github.com/klauspost/compress/pull/656
|
* flate: Improve level 5+6 compression https://github.com/klauspost/compress/pull/656
|
||||||
* zstd: Improve "better" compresssion https://github.com/klauspost/compress/pull/657
|
* zstd: Improve "better" compression https://github.com/klauspost/compress/pull/657
|
||||||
* s2: Improve "best" compression https://github.com/klauspost/compress/pull/658
|
* s2: Improve "best" compression https://github.com/klauspost/compress/pull/658
|
||||||
* s2: Improve "better" compression. https://github.com/klauspost/compress/pull/635
|
* s2: Improve "better" compression. https://github.com/klauspost/compress/pull/635
|
||||||
* s2: Slightly faster non-assembly decompression https://github.com/klauspost/compress/pull/646
|
* s2: Slightly faster non-assembly decompression https://github.com/klauspost/compress/pull/646
|
||||||
@@ -339,7 +360,7 @@ While the release has been extensively tested, it is recommended to testing when
|
|||||||
* s2: Fix binaries.
|
* s2: Fix binaries.
|
||||||
|
|
||||||
* Feb 25, 2021 (v1.11.8)
|
* Feb 25, 2021 (v1.11.8)
|
||||||
* s2: Fixed occational out-of-bounds write on amd64. Upgrade recommended.
|
* s2: Fixed occasional out-of-bounds write on amd64. Upgrade recommended.
|
||||||
* s2: Add AMD64 assembly for better mode. 25-50% faster. [#315](https://github.com/klauspost/compress/pull/315)
|
* s2: Add AMD64 assembly for better mode. 25-50% faster. [#315](https://github.com/klauspost/compress/pull/315)
|
||||||
* s2: Less upfront decoder allocation. [#322](https://github.com/klauspost/compress/pull/322)
|
* s2: Less upfront decoder allocation. [#322](https://github.com/klauspost/compress/pull/322)
|
||||||
* zstd: Faster "compression" of incompressible data. [#314](https://github.com/klauspost/compress/pull/314)
|
* zstd: Faster "compression" of incompressible data. [#314](https://github.com/klauspost/compress/pull/314)
|
||||||
@@ -518,7 +539,7 @@ While the release has been extensively tested, it is recommended to testing when
|
|||||||
* Feb 19, 2016: Faster bit writer, level -2 is 15% faster, level 1 is 4% faster.
|
* Feb 19, 2016: Faster bit writer, level -2 is 15% faster, level 1 is 4% faster.
|
||||||
* Feb 19, 2016: Handle small payloads faster in level 1-3.
|
* Feb 19, 2016: Handle small payloads faster in level 1-3.
|
||||||
* Feb 19, 2016: Added faster level 2 + 3 compression modes.
|
* Feb 19, 2016: Added faster level 2 + 3 compression modes.
|
||||||
* Feb 19, 2016: [Rebalanced compression levels](https://blog.klauspost.com/rebalancing-deflate-compression-levels/), so there is a more even progresssion in terms of compression. New default level is 5.
|
* Feb 19, 2016: [Rebalanced compression levels](https://blog.klauspost.com/rebalancing-deflate-compression-levels/), so there is a more even progression in terms of compression. New default level is 5.
|
||||||
* Feb 14, 2016: Snappy: Merge upstream changes.
|
* Feb 14, 2016: Snappy: Merge upstream changes.
|
||||||
* Feb 14, 2016: Snappy: Fix aggressive skipping.
|
* Feb 14, 2016: Snappy: Fix aggressive skipping.
|
||||||
* Feb 14, 2016: Snappy: Update benchmark.
|
* Feb 14, 2016: Snappy: Update benchmark.
|
||||||
|
|||||||
2
vendor/github.com/klauspost/compress/fse/decompress.go
generated
vendored
2
vendor/github.com/klauspost/compress/fse/decompress.go
generated
vendored
@@ -15,7 +15,7 @@ const (
|
|||||||
// It is possible, but by no way guaranteed that corrupt data will
|
// It is possible, but by no way guaranteed that corrupt data will
|
||||||
// return an error.
|
// return an error.
|
||||||
// It is up to the caller to verify integrity of the returned data.
|
// It is up to the caller to verify integrity of the returned data.
|
||||||
// Use a predefined Scrach to set maximum acceptable output size.
|
// Use a predefined Scratch to set maximum acceptable output size.
|
||||||
func Decompress(b []byte, s *Scratch) ([]byte, error) {
|
func Decompress(b []byte, s *Scratch) ([]byte, error) {
|
||||||
s, err := s.prepare(b)
|
s, err := s.prepare(b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
4
vendor/github.com/klauspost/compress/huff0/decompress.go
generated
vendored
4
vendor/github.com/klauspost/compress/huff0/decompress.go
generated
vendored
@@ -1136,7 +1136,7 @@ func (s *Scratch) matches(ct cTable, w io.Writer) {
|
|||||||
errs++
|
errs++
|
||||||
}
|
}
|
||||||
if errs > 0 {
|
if errs > 0 {
|
||||||
fmt.Fprintf(w, "%d errros in base, stopping\n", errs)
|
fmt.Fprintf(w, "%d errors in base, stopping\n", errs)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// Ensure that all combinations are covered.
|
// Ensure that all combinations are covered.
|
||||||
@@ -1152,7 +1152,7 @@ func (s *Scratch) matches(ct cTable, w io.Writer) {
|
|||||||
errs++
|
errs++
|
||||||
}
|
}
|
||||||
if errs > 20 {
|
if errs > 20 {
|
||||||
fmt.Fprintf(w, "%d errros, stopping\n", errs)
|
fmt.Fprintf(w, "%d errors, stopping\n", errs)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
4
vendor/github.com/klauspost/compress/zstd/blockdec.go
generated
vendored
4
vendor/github.com/klauspost/compress/zstd/blockdec.go
generated
vendored
@@ -598,7 +598,9 @@ func (b *blockDec) prepareSequences(in []byte, hist *history) (err error) {
|
|||||||
printf("RLE set to 0x%x, code: %v", symb, v)
|
printf("RLE set to 0x%x, code: %v", symb, v)
|
||||||
}
|
}
|
||||||
case compModeFSE:
|
case compModeFSE:
|
||||||
println("Reading table for", tableIndex(i))
|
if debugDecoder {
|
||||||
|
println("Reading table for", tableIndex(i))
|
||||||
|
}
|
||||||
if seq.fse == nil || seq.fse.preDefined {
|
if seq.fse == nil || seq.fse.preDefined {
|
||||||
seq.fse = fseDecoderPool.Get().(*fseDecoder)
|
seq.fse = fseDecoderPool.Get().(*fseDecoder)
|
||||||
}
|
}
|
||||||
|
|||||||
32
vendor/github.com/klauspost/compress/zstd/enc_better.go
generated
vendored
32
vendor/github.com/klauspost/compress/zstd/enc_better.go
generated
vendored
@@ -179,9 +179,9 @@ encodeLoop:
|
|||||||
if repIndex >= 0 && load3232(src, repIndex) == uint32(cv>>(repOff*8)) {
|
if repIndex >= 0 && load3232(src, repIndex) == uint32(cv>>(repOff*8)) {
|
||||||
// Consider history as well.
|
// Consider history as well.
|
||||||
var seq seq
|
var seq seq
|
||||||
lenght := 4 + e.matchlen(s+4+repOff, repIndex+4, src)
|
length := 4 + e.matchlen(s+4+repOff, repIndex+4, src)
|
||||||
|
|
||||||
seq.matchLen = uint32(lenght - zstdMinMatch)
|
seq.matchLen = uint32(length - zstdMinMatch)
|
||||||
|
|
||||||
// We might be able to match backwards.
|
// We might be able to match backwards.
|
||||||
// Extend as long as we can.
|
// Extend as long as we can.
|
||||||
@@ -210,12 +210,12 @@ encodeLoop:
|
|||||||
|
|
||||||
// Index match start+1 (long) -> s - 1
|
// Index match start+1 (long) -> s - 1
|
||||||
index0 := s + repOff
|
index0 := s + repOff
|
||||||
s += lenght + repOff
|
s += length + repOff
|
||||||
|
|
||||||
nextEmit = s
|
nextEmit = s
|
||||||
if s >= sLimit {
|
if s >= sLimit {
|
||||||
if debugEncoder {
|
if debugEncoder {
|
||||||
println("repeat ended", s, lenght)
|
println("repeat ended", s, length)
|
||||||
|
|
||||||
}
|
}
|
||||||
break encodeLoop
|
break encodeLoop
|
||||||
@@ -241,9 +241,9 @@ encodeLoop:
|
|||||||
if false && repIndex >= 0 && load6432(src, repIndex) == load6432(src, s+repOff) {
|
if false && repIndex >= 0 && load6432(src, repIndex) == load6432(src, s+repOff) {
|
||||||
// Consider history as well.
|
// Consider history as well.
|
||||||
var seq seq
|
var seq seq
|
||||||
lenght := 8 + e.matchlen(s+8+repOff2, repIndex+8, src)
|
length := 8 + e.matchlen(s+8+repOff2, repIndex+8, src)
|
||||||
|
|
||||||
seq.matchLen = uint32(lenght - zstdMinMatch)
|
seq.matchLen = uint32(length - zstdMinMatch)
|
||||||
|
|
||||||
// We might be able to match backwards.
|
// We might be able to match backwards.
|
||||||
// Extend as long as we can.
|
// Extend as long as we can.
|
||||||
@@ -270,11 +270,11 @@ encodeLoop:
|
|||||||
}
|
}
|
||||||
blk.sequences = append(blk.sequences, seq)
|
blk.sequences = append(blk.sequences, seq)
|
||||||
|
|
||||||
s += lenght + repOff2
|
s += length + repOff2
|
||||||
nextEmit = s
|
nextEmit = s
|
||||||
if s >= sLimit {
|
if s >= sLimit {
|
||||||
if debugEncoder {
|
if debugEncoder {
|
||||||
println("repeat ended", s, lenght)
|
println("repeat ended", s, length)
|
||||||
|
|
||||||
}
|
}
|
||||||
break encodeLoop
|
break encodeLoop
|
||||||
@@ -708,9 +708,9 @@ encodeLoop:
|
|||||||
if repIndex >= 0 && load3232(src, repIndex) == uint32(cv>>(repOff*8)) {
|
if repIndex >= 0 && load3232(src, repIndex) == uint32(cv>>(repOff*8)) {
|
||||||
// Consider history as well.
|
// Consider history as well.
|
||||||
var seq seq
|
var seq seq
|
||||||
lenght := 4 + e.matchlen(s+4+repOff, repIndex+4, src)
|
length := 4 + e.matchlen(s+4+repOff, repIndex+4, src)
|
||||||
|
|
||||||
seq.matchLen = uint32(lenght - zstdMinMatch)
|
seq.matchLen = uint32(length - zstdMinMatch)
|
||||||
|
|
||||||
// We might be able to match backwards.
|
// We might be able to match backwards.
|
||||||
// Extend as long as we can.
|
// Extend as long as we can.
|
||||||
@@ -738,12 +738,12 @@ encodeLoop:
|
|||||||
blk.sequences = append(blk.sequences, seq)
|
blk.sequences = append(blk.sequences, seq)
|
||||||
|
|
||||||
// Index match start+1 (long) -> s - 1
|
// Index match start+1 (long) -> s - 1
|
||||||
s += lenght + repOff
|
s += length + repOff
|
||||||
|
|
||||||
nextEmit = s
|
nextEmit = s
|
||||||
if s >= sLimit {
|
if s >= sLimit {
|
||||||
if debugEncoder {
|
if debugEncoder {
|
||||||
println("repeat ended", s, lenght)
|
println("repeat ended", s, length)
|
||||||
|
|
||||||
}
|
}
|
||||||
break encodeLoop
|
break encodeLoop
|
||||||
@@ -772,9 +772,9 @@ encodeLoop:
|
|||||||
if false && repIndex >= 0 && load6432(src, repIndex) == load6432(src, s+repOff) {
|
if false && repIndex >= 0 && load6432(src, repIndex) == load6432(src, s+repOff) {
|
||||||
// Consider history as well.
|
// Consider history as well.
|
||||||
var seq seq
|
var seq seq
|
||||||
lenght := 8 + e.matchlen(s+8+repOff2, repIndex+8, src)
|
length := 8 + e.matchlen(s+8+repOff2, repIndex+8, src)
|
||||||
|
|
||||||
seq.matchLen = uint32(lenght - zstdMinMatch)
|
seq.matchLen = uint32(length - zstdMinMatch)
|
||||||
|
|
||||||
// We might be able to match backwards.
|
// We might be able to match backwards.
|
||||||
// Extend as long as we can.
|
// Extend as long as we can.
|
||||||
@@ -801,11 +801,11 @@ encodeLoop:
|
|||||||
}
|
}
|
||||||
blk.sequences = append(blk.sequences, seq)
|
blk.sequences = append(blk.sequences, seq)
|
||||||
|
|
||||||
s += lenght + repOff2
|
s += length + repOff2
|
||||||
nextEmit = s
|
nextEmit = s
|
||||||
if s >= sLimit {
|
if s >= sLimit {
|
||||||
if debugEncoder {
|
if debugEncoder {
|
||||||
println("repeat ended", s, lenght)
|
println("repeat ended", s, length)
|
||||||
|
|
||||||
}
|
}
|
||||||
break encodeLoop
|
break encodeLoop
|
||||||
|
|||||||
16
vendor/github.com/klauspost/compress/zstd/enc_dfast.go
generated
vendored
16
vendor/github.com/klauspost/compress/zstd/enc_dfast.go
generated
vendored
@@ -138,9 +138,9 @@ encodeLoop:
|
|||||||
if repIndex >= 0 && load3232(src, repIndex) == uint32(cv>>(repOff*8)) {
|
if repIndex >= 0 && load3232(src, repIndex) == uint32(cv>>(repOff*8)) {
|
||||||
// Consider history as well.
|
// Consider history as well.
|
||||||
var seq seq
|
var seq seq
|
||||||
lenght := 4 + e.matchlen(s+4+repOff, repIndex+4, src)
|
length := 4 + e.matchlen(s+4+repOff, repIndex+4, src)
|
||||||
|
|
||||||
seq.matchLen = uint32(lenght - zstdMinMatch)
|
seq.matchLen = uint32(length - zstdMinMatch)
|
||||||
|
|
||||||
// We might be able to match backwards.
|
// We might be able to match backwards.
|
||||||
// Extend as long as we can.
|
// Extend as long as we can.
|
||||||
@@ -166,11 +166,11 @@ encodeLoop:
|
|||||||
println("repeat sequence", seq, "next s:", s)
|
println("repeat sequence", seq, "next s:", s)
|
||||||
}
|
}
|
||||||
blk.sequences = append(blk.sequences, seq)
|
blk.sequences = append(blk.sequences, seq)
|
||||||
s += lenght + repOff
|
s += length + repOff
|
||||||
nextEmit = s
|
nextEmit = s
|
||||||
if s >= sLimit {
|
if s >= sLimit {
|
||||||
if debugEncoder {
|
if debugEncoder {
|
||||||
println("repeat ended", s, lenght)
|
println("repeat ended", s, length)
|
||||||
|
|
||||||
}
|
}
|
||||||
break encodeLoop
|
break encodeLoop
|
||||||
@@ -798,9 +798,9 @@ encodeLoop:
|
|||||||
if repIndex >= 0 && load3232(src, repIndex) == uint32(cv>>(repOff*8)) {
|
if repIndex >= 0 && load3232(src, repIndex) == uint32(cv>>(repOff*8)) {
|
||||||
// Consider history as well.
|
// Consider history as well.
|
||||||
var seq seq
|
var seq seq
|
||||||
lenght := 4 + e.matchlen(s+4+repOff, repIndex+4, src)
|
length := 4 + e.matchlen(s+4+repOff, repIndex+4, src)
|
||||||
|
|
||||||
seq.matchLen = uint32(lenght - zstdMinMatch)
|
seq.matchLen = uint32(length - zstdMinMatch)
|
||||||
|
|
||||||
// We might be able to match backwards.
|
// We might be able to match backwards.
|
||||||
// Extend as long as we can.
|
// Extend as long as we can.
|
||||||
@@ -826,11 +826,11 @@ encodeLoop:
|
|||||||
println("repeat sequence", seq, "next s:", s)
|
println("repeat sequence", seq, "next s:", s)
|
||||||
}
|
}
|
||||||
blk.sequences = append(blk.sequences, seq)
|
blk.sequences = append(blk.sequences, seq)
|
||||||
s += lenght + repOff
|
s += length + repOff
|
||||||
nextEmit = s
|
nextEmit = s
|
||||||
if s >= sLimit {
|
if s >= sLimit {
|
||||||
if debugEncoder {
|
if debugEncoder {
|
||||||
println("repeat ended", s, lenght)
|
println("repeat ended", s, length)
|
||||||
|
|
||||||
}
|
}
|
||||||
break encodeLoop
|
break encodeLoop
|
||||||
|
|||||||
45
vendor/github.com/klauspost/compress/zstd/encoder.go
generated
vendored
45
vendor/github.com/klauspost/compress/zstd/encoder.go
generated
vendored
@@ -6,6 +6,7 @@ package zstd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
@@ -149,6 +150,9 @@ func (e *Encoder) ResetContentSize(w io.Writer, size int64) {
|
|||||||
// and write CRC if requested.
|
// and write CRC if requested.
|
||||||
func (e *Encoder) Write(p []byte) (n int, err error) {
|
func (e *Encoder) Write(p []byte) (n int, err error) {
|
||||||
s := &e.state
|
s := &e.state
|
||||||
|
if s.eofWritten {
|
||||||
|
return 0, ErrEncoderClosed
|
||||||
|
}
|
||||||
for len(p) > 0 {
|
for len(p) > 0 {
|
||||||
if len(p)+len(s.filling) < e.o.blockSize {
|
if len(p)+len(s.filling) < e.o.blockSize {
|
||||||
if e.o.crc {
|
if e.o.crc {
|
||||||
@@ -202,7 +206,7 @@ func (e *Encoder) nextBlock(final bool) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if final && len(s.filling) > 0 {
|
if final && len(s.filling) > 0 {
|
||||||
s.current = e.EncodeAll(s.filling, s.current[:0])
|
s.current = e.encodeAll(s.encoder, s.filling, s.current[:0])
|
||||||
var n2 int
|
var n2 int
|
||||||
n2, s.err = s.w.Write(s.current)
|
n2, s.err = s.w.Write(s.current)
|
||||||
if s.err != nil {
|
if s.err != nil {
|
||||||
@@ -288,6 +292,9 @@ func (e *Encoder) nextBlock(final bool) error {
|
|||||||
s.filling, s.current, s.previous = s.previous[:0], s.filling, s.current
|
s.filling, s.current, s.previous = s.previous[:0], s.filling, s.current
|
||||||
s.nInput += int64(len(s.current))
|
s.nInput += int64(len(s.current))
|
||||||
s.wg.Add(1)
|
s.wg.Add(1)
|
||||||
|
if final {
|
||||||
|
s.eofWritten = true
|
||||||
|
}
|
||||||
go func(src []byte) {
|
go func(src []byte) {
|
||||||
if debugEncoder {
|
if debugEncoder {
|
||||||
println("Adding block,", len(src), "bytes, final:", final)
|
println("Adding block,", len(src), "bytes, final:", final)
|
||||||
@@ -303,9 +310,6 @@ func (e *Encoder) nextBlock(final bool) error {
|
|||||||
blk := enc.Block()
|
blk := enc.Block()
|
||||||
enc.Encode(blk, src)
|
enc.Encode(blk, src)
|
||||||
blk.last = final
|
blk.last = final
|
||||||
if final {
|
|
||||||
s.eofWritten = true
|
|
||||||
}
|
|
||||||
// Wait for pending writes.
|
// Wait for pending writes.
|
||||||
s.wWg.Wait()
|
s.wWg.Wait()
|
||||||
if s.writeErr != nil {
|
if s.writeErr != nil {
|
||||||
@@ -401,12 +405,20 @@ func (e *Encoder) Flush() error {
|
|||||||
if len(s.filling) > 0 {
|
if len(s.filling) > 0 {
|
||||||
err := e.nextBlock(false)
|
err := e.nextBlock(false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// Ignore Flush after Close.
|
||||||
|
if errors.Is(s.err, ErrEncoderClosed) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.wg.Wait()
|
s.wg.Wait()
|
||||||
s.wWg.Wait()
|
s.wWg.Wait()
|
||||||
if s.err != nil {
|
if s.err != nil {
|
||||||
|
// Ignore Flush after Close.
|
||||||
|
if errors.Is(s.err, ErrEncoderClosed) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return s.err
|
return s.err
|
||||||
}
|
}
|
||||||
return s.writeErr
|
return s.writeErr
|
||||||
@@ -422,6 +434,9 @@ func (e *Encoder) Close() error {
|
|||||||
}
|
}
|
||||||
err := e.nextBlock(true)
|
err := e.nextBlock(true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if errors.Is(s.err, ErrEncoderClosed) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if s.frameContentSize > 0 {
|
if s.frameContentSize > 0 {
|
||||||
@@ -459,6 +474,11 @@ func (e *Encoder) Close() error {
|
|||||||
}
|
}
|
||||||
_, s.err = s.w.Write(frame)
|
_, s.err = s.w.Write(frame)
|
||||||
}
|
}
|
||||||
|
if s.err == nil {
|
||||||
|
s.err = ErrEncoderClosed
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
return s.err
|
return s.err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -469,6 +489,15 @@ func (e *Encoder) Close() error {
|
|||||||
// Data compressed with EncodeAll can be decoded with the Decoder,
|
// Data compressed with EncodeAll can be decoded with the Decoder,
|
||||||
// using either a stream or DecodeAll.
|
// using either a stream or DecodeAll.
|
||||||
func (e *Encoder) EncodeAll(src, dst []byte) []byte {
|
func (e *Encoder) EncodeAll(src, dst []byte) []byte {
|
||||||
|
e.init.Do(e.initialize)
|
||||||
|
enc := <-e.encoders
|
||||||
|
defer func() {
|
||||||
|
e.encoders <- enc
|
||||||
|
}()
|
||||||
|
return e.encodeAll(enc, src, dst)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Encoder) encodeAll(enc encoder, src, dst []byte) []byte {
|
||||||
if len(src) == 0 {
|
if len(src) == 0 {
|
||||||
if e.o.fullZero {
|
if e.o.fullZero {
|
||||||
// Add frame header.
|
// Add frame header.
|
||||||
@@ -491,13 +520,7 @@ func (e *Encoder) EncodeAll(src, dst []byte) []byte {
|
|||||||
}
|
}
|
||||||
return dst
|
return dst
|
||||||
}
|
}
|
||||||
e.init.Do(e.initialize)
|
|
||||||
enc := <-e.encoders
|
|
||||||
defer func() {
|
|
||||||
// Release encoder reference to last block.
|
|
||||||
// If a non-single block is needed the encoder will reset again.
|
|
||||||
e.encoders <- enc
|
|
||||||
}()
|
|
||||||
// Use single segments when above minimum window and below window size.
|
// Use single segments when above minimum window and below window size.
|
||||||
single := len(src) <= e.o.windowSize && len(src) > MinWindowSize
|
single := len(src) <= e.o.windowSize && len(src) > MinWindowSize
|
||||||
if e.o.single != nil {
|
if e.o.single != nil {
|
||||||
|
|||||||
4
vendor/github.com/klauspost/compress/zstd/framedec.go
generated
vendored
4
vendor/github.com/klauspost/compress/zstd/framedec.go
generated
vendored
@@ -146,7 +146,9 @@ func (d *frameDec) reset(br byteBuffer) error {
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
printf("raw: %x, mantissa: %d, exponent: %d\n", wd, wd&7, wd>>3)
|
if debugDecoder {
|
||||||
|
printf("raw: %x, mantissa: %d, exponent: %d\n", wd, wd&7, wd>>3)
|
||||||
|
}
|
||||||
windowLog := 10 + (wd >> 3)
|
windowLog := 10 + (wd >> 3)
|
||||||
windowBase := uint64(1) << windowLog
|
windowBase := uint64(1) << windowLog
|
||||||
windowAdd := (windowBase / 8) * uint64(wd&0x7)
|
windowAdd := (windowBase / 8) * uint64(wd&0x7)
|
||||||
|
|||||||
4
vendor/github.com/klauspost/compress/zstd/seqdec_amd64.go
generated
vendored
4
vendor/github.com/klauspost/compress/zstd/seqdec_amd64.go
generated
vendored
@@ -146,7 +146,7 @@ func (s *sequenceDecs) decodeSyncSimple(hist []byte) (bool, error) {
|
|||||||
return true, fmt.Errorf("output bigger than max block size (%d)", maxBlockSize)
|
return true, fmt.Errorf("output bigger than max block size (%d)", maxBlockSize)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return true, fmt.Errorf("sequenceDecs_decode returned erronous code %d", errCode)
|
return true, fmt.Errorf("sequenceDecs_decode returned erroneous code %d", errCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
s.seqSize += ctx.litRemain
|
s.seqSize += ctx.litRemain
|
||||||
@@ -292,7 +292,7 @@ func (s *sequenceDecs) decode(seqs []seqVals) error {
|
|||||||
return io.ErrUnexpectedEOF
|
return io.ErrUnexpectedEOF
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Errorf("sequenceDecs_decode_amd64 returned erronous code %d", errCode)
|
return fmt.Errorf("sequenceDecs_decode_amd64 returned erroneous code %d", errCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.litRemain < 0 {
|
if ctx.litRemain < 0 {
|
||||||
|
|||||||
8
vendor/github.com/klauspost/compress/zstd/seqdec_amd64.s
generated
vendored
8
vendor/github.com/klauspost/compress/zstd/seqdec_amd64.s
generated
vendored
@@ -1814,7 +1814,7 @@ TEXT ·sequenceDecs_decodeSync_amd64(SB), $64-32
|
|||||||
MOVQ 40(SP), AX
|
MOVQ 40(SP), AX
|
||||||
ADDQ AX, 48(SP)
|
ADDQ AX, 48(SP)
|
||||||
|
|
||||||
// Calculate poiter to s.out[cap(s.out)] (a past-end pointer)
|
// Calculate pointer to s.out[cap(s.out)] (a past-end pointer)
|
||||||
ADDQ R10, 32(SP)
|
ADDQ R10, 32(SP)
|
||||||
|
|
||||||
// outBase += outPosition
|
// outBase += outPosition
|
||||||
@@ -2376,7 +2376,7 @@ TEXT ·sequenceDecs_decodeSync_bmi2(SB), $64-32
|
|||||||
MOVQ 40(SP), CX
|
MOVQ 40(SP), CX
|
||||||
ADDQ CX, 48(SP)
|
ADDQ CX, 48(SP)
|
||||||
|
|
||||||
// Calculate poiter to s.out[cap(s.out)] (a past-end pointer)
|
// Calculate pointer to s.out[cap(s.out)] (a past-end pointer)
|
||||||
ADDQ R9, 32(SP)
|
ADDQ R9, 32(SP)
|
||||||
|
|
||||||
// outBase += outPosition
|
// outBase += outPosition
|
||||||
@@ -2896,7 +2896,7 @@ TEXT ·sequenceDecs_decodeSync_safe_amd64(SB), $64-32
|
|||||||
MOVQ 40(SP), AX
|
MOVQ 40(SP), AX
|
||||||
ADDQ AX, 48(SP)
|
ADDQ AX, 48(SP)
|
||||||
|
|
||||||
// Calculate poiter to s.out[cap(s.out)] (a past-end pointer)
|
// Calculate pointer to s.out[cap(s.out)] (a past-end pointer)
|
||||||
ADDQ R10, 32(SP)
|
ADDQ R10, 32(SP)
|
||||||
|
|
||||||
// outBase += outPosition
|
// outBase += outPosition
|
||||||
@@ -3560,7 +3560,7 @@ TEXT ·sequenceDecs_decodeSync_safe_bmi2(SB), $64-32
|
|||||||
MOVQ 40(SP), CX
|
MOVQ 40(SP), CX
|
||||||
ADDQ CX, 48(SP)
|
ADDQ CX, 48(SP)
|
||||||
|
|
||||||
// Calculate poiter to s.out[cap(s.out)] (a past-end pointer)
|
// Calculate pointer to s.out[cap(s.out)] (a past-end pointer)
|
||||||
ADDQ R9, 32(SP)
|
ADDQ R9, 32(SP)
|
||||||
|
|
||||||
// outBase += outPosition
|
// outBase += outPosition
|
||||||
|
|||||||
4
vendor/github.com/klauspost/compress/zstd/zstd.go
generated
vendored
4
vendor/github.com/klauspost/compress/zstd/zstd.go
generated
vendored
@@ -88,6 +88,10 @@ var (
|
|||||||
// Close has been called.
|
// Close has been called.
|
||||||
ErrDecoderClosed = errors.New("decoder used after Close")
|
ErrDecoderClosed = errors.New("decoder used after Close")
|
||||||
|
|
||||||
|
// ErrEncoderClosed will be returned if the Encoder was used after
|
||||||
|
// Close has been called.
|
||||||
|
ErrEncoderClosed = errors.New("encoder used after Close")
|
||||||
|
|
||||||
// ErrDecoderNilInput is returned when a nil Reader was provided
|
// ErrDecoderNilInput is returned when a nil Reader was provided
|
||||||
// and an operation other than Reset/DecodeAll/Close was attempted.
|
// and an operation other than Reset/DecodeAll/Close was attempted.
|
||||||
ErrDecoderNilInput = errors.New("nil input provided as reader")
|
ErrDecoderNilInput = errors.New("nil input provided as reader")
|
||||||
|
|||||||
5
vendor/github.com/prometheus/client_golang/NOTICE
generated
vendored
5
vendor/github.com/prometheus/client_golang/NOTICE
generated
vendored
@@ -16,8 +16,3 @@ Go support for Protocol Buffers - Google's data interchange format
|
|||||||
http://github.com/golang/protobuf/
|
http://github.com/golang/protobuf/
|
||||||
Copyright 2010 The Go Authors
|
Copyright 2010 The Go Authors
|
||||||
See source code for license details.
|
See source code for license details.
|
||||||
|
|
||||||
Support for streaming Protocol Buffer messages for the Go language (golang).
|
|
||||||
https://github.com/matttproud/golang_protobuf_extensions
|
|
||||||
Copyright 2013 Matt T. Proud
|
|
||||||
Licensed under the Apache License, Version 2.0
|
|
||||||
|
|||||||
55
vendor/github.com/prometheus/client_golang/prometheus/go_collector.go
generated
vendored
55
vendor/github.com/prometheus/client_golang/prometheus/go_collector.go
generated
vendored
@@ -22,13 +22,13 @@ import (
|
|||||||
// goRuntimeMemStats provides the metrics initially provided by runtime.ReadMemStats.
|
// goRuntimeMemStats provides the metrics initially provided by runtime.ReadMemStats.
|
||||||
// From Go 1.17 those similar (and better) statistics are provided by runtime/metrics, so
|
// From Go 1.17 those similar (and better) statistics are provided by runtime/metrics, so
|
||||||
// while eval closure works on runtime.MemStats, the struct from Go 1.17+ is
|
// while eval closure works on runtime.MemStats, the struct from Go 1.17+ is
|
||||||
// populated using runtime/metrics.
|
// populated using runtime/metrics. Those are the defaults we can't alter.
|
||||||
func goRuntimeMemStats() memStatsMetrics {
|
func goRuntimeMemStats() memStatsMetrics {
|
||||||
return memStatsMetrics{
|
return memStatsMetrics{
|
||||||
{
|
{
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("alloc_bytes"),
|
memstatNamespace("alloc_bytes"),
|
||||||
"Number of bytes allocated and still in use.",
|
"Number of bytes allocated in heap and currently in use. Equals to /memory/classes/heap/objects:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.Alloc) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.Alloc) },
|
||||||
@@ -36,7 +36,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("alloc_bytes_total"),
|
memstatNamespace("alloc_bytes_total"),
|
||||||
"Total number of bytes allocated, even if freed.",
|
"Total number of bytes allocated in heap until now, even if released already. Equals to /gc/heap/allocs:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.TotalAlloc) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.TotalAlloc) },
|
||||||
@@ -44,23 +44,16 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("sys_bytes"),
|
memstatNamespace("sys_bytes"),
|
||||||
"Number of bytes obtained from system.",
|
"Number of bytes obtained from system. Equals to /memory/classes/total:byte.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.Sys) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.Sys) },
|
||||||
valType: GaugeValue,
|
valType: GaugeValue,
|
||||||
}, {
|
|
||||||
desc: NewDesc(
|
|
||||||
memstatNamespace("lookups_total"),
|
|
||||||
"Total number of pointer lookups.",
|
|
||||||
nil, nil,
|
|
||||||
),
|
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.Lookups) },
|
|
||||||
valType: CounterValue,
|
|
||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("mallocs_total"),
|
memstatNamespace("mallocs_total"),
|
||||||
"Total number of mallocs.",
|
// TODO(bwplotka): We could add go_memstats_heap_objects, probably useful for discovery. Let's gather more feedback, kind of a waste of bytes for everybody for compatibility reasons to keep both, and we can't really rename/remove useful metric.
|
||||||
|
"Total number of heap objects allocated, both live and gc-ed. Semantically a counter version for go_memstats_heap_objects gauge. Equals to /gc/heap/allocs:objects + /gc/heap/tiny/allocs:objects.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.Mallocs) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.Mallocs) },
|
||||||
@@ -68,7 +61,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("frees_total"),
|
memstatNamespace("frees_total"),
|
||||||
"Total number of frees.",
|
"Total number of heap objects frees. Equals to /gc/heap/frees:objects + /gc/heap/tiny/allocs:objects.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.Frees) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.Frees) },
|
||||||
@@ -76,7 +69,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("heap_alloc_bytes"),
|
memstatNamespace("heap_alloc_bytes"),
|
||||||
"Number of heap bytes allocated and still in use.",
|
"Number of heap bytes allocated and currently in use, same as go_memstats_alloc_bytes. Equals to /memory/classes/heap/objects:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapAlloc) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapAlloc) },
|
||||||
@@ -84,7 +77,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("heap_sys_bytes"),
|
memstatNamespace("heap_sys_bytes"),
|
||||||
"Number of heap bytes obtained from system.",
|
"Number of heap bytes obtained from system. Equals to /memory/classes/heap/objects:bytes + /memory/classes/heap/unused:bytes + /memory/classes/heap/released:bytes + /memory/classes/heap/free:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapSys) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapSys) },
|
||||||
@@ -92,7 +85,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("heap_idle_bytes"),
|
memstatNamespace("heap_idle_bytes"),
|
||||||
"Number of heap bytes waiting to be used.",
|
"Number of heap bytes waiting to be used. Equals to /memory/classes/heap/released:bytes + /memory/classes/heap/free:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapIdle) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapIdle) },
|
||||||
@@ -100,7 +93,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("heap_inuse_bytes"),
|
memstatNamespace("heap_inuse_bytes"),
|
||||||
"Number of heap bytes that are in use.",
|
"Number of heap bytes that are in use. Equals to /memory/classes/heap/objects:bytes + /memory/classes/heap/unused:bytes",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapInuse) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapInuse) },
|
||||||
@@ -108,7 +101,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("heap_released_bytes"),
|
memstatNamespace("heap_released_bytes"),
|
||||||
"Number of heap bytes released to OS.",
|
"Number of heap bytes released to OS. Equals to /memory/classes/heap/released:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapReleased) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapReleased) },
|
||||||
@@ -116,7 +109,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("heap_objects"),
|
memstatNamespace("heap_objects"),
|
||||||
"Number of allocated objects.",
|
"Number of currently allocated objects. Equals to /gc/heap/objects:objects.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapObjects) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.HeapObjects) },
|
||||||
@@ -124,7 +117,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("stack_inuse_bytes"),
|
memstatNamespace("stack_inuse_bytes"),
|
||||||
"Number of bytes in use by the stack allocator.",
|
"Number of bytes obtained from system for stack allocator in non-CGO environments. Equals to /memory/classes/heap/stacks:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.StackInuse) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.StackInuse) },
|
||||||
@@ -132,7 +125,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("stack_sys_bytes"),
|
memstatNamespace("stack_sys_bytes"),
|
||||||
"Number of bytes obtained from system for stack allocator.",
|
"Number of bytes obtained from system for stack allocator. Equals to /memory/classes/heap/stacks:bytes + /memory/classes/os-stacks:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.StackSys) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.StackSys) },
|
||||||
@@ -140,7 +133,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("mspan_inuse_bytes"),
|
memstatNamespace("mspan_inuse_bytes"),
|
||||||
"Number of bytes in use by mspan structures.",
|
"Number of bytes in use by mspan structures. Equals to /memory/classes/metadata/mspan/inuse:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.MSpanInuse) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.MSpanInuse) },
|
||||||
@@ -148,7 +141,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("mspan_sys_bytes"),
|
memstatNamespace("mspan_sys_bytes"),
|
||||||
"Number of bytes used for mspan structures obtained from system.",
|
"Number of bytes used for mspan structures obtained from system. Equals to /memory/classes/metadata/mspan/inuse:bytes + /memory/classes/metadata/mspan/free:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.MSpanSys) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.MSpanSys) },
|
||||||
@@ -156,7 +149,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("mcache_inuse_bytes"),
|
memstatNamespace("mcache_inuse_bytes"),
|
||||||
"Number of bytes in use by mcache structures.",
|
"Number of bytes in use by mcache structures. Equals to /memory/classes/metadata/mcache/inuse:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.MCacheInuse) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.MCacheInuse) },
|
||||||
@@ -164,7 +157,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("mcache_sys_bytes"),
|
memstatNamespace("mcache_sys_bytes"),
|
||||||
"Number of bytes used for mcache structures obtained from system.",
|
"Number of bytes used for mcache structures obtained from system. Equals to /memory/classes/metadata/mcache/inuse:bytes + /memory/classes/metadata/mcache/free:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.MCacheSys) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.MCacheSys) },
|
||||||
@@ -172,7 +165,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("buck_hash_sys_bytes"),
|
memstatNamespace("buck_hash_sys_bytes"),
|
||||||
"Number of bytes used by the profiling bucket hash table.",
|
"Number of bytes used by the profiling bucket hash table. Equals to /memory/classes/profiling/buckets:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.BuckHashSys) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.BuckHashSys) },
|
||||||
@@ -180,7 +173,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("gc_sys_bytes"),
|
memstatNamespace("gc_sys_bytes"),
|
||||||
"Number of bytes used for garbage collection system metadata.",
|
"Number of bytes used for garbage collection system metadata. Equals to /memory/classes/metadata/other:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.GCSys) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.GCSys) },
|
||||||
@@ -188,7 +181,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("other_sys_bytes"),
|
memstatNamespace("other_sys_bytes"),
|
||||||
"Number of bytes used for other system allocations.",
|
"Number of bytes used for other system allocations. Equals to /memory/classes/other:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.OtherSys) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.OtherSys) },
|
||||||
@@ -196,7 +189,7 @@ func goRuntimeMemStats() memStatsMetrics {
|
|||||||
}, {
|
}, {
|
||||||
desc: NewDesc(
|
desc: NewDesc(
|
||||||
memstatNamespace("next_gc_bytes"),
|
memstatNamespace("next_gc_bytes"),
|
||||||
"Number of heap bytes when next garbage collection will take place.",
|
"Number of heap bytes when next garbage collection will take place. Equals to /gc/heap/goal:bytes.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
eval: func(ms *runtime.MemStats) float64 { return float64(ms.NextGC) },
|
eval: func(ms *runtime.MemStats) float64 { return float64(ms.NextGC) },
|
||||||
@@ -225,7 +218,7 @@ func newBaseGoCollector() baseGoCollector {
|
|||||||
nil, nil),
|
nil, nil),
|
||||||
gcDesc: NewDesc(
|
gcDesc: NewDesc(
|
||||||
"go_gc_duration_seconds",
|
"go_gc_duration_seconds",
|
||||||
"A summary of the pause duration of garbage collection cycles.",
|
"A summary of the wall-time pause (stop-the-world) duration in garbage collection cycles.",
|
||||||
nil, nil),
|
nil, nil),
|
||||||
gcLastTimeDesc: NewDesc(
|
gcLastTimeDesc: NewDesc(
|
||||||
"go_memstats_last_gc_time_seconds",
|
"go_memstats_last_gc_time_seconds",
|
||||||
|
|||||||
19
vendor/github.com/prometheus/client_golang/prometheus/go_collector_latest.go
generated
vendored
19
vendor/github.com/prometheus/client_golang/prometheus/go_collector_latest.go
generated
vendored
@@ -17,6 +17,7 @@
|
|||||||
package prometheus
|
package prometheus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"runtime"
|
"runtime"
|
||||||
"runtime/metrics"
|
"runtime/metrics"
|
||||||
@@ -153,7 +154,8 @@ func defaultGoCollectorOptions() internal.GoCollectorOptions {
|
|||||||
"/gc/heap/frees-by-size:bytes": goGCHeapFreesBytes,
|
"/gc/heap/frees-by-size:bytes": goGCHeapFreesBytes,
|
||||||
},
|
},
|
||||||
RuntimeMetricRules: []internal.GoCollectorRule{
|
RuntimeMetricRules: []internal.GoCollectorRule{
|
||||||
//{Matcher: regexp.MustCompile("")},
|
// Recommended metrics we want by default from runtime/metrics.
|
||||||
|
{Matcher: internal.GoCollectorDefaultRuntimeMetrics},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -203,6 +205,7 @@ func NewGoCollector(opts ...func(o *internal.GoCollectorOptions)) Collector {
|
|||||||
// to fail here. This condition is tested in TestExpectedRuntimeMetrics.
|
// to fail here. This condition is tested in TestExpectedRuntimeMetrics.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
help := attachOriginalName(d.Description.Description, d.Name)
|
||||||
|
|
||||||
sampleBuf = append(sampleBuf, metrics.Sample{Name: d.Name})
|
sampleBuf = append(sampleBuf, metrics.Sample{Name: d.Name})
|
||||||
sampleMap[d.Name] = &sampleBuf[len(sampleBuf)-1]
|
sampleMap[d.Name] = &sampleBuf[len(sampleBuf)-1]
|
||||||
@@ -214,7 +217,7 @@ func NewGoCollector(opts ...func(o *internal.GoCollectorOptions)) Collector {
|
|||||||
m = newBatchHistogram(
|
m = newBatchHistogram(
|
||||||
NewDesc(
|
NewDesc(
|
||||||
BuildFQName(namespace, subsystem, name),
|
BuildFQName(namespace, subsystem, name),
|
||||||
d.Description.Description,
|
help,
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
@@ -226,7 +229,7 @@ func NewGoCollector(opts ...func(o *internal.GoCollectorOptions)) Collector {
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Subsystem: subsystem,
|
Subsystem: subsystem,
|
||||||
Name: name,
|
Name: name,
|
||||||
Help: d.Description.Description,
|
Help: help,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
@@ -234,7 +237,7 @@ func NewGoCollector(opts ...func(o *internal.GoCollectorOptions)) Collector {
|
|||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Subsystem: subsystem,
|
Subsystem: subsystem,
|
||||||
Name: name,
|
Name: name,
|
||||||
Help: d.Description.Description,
|
Help: help,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
metricSet = append(metricSet, m)
|
metricSet = append(metricSet, m)
|
||||||
@@ -284,6 +287,10 @@ func NewGoCollector(opts ...func(o *internal.GoCollectorOptions)) Collector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func attachOriginalName(desc, origName string) string {
|
||||||
|
return fmt.Sprintf("%s Sourced from %s", desc, origName)
|
||||||
|
}
|
||||||
|
|
||||||
// Describe returns all descriptions of the collector.
|
// Describe returns all descriptions of the collector.
|
||||||
func (c *goCollector) Describe(ch chan<- *Desc) {
|
func (c *goCollector) Describe(ch chan<- *Desc) {
|
||||||
c.base.Describe(ch)
|
c.base.Describe(ch)
|
||||||
@@ -376,13 +383,13 @@ func unwrapScalarRMValue(v metrics.Value) float64 {
|
|||||||
//
|
//
|
||||||
// This should never happen because we always populate our metric
|
// This should never happen because we always populate our metric
|
||||||
// set from the runtime/metrics package.
|
// set from the runtime/metrics package.
|
||||||
panic("unexpected unsupported metric")
|
panic("unexpected bad kind metric")
|
||||||
default:
|
default:
|
||||||
// Unsupported metric kind.
|
// Unsupported metric kind.
|
||||||
//
|
//
|
||||||
// This should never happen because we check for this during initialization
|
// This should never happen because we check for this during initialization
|
||||||
// and flag and filter metrics whose kinds we don't understand.
|
// and flag and filter metrics whose kinds we don't understand.
|
||||||
panic("unexpected unsupported metric kind")
|
panic(fmt.Sprintf("unexpected unsupported metric: %v", v.Kind()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
268
vendor/github.com/prometheus/client_golang/prometheus/histogram.go
generated
vendored
268
vendor/github.com/prometheus/client_golang/prometheus/histogram.go
generated
vendored
@@ -440,7 +440,7 @@ type HistogramOpts struct {
|
|||||||
// constant (or any negative float value).
|
// constant (or any negative float value).
|
||||||
NativeHistogramZeroThreshold float64
|
NativeHistogramZeroThreshold float64
|
||||||
|
|
||||||
// The remaining fields define a strategy to limit the number of
|
// The next three fields define a strategy to limit the number of
|
||||||
// populated sparse buckets. If NativeHistogramMaxBucketNumber is left
|
// populated sparse buckets. If NativeHistogramMaxBucketNumber is left
|
||||||
// at zero, the number of buckets is not limited. (Note that this might
|
// at zero, the number of buckets is not limited. (Note that this might
|
||||||
// lead to unbounded memory consumption if the values observed by the
|
// lead to unbounded memory consumption if the values observed by the
|
||||||
@@ -473,6 +473,22 @@ type HistogramOpts struct {
|
|||||||
NativeHistogramMinResetDuration time.Duration
|
NativeHistogramMinResetDuration time.Duration
|
||||||
NativeHistogramMaxZeroThreshold float64
|
NativeHistogramMaxZeroThreshold float64
|
||||||
|
|
||||||
|
// NativeHistogramMaxExemplars limits the number of exemplars
|
||||||
|
// that are kept in memory for each native histogram. If you leave it at
|
||||||
|
// zero, a default value of 10 is used. If no exemplars should be kept specifically
|
||||||
|
// for native histograms, set it to a negative value. (Scrapers can
|
||||||
|
// still use the exemplars exposed for classic buckets, which are managed
|
||||||
|
// independently.)
|
||||||
|
NativeHistogramMaxExemplars int
|
||||||
|
// NativeHistogramExemplarTTL is only checked once
|
||||||
|
// NativeHistogramMaxExemplars is exceeded. In that case, the
|
||||||
|
// oldest exemplar is removed if it is older than NativeHistogramExemplarTTL.
|
||||||
|
// Otherwise, the older exemplar in the pair of exemplars that are closest
|
||||||
|
// together (on an exponential scale) is removed.
|
||||||
|
// If NativeHistogramExemplarTTL is left at its zero value, a default value of
|
||||||
|
// 5m is used. To always delete the oldest exemplar, set it to a negative value.
|
||||||
|
NativeHistogramExemplarTTL time.Duration
|
||||||
|
|
||||||
// now is for testing purposes, by default it's time.Now.
|
// now is for testing purposes, by default it's time.Now.
|
||||||
now func() time.Time
|
now func() time.Time
|
||||||
|
|
||||||
@@ -532,6 +548,7 @@ func newHistogram(desc *Desc, opts HistogramOpts, labelValues ...string) Histogr
|
|||||||
if opts.afterFunc == nil {
|
if opts.afterFunc == nil {
|
||||||
opts.afterFunc = time.AfterFunc
|
opts.afterFunc = time.AfterFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
h := &histogram{
|
h := &histogram{
|
||||||
desc: desc,
|
desc: desc,
|
||||||
upperBounds: opts.Buckets,
|
upperBounds: opts.Buckets,
|
||||||
@@ -556,6 +573,7 @@ func newHistogram(desc *Desc, opts HistogramOpts, labelValues ...string) Histogr
|
|||||||
h.nativeHistogramZeroThreshold = DefNativeHistogramZeroThreshold
|
h.nativeHistogramZeroThreshold = DefNativeHistogramZeroThreshold
|
||||||
} // Leave h.nativeHistogramZeroThreshold at 0 otherwise.
|
} // Leave h.nativeHistogramZeroThreshold at 0 otherwise.
|
||||||
h.nativeHistogramSchema = pickSchema(opts.NativeHistogramBucketFactor)
|
h.nativeHistogramSchema = pickSchema(opts.NativeHistogramBucketFactor)
|
||||||
|
h.nativeExemplars = makeNativeExemplars(opts.NativeHistogramExemplarTTL, opts.NativeHistogramMaxExemplars)
|
||||||
}
|
}
|
||||||
for i, upperBound := range h.upperBounds {
|
for i, upperBound := range h.upperBounds {
|
||||||
if i < len(h.upperBounds)-1 {
|
if i < len(h.upperBounds)-1 {
|
||||||
@@ -725,7 +743,8 @@ type histogram struct {
|
|||||||
// resetScheduled is protected by mtx. It is true if a reset is
|
// resetScheduled is protected by mtx. It is true if a reset is
|
||||||
// scheduled for a later time (when nativeHistogramMinResetDuration has
|
// scheduled for a later time (when nativeHistogramMinResetDuration has
|
||||||
// passed).
|
// passed).
|
||||||
resetScheduled bool
|
resetScheduled bool
|
||||||
|
nativeExemplars nativeExemplars
|
||||||
|
|
||||||
// now is for testing purposes, by default it's time.Now.
|
// now is for testing purposes, by default it's time.Now.
|
||||||
now func() time.Time
|
now func() time.Time
|
||||||
@@ -742,6 +761,9 @@ func (h *histogram) Observe(v float64) {
|
|||||||
h.observe(v, h.findBucket(v))
|
h.observe(v, h.findBucket(v))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ObserveWithExemplar should not be called in a high-frequency setting
|
||||||
|
// for a native histogram with configured exemplars. For this case,
|
||||||
|
// the implementation isn't lock-free and might suffer from lock contention.
|
||||||
func (h *histogram) ObserveWithExemplar(v float64, e Labels) {
|
func (h *histogram) ObserveWithExemplar(v float64, e Labels) {
|
||||||
i := h.findBucket(v)
|
i := h.findBucket(v)
|
||||||
h.observe(v, i)
|
h.observe(v, i)
|
||||||
@@ -821,6 +843,13 @@ func (h *histogram) Write(out *dto.Metric) error {
|
|||||||
Length: proto.Uint32(0),
|
Length: proto.Uint32(0),
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if h.nativeExemplars.isEnabled() {
|
||||||
|
h.nativeExemplars.Lock()
|
||||||
|
his.Exemplars = append(his.Exemplars, h.nativeExemplars.exemplars...)
|
||||||
|
h.nativeExemplars.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
addAndResetCounts(hotCounts, coldCounts)
|
addAndResetCounts(hotCounts, coldCounts)
|
||||||
return nil
|
return nil
|
||||||
@@ -1091,8 +1120,10 @@ func (h *histogram) resetCounts(counts *histogramCounts) {
|
|||||||
deleteSyncMap(&counts.nativeHistogramBucketsPositive)
|
deleteSyncMap(&counts.nativeHistogramBucketsPositive)
|
||||||
}
|
}
|
||||||
|
|
||||||
// updateExemplar replaces the exemplar for the provided bucket. With empty
|
// updateExemplar replaces the exemplar for the provided classic bucket.
|
||||||
// labels, it's a no-op. It panics if any of the labels is invalid.
|
// With empty labels, it's a no-op. It panics if any of the labels is invalid.
|
||||||
|
// If histogram is native, the exemplar will be cached into nativeExemplars,
|
||||||
|
// which has a limit, and will remove one exemplar when limit is reached.
|
||||||
func (h *histogram) updateExemplar(v float64, bucket int, l Labels) {
|
func (h *histogram) updateExemplar(v float64, bucket int, l Labels) {
|
||||||
if l == nil {
|
if l == nil {
|
||||||
return
|
return
|
||||||
@@ -1102,6 +1133,10 @@ func (h *histogram) updateExemplar(v float64, bucket int, l Labels) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
h.exemplars[bucket].Store(e)
|
h.exemplars[bucket].Store(e)
|
||||||
|
doSparse := h.nativeHistogramSchema > math.MinInt32 && !math.IsNaN(v)
|
||||||
|
if doSparse {
|
||||||
|
h.nativeExemplars.addExemplar(e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// HistogramVec is a Collector that bundles a set of Histograms that all share the
|
// HistogramVec is a Collector that bundles a set of Histograms that all share the
|
||||||
@@ -1336,6 +1371,48 @@ func MustNewConstHistogram(
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewConstHistogramWithCreatedTimestamp does the same thing as NewConstHistogram but sets the created timestamp.
|
||||||
|
func NewConstHistogramWithCreatedTimestamp(
|
||||||
|
desc *Desc,
|
||||||
|
count uint64,
|
||||||
|
sum float64,
|
||||||
|
buckets map[float64]uint64,
|
||||||
|
ct time.Time,
|
||||||
|
labelValues ...string,
|
||||||
|
) (Metric, error) {
|
||||||
|
if desc.err != nil {
|
||||||
|
return nil, desc.err
|
||||||
|
}
|
||||||
|
if err := validateLabelValues(labelValues, len(desc.variableLabels.names)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &constHistogram{
|
||||||
|
desc: desc,
|
||||||
|
count: count,
|
||||||
|
sum: sum,
|
||||||
|
buckets: buckets,
|
||||||
|
labelPairs: MakeLabelPairs(desc, labelValues),
|
||||||
|
createdTs: timestamppb.New(ct),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MustNewConstHistogramWithCreatedTimestamp is a version of NewConstHistogramWithCreatedTimestamp that panics where
|
||||||
|
// NewConstHistogramWithCreatedTimestamp would have returned an error.
|
||||||
|
func MustNewConstHistogramWithCreatedTimestamp(
|
||||||
|
desc *Desc,
|
||||||
|
count uint64,
|
||||||
|
sum float64,
|
||||||
|
buckets map[float64]uint64,
|
||||||
|
ct time.Time,
|
||||||
|
labelValues ...string,
|
||||||
|
) Metric {
|
||||||
|
m, err := NewConstHistogramWithCreatedTimestamp(desc, count, sum, buckets, ct, labelValues...)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
|
||||||
type buckSort []*dto.Bucket
|
type buckSort []*dto.Bucket
|
||||||
|
|
||||||
func (s buckSort) Len() int {
|
func (s buckSort) Len() int {
|
||||||
@@ -1575,3 +1652,186 @@ func addAndResetCounts(hot, cold *histogramCounts) {
|
|||||||
atomic.AddUint64(&hot.nativeHistogramZeroBucket, atomic.LoadUint64(&cold.nativeHistogramZeroBucket))
|
atomic.AddUint64(&hot.nativeHistogramZeroBucket, atomic.LoadUint64(&cold.nativeHistogramZeroBucket))
|
||||||
atomic.StoreUint64(&cold.nativeHistogramZeroBucket, 0)
|
atomic.StoreUint64(&cold.nativeHistogramZeroBucket, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type nativeExemplars struct {
|
||||||
|
sync.Mutex
|
||||||
|
|
||||||
|
// Time-to-live for exemplars, it is set to -1 if exemplars are disabled, that is NativeHistogramMaxExemplars is below 0.
|
||||||
|
// The ttl is used on insertion to remove an exemplar that is older than ttl, if present.
|
||||||
|
ttl time.Duration
|
||||||
|
|
||||||
|
exemplars []*dto.Exemplar
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *nativeExemplars) isEnabled() bool {
|
||||||
|
return n.ttl != -1
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeNativeExemplars(ttl time.Duration, maxCount int) nativeExemplars {
|
||||||
|
if ttl == 0 {
|
||||||
|
ttl = 5 * time.Minute
|
||||||
|
}
|
||||||
|
|
||||||
|
if maxCount == 0 {
|
||||||
|
maxCount = 10
|
||||||
|
}
|
||||||
|
|
||||||
|
if maxCount < 0 {
|
||||||
|
maxCount = 0
|
||||||
|
ttl = -1
|
||||||
|
}
|
||||||
|
|
||||||
|
return nativeExemplars{
|
||||||
|
ttl: ttl,
|
||||||
|
exemplars: make([]*dto.Exemplar, 0, maxCount),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *nativeExemplars) addExemplar(e *dto.Exemplar) {
|
||||||
|
if !n.isEnabled() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
n.Lock()
|
||||||
|
defer n.Unlock()
|
||||||
|
|
||||||
|
// When the number of exemplars has not yet exceeded or
|
||||||
|
// is equal to cap(n.exemplars), then
|
||||||
|
// insert the new exemplar directly.
|
||||||
|
if len(n.exemplars) < cap(n.exemplars) {
|
||||||
|
var nIdx int
|
||||||
|
for nIdx = 0; nIdx < len(n.exemplars); nIdx++ {
|
||||||
|
if *e.Value < *n.exemplars[nIdx].Value {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
n.exemplars = append(n.exemplars[:nIdx], append([]*dto.Exemplar{e}, n.exemplars[nIdx:]...)...)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(n.exemplars) == 1 {
|
||||||
|
// When the number of exemplars is 1, then
|
||||||
|
// replace the existing exemplar with the new exemplar.
|
||||||
|
n.exemplars[0] = e
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// From this point on, the number of exemplars is greater than 1.
|
||||||
|
|
||||||
|
// When the number of exemplars exceeds the limit, remove one exemplar.
|
||||||
|
var (
|
||||||
|
ot = time.Time{} // Oldest timestamp seen. Initial value doesn't matter as we replace it due to otIdx == -1 in the loop.
|
||||||
|
otIdx = -1 // Index of the exemplar with the oldest timestamp.
|
||||||
|
|
||||||
|
md = -1.0 // Logarithm of the delta of the closest pair of exemplars.
|
||||||
|
|
||||||
|
// The insertion point of the new exemplar in the exemplars slice after insertion.
|
||||||
|
// This is calculated purely based on the order of the exemplars by value.
|
||||||
|
// nIdx == len(n.exemplars) means the new exemplar is to be inserted after the end.
|
||||||
|
nIdx = -1
|
||||||
|
|
||||||
|
// rIdx is ultimately the index for the exemplar that we are replacing with the new exemplar.
|
||||||
|
// The aim is to keep a good spread of exemplars by value and not let them bunch up too much.
|
||||||
|
// It is calculated in 3 steps:
|
||||||
|
// 1. First we set rIdx to the index of the older exemplar within the closest pair by value.
|
||||||
|
// That is the following will be true (on log scale):
|
||||||
|
// either the exemplar pair on index (rIdx-1, rIdx) or (rIdx, rIdx+1) will have
|
||||||
|
// the closest values to each other from all pairs.
|
||||||
|
// For example, suppose the values are distributed like this:
|
||||||
|
// |-----------x-------------x----------------x----x-----|
|
||||||
|
// ^--rIdx as this is older.
|
||||||
|
// Or like this:
|
||||||
|
// |-----------x-------------x----------------x----x-----|
|
||||||
|
// ^--rIdx as this is older.
|
||||||
|
// 2. If there is an exemplar that expired, then we simple reset rIdx to that index.
|
||||||
|
// 3. We check if by inserting the new exemplar we would create a closer pair at
|
||||||
|
// (nIdx-1, nIdx) or (nIdx, nIdx+1) and set rIdx to nIdx-1 or nIdx accordingly to
|
||||||
|
// keep the spread of exemplars by value; otherwise we keep rIdx as it is.
|
||||||
|
rIdx = -1
|
||||||
|
cLog float64 // Logarithm of the current exemplar.
|
||||||
|
pLog float64 // Logarithm of the previous exemplar.
|
||||||
|
)
|
||||||
|
|
||||||
|
for i, exemplar := range n.exemplars {
|
||||||
|
// Find the exemplar with the oldest timestamp.
|
||||||
|
if otIdx == -1 || exemplar.Timestamp.AsTime().Before(ot) {
|
||||||
|
ot = exemplar.Timestamp.AsTime()
|
||||||
|
otIdx = i
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the index at which to insert new the exemplar.
|
||||||
|
if nIdx == -1 && *e.Value <= *exemplar.Value {
|
||||||
|
nIdx = i
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the two closest exemplars and pick the one the with older timestamp.
|
||||||
|
pLog = cLog
|
||||||
|
cLog = math.Log(exemplar.GetValue())
|
||||||
|
if i == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
diff := math.Abs(cLog - pLog)
|
||||||
|
if md == -1 || diff < md {
|
||||||
|
// The closest exemplar pair is at index: i-1, i.
|
||||||
|
// Choose the exemplar with the older timestamp for replacement.
|
||||||
|
md = diff
|
||||||
|
if n.exemplars[i].Timestamp.AsTime().Before(n.exemplars[i-1].Timestamp.AsTime()) {
|
||||||
|
rIdx = i
|
||||||
|
} else {
|
||||||
|
rIdx = i - 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// If all existing exemplar are smaller than new exemplar,
|
||||||
|
// then the exemplar should be inserted at the end.
|
||||||
|
if nIdx == -1 {
|
||||||
|
nIdx = len(n.exemplars)
|
||||||
|
}
|
||||||
|
// Here, we have the following relationships:
|
||||||
|
// n.exemplars[nIdx-1].Value < e.Value (if nIdx > 0)
|
||||||
|
// e.Value <= n.exemplars[nIdx].Value (if nIdx < len(n.exemplars))
|
||||||
|
|
||||||
|
if otIdx != -1 && e.Timestamp.AsTime().Sub(ot) > n.ttl {
|
||||||
|
// If the oldest exemplar has expired, then replace it with the new exemplar.
|
||||||
|
rIdx = otIdx
|
||||||
|
} else {
|
||||||
|
// In the previous for loop, when calculating the closest pair of exemplars,
|
||||||
|
// we did not take into account the newly inserted exemplar.
|
||||||
|
// So we need to calculate with the newly inserted exemplar again.
|
||||||
|
elog := math.Log(e.GetValue())
|
||||||
|
if nIdx > 0 {
|
||||||
|
diff := math.Abs(elog - math.Log(n.exemplars[nIdx-1].GetValue()))
|
||||||
|
if diff < md {
|
||||||
|
// The value we are about to insert is closer to the previous exemplar at the insertion point than what we calculated before in rIdx.
|
||||||
|
// v--rIdx
|
||||||
|
// |-----------x-n-----------x----------------x----x-----|
|
||||||
|
// nIdx-1--^ ^--new exemplar value
|
||||||
|
// Do not make the spread worse, replace nIdx-1 and not rIdx.
|
||||||
|
md = diff
|
||||||
|
rIdx = nIdx - 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if nIdx < len(n.exemplars) {
|
||||||
|
diff := math.Abs(math.Log(n.exemplars[nIdx].GetValue()) - elog)
|
||||||
|
if diff < md {
|
||||||
|
// The value we are about to insert is closer to the next exemplar at the insertion point than what we calculated before in rIdx.
|
||||||
|
// v--rIdx
|
||||||
|
// |-----------x-----------n-x----------------x----x-----|
|
||||||
|
// new exemplar value--^ ^--nIdx
|
||||||
|
// Do not make the spread worse, replace nIdx-1 and not rIdx.
|
||||||
|
rIdx = nIdx
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adjust the slice according to rIdx and nIdx.
|
||||||
|
switch {
|
||||||
|
case rIdx == nIdx:
|
||||||
|
n.exemplars[nIdx] = e
|
||||||
|
case rIdx < nIdx:
|
||||||
|
n.exemplars = append(n.exemplars[:rIdx], append(n.exemplars[rIdx+1:nIdx], append([]*dto.Exemplar{e}, n.exemplars[nIdx:]...)...)...)
|
||||||
|
case rIdx > nIdx:
|
||||||
|
n.exemplars = append(n.exemplars[:nIdx], append([]*dto.Exemplar{e}, append(n.exemplars[nIdx:rIdx], n.exemplars[rIdx+1:]...)...)...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -30,3 +30,5 @@ type GoCollectorOptions struct {
|
|||||||
RuntimeMetricSumForHist map[string]string
|
RuntimeMetricSumForHist map[string]string
|
||||||
RuntimeMetricRules []GoCollectorRule
|
RuntimeMetricRules []GoCollectorRule
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var GoCollectorDefaultRuntimeMetrics = regexp.MustCompile(`/gc/gogc:percent|/gc/gomemlimit:bytes|/sched/gomaxprocs:threads`)
|
||||||
|
|||||||
2
vendor/github.com/prometheus/client_golang/prometheus/metric.go
generated
vendored
2
vendor/github.com/prometheus/client_golang/prometheus/metric.go
generated
vendored
@@ -234,7 +234,7 @@ func NewMetricWithExemplars(m Metric, exemplars ...Exemplar) (Metric, error) {
|
|||||||
)
|
)
|
||||||
for i, e := range exemplars {
|
for i, e := range exemplars {
|
||||||
ts := e.Timestamp
|
ts := e.Timestamp
|
||||||
if ts == (time.Time{}) {
|
if ts.IsZero() {
|
||||||
ts = now
|
ts = now
|
||||||
}
|
}
|
||||||
exs[i], err = newExemplar(e.Value, ts, e.Labels)
|
exs[i], err = newExemplar(e.Value, ts, e.Labels)
|
||||||
|
|||||||
29
vendor/github.com/prometheus/client_golang/prometheus/process_collector.go
generated
vendored
29
vendor/github.com/prometheus/client_golang/prometheus/process_collector.go
generated
vendored
@@ -22,14 +22,15 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type processCollector struct {
|
type processCollector struct {
|
||||||
collectFn func(chan<- Metric)
|
collectFn func(chan<- Metric)
|
||||||
pidFn func() (int, error)
|
pidFn func() (int, error)
|
||||||
reportErrors bool
|
reportErrors bool
|
||||||
cpuTotal *Desc
|
cpuTotal *Desc
|
||||||
openFDs, maxFDs *Desc
|
openFDs, maxFDs *Desc
|
||||||
vsize, maxVsize *Desc
|
vsize, maxVsize *Desc
|
||||||
rss *Desc
|
rss *Desc
|
||||||
startTime *Desc
|
startTime *Desc
|
||||||
|
inBytes, outBytes *Desc
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProcessCollectorOpts defines the behavior of a process metrics collector
|
// ProcessCollectorOpts defines the behavior of a process metrics collector
|
||||||
@@ -100,6 +101,16 @@ func NewProcessCollector(opts ProcessCollectorOpts) Collector {
|
|||||||
"Start time of the process since unix epoch in seconds.",
|
"Start time of the process since unix epoch in seconds.",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
|
inBytes: NewDesc(
|
||||||
|
ns+"process_network_receive_bytes_total",
|
||||||
|
"Number of bytes received by the process over the network.",
|
||||||
|
nil, nil,
|
||||||
|
),
|
||||||
|
outBytes: NewDesc(
|
||||||
|
ns+"process_network_transmit_bytes_total",
|
||||||
|
"Number of bytes sent by the process over the network.",
|
||||||
|
nil, nil,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.PidFn == nil {
|
if opts.PidFn == nil {
|
||||||
@@ -129,6 +140,8 @@ func (c *processCollector) Describe(ch chan<- *Desc) {
|
|||||||
ch <- c.maxVsize
|
ch <- c.maxVsize
|
||||||
ch <- c.rss
|
ch <- c.rss
|
||||||
ch <- c.startTime
|
ch <- c.startTime
|
||||||
|
ch <- c.inBytes
|
||||||
|
ch <- c.outBytes
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect returns the current state of all metrics of the collector.
|
// Collect returns the current state of all metrics of the collector.
|
||||||
|
|||||||
14
vendor/github.com/prometheus/client_golang/prometheus/process_collector_other.go
generated
vendored
14
vendor/github.com/prometheus/client_golang/prometheus/process_collector_other.go
generated
vendored
@@ -63,4 +63,18 @@ func (c *processCollector) processCollect(ch chan<- Metric) {
|
|||||||
} else {
|
} else {
|
||||||
c.reportError(ch, nil, err)
|
c.reportError(ch, nil, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if netstat, err := p.Netstat(); err == nil {
|
||||||
|
var inOctets, outOctets float64
|
||||||
|
if netstat.IpExt.InOctets != nil {
|
||||||
|
inOctets = *netstat.IpExt.InOctets
|
||||||
|
}
|
||||||
|
if netstat.IpExt.OutOctets != nil {
|
||||||
|
outOctets = *netstat.IpExt.OutOctets
|
||||||
|
}
|
||||||
|
ch <- MustNewConstMetric(c.inBytes, CounterValue, inOctets)
|
||||||
|
ch <- MustNewConstMetric(c.outBytes, CounterValue, outOctets)
|
||||||
|
} else {
|
||||||
|
c.reportError(ch, nil, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
19
vendor/github.com/prometheus/client_golang/prometheus/registry.go
generated
vendored
19
vendor/github.com/prometheus/client_golang/prometheus/registry.go
generated
vendored
@@ -314,16 +314,17 @@ func (r *Registry) Register(c Collector) error {
|
|||||||
if dimHash != desc.dimHash {
|
if dimHash != desc.dimHash {
|
||||||
return fmt.Errorf("a previously registered descriptor with the same fully-qualified name as %s has different label names or a different help string", desc)
|
return fmt.Errorf("a previously registered descriptor with the same fully-qualified name as %s has different label names or a different help string", desc)
|
||||||
}
|
}
|
||||||
} else {
|
continue
|
||||||
// ...then check the new descriptors already seen.
|
|
||||||
if dimHash, exists := newDimHashesByName[desc.fqName]; exists {
|
|
||||||
if dimHash != desc.dimHash {
|
|
||||||
return fmt.Errorf("descriptors reported by collector have inconsistent label names or help strings for the same fully-qualified name, offender is %s", desc)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
newDimHashesByName[desc.fqName] = desc.dimHash
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ...then check the new descriptors already seen.
|
||||||
|
if dimHash, exists := newDimHashesByName[desc.fqName]; exists {
|
||||||
|
if dimHash != desc.dimHash {
|
||||||
|
return fmt.Errorf("descriptors reported by collector have inconsistent label names or help strings for the same fully-qualified name, offender is %s", desc)
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
newDimHashesByName[desc.fqName] = desc.dimHash
|
||||||
}
|
}
|
||||||
// A Collector yielding no Desc at all is considered unchecked.
|
// A Collector yielding no Desc at all is considered unchecked.
|
||||||
if len(newDescIDs) == 0 {
|
if len(newDescIDs) == 0 {
|
||||||
|
|||||||
42
vendor/github.com/prometheus/client_golang/prometheus/summary.go
generated
vendored
42
vendor/github.com/prometheus/client_golang/prometheus/summary.go
generated
vendored
@@ -783,3 +783,45 @@ func MustNewConstSummary(
|
|||||||
}
|
}
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewConstSummaryWithCreatedTimestamp does the same thing as NewConstSummary but sets the created timestamp.
|
||||||
|
func NewConstSummaryWithCreatedTimestamp(
|
||||||
|
desc *Desc,
|
||||||
|
count uint64,
|
||||||
|
sum float64,
|
||||||
|
quantiles map[float64]float64,
|
||||||
|
ct time.Time,
|
||||||
|
labelValues ...string,
|
||||||
|
) (Metric, error) {
|
||||||
|
if desc.err != nil {
|
||||||
|
return nil, desc.err
|
||||||
|
}
|
||||||
|
if err := validateLabelValues(labelValues, len(desc.variableLabels.names)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &constSummary{
|
||||||
|
desc: desc,
|
||||||
|
count: count,
|
||||||
|
sum: sum,
|
||||||
|
quantiles: quantiles,
|
||||||
|
labelPairs: MakeLabelPairs(desc, labelValues),
|
||||||
|
createdTs: timestamppb.New(ct),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MustNewConstSummaryWithCreatedTimestamp is a version of NewConstSummaryWithCreatedTimestamp that panics where
|
||||||
|
// NewConstSummaryWithCreatedTimestamp would have returned an error.
|
||||||
|
func MustNewConstSummaryWithCreatedTimestamp(
|
||||||
|
desc *Desc,
|
||||||
|
count uint64,
|
||||||
|
sum float64,
|
||||||
|
quantiles map[float64]float64,
|
||||||
|
ct time.Time,
|
||||||
|
labelValues ...string,
|
||||||
|
) Metric {
|
||||||
|
m, err := NewConstSummaryWithCreatedTimestamp(desc, count, sum, quantiles, ct, labelValues...)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
|||||||
2
vendor/github.com/prometheus/client_golang/prometheus/vec.go
generated
vendored
2
vendor/github.com/prometheus/client_golang/prometheus/vec.go
generated
vendored
@@ -507,7 +507,7 @@ func (m *metricMap) getOrCreateMetricWithLabelValues(
|
|||||||
return metric
|
return metric
|
||||||
}
|
}
|
||||||
|
|
||||||
// getOrCreateMetricWithLabelValues retrieves the metric by hash and label value
|
// getOrCreateMetricWithLabels retrieves the metric by hash and label value
|
||||||
// or creates it and returns the new one.
|
// or creates it and returns the new one.
|
||||||
//
|
//
|
||||||
// This function holds the mutex.
|
// This function holds the mutex.
|
||||||
|
|||||||
14
vendor/github.com/prometheus/common/expfmt/decode.go
generated
vendored
14
vendor/github.com/prometheus/common/expfmt/decode.go
generated
vendored
@@ -45,7 +45,7 @@ func ResponseFormat(h http.Header) Format {
|
|||||||
|
|
||||||
mediatype, params, err := mime.ParseMediaType(ct)
|
mediatype, params, err := mime.ParseMediaType(ct)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmtUnknown
|
return FmtUnknown
|
||||||
}
|
}
|
||||||
|
|
||||||
const textType = "text/plain"
|
const textType = "text/plain"
|
||||||
@@ -53,21 +53,21 @@ func ResponseFormat(h http.Header) Format {
|
|||||||
switch mediatype {
|
switch mediatype {
|
||||||
case ProtoType:
|
case ProtoType:
|
||||||
if p, ok := params["proto"]; ok && p != ProtoProtocol {
|
if p, ok := params["proto"]; ok && p != ProtoProtocol {
|
||||||
return fmtUnknown
|
return FmtUnknown
|
||||||
}
|
}
|
||||||
if e, ok := params["encoding"]; ok && e != "delimited" {
|
if e, ok := params["encoding"]; ok && e != "delimited" {
|
||||||
return fmtUnknown
|
return FmtUnknown
|
||||||
}
|
}
|
||||||
return fmtProtoDelim
|
return FmtProtoDelim
|
||||||
|
|
||||||
case textType:
|
case textType:
|
||||||
if v, ok := params["version"]; ok && v != TextVersion {
|
if v, ok := params["version"]; ok && v != TextVersion {
|
||||||
return fmtUnknown
|
return FmtUnknown
|
||||||
}
|
}
|
||||||
return fmtText
|
return FmtText
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmtUnknown
|
return FmtUnknown
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDecoder returns a new decoder based on the given input format.
|
// NewDecoder returns a new decoder based on the given input format.
|
||||||
|
|||||||
28
vendor/github.com/prometheus/common/expfmt/encode.go
generated
vendored
28
vendor/github.com/prometheus/common/expfmt/encode.go
generated
vendored
@@ -68,7 +68,7 @@ func Negotiate(h http.Header) Format {
|
|||||||
if escapeParam := ac.Params[model.EscapingKey]; escapeParam != "" {
|
if escapeParam := ac.Params[model.EscapingKey]; escapeParam != "" {
|
||||||
switch Format(escapeParam) {
|
switch Format(escapeParam) {
|
||||||
case model.AllowUTF8, model.EscapeUnderscores, model.EscapeDots, model.EscapeValues:
|
case model.AllowUTF8, model.EscapeUnderscores, model.EscapeDots, model.EscapeValues:
|
||||||
escapingScheme = Format(fmt.Sprintf("; escaping=%s", escapeParam))
|
escapingScheme = Format("; escaping=" + escapeParam)
|
||||||
default:
|
default:
|
||||||
// If the escaping parameter is unknown, ignore it.
|
// If the escaping parameter is unknown, ignore it.
|
||||||
}
|
}
|
||||||
@@ -77,18 +77,18 @@ func Negotiate(h http.Header) Format {
|
|||||||
if ac.Type+"/"+ac.SubType == ProtoType && ac.Params["proto"] == ProtoProtocol {
|
if ac.Type+"/"+ac.SubType == ProtoType && ac.Params["proto"] == ProtoProtocol {
|
||||||
switch ac.Params["encoding"] {
|
switch ac.Params["encoding"] {
|
||||||
case "delimited":
|
case "delimited":
|
||||||
return fmtProtoDelim + escapingScheme
|
return FmtProtoDelim + escapingScheme
|
||||||
case "text":
|
case "text":
|
||||||
return fmtProtoText + escapingScheme
|
return FmtProtoText + escapingScheme
|
||||||
case "compact-text":
|
case "compact-text":
|
||||||
return fmtProtoCompact + escapingScheme
|
return FmtProtoCompact + escapingScheme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ac.Type == "text" && ac.SubType == "plain" && (ver == TextVersion || ver == "") {
|
if ac.Type == "text" && ac.SubType == "plain" && (ver == TextVersion || ver == "") {
|
||||||
return fmtText + escapingScheme
|
return FmtText + escapingScheme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fmtText + escapingScheme
|
return FmtText + escapingScheme
|
||||||
}
|
}
|
||||||
|
|
||||||
// NegotiateIncludingOpenMetrics works like Negotiate but includes
|
// NegotiateIncludingOpenMetrics works like Negotiate but includes
|
||||||
@@ -101,7 +101,7 @@ func NegotiateIncludingOpenMetrics(h http.Header) Format {
|
|||||||
if escapeParam := ac.Params[model.EscapingKey]; escapeParam != "" {
|
if escapeParam := ac.Params[model.EscapingKey]; escapeParam != "" {
|
||||||
switch Format(escapeParam) {
|
switch Format(escapeParam) {
|
||||||
case model.AllowUTF8, model.EscapeUnderscores, model.EscapeDots, model.EscapeValues:
|
case model.AllowUTF8, model.EscapeUnderscores, model.EscapeDots, model.EscapeValues:
|
||||||
escapingScheme = Format(fmt.Sprintf("; escaping=%s", escapeParam))
|
escapingScheme = Format("; escaping=" + escapeParam)
|
||||||
default:
|
default:
|
||||||
// If the escaping parameter is unknown, ignore it.
|
// If the escaping parameter is unknown, ignore it.
|
||||||
}
|
}
|
||||||
@@ -110,26 +110,26 @@ func NegotiateIncludingOpenMetrics(h http.Header) Format {
|
|||||||
if ac.Type+"/"+ac.SubType == ProtoType && ac.Params["proto"] == ProtoProtocol {
|
if ac.Type+"/"+ac.SubType == ProtoType && ac.Params["proto"] == ProtoProtocol {
|
||||||
switch ac.Params["encoding"] {
|
switch ac.Params["encoding"] {
|
||||||
case "delimited":
|
case "delimited":
|
||||||
return fmtProtoDelim + escapingScheme
|
return FmtProtoDelim + escapingScheme
|
||||||
case "text":
|
case "text":
|
||||||
return fmtProtoText + escapingScheme
|
return FmtProtoText + escapingScheme
|
||||||
case "compact-text":
|
case "compact-text":
|
||||||
return fmtProtoCompact + escapingScheme
|
return FmtProtoCompact + escapingScheme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ac.Type == "text" && ac.SubType == "plain" && (ver == TextVersion || ver == "") {
|
if ac.Type == "text" && ac.SubType == "plain" && (ver == TextVersion || ver == "") {
|
||||||
return fmtText + escapingScheme
|
return FmtText + escapingScheme
|
||||||
}
|
}
|
||||||
if ac.Type+"/"+ac.SubType == OpenMetricsType && (ver == OpenMetricsVersion_0_0_1 || ver == OpenMetricsVersion_1_0_0 || ver == "") {
|
if ac.Type+"/"+ac.SubType == OpenMetricsType && (ver == OpenMetricsVersion_0_0_1 || ver == OpenMetricsVersion_1_0_0 || ver == "") {
|
||||||
switch ver {
|
switch ver {
|
||||||
case OpenMetricsVersion_1_0_0:
|
case OpenMetricsVersion_1_0_0:
|
||||||
return fmtOpenMetrics_1_0_0 + escapingScheme
|
return FmtOpenMetrics_1_0_0 + escapingScheme
|
||||||
default:
|
default:
|
||||||
return fmtOpenMetrics_0_0_1 + escapingScheme
|
return FmtOpenMetrics_0_0_1 + escapingScheme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fmtText + escapingScheme
|
return FmtText + escapingScheme
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewEncoder returns a new encoder based on content type negotiation. All
|
// NewEncoder returns a new encoder based on content type negotiation. All
|
||||||
|
|||||||
78
vendor/github.com/prometheus/common/expfmt/expfmt.go
generated
vendored
78
vendor/github.com/prometheus/common/expfmt/expfmt.go
generated
vendored
@@ -15,7 +15,7 @@
|
|||||||
package expfmt
|
package expfmt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"errors"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/prometheus/common/model"
|
"github.com/prometheus/common/model"
|
||||||
@@ -32,24 +32,31 @@ type Format string
|
|||||||
// it on the wire, new content-type strings will have to be agreed upon and
|
// it on the wire, new content-type strings will have to be agreed upon and
|
||||||
// added here.
|
// added here.
|
||||||
const (
|
const (
|
||||||
TextVersion = "0.0.4"
|
TextVersion = "0.0.4"
|
||||||
ProtoType = `application/vnd.google.protobuf`
|
ProtoType = `application/vnd.google.protobuf`
|
||||||
ProtoProtocol = `io.prometheus.client.MetricFamily`
|
ProtoProtocol = `io.prometheus.client.MetricFamily`
|
||||||
protoFmt = ProtoType + "; proto=" + ProtoProtocol + ";"
|
// Deprecated: Use expfmt.NewFormat(expfmt.TypeProtoCompact) instead.
|
||||||
|
ProtoFmt = ProtoType + "; proto=" + ProtoProtocol + ";"
|
||||||
OpenMetricsType = `application/openmetrics-text`
|
OpenMetricsType = `application/openmetrics-text`
|
||||||
OpenMetricsVersion_0_0_1 = "0.0.1"
|
OpenMetricsVersion_0_0_1 = "0.0.1"
|
||||||
OpenMetricsVersion_1_0_0 = "1.0.0"
|
OpenMetricsVersion_1_0_0 = "1.0.0"
|
||||||
|
|
||||||
// The Content-Type values for the different wire protocols. Note that these
|
// The Content-Type values for the different wire protocols. Do not do direct
|
||||||
// values are now unexported. If code was relying on comparisons to these
|
// comparisons to these constants, instead use the comparison functions.
|
||||||
// constants, instead use FormatType().
|
// Deprecated: Use expfmt.NewFormat(expfmt.TypeUnknown) instead.
|
||||||
fmtUnknown Format = `<unknown>`
|
FmtUnknown Format = `<unknown>`
|
||||||
fmtText Format = `text/plain; version=` + TextVersion + `; charset=utf-8`
|
// Deprecated: Use expfmt.NewFormat(expfmt.TypeTextPlain) instead.
|
||||||
fmtProtoDelim Format = protoFmt + ` encoding=delimited`
|
FmtText Format = `text/plain; version=` + TextVersion + `; charset=utf-8`
|
||||||
fmtProtoText Format = protoFmt + ` encoding=text`
|
// Deprecated: Use expfmt.NewFormat(expfmt.TypeProtoDelim) instead.
|
||||||
fmtProtoCompact Format = protoFmt + ` encoding=compact-text`
|
FmtProtoDelim Format = ProtoFmt + ` encoding=delimited`
|
||||||
fmtOpenMetrics_1_0_0 Format = OpenMetricsType + `; version=` + OpenMetricsVersion_1_0_0 + `; charset=utf-8`
|
// Deprecated: Use expfmt.NewFormat(expfmt.TypeProtoText) instead.
|
||||||
fmtOpenMetrics_0_0_1 Format = OpenMetricsType + `; version=` + OpenMetricsVersion_0_0_1 + `; charset=utf-8`
|
FmtProtoText Format = ProtoFmt + ` encoding=text`
|
||||||
|
// Deprecated: Use expfmt.NewFormat(expfmt.TypeProtoCompact) instead.
|
||||||
|
FmtProtoCompact Format = ProtoFmt + ` encoding=compact-text`
|
||||||
|
// Deprecated: Use expfmt.NewFormat(expfmt.TypeOpenMetrics) instead.
|
||||||
|
FmtOpenMetrics_1_0_0 Format = OpenMetricsType + `; version=` + OpenMetricsVersion_1_0_0 + `; charset=utf-8`
|
||||||
|
// Deprecated: Use expfmt.NewFormat(expfmt.TypeOpenMetrics) instead.
|
||||||
|
FmtOpenMetrics_0_0_1 Format = OpenMetricsType + `; version=` + OpenMetricsVersion_0_0_1 + `; charset=utf-8`
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -79,17 +86,17 @@ const (
|
|||||||
func NewFormat(t FormatType) Format {
|
func NewFormat(t FormatType) Format {
|
||||||
switch t {
|
switch t {
|
||||||
case TypeProtoCompact:
|
case TypeProtoCompact:
|
||||||
return fmtProtoCompact
|
return FmtProtoCompact
|
||||||
case TypeProtoDelim:
|
case TypeProtoDelim:
|
||||||
return fmtProtoDelim
|
return FmtProtoDelim
|
||||||
case TypeProtoText:
|
case TypeProtoText:
|
||||||
return fmtProtoText
|
return FmtProtoText
|
||||||
case TypeTextPlain:
|
case TypeTextPlain:
|
||||||
return fmtText
|
return FmtText
|
||||||
case TypeOpenMetrics:
|
case TypeOpenMetrics:
|
||||||
return fmtOpenMetrics_1_0_0
|
return FmtOpenMetrics_1_0_0
|
||||||
default:
|
default:
|
||||||
return fmtUnknown
|
return FmtUnknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,12 +104,35 @@ func NewFormat(t FormatType) Format {
|
|||||||
// specified version number.
|
// specified version number.
|
||||||
func NewOpenMetricsFormat(version string) (Format, error) {
|
func NewOpenMetricsFormat(version string) (Format, error) {
|
||||||
if version == OpenMetricsVersion_0_0_1 {
|
if version == OpenMetricsVersion_0_0_1 {
|
||||||
return fmtOpenMetrics_0_0_1, nil
|
return FmtOpenMetrics_0_0_1, nil
|
||||||
}
|
}
|
||||||
if version == OpenMetricsVersion_1_0_0 {
|
if version == OpenMetricsVersion_1_0_0 {
|
||||||
return fmtOpenMetrics_1_0_0, nil
|
return FmtOpenMetrics_1_0_0, nil
|
||||||
}
|
}
|
||||||
return fmtUnknown, fmt.Errorf("unknown open metrics version string")
|
return FmtUnknown, errors.New("unknown open metrics version string")
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithEscapingScheme returns a copy of Format with the specified escaping
|
||||||
|
// scheme appended to the end. If an escaping scheme already exists it is
|
||||||
|
// removed.
|
||||||
|
func (f Format) WithEscapingScheme(s model.EscapingScheme) Format {
|
||||||
|
var terms []string
|
||||||
|
for _, p := range strings.Split(string(f), ";") {
|
||||||
|
toks := strings.Split(p, "=")
|
||||||
|
if len(toks) != 2 {
|
||||||
|
trimmed := strings.TrimSpace(p)
|
||||||
|
if len(trimmed) > 0 {
|
||||||
|
terms = append(terms, trimmed)
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
key := strings.TrimSpace(toks[0])
|
||||||
|
if key != model.EscapingKey {
|
||||||
|
terms = append(terms, strings.TrimSpace(p))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
terms = append(terms, model.EscapingKey+"="+s.String())
|
||||||
|
return Format(strings.Join(terms, "; "))
|
||||||
}
|
}
|
||||||
|
|
||||||
// FormatType deduces an overall FormatType for the given format.
|
// FormatType deduces an overall FormatType for the given format.
|
||||||
|
|||||||
10
vendor/github.com/prometheus/common/expfmt/openmetrics_create.go
generated
vendored
10
vendor/github.com/prometheus/common/expfmt/openmetrics_create.go
generated
vendored
@@ -38,7 +38,7 @@ type EncoderOption func(*encoderOption)
|
|||||||
|
|
||||||
// WithCreatedLines is an EncoderOption that configures the OpenMetrics encoder
|
// WithCreatedLines is an EncoderOption that configures the OpenMetrics encoder
|
||||||
// to include _created lines (See
|
// to include _created lines (See
|
||||||
// https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#counter-1).
|
// https://github.com/prometheus/OpenMetrics/blob/v1.0.0/specification/OpenMetrics.md#counter-1).
|
||||||
// Created timestamps can improve the accuracy of series reset detection, but
|
// Created timestamps can improve the accuracy of series reset detection, but
|
||||||
// come with a bandwidth cost.
|
// come with a bandwidth cost.
|
||||||
//
|
//
|
||||||
@@ -102,7 +102,7 @@ func WithUnit() EncoderOption {
|
|||||||
//
|
//
|
||||||
// - According to the OM specs, the `# UNIT` line is optional, but if populated,
|
// - According to the OM specs, the `# UNIT` line is optional, but if populated,
|
||||||
// the unit has to be present in the metric name as its suffix:
|
// the unit has to be present in the metric name as its suffix:
|
||||||
// (see https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#unit).
|
// (see https://github.com/prometheus/OpenMetrics/blob/v1.0.0/specification/OpenMetrics.md#unit).
|
||||||
// However, in order to accommodate any potential scenario where such a change in the
|
// However, in order to accommodate any potential scenario where such a change in the
|
||||||
// metric name is not desirable, the users are here given the choice of either explicitly
|
// metric name is not desirable, the users are here given the choice of either explicitly
|
||||||
// opt in, in case they wish for the unit to be included in the output AND in the metric name
|
// opt in, in case they wish for the unit to be included in the output AND in the metric name
|
||||||
@@ -152,8 +152,8 @@ func MetricFamilyToOpenMetrics(out io.Writer, in *dto.MetricFamily, options ...E
|
|||||||
if metricType == dto.MetricType_COUNTER && strings.HasSuffix(compliantName, "_total") {
|
if metricType == dto.MetricType_COUNTER && strings.HasSuffix(compliantName, "_total") {
|
||||||
compliantName = name[:len(name)-6]
|
compliantName = name[:len(name)-6]
|
||||||
}
|
}
|
||||||
if toOM.withUnit && in.Unit != nil && !strings.HasSuffix(compliantName, fmt.Sprintf("_%s", *in.Unit)) {
|
if toOM.withUnit && in.Unit != nil && !strings.HasSuffix(compliantName, "_"+*in.Unit) {
|
||||||
compliantName = compliantName + fmt.Sprintf("_%s", *in.Unit)
|
compliantName = compliantName + "_" + *in.Unit
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comments, first HELP, then TYPE.
|
// Comments, first HELP, then TYPE.
|
||||||
@@ -477,7 +477,7 @@ func writeOpenMetricsNameAndLabelPairs(
|
|||||||
if name != "" {
|
if name != "" {
|
||||||
// If the name does not pass the legacy validity check, we must put the
|
// If the name does not pass the legacy validity check, we must put the
|
||||||
// metric name inside the braces, quoted.
|
// metric name inside the braces, quoted.
|
||||||
if !model.IsValidLegacyMetricName(model.LabelValue(name)) {
|
if !model.IsValidLegacyMetricName(name) {
|
||||||
metricInsideBraces = true
|
metricInsideBraces = true
|
||||||
err := w.WriteByte(separator)
|
err := w.WriteByte(separator)
|
||||||
written++
|
written++
|
||||||
|
|||||||
4
vendor/github.com/prometheus/common/expfmt/text_create.go
generated
vendored
4
vendor/github.com/prometheus/common/expfmt/text_create.go
generated
vendored
@@ -354,7 +354,7 @@ func writeNameAndLabelPairs(
|
|||||||
if name != "" {
|
if name != "" {
|
||||||
// If the name does not pass the legacy validity check, we must put the
|
// If the name does not pass the legacy validity check, we must put the
|
||||||
// metric name inside the braces.
|
// metric name inside the braces.
|
||||||
if !model.IsValidLegacyMetricName(model.LabelValue(name)) {
|
if !model.IsValidLegacyMetricName(name) {
|
||||||
metricInsideBraces = true
|
metricInsideBraces = true
|
||||||
err := w.WriteByte(separator)
|
err := w.WriteByte(separator)
|
||||||
written++
|
written++
|
||||||
@@ -498,7 +498,7 @@ func writeInt(w enhancedWriter, i int64) (int, error) {
|
|||||||
// writeName writes a string as-is if it complies with the legacy naming
|
// writeName writes a string as-is if it complies with the legacy naming
|
||||||
// scheme, or escapes it in double quotes if not.
|
// scheme, or escapes it in double quotes if not.
|
||||||
func writeName(w enhancedWriter, name string) (int, error) {
|
func writeName(w enhancedWriter, name string) (int, error) {
|
||||||
if model.IsValidLegacyMetricName(model.LabelValue(name)) {
|
if model.IsValidLegacyMetricName(name) {
|
||||||
return w.WriteString(name)
|
return w.WriteString(name)
|
||||||
}
|
}
|
||||||
var written int
|
var written int
|
||||||
|
|||||||
164
vendor/github.com/prometheus/common/expfmt/text_parse.go
generated
vendored
164
vendor/github.com/prometheus/common/expfmt/text_parse.go
generated
vendored
@@ -22,9 +22,9 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"unicode/utf8"
|
||||||
|
|
||||||
dto "github.com/prometheus/client_model/go"
|
dto "github.com/prometheus/client_model/go"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
|
|
||||||
"github.com/prometheus/common/model"
|
"github.com/prometheus/common/model"
|
||||||
@@ -60,6 +60,7 @@ type TextParser struct {
|
|||||||
currentMF *dto.MetricFamily
|
currentMF *dto.MetricFamily
|
||||||
currentMetric *dto.Metric
|
currentMetric *dto.Metric
|
||||||
currentLabelPair *dto.LabelPair
|
currentLabelPair *dto.LabelPair
|
||||||
|
currentLabelPairs []*dto.LabelPair // Temporarily stores label pairs while parsing a metric line.
|
||||||
|
|
||||||
// The remaining member variables are only used for summaries/histograms.
|
// The remaining member variables are only used for summaries/histograms.
|
||||||
currentLabels map[string]string // All labels including '__name__' but excluding 'quantile'/'le'
|
currentLabels map[string]string // All labels including '__name__' but excluding 'quantile'/'le'
|
||||||
@@ -74,6 +75,9 @@ type TextParser struct {
|
|||||||
// count and sum of that summary/histogram.
|
// count and sum of that summary/histogram.
|
||||||
currentIsSummaryCount, currentIsSummarySum bool
|
currentIsSummaryCount, currentIsSummarySum bool
|
||||||
currentIsHistogramCount, currentIsHistogramSum bool
|
currentIsHistogramCount, currentIsHistogramSum bool
|
||||||
|
// These indicate if the metric name from the current line being parsed is inside
|
||||||
|
// braces and if that metric name was found respectively.
|
||||||
|
currentMetricIsInsideBraces, currentMetricInsideBracesIsPresent bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextToMetricFamilies reads 'in' as the simple and flat text-based exchange
|
// TextToMetricFamilies reads 'in' as the simple and flat text-based exchange
|
||||||
@@ -137,12 +141,15 @@ func (p *TextParser) reset(in io.Reader) {
|
|||||||
}
|
}
|
||||||
p.currentQuantile = math.NaN()
|
p.currentQuantile = math.NaN()
|
||||||
p.currentBucket = math.NaN()
|
p.currentBucket = math.NaN()
|
||||||
|
p.currentMF = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// startOfLine represents the state where the next byte read from p.buf is the
|
// startOfLine represents the state where the next byte read from p.buf is the
|
||||||
// start of a line (or whitespace leading up to it).
|
// start of a line (or whitespace leading up to it).
|
||||||
func (p *TextParser) startOfLine() stateFn {
|
func (p *TextParser) startOfLine() stateFn {
|
||||||
p.lineCount++
|
p.lineCount++
|
||||||
|
p.currentMetricIsInsideBraces = false
|
||||||
|
p.currentMetricInsideBracesIsPresent = false
|
||||||
if p.skipBlankTab(); p.err != nil {
|
if p.skipBlankTab(); p.err != nil {
|
||||||
// This is the only place that we expect to see io.EOF,
|
// This is the only place that we expect to see io.EOF,
|
||||||
// which is not an error but the signal that we are done.
|
// which is not an error but the signal that we are done.
|
||||||
@@ -158,6 +165,9 @@ func (p *TextParser) startOfLine() stateFn {
|
|||||||
return p.startComment
|
return p.startComment
|
||||||
case '\n':
|
case '\n':
|
||||||
return p.startOfLine // Empty line, start the next one.
|
return p.startOfLine // Empty line, start the next one.
|
||||||
|
case '{':
|
||||||
|
p.currentMetricIsInsideBraces = true
|
||||||
|
return p.readingLabels
|
||||||
}
|
}
|
||||||
return p.readingMetricName
|
return p.readingMetricName
|
||||||
}
|
}
|
||||||
@@ -275,6 +285,8 @@ func (p *TextParser) startLabelName() stateFn {
|
|||||||
return nil // Unexpected end of input.
|
return nil // Unexpected end of input.
|
||||||
}
|
}
|
||||||
if p.currentByte == '}' {
|
if p.currentByte == '}' {
|
||||||
|
p.currentMetric.Label = append(p.currentMetric.Label, p.currentLabelPairs...)
|
||||||
|
p.currentLabelPairs = nil
|
||||||
if p.skipBlankTab(); p.err != nil {
|
if p.skipBlankTab(); p.err != nil {
|
||||||
return nil // Unexpected end of input.
|
return nil // Unexpected end of input.
|
||||||
}
|
}
|
||||||
@@ -287,6 +299,45 @@ func (p *TextParser) startLabelName() stateFn {
|
|||||||
p.parseError(fmt.Sprintf("invalid label name for metric %q", p.currentMF.GetName()))
|
p.parseError(fmt.Sprintf("invalid label name for metric %q", p.currentMF.GetName()))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
if p.skipBlankTabIfCurrentBlankTab(); p.err != nil {
|
||||||
|
return nil // Unexpected end of input.
|
||||||
|
}
|
||||||
|
if p.currentByte != '=' {
|
||||||
|
if p.currentMetricIsInsideBraces {
|
||||||
|
if p.currentMetricInsideBracesIsPresent {
|
||||||
|
p.parseError(fmt.Sprintf("multiple metric names for metric %q", p.currentMF.GetName()))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
switch p.currentByte {
|
||||||
|
case ',':
|
||||||
|
p.setOrCreateCurrentMF()
|
||||||
|
if p.currentMF.Type == nil {
|
||||||
|
p.currentMF.Type = dto.MetricType_UNTYPED.Enum()
|
||||||
|
}
|
||||||
|
p.currentMetric = &dto.Metric{}
|
||||||
|
p.currentMetricInsideBracesIsPresent = true
|
||||||
|
return p.startLabelName
|
||||||
|
case '}':
|
||||||
|
p.setOrCreateCurrentMF()
|
||||||
|
if p.currentMF.Type == nil {
|
||||||
|
p.currentMF.Type = dto.MetricType_UNTYPED.Enum()
|
||||||
|
}
|
||||||
|
p.currentMetric = &dto.Metric{}
|
||||||
|
p.currentMetric.Label = append(p.currentMetric.Label, p.currentLabelPairs...)
|
||||||
|
p.currentLabelPairs = nil
|
||||||
|
if p.skipBlankTab(); p.err != nil {
|
||||||
|
return nil // Unexpected end of input.
|
||||||
|
}
|
||||||
|
return p.readingValue
|
||||||
|
default:
|
||||||
|
p.parseError(fmt.Sprintf("unexpected end of metric name %q", p.currentByte))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p.parseError(fmt.Sprintf("expected '=' after label name, found %q", p.currentByte))
|
||||||
|
p.currentLabelPairs = nil
|
||||||
|
return nil
|
||||||
|
}
|
||||||
p.currentLabelPair = &dto.LabelPair{Name: proto.String(p.currentToken.String())}
|
p.currentLabelPair = &dto.LabelPair{Name: proto.String(p.currentToken.String())}
|
||||||
if p.currentLabelPair.GetName() == string(model.MetricNameLabel) {
|
if p.currentLabelPair.GetName() == string(model.MetricNameLabel) {
|
||||||
p.parseError(fmt.Sprintf("label name %q is reserved", model.MetricNameLabel))
|
p.parseError(fmt.Sprintf("label name %q is reserved", model.MetricNameLabel))
|
||||||
@@ -296,23 +347,17 @@ func (p *TextParser) startLabelName() stateFn {
|
|||||||
// labels to 'real' labels.
|
// labels to 'real' labels.
|
||||||
if !(p.currentMF.GetType() == dto.MetricType_SUMMARY && p.currentLabelPair.GetName() == model.QuantileLabel) &&
|
if !(p.currentMF.GetType() == dto.MetricType_SUMMARY && p.currentLabelPair.GetName() == model.QuantileLabel) &&
|
||||||
!(p.currentMF.GetType() == dto.MetricType_HISTOGRAM && p.currentLabelPair.GetName() == model.BucketLabel) {
|
!(p.currentMF.GetType() == dto.MetricType_HISTOGRAM && p.currentLabelPair.GetName() == model.BucketLabel) {
|
||||||
p.currentMetric.Label = append(p.currentMetric.Label, p.currentLabelPair)
|
p.currentLabelPairs = append(p.currentLabelPairs, p.currentLabelPair)
|
||||||
}
|
|
||||||
if p.skipBlankTabIfCurrentBlankTab(); p.err != nil {
|
|
||||||
return nil // Unexpected end of input.
|
|
||||||
}
|
|
||||||
if p.currentByte != '=' {
|
|
||||||
p.parseError(fmt.Sprintf("expected '=' after label name, found %q", p.currentByte))
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
// Check for duplicate label names.
|
// Check for duplicate label names.
|
||||||
labels := make(map[string]struct{})
|
labels := make(map[string]struct{})
|
||||||
for _, l := range p.currentMetric.Label {
|
for _, l := range p.currentLabelPairs {
|
||||||
lName := l.GetName()
|
lName := l.GetName()
|
||||||
if _, exists := labels[lName]; !exists {
|
if _, exists := labels[lName]; !exists {
|
||||||
labels[lName] = struct{}{}
|
labels[lName] = struct{}{}
|
||||||
} else {
|
} else {
|
||||||
p.parseError(fmt.Sprintf("duplicate label names for metric %q", p.currentMF.GetName()))
|
p.parseError(fmt.Sprintf("duplicate label names for metric %q", p.currentMF.GetName()))
|
||||||
|
p.currentLabelPairs = nil
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -345,6 +390,7 @@ func (p *TextParser) startLabelValue() stateFn {
|
|||||||
if p.currentQuantile, p.err = parseFloat(p.currentLabelPair.GetValue()); p.err != nil {
|
if p.currentQuantile, p.err = parseFloat(p.currentLabelPair.GetValue()); p.err != nil {
|
||||||
// Create a more helpful error message.
|
// Create a more helpful error message.
|
||||||
p.parseError(fmt.Sprintf("expected float as value for 'quantile' label, got %q", p.currentLabelPair.GetValue()))
|
p.parseError(fmt.Sprintf("expected float as value for 'quantile' label, got %q", p.currentLabelPair.GetValue()))
|
||||||
|
p.currentLabelPairs = nil
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -371,12 +417,19 @@ func (p *TextParser) startLabelValue() stateFn {
|
|||||||
return p.startLabelName
|
return p.startLabelName
|
||||||
|
|
||||||
case '}':
|
case '}':
|
||||||
|
if p.currentMF == nil {
|
||||||
|
p.parseError("invalid metric name")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
p.currentMetric.Label = append(p.currentMetric.Label, p.currentLabelPairs...)
|
||||||
|
p.currentLabelPairs = nil
|
||||||
if p.skipBlankTab(); p.err != nil {
|
if p.skipBlankTab(); p.err != nil {
|
||||||
return nil // Unexpected end of input.
|
return nil // Unexpected end of input.
|
||||||
}
|
}
|
||||||
return p.readingValue
|
return p.readingValue
|
||||||
default:
|
default:
|
||||||
p.parseError(fmt.Sprintf("unexpected end of label value %q", p.currentLabelPair.GetValue()))
|
p.parseError(fmt.Sprintf("unexpected end of label value %q", p.currentLabelPair.GetValue()))
|
||||||
|
p.currentLabelPairs = nil
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -585,6 +638,8 @@ func (p *TextParser) readTokenUntilNewline(recognizeEscapeSequence bool) {
|
|||||||
p.currentToken.WriteByte(p.currentByte)
|
p.currentToken.WriteByte(p.currentByte)
|
||||||
case 'n':
|
case 'n':
|
||||||
p.currentToken.WriteByte('\n')
|
p.currentToken.WriteByte('\n')
|
||||||
|
case '"':
|
||||||
|
p.currentToken.WriteByte('"')
|
||||||
default:
|
default:
|
||||||
p.parseError(fmt.Sprintf("invalid escape sequence '\\%c'", p.currentByte))
|
p.parseError(fmt.Sprintf("invalid escape sequence '\\%c'", p.currentByte))
|
||||||
return
|
return
|
||||||
@@ -610,13 +665,45 @@ func (p *TextParser) readTokenUntilNewline(recognizeEscapeSequence bool) {
|
|||||||
// but not into p.currentToken.
|
// but not into p.currentToken.
|
||||||
func (p *TextParser) readTokenAsMetricName() {
|
func (p *TextParser) readTokenAsMetricName() {
|
||||||
p.currentToken.Reset()
|
p.currentToken.Reset()
|
||||||
|
// A UTF-8 metric name must be quoted and may have escaped characters.
|
||||||
|
quoted := false
|
||||||
|
escaped := false
|
||||||
if !isValidMetricNameStart(p.currentByte) {
|
if !isValidMetricNameStart(p.currentByte) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for {
|
for p.err == nil {
|
||||||
p.currentToken.WriteByte(p.currentByte)
|
if escaped {
|
||||||
|
switch p.currentByte {
|
||||||
|
case '\\':
|
||||||
|
p.currentToken.WriteByte(p.currentByte)
|
||||||
|
case 'n':
|
||||||
|
p.currentToken.WriteByte('\n')
|
||||||
|
case '"':
|
||||||
|
p.currentToken.WriteByte('"')
|
||||||
|
default:
|
||||||
|
p.parseError(fmt.Sprintf("invalid escape sequence '\\%c'", p.currentByte))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
escaped = false
|
||||||
|
} else {
|
||||||
|
switch p.currentByte {
|
||||||
|
case '"':
|
||||||
|
quoted = !quoted
|
||||||
|
if !quoted {
|
||||||
|
p.currentByte, p.err = p.buf.ReadByte()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
case '\n':
|
||||||
|
p.parseError(fmt.Sprintf("metric name %q contains unescaped new-line", p.currentToken.String()))
|
||||||
|
return
|
||||||
|
case '\\':
|
||||||
|
escaped = true
|
||||||
|
default:
|
||||||
|
p.currentToken.WriteByte(p.currentByte)
|
||||||
|
}
|
||||||
|
}
|
||||||
p.currentByte, p.err = p.buf.ReadByte()
|
p.currentByte, p.err = p.buf.ReadByte()
|
||||||
if p.err != nil || !isValidMetricNameContinuation(p.currentByte) {
|
if !isValidMetricNameContinuation(p.currentByte, quoted) || (!quoted && p.currentByte == ' ') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -628,13 +715,45 @@ func (p *TextParser) readTokenAsMetricName() {
|
|||||||
// but not into p.currentToken.
|
// but not into p.currentToken.
|
||||||
func (p *TextParser) readTokenAsLabelName() {
|
func (p *TextParser) readTokenAsLabelName() {
|
||||||
p.currentToken.Reset()
|
p.currentToken.Reset()
|
||||||
|
// A UTF-8 label name must be quoted and may have escaped characters.
|
||||||
|
quoted := false
|
||||||
|
escaped := false
|
||||||
if !isValidLabelNameStart(p.currentByte) {
|
if !isValidLabelNameStart(p.currentByte) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for {
|
for p.err == nil {
|
||||||
p.currentToken.WriteByte(p.currentByte)
|
if escaped {
|
||||||
|
switch p.currentByte {
|
||||||
|
case '\\':
|
||||||
|
p.currentToken.WriteByte(p.currentByte)
|
||||||
|
case 'n':
|
||||||
|
p.currentToken.WriteByte('\n')
|
||||||
|
case '"':
|
||||||
|
p.currentToken.WriteByte('"')
|
||||||
|
default:
|
||||||
|
p.parseError(fmt.Sprintf("invalid escape sequence '\\%c'", p.currentByte))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
escaped = false
|
||||||
|
} else {
|
||||||
|
switch p.currentByte {
|
||||||
|
case '"':
|
||||||
|
quoted = !quoted
|
||||||
|
if !quoted {
|
||||||
|
p.currentByte, p.err = p.buf.ReadByte()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
case '\n':
|
||||||
|
p.parseError(fmt.Sprintf("label name %q contains unescaped new-line", p.currentToken.String()))
|
||||||
|
return
|
||||||
|
case '\\':
|
||||||
|
escaped = true
|
||||||
|
default:
|
||||||
|
p.currentToken.WriteByte(p.currentByte)
|
||||||
|
}
|
||||||
|
}
|
||||||
p.currentByte, p.err = p.buf.ReadByte()
|
p.currentByte, p.err = p.buf.ReadByte()
|
||||||
if p.err != nil || !isValidLabelNameContinuation(p.currentByte) {
|
if !isValidLabelNameContinuation(p.currentByte, quoted) || (!quoted && p.currentByte == '=') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -660,6 +779,7 @@ func (p *TextParser) readTokenAsLabelValue() {
|
|||||||
p.currentToken.WriteByte('\n')
|
p.currentToken.WriteByte('\n')
|
||||||
default:
|
default:
|
||||||
p.parseError(fmt.Sprintf("invalid escape sequence '\\%c'", p.currentByte))
|
p.parseError(fmt.Sprintf("invalid escape sequence '\\%c'", p.currentByte))
|
||||||
|
p.currentLabelPairs = nil
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
escaped = false
|
escaped = false
|
||||||
@@ -718,19 +838,19 @@ func (p *TextParser) setOrCreateCurrentMF() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func isValidLabelNameStart(b byte) bool {
|
func isValidLabelNameStart(b byte) bool {
|
||||||
return (b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || b == '_'
|
return (b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || b == '_' || b == '"'
|
||||||
}
|
}
|
||||||
|
|
||||||
func isValidLabelNameContinuation(b byte) bool {
|
func isValidLabelNameContinuation(b byte, quoted bool) bool {
|
||||||
return isValidLabelNameStart(b) || (b >= '0' && b <= '9')
|
return isValidLabelNameStart(b) || (b >= '0' && b <= '9') || (quoted && utf8.ValidString(string(b)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func isValidMetricNameStart(b byte) bool {
|
func isValidMetricNameStart(b byte) bool {
|
||||||
return isValidLabelNameStart(b) || b == ':'
|
return isValidLabelNameStart(b) || b == ':'
|
||||||
}
|
}
|
||||||
|
|
||||||
func isValidMetricNameContinuation(b byte) bool {
|
func isValidMetricNameContinuation(b byte, quoted bool) bool {
|
||||||
return isValidLabelNameContinuation(b) || b == ':'
|
return isValidLabelNameContinuation(b, quoted) || b == ':'
|
||||||
}
|
}
|
||||||
|
|
||||||
func isBlankOrTab(b byte) bool {
|
func isBlankOrTab(b byte) bool {
|
||||||
@@ -775,7 +895,7 @@ func histogramMetricName(name string) string {
|
|||||||
|
|
||||||
func parseFloat(s string) (float64, error) {
|
func parseFloat(s string) (float64, error) {
|
||||||
if strings.ContainsAny(s, "pP_") {
|
if strings.ContainsAny(s, "pP_") {
|
||||||
return 0, fmt.Errorf("unsupported character in float")
|
return 0, errors.New("unsupported character in float")
|
||||||
}
|
}
|
||||||
return strconv.ParseFloat(s, 64)
|
return strconv.ParseFloat(s, 64)
|
||||||
}
|
}
|
||||||
|
|||||||
7
vendor/github.com/prometheus/common/model/alert.go
generated
vendored
7
vendor/github.com/prometheus/common/model/alert.go
generated
vendored
@@ -14,6 +14,7 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -89,16 +90,16 @@ func (a *Alert) StatusAt(ts time.Time) AlertStatus {
|
|||||||
// Validate checks whether the alert data is inconsistent.
|
// Validate checks whether the alert data is inconsistent.
|
||||||
func (a *Alert) Validate() error {
|
func (a *Alert) Validate() error {
|
||||||
if a.StartsAt.IsZero() {
|
if a.StartsAt.IsZero() {
|
||||||
return fmt.Errorf("start time missing")
|
return errors.New("start time missing")
|
||||||
}
|
}
|
||||||
if !a.EndsAt.IsZero() && a.EndsAt.Before(a.StartsAt) {
|
if !a.EndsAt.IsZero() && a.EndsAt.Before(a.StartsAt) {
|
||||||
return fmt.Errorf("start time must be before end time")
|
return errors.New("start time must be before end time")
|
||||||
}
|
}
|
||||||
if err := a.Labels.Validate(); err != nil {
|
if err := a.Labels.Validate(); err != nil {
|
||||||
return fmt.Errorf("invalid label set: %w", err)
|
return fmt.Errorf("invalid label set: %w", err)
|
||||||
}
|
}
|
||||||
if len(a.Labels) == 0 {
|
if len(a.Labels) == 0 {
|
||||||
return fmt.Errorf("at least one label pair required")
|
return errors.New("at least one label pair required")
|
||||||
}
|
}
|
||||||
if err := a.Annotations.Validate(); err != nil {
|
if err := a.Annotations.Validate(); err != nil {
|
||||||
return fmt.Errorf("invalid annotations: %w", err)
|
return fmt.Errorf("invalid annotations: %w", err)
|
||||||
|
|||||||
27
vendor/github.com/prometheus/common/model/labels.go
generated
vendored
27
vendor/github.com/prometheus/common/model/labels.go
generated
vendored
@@ -97,26 +97,35 @@ var LabelNameRE = regexp.MustCompile("^[a-zA-Z_][a-zA-Z0-9_]*$")
|
|||||||
// therewith.
|
// therewith.
|
||||||
type LabelName string
|
type LabelName string
|
||||||
|
|
||||||
// IsValid returns true iff name matches the pattern of LabelNameRE for legacy
|
// IsValid returns true iff the name matches the pattern of LabelNameRE when
|
||||||
// names, and iff it's valid UTF-8 if NameValidationScheme is set to
|
// NameValidationScheme is set to LegacyValidation, or valid UTF-8 if
|
||||||
// UTF8Validation. For the legacy matching, it does not use LabelNameRE for the
|
// NameValidationScheme is set to UTF8Validation.
|
||||||
// check but a much faster hardcoded implementation.
|
|
||||||
func (ln LabelName) IsValid() bool {
|
func (ln LabelName) IsValid() bool {
|
||||||
if len(ln) == 0 {
|
if len(ln) == 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
switch NameValidationScheme {
|
switch NameValidationScheme {
|
||||||
case LegacyValidation:
|
case LegacyValidation:
|
||||||
for i, b := range ln {
|
return ln.IsValidLegacy()
|
||||||
if !((b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || b == '_' || (b >= '0' && b <= '9' && i > 0)) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case UTF8Validation:
|
case UTF8Validation:
|
||||||
return utf8.ValidString(string(ln))
|
return utf8.ValidString(string(ln))
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("Invalid name validation scheme requested: %d", NameValidationScheme))
|
panic(fmt.Sprintf("Invalid name validation scheme requested: %d", NameValidationScheme))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsValidLegacy returns true iff name matches the pattern of LabelNameRE for
|
||||||
|
// legacy names. It does not use LabelNameRE for the check but a much faster
|
||||||
|
// hardcoded implementation.
|
||||||
|
func (ln LabelName) IsValidLegacy() bool {
|
||||||
|
if len(ln) == 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for i, b := range ln {
|
||||||
|
if !((b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || b == '_' || (b >= '0' && b <= '9' && i > 0)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
vendor/github.com/prometheus/common/model/labelset_string.go
generated
vendored
2
vendor/github.com/prometheus/common/model/labelset_string.go
generated
vendored
@@ -11,8 +11,6 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
//go:build go1.21
|
|
||||||
|
|
||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
39
vendor/github.com/prometheus/common/model/labelset_string_go120.go
generated
vendored
39
vendor/github.com/prometheus/common/model/labelset_string_go120.go
generated
vendored
@@ -1,39 +0,0 @@
|
|||||||
// Copyright 2024 The Prometheus Authors
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
//go:build !go1.21
|
|
||||||
|
|
||||||
package model
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"sort"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
// String was optimized using functions not available for go 1.20
|
|
||||||
// or lower. We keep the old implementation for compatibility with client_golang.
|
|
||||||
// Once client golang drops support for go 1.20 (scheduled for August 2024), this
|
|
||||||
// file can be removed.
|
|
||||||
func (l LabelSet) String() string {
|
|
||||||
labelNames := make([]string, 0, len(l))
|
|
||||||
for name := range l {
|
|
||||||
labelNames = append(labelNames, string(name))
|
|
||||||
}
|
|
||||||
sort.Strings(labelNames)
|
|
||||||
lstrs := make([]string, 0, len(l))
|
|
||||||
for _, name := range labelNames {
|
|
||||||
lstrs = append(lstrs, fmt.Sprintf("%s=%q", name, l[LabelName(name)]))
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("{%s}", strings.Join(lstrs, ", "))
|
|
||||||
}
|
|
||||||
76
vendor/github.com/prometheus/common/model/metric.go
generated
vendored
76
vendor/github.com/prometheus/common/model/metric.go
generated
vendored
@@ -14,9 +14,11 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
@@ -26,18 +28,21 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
// NameValidationScheme determines the method of name validation to be used by
|
// NameValidationScheme determines the method of name validation to be used by
|
||||||
// all calls to IsValidMetricName() and LabelName IsValid(). Setting UTF-8 mode
|
// all calls to IsValidMetricName() and LabelName IsValid(). Setting UTF-8
|
||||||
// in isolation from other components that don't support UTF-8 may result in
|
// mode in isolation from other components that don't support UTF-8 may result
|
||||||
// bugs or other undefined behavior. This value is intended to be set by
|
// in bugs or other undefined behavior. This value can be set to
|
||||||
// UTF-8-aware binaries as part of their startup. To avoid need for locking,
|
// LegacyValidation during startup if a binary is not UTF-8-aware binaries. To
|
||||||
// this value should be set once, ideally in an init(), before multiple
|
// avoid need for locking, this value should be set once, ideally in an
|
||||||
// goroutines are started.
|
// init(), before multiple goroutines are started.
|
||||||
NameValidationScheme = LegacyValidation
|
NameValidationScheme = UTF8Validation
|
||||||
|
|
||||||
// NameEscapingScheme defines the default way that names will be
|
// NameEscapingScheme defines the default way that names will be escaped when
|
||||||
// escaped when presented to systems that do not support UTF-8 names. If the
|
// presented to systems that do not support UTF-8 names. If the Content-Type
|
||||||
// Content-Type "escaping" term is specified, that will override this value.
|
// "escaping" term is specified, that will override this value.
|
||||||
NameEscapingScheme = ValueEncodingEscaping
|
// NameEscapingScheme should not be set to the NoEscaping value. That string
|
||||||
|
// is used in content negotiation to indicate that a system supports UTF-8 and
|
||||||
|
// has that feature enabled.
|
||||||
|
NameEscapingScheme = UnderscoreEscaping
|
||||||
)
|
)
|
||||||
|
|
||||||
// ValidationScheme is a Go enum for determining how metric and label names will
|
// ValidationScheme is a Go enum for determining how metric and label names will
|
||||||
@@ -161,7 +166,7 @@ func (m Metric) FastFingerprint() Fingerprint {
|
|||||||
func IsValidMetricName(n LabelValue) bool {
|
func IsValidMetricName(n LabelValue) bool {
|
||||||
switch NameValidationScheme {
|
switch NameValidationScheme {
|
||||||
case LegacyValidation:
|
case LegacyValidation:
|
||||||
return IsValidLegacyMetricName(n)
|
return IsValidLegacyMetricName(string(n))
|
||||||
case UTF8Validation:
|
case UTF8Validation:
|
||||||
if len(n) == 0 {
|
if len(n) == 0 {
|
||||||
return false
|
return false
|
||||||
@@ -176,7 +181,7 @@ func IsValidMetricName(n LabelValue) bool {
|
|||||||
// legacy validation scheme regardless of the value of NameValidationScheme.
|
// legacy validation scheme regardless of the value of NameValidationScheme.
|
||||||
// This function, however, does not use MetricNameRE for the check but a much
|
// This function, however, does not use MetricNameRE for the check but a much
|
||||||
// faster hardcoded implementation.
|
// faster hardcoded implementation.
|
||||||
func IsValidLegacyMetricName(n LabelValue) bool {
|
func IsValidLegacyMetricName(n string) bool {
|
||||||
if len(n) == 0 {
|
if len(n) == 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -208,7 +213,7 @@ func EscapeMetricFamily(v *dto.MetricFamily, scheme EscapingScheme) *dto.MetricF
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the name is nil, copy as-is, don't try to escape.
|
// If the name is nil, copy as-is, don't try to escape.
|
||||||
if v.Name == nil || IsValidLegacyMetricName(LabelValue(v.GetName())) {
|
if v.Name == nil || IsValidLegacyMetricName(v.GetName()) {
|
||||||
out.Name = v.Name
|
out.Name = v.Name
|
||||||
} else {
|
} else {
|
||||||
out.Name = proto.String(EscapeName(v.GetName(), scheme))
|
out.Name = proto.String(EscapeName(v.GetName(), scheme))
|
||||||
@@ -230,7 +235,7 @@ func EscapeMetricFamily(v *dto.MetricFamily, scheme EscapingScheme) *dto.MetricF
|
|||||||
|
|
||||||
for _, l := range m.Label {
|
for _, l := range m.Label {
|
||||||
if l.GetName() == MetricNameLabel {
|
if l.GetName() == MetricNameLabel {
|
||||||
if l.Value == nil || IsValidLegacyMetricName(LabelValue(l.GetValue())) {
|
if l.Value == nil || IsValidLegacyMetricName(l.GetValue()) {
|
||||||
escaped.Label = append(escaped.Label, l)
|
escaped.Label = append(escaped.Label, l)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -240,7 +245,7 @@ func EscapeMetricFamily(v *dto.MetricFamily, scheme EscapingScheme) *dto.MetricF
|
|||||||
})
|
})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if l.Name == nil || IsValidLegacyMetricName(LabelValue(l.GetName())) {
|
if l.Name == nil || IsValidLegacyMetricName(l.GetName()) {
|
||||||
escaped.Label = append(escaped.Label, l)
|
escaped.Label = append(escaped.Label, l)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -256,20 +261,16 @@ func EscapeMetricFamily(v *dto.MetricFamily, scheme EscapingScheme) *dto.MetricF
|
|||||||
|
|
||||||
func metricNeedsEscaping(m *dto.Metric) bool {
|
func metricNeedsEscaping(m *dto.Metric) bool {
|
||||||
for _, l := range m.Label {
|
for _, l := range m.Label {
|
||||||
if l.GetName() == MetricNameLabel && !IsValidLegacyMetricName(LabelValue(l.GetValue())) {
|
if l.GetName() == MetricNameLabel && !IsValidLegacyMetricName(l.GetValue()) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if !IsValidLegacyMetricName(LabelValue(l.GetName())) {
|
if !IsValidLegacyMetricName(l.GetName()) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
|
||||||
lowerhex = "0123456789abcdef"
|
|
||||||
)
|
|
||||||
|
|
||||||
// EscapeName escapes the incoming name according to the provided escaping
|
// EscapeName escapes the incoming name according to the provided escaping
|
||||||
// scheme. Depending on the rules of escaping, this may cause no change in the
|
// scheme. Depending on the rules of escaping, this may cause no change in the
|
||||||
// string that is returned. (Especially NoEscaping, which by definition is a
|
// string that is returned. (Especially NoEscaping, which by definition is a
|
||||||
@@ -283,7 +284,7 @@ func EscapeName(name string, scheme EscapingScheme) string {
|
|||||||
case NoEscaping:
|
case NoEscaping:
|
||||||
return name
|
return name
|
||||||
case UnderscoreEscaping:
|
case UnderscoreEscaping:
|
||||||
if IsValidLegacyMetricName(LabelValue(name)) {
|
if IsValidLegacyMetricName(name) {
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
for i, b := range name {
|
for i, b := range name {
|
||||||
@@ -304,31 +305,25 @@ func EscapeName(name string, scheme EscapingScheme) string {
|
|||||||
} else if isValidLegacyRune(b, i) {
|
} else if isValidLegacyRune(b, i) {
|
||||||
escaped.WriteRune(b)
|
escaped.WriteRune(b)
|
||||||
} else {
|
} else {
|
||||||
escaped.WriteRune('_')
|
escaped.WriteString("__")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return escaped.String()
|
return escaped.String()
|
||||||
case ValueEncodingEscaping:
|
case ValueEncodingEscaping:
|
||||||
if IsValidLegacyMetricName(LabelValue(name)) {
|
if IsValidLegacyMetricName(name) {
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
escaped.WriteString("U__")
|
escaped.WriteString("U__")
|
||||||
for i, b := range name {
|
for i, b := range name {
|
||||||
if isValidLegacyRune(b, i) {
|
if b == '_' {
|
||||||
|
escaped.WriteString("__")
|
||||||
|
} else if isValidLegacyRune(b, i) {
|
||||||
escaped.WriteRune(b)
|
escaped.WriteRune(b)
|
||||||
} else if !utf8.ValidRune(b) {
|
} else if !utf8.ValidRune(b) {
|
||||||
escaped.WriteString("_FFFD_")
|
escaped.WriteString("_FFFD_")
|
||||||
} else if b < 0x100 {
|
} else {
|
||||||
escaped.WriteRune('_')
|
escaped.WriteRune('_')
|
||||||
for s := 4; s >= 0; s -= 4 {
|
escaped.WriteString(strconv.FormatInt(int64(b), 16))
|
||||||
escaped.WriteByte(lowerhex[b>>uint(s)&0xF])
|
|
||||||
}
|
|
||||||
escaped.WriteRune('_')
|
|
||||||
} else if b < 0x10000 {
|
|
||||||
escaped.WriteRune('_')
|
|
||||||
for s := 12; s >= 0; s -= 4 {
|
|
||||||
escaped.WriteByte(lowerhex[b>>uint(s)&0xF])
|
|
||||||
}
|
|
||||||
escaped.WriteRune('_')
|
escaped.WriteRune('_')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -386,8 +381,9 @@ func UnescapeName(name string, scheme EscapingScheme) string {
|
|||||||
// We think we are in a UTF-8 code, process it.
|
// We think we are in a UTF-8 code, process it.
|
||||||
var utf8Val uint
|
var utf8Val uint
|
||||||
for j := 0; i < len(escapedName); j++ {
|
for j := 0; i < len(escapedName); j++ {
|
||||||
// This is too many characters for a utf8 value.
|
// This is too many characters for a utf8 value based on the MaxRune
|
||||||
if j > 4 {
|
// value of '\U0010FFFF'.
|
||||||
|
if j >= 6 {
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
// Found a closing underscore, convert to a rune, check validity, and append.
|
// Found a closing underscore, convert to a rune, check validity, and append.
|
||||||
@@ -440,7 +436,7 @@ func (e EscapingScheme) String() string {
|
|||||||
|
|
||||||
func ToEscapingScheme(s string) (EscapingScheme, error) {
|
func ToEscapingScheme(s string) (EscapingScheme, error) {
|
||||||
if s == "" {
|
if s == "" {
|
||||||
return NoEscaping, fmt.Errorf("got empty string instead of escaping scheme")
|
return NoEscaping, errors.New("got empty string instead of escaping scheme")
|
||||||
}
|
}
|
||||||
switch s {
|
switch s {
|
||||||
case AllowUTF8:
|
case AllowUTF8:
|
||||||
@@ -452,6 +448,6 @@ func ToEscapingScheme(s string) (EscapingScheme, error) {
|
|||||||
case EscapeValues:
|
case EscapeValues:
|
||||||
return ValueEncodingEscaping, nil
|
return ValueEncodingEscaping, nil
|
||||||
default:
|
default:
|
||||||
return NoEscaping, fmt.Errorf("unknown format scheme " + s)
|
return NoEscaping, fmt.Errorf("unknown format scheme %s", s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
17
vendor/github.com/prometheus/common/model/silence.go
generated
vendored
17
vendor/github.com/prometheus/common/model/silence.go
generated
vendored
@@ -15,6 +15,7 @@ package model
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
"time"
|
"time"
|
||||||
@@ -34,7 +35,7 @@ func (m *Matcher) UnmarshalJSON(b []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(m.Name) == 0 {
|
if len(m.Name) == 0 {
|
||||||
return fmt.Errorf("label name in matcher must not be empty")
|
return errors.New("label name in matcher must not be empty")
|
||||||
}
|
}
|
||||||
if m.IsRegex {
|
if m.IsRegex {
|
||||||
if _, err := regexp.Compile(m.Value); err != nil {
|
if _, err := regexp.Compile(m.Value); err != nil {
|
||||||
@@ -77,7 +78,7 @@ type Silence struct {
|
|||||||
// Validate returns true iff all fields of the silence have valid values.
|
// Validate returns true iff all fields of the silence have valid values.
|
||||||
func (s *Silence) Validate() error {
|
func (s *Silence) Validate() error {
|
||||||
if len(s.Matchers) == 0 {
|
if len(s.Matchers) == 0 {
|
||||||
return fmt.Errorf("at least one matcher required")
|
return errors.New("at least one matcher required")
|
||||||
}
|
}
|
||||||
for _, m := range s.Matchers {
|
for _, m := range s.Matchers {
|
||||||
if err := m.Validate(); err != nil {
|
if err := m.Validate(); err != nil {
|
||||||
@@ -85,22 +86,22 @@ func (s *Silence) Validate() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if s.StartsAt.IsZero() {
|
if s.StartsAt.IsZero() {
|
||||||
return fmt.Errorf("start time missing")
|
return errors.New("start time missing")
|
||||||
}
|
}
|
||||||
if s.EndsAt.IsZero() {
|
if s.EndsAt.IsZero() {
|
||||||
return fmt.Errorf("end time missing")
|
return errors.New("end time missing")
|
||||||
}
|
}
|
||||||
if s.EndsAt.Before(s.StartsAt) {
|
if s.EndsAt.Before(s.StartsAt) {
|
||||||
return fmt.Errorf("start time must be before end time")
|
return errors.New("start time must be before end time")
|
||||||
}
|
}
|
||||||
if s.CreatedBy == "" {
|
if s.CreatedBy == "" {
|
||||||
return fmt.Errorf("creator information missing")
|
return errors.New("creator information missing")
|
||||||
}
|
}
|
||||||
if s.Comment == "" {
|
if s.Comment == "" {
|
||||||
return fmt.Errorf("comment missing")
|
return errors.New("comment missing")
|
||||||
}
|
}
|
||||||
if s.CreatedAt.IsZero() {
|
if s.CreatedAt.IsZero() {
|
||||||
return fmt.Errorf("creation timestamp missing")
|
return errors.New("creation timestamp missing")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
3
vendor/github.com/prometheus/common/model/value_float.go
generated
vendored
3
vendor/github.com/prometheus/common/model/value_float.go
generated
vendored
@@ -15,6 +15,7 @@ package model
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -39,7 +40,7 @@ func (v SampleValue) MarshalJSON() ([]byte, error) {
|
|||||||
// UnmarshalJSON implements json.Unmarshaler.
|
// UnmarshalJSON implements json.Unmarshaler.
|
||||||
func (v *SampleValue) UnmarshalJSON(b []byte) error {
|
func (v *SampleValue) UnmarshalJSON(b []byte) error {
|
||||||
if len(b) < 2 || b[0] != '"' || b[len(b)-1] != '"' {
|
if len(b) < 2 || b[0] != '"' || b[len(b)-1] != '"' {
|
||||||
return fmt.Errorf("sample value must be a quoted string")
|
return errors.New("sample value must be a quoted string")
|
||||||
}
|
}
|
||||||
f, err := strconv.ParseFloat(string(b[1:len(b)-1]), 64)
|
f, err := strconv.ParseFloat(string(b[1:len(b)-1]), 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
7
vendor/github.com/prometheus/common/model/value_histogram.go
generated
vendored
7
vendor/github.com/prometheus/common/model/value_histogram.go
generated
vendored
@@ -15,6 +15,7 @@ package model
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -32,7 +33,7 @@ func (v FloatString) MarshalJSON() ([]byte, error) {
|
|||||||
|
|
||||||
func (v *FloatString) UnmarshalJSON(b []byte) error {
|
func (v *FloatString) UnmarshalJSON(b []byte) error {
|
||||||
if len(b) < 2 || b[0] != '"' || b[len(b)-1] != '"' {
|
if len(b) < 2 || b[0] != '"' || b[len(b)-1] != '"' {
|
||||||
return fmt.Errorf("float value must be a quoted string")
|
return errors.New("float value must be a quoted string")
|
||||||
}
|
}
|
||||||
f, err := strconv.ParseFloat(string(b[1:len(b)-1]), 64)
|
f, err := strconv.ParseFloat(string(b[1:len(b)-1]), 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -141,7 +142,7 @@ type SampleHistogramPair struct {
|
|||||||
|
|
||||||
func (s SampleHistogramPair) MarshalJSON() ([]byte, error) {
|
func (s SampleHistogramPair) MarshalJSON() ([]byte, error) {
|
||||||
if s.Histogram == nil {
|
if s.Histogram == nil {
|
||||||
return nil, fmt.Errorf("histogram is nil")
|
return nil, errors.New("histogram is nil")
|
||||||
}
|
}
|
||||||
t, err := json.Marshal(s.Timestamp)
|
t, err := json.Marshal(s.Timestamp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -164,7 +165,7 @@ func (s *SampleHistogramPair) UnmarshalJSON(buf []byte) error {
|
|||||||
return fmt.Errorf("wrong number of fields: %d != %d", gotLen, wantLen)
|
return fmt.Errorf("wrong number of fields: %d != %d", gotLen, wantLen)
|
||||||
}
|
}
|
||||||
if s.Histogram == nil {
|
if s.Histogram == nil {
|
||||||
return fmt.Errorf("histogram is null")
|
return errors.New("histogram is null")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
2
vendor/golang.org/x/exp/constraints/constraints.go
generated
vendored
2
vendor/golang.org/x/exp/constraints/constraints.go
generated
vendored
@@ -45,6 +45,8 @@ type Complex interface {
|
|||||||
// that supports the operators < <= >= >.
|
// that supports the operators < <= >= >.
|
||||||
// If future releases of Go add new ordered types,
|
// If future releases of Go add new ordered types,
|
||||||
// this constraint will be modified to include them.
|
// this constraint will be modified to include them.
|
||||||
|
//
|
||||||
|
// This type is redundant since Go 1.21 introduced [cmp.Ordered].
|
||||||
type Ordered interface {
|
type Ordered interface {
|
||||||
Integer | Float | ~string
|
Integer | Float | ~string
|
||||||
}
|
}
|
||||||
|
|||||||
12
vendor/golang.org/x/exp/rand/rand.go
generated
vendored
12
vendor/golang.org/x/exp/rand/rand.go
generated
vendored
@@ -4,17 +4,11 @@
|
|||||||
|
|
||||||
// Package rand implements pseudo-random number generators.
|
// Package rand implements pseudo-random number generators.
|
||||||
//
|
//
|
||||||
// Random numbers are generated by a Source. Top-level functions, such as
|
|
||||||
// Float64 and Int, use a default shared Source that produces a deterministic
|
|
||||||
// sequence of values each time a program is run. Use the Seed function to
|
|
||||||
// initialize the default Source if different behavior is required for each run.
|
|
||||||
// The default Source, a LockedSource, is safe for concurrent use by multiple
|
|
||||||
// goroutines, but Sources created by NewSource are not. However, Sources are small
|
|
||||||
// and it is reasonable to have a separate Source for each goroutine, seeded
|
|
||||||
// differently, to avoid locking.
|
|
||||||
//
|
|
||||||
// For random numbers suitable for security-sensitive work, see the crypto/rand
|
// For random numbers suitable for security-sensitive work, see the crypto/rand
|
||||||
// package.
|
// package.
|
||||||
|
//
|
||||||
|
// Deprecated: use the math/rand/v2 package instead. This package is
|
||||||
|
// scheduled to be tagged and deleted, per https://go.dev/issue/61716.
|
||||||
package rand
|
package rand
|
||||||
|
|
||||||
import "sync"
|
import "sync"
|
||||||
|
|||||||
4
vendor/golang.org/x/net/LICENSE
generated
vendored
4
vendor/golang.org/x/net/LICENSE
generated
vendored
@@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
Copyright 2009 The Go Authors.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are
|
modification, are permitted provided that the following conditions are
|
||||||
@@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer.
|
|||||||
copyright notice, this list of conditions and the following disclaimer
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
in the documentation and/or other materials provided with the
|
in the documentation and/or other materials provided with the
|
||||||
distribution.
|
distribution.
|
||||||
* Neither the name of Google Inc. nor the names of its
|
* Neither the name of Google LLC nor the names of its
|
||||||
contributors may be used to endorse or promote products derived from
|
contributors may be used to endorse or promote products derived from
|
||||||
this software without specific prior written permission.
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
|||||||
4
vendor/golang.org/x/sys/LICENSE
generated
vendored
4
vendor/golang.org/x/sys/LICENSE
generated
vendored
@@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
Copyright 2009 The Go Authors.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are
|
modification, are permitted provided that the following conditions are
|
||||||
@@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer.
|
|||||||
copyright notice, this list of conditions and the following disclaimer
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
in the documentation and/or other materials provided with the
|
in the documentation and/or other materials provided with the
|
||||||
distribution.
|
distribution.
|
||||||
* Neither the name of Google Inc. nor the names of its
|
* Neither the name of Google LLC nor the names of its
|
||||||
contributors may be used to endorse or promote products derived from
|
contributors may be used to endorse or promote products derived from
|
||||||
this software without specific prior written permission.
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
|||||||
2
vendor/golang.org/x/sys/unix/README.md
generated
vendored
2
vendor/golang.org/x/sys/unix/README.md
generated
vendored
@@ -156,7 +156,7 @@ from the generated architecture-specific files listed below, and merge these
|
|||||||
into a common file for each OS.
|
into a common file for each OS.
|
||||||
|
|
||||||
The merge is performed in the following steps:
|
The merge is performed in the following steps:
|
||||||
1. Construct the set of common code that is idential in all architecture-specific files.
|
1. Construct the set of common code that is identical in all architecture-specific files.
|
||||||
2. Write this common code to the merged file.
|
2. Write this common code to the merged file.
|
||||||
3. Remove the common code from all architecture-specific files.
|
3. Remove the common code from all architecture-specific files.
|
||||||
|
|
||||||
|
|||||||
36
vendor/golang.org/x/sys/unix/auxv.go
generated
vendored
Normal file
36
vendor/golang.org/x/sys/unix/auxv.go
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
// Copyright 2025 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build go1.21 && (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos)
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:linkname runtime_getAuxv runtime.getAuxv
|
||||||
|
func runtime_getAuxv() []uintptr
|
||||||
|
|
||||||
|
// Auxv returns the ELF auxiliary vector as a sequence of key/value pairs.
|
||||||
|
// The returned slice is always a fresh copy, owned by the caller.
|
||||||
|
// It returns an error on non-ELF platforms, or if the auxiliary vector cannot be accessed,
|
||||||
|
// which happens in some locked-down environments and build modes.
|
||||||
|
func Auxv() ([][2]uintptr, error) {
|
||||||
|
vec := runtime_getAuxv()
|
||||||
|
vecLen := len(vec)
|
||||||
|
|
||||||
|
if vecLen == 0 {
|
||||||
|
return nil, syscall.ENOENT
|
||||||
|
}
|
||||||
|
|
||||||
|
if vecLen%2 != 0 {
|
||||||
|
return nil, syscall.EINVAL
|
||||||
|
}
|
||||||
|
|
||||||
|
result := make([]uintptr, vecLen)
|
||||||
|
copy(result, vec)
|
||||||
|
return unsafe.Slice((*[2]uintptr)(unsafe.Pointer(&result[0])), vecLen/2), nil
|
||||||
|
}
|
||||||
13
vendor/golang.org/x/sys/unix/auxv_unsupported.go
generated
vendored
Normal file
13
vendor/golang.org/x/sys/unix/auxv_unsupported.go
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
// Copyright 2025 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build !go1.21 && (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos)
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
func Auxv() ([][2]uintptr, error) {
|
||||||
|
return nil, syscall.ENOTSUP
|
||||||
|
}
|
||||||
96
vendor/golang.org/x/sys/unix/ioctl_linux.go
generated
vendored
96
vendor/golang.org/x/sys/unix/ioctl_linux.go
generated
vendored
@@ -58,6 +58,102 @@ func IoctlGetEthtoolDrvinfo(fd int, ifname string) (*EthtoolDrvinfo, error) {
|
|||||||
return &value, err
|
return &value, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IoctlGetEthtoolTsInfo fetches ethtool timestamping and PHC
|
||||||
|
// association for the network device specified by ifname.
|
||||||
|
func IoctlGetEthtoolTsInfo(fd int, ifname string) (*EthtoolTsInfo, error) {
|
||||||
|
ifr, err := NewIfreq(ifname)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
value := EthtoolTsInfo{Cmd: ETHTOOL_GET_TS_INFO}
|
||||||
|
ifrd := ifr.withData(unsafe.Pointer(&value))
|
||||||
|
|
||||||
|
err = ioctlIfreqData(fd, SIOCETHTOOL, &ifrd)
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlGetHwTstamp retrieves the hardware timestamping configuration
|
||||||
|
// for the network device specified by ifname.
|
||||||
|
func IoctlGetHwTstamp(fd int, ifname string) (*HwTstampConfig, error) {
|
||||||
|
ifr, err := NewIfreq(ifname)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
value := HwTstampConfig{}
|
||||||
|
ifrd := ifr.withData(unsafe.Pointer(&value))
|
||||||
|
|
||||||
|
err = ioctlIfreqData(fd, SIOCGHWTSTAMP, &ifrd)
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlSetHwTstamp updates the hardware timestamping configuration for
|
||||||
|
// the network device specified by ifname.
|
||||||
|
func IoctlSetHwTstamp(fd int, ifname string, cfg *HwTstampConfig) error {
|
||||||
|
ifr, err := NewIfreq(ifname)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
ifrd := ifr.withData(unsafe.Pointer(cfg))
|
||||||
|
return ioctlIfreqData(fd, SIOCSHWTSTAMP, &ifrd)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FdToClockID derives the clock ID from the file descriptor number
|
||||||
|
// - see clock_gettime(3), FD_TO_CLOCKID macros. The resulting ID is
|
||||||
|
// suitable for system calls like ClockGettime.
|
||||||
|
func FdToClockID(fd int) int32 { return int32((int(^fd) << 3) | 3) }
|
||||||
|
|
||||||
|
// IoctlPtpClockGetcaps returns the description of a given PTP device.
|
||||||
|
func IoctlPtpClockGetcaps(fd int) (*PtpClockCaps, error) {
|
||||||
|
var value PtpClockCaps
|
||||||
|
err := ioctlPtr(fd, PTP_CLOCK_GETCAPS2, unsafe.Pointer(&value))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlPtpSysOffsetPrecise returns a description of the clock
|
||||||
|
// offset compared to the system clock.
|
||||||
|
func IoctlPtpSysOffsetPrecise(fd int) (*PtpSysOffsetPrecise, error) {
|
||||||
|
var value PtpSysOffsetPrecise
|
||||||
|
err := ioctlPtr(fd, PTP_SYS_OFFSET_PRECISE2, unsafe.Pointer(&value))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlPtpSysOffsetExtended returns an extended description of the
|
||||||
|
// clock offset compared to the system clock. The samples parameter
|
||||||
|
// specifies the desired number of measurements.
|
||||||
|
func IoctlPtpSysOffsetExtended(fd int, samples uint) (*PtpSysOffsetExtended, error) {
|
||||||
|
value := PtpSysOffsetExtended{Samples: uint32(samples)}
|
||||||
|
err := ioctlPtr(fd, PTP_SYS_OFFSET_EXTENDED2, unsafe.Pointer(&value))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlPtpPinGetfunc returns the configuration of the specified
|
||||||
|
// I/O pin on given PTP device.
|
||||||
|
func IoctlPtpPinGetfunc(fd int, index uint) (*PtpPinDesc, error) {
|
||||||
|
value := PtpPinDesc{Index: uint32(index)}
|
||||||
|
err := ioctlPtr(fd, PTP_PIN_GETFUNC2, unsafe.Pointer(&value))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlPtpPinSetfunc updates configuration of the specified PTP
|
||||||
|
// I/O pin.
|
||||||
|
func IoctlPtpPinSetfunc(fd int, pd *PtpPinDesc) error {
|
||||||
|
return ioctlPtr(fd, PTP_PIN_SETFUNC2, unsafe.Pointer(pd))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlPtpPeroutRequest configures the periodic output mode of the
|
||||||
|
// PTP I/O pins.
|
||||||
|
func IoctlPtpPeroutRequest(fd int, r *PtpPeroutRequest) error {
|
||||||
|
return ioctlPtr(fd, PTP_PEROUT_REQUEST2, unsafe.Pointer(r))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlPtpExttsRequest configures the external timestamping mode
|
||||||
|
// of the PTP I/O pins.
|
||||||
|
func IoctlPtpExttsRequest(fd int, r *PtpExttsRequest) error {
|
||||||
|
return ioctlPtr(fd, PTP_EXTTS_REQUEST2, unsafe.Pointer(r))
|
||||||
|
}
|
||||||
|
|
||||||
// IoctlGetWatchdogInfo fetches information about a watchdog device from the
|
// IoctlGetWatchdogInfo fetches information about a watchdog device from the
|
||||||
// Linux watchdog API. For more information, see:
|
// Linux watchdog API. For more information, see:
|
||||||
// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html.
|
// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html.
|
||||||
|
|||||||
18
vendor/golang.org/x/sys/unix/mkerrors.sh
generated
vendored
18
vendor/golang.org/x/sys/unix/mkerrors.sh
generated
vendored
@@ -58,6 +58,7 @@ includes_Darwin='
|
|||||||
#define _DARWIN_USE_64_BIT_INODE
|
#define _DARWIN_USE_64_BIT_INODE
|
||||||
#define __APPLE_USE_RFC_3542
|
#define __APPLE_USE_RFC_3542
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <sys/stdio.h>
|
||||||
#include <sys/attr.h>
|
#include <sys/attr.h>
|
||||||
#include <sys/clonefile.h>
|
#include <sys/clonefile.h>
|
||||||
#include <sys/kern_control.h>
|
#include <sys/kern_control.h>
|
||||||
@@ -157,6 +158,16 @@ includes_Linux='
|
|||||||
#endif
|
#endif
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
|
// See the description in unix/linux/types.go
|
||||||
|
#if defined(__ARM_EABI__) || \
|
||||||
|
(defined(__mips__) && (_MIPS_SIM == _ABIO32)) || \
|
||||||
|
(defined(__powerpc__) && (!defined(__powerpc64__)))
|
||||||
|
# ifdef _TIME_BITS
|
||||||
|
# undef _TIME_BITS
|
||||||
|
# endif
|
||||||
|
# define _TIME_BITS 32
|
||||||
|
#endif
|
||||||
|
|
||||||
// <sys/ioctl.h> is broken on powerpc64, as it fails to include definitions of
|
// <sys/ioctl.h> is broken on powerpc64, as it fails to include definitions of
|
||||||
// these structures. We just include them copied from <bits/termios.h>.
|
// these structures. We just include them copied from <bits/termios.h>.
|
||||||
#if defined(__powerpc__)
|
#if defined(__powerpc__)
|
||||||
@@ -255,6 +266,7 @@ struct ltchars {
|
|||||||
#include <linux/nsfs.h>
|
#include <linux/nsfs.h>
|
||||||
#include <linux/perf_event.h>
|
#include <linux/perf_event.h>
|
||||||
#include <linux/pps.h>
|
#include <linux/pps.h>
|
||||||
|
#include <linux/ptp_clock.h>
|
||||||
#include <linux/ptrace.h>
|
#include <linux/ptrace.h>
|
||||||
#include <linux/random.h>
|
#include <linux/random.h>
|
||||||
#include <linux/reboot.h>
|
#include <linux/reboot.h>
|
||||||
@@ -526,6 +538,7 @@ ccflags="$@"
|
|||||||
$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|TCP|MCAST|EVFILT|NOTE|SHUT|PROT|MAP|MREMAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR|LOCAL|TCPOPT|UDP)_/ ||
|
$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|TCP|MCAST|EVFILT|NOTE|SHUT|PROT|MAP|MREMAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR|LOCAL|TCPOPT|UDP)_/ ||
|
||||||
$2 ~ /^NFC_(GENL|PROTO|COMM|RF|SE|DIRECTION|LLCP|SOCKPROTO)_/ ||
|
$2 ~ /^NFC_(GENL|PROTO|COMM|RF|SE|DIRECTION|LLCP|SOCKPROTO)_/ ||
|
||||||
$2 ~ /^NFC_.*_(MAX)?SIZE$/ ||
|
$2 ~ /^NFC_.*_(MAX)?SIZE$/ ||
|
||||||
|
$2 ~ /^PTP_/ ||
|
||||||
$2 ~ /^RAW_PAYLOAD_/ ||
|
$2 ~ /^RAW_PAYLOAD_/ ||
|
||||||
$2 ~ /^[US]F_/ ||
|
$2 ~ /^[US]F_/ ||
|
||||||
$2 ~ /^TP_STATUS_/ ||
|
$2 ~ /^TP_STATUS_/ ||
|
||||||
@@ -551,6 +564,7 @@ ccflags="$@"
|
|||||||
$2 !~ /^RTC_VL_(ACCURACY|BACKUP|DATA)/ &&
|
$2 !~ /^RTC_VL_(ACCURACY|BACKUP|DATA)/ &&
|
||||||
$2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTC|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P|NETNSA)_/ ||
|
$2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTC|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P|NETNSA)_/ ||
|
||||||
$2 ~ /^SOCK_|SK_DIAG_|SKNLGRP_$/ ||
|
$2 ~ /^SOCK_|SK_DIAG_|SKNLGRP_$/ ||
|
||||||
|
$2 ~ /^(CONNECT|SAE)_/ ||
|
||||||
$2 ~ /^FIORDCHK$/ ||
|
$2 ~ /^FIORDCHK$/ ||
|
||||||
$2 ~ /^SIOC/ ||
|
$2 ~ /^SIOC/ ||
|
||||||
$2 ~ /^TIOC/ ||
|
$2 ~ /^TIOC/ ||
|
||||||
@@ -654,7 +668,7 @@ errors=$(
|
|||||||
signals=$(
|
signals=$(
|
||||||
echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
|
echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
|
||||||
awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' |
|
awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' |
|
||||||
grep -v 'SIGSTKSIZE\|SIGSTKSZ\|SIGRT\|SIGMAX64' |
|
grep -E -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT|SIGMAX64)' |
|
||||||
sort
|
sort
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -664,7 +678,7 @@ echo '#include <errno.h>' | $CC -x c - -E -dM $ccflags |
|
|||||||
sort >_error.grep
|
sort >_error.grep
|
||||||
echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
|
echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
|
||||||
awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' |
|
awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' |
|
||||||
grep -v 'SIGSTKSIZE\|SIGSTKSZ\|SIGRT\|SIGMAX64' |
|
grep -E -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT|SIGMAX64)' |
|
||||||
sort >_signal.grep
|
sort >_signal.grep
|
||||||
|
|
||||||
echo '// mkerrors.sh' "$@"
|
echo '// mkerrors.sh' "$@"
|
||||||
|
|||||||
2
vendor/golang.org/x/sys/unix/syscall_aix.go
generated
vendored
2
vendor/golang.org/x/sys/unix/syscall_aix.go
generated
vendored
@@ -360,7 +360,7 @@ func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int,
|
|||||||
var status _C_int
|
var status _C_int
|
||||||
var r Pid_t
|
var r Pid_t
|
||||||
err = ERESTART
|
err = ERESTART
|
||||||
// AIX wait4 may return with ERESTART errno, while the processus is still
|
// AIX wait4 may return with ERESTART errno, while the process is still
|
||||||
// active.
|
// active.
|
||||||
for err == ERESTART {
|
for err == ERESTART {
|
||||||
r, err = wait4(Pid_t(pid), &status, options, rusage)
|
r, err = wait4(Pid_t(pid), &status, options, rusage)
|
||||||
|
|||||||
49
vendor/golang.org/x/sys/unix/syscall_darwin.go
generated
vendored
49
vendor/golang.org/x/sys/unix/syscall_darwin.go
generated
vendored
@@ -402,6 +402,18 @@ func IoctlSetIfreqMTU(fd int, ifreq *IfreqMTU) error {
|
|||||||
return ioctlPtr(fd, SIOCSIFMTU, unsafe.Pointer(ifreq))
|
return ioctlPtr(fd, SIOCSIFMTU, unsafe.Pointer(ifreq))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//sys renamexNp(from string, to string, flag uint32) (err error)
|
||||||
|
|
||||||
|
func RenamexNp(from string, to string, flag uint32) (err error) {
|
||||||
|
return renamexNp(from, to, flag)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error)
|
||||||
|
|
||||||
|
func RenameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) {
|
||||||
|
return renameatxNp(fromfd, from, tofd, to, flag)
|
||||||
|
}
|
||||||
|
|
||||||
//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS_SYSCTL
|
//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS_SYSCTL
|
||||||
|
|
||||||
func Uname(uname *Utsname) error {
|
func Uname(uname *Utsname) error {
|
||||||
@@ -554,6 +566,43 @@ func PthreadFchdir(fd int) (err error) {
|
|||||||
return pthread_fchdir_np(fd)
|
return pthread_fchdir_np(fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Connectx calls connectx(2) to initiate a connection on a socket.
|
||||||
|
//
|
||||||
|
// srcIf, srcAddr, and dstAddr are filled into a [SaEndpoints] struct and passed as the endpoints argument.
|
||||||
|
//
|
||||||
|
// - srcIf is the optional source interface index. 0 means unspecified.
|
||||||
|
// - srcAddr is the optional source address. nil means unspecified.
|
||||||
|
// - dstAddr is the destination address.
|
||||||
|
//
|
||||||
|
// On success, Connectx returns the number of bytes enqueued for transmission.
|
||||||
|
func Connectx(fd int, srcIf uint32, srcAddr, dstAddr Sockaddr, associd SaeAssocID, flags uint32, iov []Iovec, connid *SaeConnID) (n uintptr, err error) {
|
||||||
|
endpoints := SaEndpoints{
|
||||||
|
Srcif: srcIf,
|
||||||
|
}
|
||||||
|
|
||||||
|
if srcAddr != nil {
|
||||||
|
addrp, addrlen, err := srcAddr.sockaddr()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
endpoints.Srcaddr = (*RawSockaddr)(addrp)
|
||||||
|
endpoints.Srcaddrlen = uint32(addrlen)
|
||||||
|
}
|
||||||
|
|
||||||
|
if dstAddr != nil {
|
||||||
|
addrp, addrlen, err := dstAddr.sockaddr()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
endpoints.Dstaddr = (*RawSockaddr)(addrp)
|
||||||
|
endpoints.Dstaddrlen = uint32(addrlen)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = connectx(fd, &endpoints, associd, flags, iov, &n, connid)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys connectx(fd int, endpoints *SaEndpoints, associd SaeAssocID, flags uint32, iov []Iovec, n *uintptr, connid *SaeConnID) (err error)
|
||||||
//sys sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error)
|
//sys sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error)
|
||||||
|
|
||||||
//sys shmat(id int, addr uintptr, flag int) (ret uintptr, err error)
|
//sys shmat(id int, addr uintptr, flag int) (ret uintptr, err error)
|
||||||
|
|||||||
12
vendor/golang.org/x/sys/unix/syscall_dragonfly.go
generated
vendored
12
vendor/golang.org/x/sys/unix/syscall_dragonfly.go
generated
vendored
@@ -246,6 +246,18 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
|
|||||||
return sendfile(outfd, infd, offset, count)
|
return sendfile(outfd, infd, offset, count)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Dup3(oldfd, newfd, flags int) error {
|
||||||
|
if oldfd == newfd || flags&^O_CLOEXEC != 0 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
how := F_DUP2FD
|
||||||
|
if flags&O_CLOEXEC != 0 {
|
||||||
|
how = F_DUP2FD_CLOEXEC
|
||||||
|
}
|
||||||
|
_, err := fcntl(oldfd, how, newfd)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Exposed directly
|
* Exposed directly
|
||||||
*/
|
*/
|
||||||
|
|||||||
1
vendor/golang.org/x/sys/unix/syscall_hurd.go
generated
vendored
1
vendor/golang.org/x/sys/unix/syscall_hurd.go
generated
vendored
@@ -11,6 +11,7 @@ package unix
|
|||||||
int ioctl(int, unsigned long int, uintptr_t);
|
int ioctl(int, unsigned long int, uintptr_t);
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
func ioctl(fd int, req uint, arg uintptr) (err error) {
|
func ioctl(fd int, req uint, arg uintptr) (err error) {
|
||||||
r0, er := C.ioctl(C.int(fd), C.ulong(req), C.uintptr_t(arg))
|
r0, er := C.ioctl(C.int(fd), C.ulong(req), C.uintptr_t(arg))
|
||||||
|
|||||||
65
vendor/golang.org/x/sys/unix/syscall_linux.go
generated
vendored
65
vendor/golang.org/x/sys/unix/syscall_linux.go
generated
vendored
@@ -1295,6 +1295,48 @@ func GetsockoptTCPInfo(fd, level, opt int) (*TCPInfo, error) {
|
|||||||
return &value, err
|
return &value, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetsockoptTCPCCVegasInfo returns algorithm specific congestion control information for a socket using the "vegas"
|
||||||
|
// algorithm.
|
||||||
|
//
|
||||||
|
// The socket's congestion control algorighm can be retrieved via [GetsockoptString] with the [TCP_CONGESTION] option:
|
||||||
|
//
|
||||||
|
// algo, err := unix.GetsockoptString(fd, unix.IPPROTO_TCP, unix.TCP_CONGESTION)
|
||||||
|
func GetsockoptTCPCCVegasInfo(fd, level, opt int) (*TCPVegasInfo, error) {
|
||||||
|
var value [SizeofTCPCCInfo / 4]uint32 // ensure proper alignment
|
||||||
|
vallen := _Socklen(SizeofTCPCCInfo)
|
||||||
|
err := getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
|
||||||
|
out := (*TCPVegasInfo)(unsafe.Pointer(&value[0]))
|
||||||
|
return out, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetsockoptTCPCCDCTCPInfo returns algorithm specific congestion control information for a socket using the "dctp"
|
||||||
|
// algorithm.
|
||||||
|
//
|
||||||
|
// The socket's congestion control algorighm can be retrieved via [GetsockoptString] with the [TCP_CONGESTION] option:
|
||||||
|
//
|
||||||
|
// algo, err := unix.GetsockoptString(fd, unix.IPPROTO_TCP, unix.TCP_CONGESTION)
|
||||||
|
func GetsockoptTCPCCDCTCPInfo(fd, level, opt int) (*TCPDCTCPInfo, error) {
|
||||||
|
var value [SizeofTCPCCInfo / 4]uint32 // ensure proper alignment
|
||||||
|
vallen := _Socklen(SizeofTCPCCInfo)
|
||||||
|
err := getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
|
||||||
|
out := (*TCPDCTCPInfo)(unsafe.Pointer(&value[0]))
|
||||||
|
return out, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetsockoptTCPCCBBRInfo returns algorithm specific congestion control information for a socket using the "bbr"
|
||||||
|
// algorithm.
|
||||||
|
//
|
||||||
|
// The socket's congestion control algorighm can be retrieved via [GetsockoptString] with the [TCP_CONGESTION] option:
|
||||||
|
//
|
||||||
|
// algo, err := unix.GetsockoptString(fd, unix.IPPROTO_TCP, unix.TCP_CONGESTION)
|
||||||
|
func GetsockoptTCPCCBBRInfo(fd, level, opt int) (*TCPBBRInfo, error) {
|
||||||
|
var value [SizeofTCPCCInfo / 4]uint32 // ensure proper alignment
|
||||||
|
vallen := _Socklen(SizeofTCPCCInfo)
|
||||||
|
err := getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
|
||||||
|
out := (*TCPBBRInfo)(unsafe.Pointer(&value[0]))
|
||||||
|
return out, err
|
||||||
|
}
|
||||||
|
|
||||||
// GetsockoptString returns the string value of the socket option opt for the
|
// GetsockoptString returns the string value of the socket option opt for the
|
||||||
// socket associated with fd at the given socket level.
|
// socket associated with fd at the given socket level.
|
||||||
func GetsockoptString(fd, level, opt int) (string, error) {
|
func GetsockoptString(fd, level, opt int) (string, error) {
|
||||||
@@ -1818,6 +1860,7 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
|
|||||||
//sys ClockAdjtime(clockid int32, buf *Timex) (state int, err error)
|
//sys ClockAdjtime(clockid int32, buf *Timex) (state int, err error)
|
||||||
//sys ClockGetres(clockid int32, res *Timespec) (err error)
|
//sys ClockGetres(clockid int32, res *Timespec) (err error)
|
||||||
//sys ClockGettime(clockid int32, time *Timespec) (err error)
|
//sys ClockGettime(clockid int32, time *Timespec) (err error)
|
||||||
|
//sys ClockSettime(clockid int32, time *Timespec) (err error)
|
||||||
//sys ClockNanosleep(clockid int32, flags int, request *Timespec, remain *Timespec) (err error)
|
//sys ClockNanosleep(clockid int32, flags int, request *Timespec, remain *Timespec) (err error)
|
||||||
//sys Close(fd int) (err error)
|
//sys Close(fd int) (err error)
|
||||||
//sys CloseRange(first uint, last uint, flags uint) (err error)
|
//sys CloseRange(first uint, last uint, flags uint) (err error)
|
||||||
@@ -1959,7 +2002,26 @@ func Getpgrp() (pid int) {
|
|||||||
//sysnb Getpid() (pid int)
|
//sysnb Getpid() (pid int)
|
||||||
//sysnb Getppid() (ppid int)
|
//sysnb Getppid() (ppid int)
|
||||||
//sys Getpriority(which int, who int) (prio int, err error)
|
//sys Getpriority(which int, who int) (prio int, err error)
|
||||||
//sys Getrandom(buf []byte, flags int) (n int, err error)
|
|
||||||
|
func Getrandom(buf []byte, flags int) (n int, err error) {
|
||||||
|
vdsoRet, supported := vgetrandom(buf, uint32(flags))
|
||||||
|
if supported {
|
||||||
|
if vdsoRet < 0 {
|
||||||
|
return 0, errnoErr(syscall.Errno(-vdsoRet))
|
||||||
|
}
|
||||||
|
return vdsoRet, nil
|
||||||
|
}
|
||||||
|
var p *byte
|
||||||
|
if len(buf) > 0 {
|
||||||
|
p = &buf[0]
|
||||||
|
}
|
||||||
|
r, _, e := Syscall(SYS_GETRANDOM, uintptr(unsafe.Pointer(p)), uintptr(len(buf)), uintptr(flags))
|
||||||
|
if e != 0 {
|
||||||
|
return 0, errnoErr(e)
|
||||||
|
}
|
||||||
|
return int(r), nil
|
||||||
|
}
|
||||||
|
|
||||||
//sysnb Getrusage(who int, rusage *Rusage) (err error)
|
//sysnb Getrusage(who int, rusage *Rusage) (err error)
|
||||||
//sysnb Getsid(pid int) (sid int, err error)
|
//sysnb Getsid(pid int) (sid int, err error)
|
||||||
//sysnb Gettid() (tid int)
|
//sysnb Gettid() (tid int)
|
||||||
@@ -2592,3 +2654,4 @@ func SchedGetAttr(pid int, flags uint) (*SchedAttr, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//sys Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) (err error)
|
//sys Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) (err error)
|
||||||
|
//sys Mseal(b []byte, flags uint) (err error)
|
||||||
|
|||||||
2
vendor/golang.org/x/sys/unix/syscall_linux_arm64.go
generated
vendored
2
vendor/golang.org/x/sys/unix/syscall_linux_arm64.go
generated
vendored
@@ -182,3 +182,5 @@ func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error
|
|||||||
}
|
}
|
||||||
return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags)
|
return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SYS_FSTATAT = SYS_NEWFSTATAT
|
||||||
|
|||||||
2
vendor/golang.org/x/sys/unix/syscall_linux_loong64.go
generated
vendored
2
vendor/golang.org/x/sys/unix/syscall_linux_loong64.go
generated
vendored
@@ -214,3 +214,5 @@ func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error
|
|||||||
}
|
}
|
||||||
return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags)
|
return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SYS_FSTATAT = SYS_NEWFSTATAT
|
||||||
|
|||||||
2
vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go
generated
vendored
2
vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go
generated
vendored
@@ -187,3 +187,5 @@ func RISCVHWProbe(pairs []RISCVHWProbePairs, set *CPUSet, flags uint) (err error
|
|||||||
}
|
}
|
||||||
return riscvHWProbe(pairs, setSize, set, flags)
|
return riscvHWProbe(pairs, setSize, set, flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SYS_FSTATAT = SYS_NEWFSTATAT
|
||||||
|
|||||||
1
vendor/golang.org/x/sys/unix/syscall_openbsd.go
generated
vendored
1
vendor/golang.org/x/sys/unix/syscall_openbsd.go
generated
vendored
@@ -293,6 +293,7 @@ func Uname(uname *Utsname) error {
|
|||||||
//sys Mkfifoat(dirfd int, path string, mode uint32) (err error)
|
//sys Mkfifoat(dirfd int, path string, mode uint32) (err error)
|
||||||
//sys Mknod(path string, mode uint32, dev int) (err error)
|
//sys Mknod(path string, mode uint32, dev int) (err error)
|
||||||
//sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error)
|
//sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error)
|
||||||
|
//sys Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error)
|
||||||
//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
|
//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
|
||||||
//sys Open(path string, mode int, perm uint32) (fd int, err error)
|
//sys Open(path string, mode int, perm uint32) (fd int, err error)
|
||||||
//sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error)
|
//sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error)
|
||||||
|
|||||||
87
vendor/golang.org/x/sys/unix/syscall_solaris.go
generated
vendored
87
vendor/golang.org/x/sys/unix/syscall_solaris.go
generated
vendored
@@ -1102,3 +1102,90 @@ func (s *Strioctl) SetInt(i int) {
|
|||||||
func IoctlSetStrioctlRetInt(fd int, req int, s *Strioctl) (int, error) {
|
func IoctlSetStrioctlRetInt(fd int, req int, s *Strioctl) (int, error) {
|
||||||
return ioctlPtrRet(fd, req, unsafe.Pointer(s))
|
return ioctlPtrRet(fd, req, unsafe.Pointer(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ucred Helpers
|
||||||
|
// See ucred(3c) and getpeerucred(3c)
|
||||||
|
|
||||||
|
//sys getpeerucred(fd uintptr, ucred *uintptr) (err error)
|
||||||
|
//sys ucredFree(ucred uintptr) = ucred_free
|
||||||
|
//sys ucredGet(pid int) (ucred uintptr, err error) = ucred_get
|
||||||
|
//sys ucredGeteuid(ucred uintptr) (uid int) = ucred_geteuid
|
||||||
|
//sys ucredGetegid(ucred uintptr) (gid int) = ucred_getegid
|
||||||
|
//sys ucredGetruid(ucred uintptr) (uid int) = ucred_getruid
|
||||||
|
//sys ucredGetrgid(ucred uintptr) (gid int) = ucred_getrgid
|
||||||
|
//sys ucredGetsuid(ucred uintptr) (uid int) = ucred_getsuid
|
||||||
|
//sys ucredGetsgid(ucred uintptr) (gid int) = ucred_getsgid
|
||||||
|
//sys ucredGetpid(ucred uintptr) (pid int) = ucred_getpid
|
||||||
|
|
||||||
|
// Ucred is an opaque struct that holds user credentials.
|
||||||
|
type Ucred struct {
|
||||||
|
ucred uintptr
|
||||||
|
}
|
||||||
|
|
||||||
|
// We need to ensure that ucredFree is called on the underlying ucred
|
||||||
|
// when the Ucred is garbage collected.
|
||||||
|
func ucredFinalizer(u *Ucred) {
|
||||||
|
ucredFree(u.ucred)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetPeerUcred(fd uintptr) (*Ucred, error) {
|
||||||
|
var ucred uintptr
|
||||||
|
err := getpeerucred(fd, &ucred)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result := &Ucred{
|
||||||
|
ucred: ucred,
|
||||||
|
}
|
||||||
|
// set the finalizer on the result so that the ucred will be freed
|
||||||
|
runtime.SetFinalizer(result, ucredFinalizer)
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func UcredGet(pid int) (*Ucred, error) {
|
||||||
|
ucred, err := ucredGet(pid)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result := &Ucred{
|
||||||
|
ucred: ucred,
|
||||||
|
}
|
||||||
|
// set the finalizer on the result so that the ucred will be freed
|
||||||
|
runtime.SetFinalizer(result, ucredFinalizer)
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *Ucred) Geteuid() int {
|
||||||
|
defer runtime.KeepAlive(u)
|
||||||
|
return ucredGeteuid(u.ucred)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *Ucred) Getruid() int {
|
||||||
|
defer runtime.KeepAlive(u)
|
||||||
|
return ucredGetruid(u.ucred)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *Ucred) Getsuid() int {
|
||||||
|
defer runtime.KeepAlive(u)
|
||||||
|
return ucredGetsuid(u.ucred)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *Ucred) Getegid() int {
|
||||||
|
defer runtime.KeepAlive(u)
|
||||||
|
return ucredGetegid(u.ucred)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *Ucred) Getrgid() int {
|
||||||
|
defer runtime.KeepAlive(u)
|
||||||
|
return ucredGetrgid(u.ucred)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *Ucred) Getsgid() int {
|
||||||
|
defer runtime.KeepAlive(u)
|
||||||
|
return ucredGetsgid(u.ucred)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *Ucred) Getpid() int {
|
||||||
|
defer runtime.KeepAlive(u)
|
||||||
|
return ucredGetpid(u.ucred)
|
||||||
|
}
|
||||||
|
|||||||
104
vendor/golang.org/x/sys/unix/syscall_zos_s390x.go
generated
vendored
104
vendor/golang.org/x/sys/unix/syscall_zos_s390x.go
generated
vendored
@@ -768,6 +768,15 @@ func Munmap(b []byte) (err error) {
|
|||||||
return mapper.Munmap(b)
|
return mapper.Munmap(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func MmapPtr(fd int, offset int64, addr unsafe.Pointer, length uintptr, prot int, flags int) (ret unsafe.Pointer, err error) {
|
||||||
|
xaddr, err := mapper.mmap(uintptr(addr), length, prot, flags, fd, offset)
|
||||||
|
return unsafe.Pointer(xaddr), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func MunmapPtr(addr unsafe.Pointer, length uintptr) (err error) {
|
||||||
|
return mapper.munmap(uintptr(addr), length)
|
||||||
|
}
|
||||||
|
|
||||||
//sys Gethostname(buf []byte) (err error) = SYS___GETHOSTNAME_A
|
//sys Gethostname(buf []byte) (err error) = SYS___GETHOSTNAME_A
|
||||||
//sysnb Getgid() (gid int)
|
//sysnb Getgid() (gid int)
|
||||||
//sysnb Getpid() (pid int)
|
//sysnb Getpid() (pid int)
|
||||||
@@ -816,10 +825,10 @@ func Lstat(path string, stat *Stat_t) (err error) {
|
|||||||
// for checking symlinks begins with $VERSION/ $SYSNAME/ $SYSSYMR/ $SYSSYMA/
|
// for checking symlinks begins with $VERSION/ $SYSNAME/ $SYSSYMR/ $SYSSYMA/
|
||||||
func isSpecialPath(path []byte) (v bool) {
|
func isSpecialPath(path []byte) (v bool) {
|
||||||
var special = [4][8]byte{
|
var special = [4][8]byte{
|
||||||
[8]byte{'V', 'E', 'R', 'S', 'I', 'O', 'N', '/'},
|
{'V', 'E', 'R', 'S', 'I', 'O', 'N', '/'},
|
||||||
[8]byte{'S', 'Y', 'S', 'N', 'A', 'M', 'E', '/'},
|
{'S', 'Y', 'S', 'N', 'A', 'M', 'E', '/'},
|
||||||
[8]byte{'S', 'Y', 'S', 'S', 'Y', 'M', 'R', '/'},
|
{'S', 'Y', 'S', 'S', 'Y', 'M', 'R', '/'},
|
||||||
[8]byte{'S', 'Y', 'S', 'S', 'Y', 'M', 'A', '/'}}
|
{'S', 'Y', 'S', 'S', 'Y', 'M', 'A', '/'}}
|
||||||
|
|
||||||
var i, j int
|
var i, j int
|
||||||
for i = 0; i < len(special); i++ {
|
for i = 0; i < len(special); i++ {
|
||||||
@@ -3115,3 +3124,90 @@ func legacy_Mkfifoat(dirfd int, path string, mode uint32) (err error) {
|
|||||||
//sys Posix_openpt(oflag int) (fd int, err error) = SYS_POSIX_OPENPT
|
//sys Posix_openpt(oflag int) (fd int, err error) = SYS_POSIX_OPENPT
|
||||||
//sys Grantpt(fildes int) (rc int, err error) = SYS_GRANTPT
|
//sys Grantpt(fildes int) (rc int, err error) = SYS_GRANTPT
|
||||||
//sys Unlockpt(fildes int) (rc int, err error) = SYS_UNLOCKPT
|
//sys Unlockpt(fildes int) (rc int, err error) = SYS_UNLOCKPT
|
||||||
|
|
||||||
|
func fcntlAsIs(fd uintptr, cmd int, arg uintptr) (val int, err error) {
|
||||||
|
runtime.EnterSyscall()
|
||||||
|
r0, e2, e1 := CallLeFuncWithErr(GetZosLibVec()+SYS_FCNTL<<4, uintptr(fd), uintptr(cmd), arg)
|
||||||
|
runtime.ExitSyscall()
|
||||||
|
val = int(r0)
|
||||||
|
if int64(r0) == -1 {
|
||||||
|
err = errnoErr2(e1, e2)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Fcntl(fd uintptr, cmd int, op interface{}) (ret int, err error) {
|
||||||
|
switch op.(type) {
|
||||||
|
case *Flock_t:
|
||||||
|
err = FcntlFlock(fd, cmd, op.(*Flock_t))
|
||||||
|
if err != nil {
|
||||||
|
ret = -1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
case int:
|
||||||
|
return FcntlInt(fd, cmd, op.(int))
|
||||||
|
case *F_cnvrt:
|
||||||
|
return fcntlAsIs(fd, cmd, uintptr(unsafe.Pointer(op.(*F_cnvrt))))
|
||||||
|
case unsafe.Pointer:
|
||||||
|
return fcntlAsIs(fd, cmd, uintptr(op.(unsafe.Pointer)))
|
||||||
|
default:
|
||||||
|
return -1, EINVAL
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||||
|
if raceenabled {
|
||||||
|
raceReleaseMerge(unsafe.Pointer(&ioSync))
|
||||||
|
}
|
||||||
|
return sendfile(outfd, infd, offset, count)
|
||||||
|
}
|
||||||
|
|
||||||
|
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||||
|
// TODO: use LE call instead if the call is implemented
|
||||||
|
originalOffset, err := Seek(infd, 0, SEEK_CUR)
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
|
//start reading data from in_fd
|
||||||
|
if offset != nil {
|
||||||
|
_, err := Seek(infd, *offset, SEEK_SET)
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buf := make([]byte, count)
|
||||||
|
readBuf := make([]byte, 0)
|
||||||
|
var n int = 0
|
||||||
|
for i := 0; i < count; i += n {
|
||||||
|
n, err := Read(infd, buf)
|
||||||
|
if n == 0 {
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
} else { // EOF
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
readBuf = append(readBuf, buf...)
|
||||||
|
buf = buf[0:0]
|
||||||
|
}
|
||||||
|
|
||||||
|
n2, err := Write(outfd, readBuf)
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
|
|
||||||
|
//When sendfile() returns, this variable will be set to the
|
||||||
|
// offset of the byte following the last byte that was read.
|
||||||
|
if offset != nil {
|
||||||
|
*offset = *offset + int64(n)
|
||||||
|
// If offset is not NULL, then sendfile() does not modify the file
|
||||||
|
// offset of in_fd
|
||||||
|
_, err := Seek(infd, originalOffset, SEEK_SET)
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return n2, nil
|
||||||
|
}
|
||||||
|
|||||||
13
vendor/golang.org/x/sys/unix/vgetrandom_linux.go
generated
vendored
Normal file
13
vendor/golang.org/x/sys/unix/vgetrandom_linux.go
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
// Copyright 2024 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build linux && go1.24
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import _ "unsafe"
|
||||||
|
|
||||||
|
//go:linkname vgetrandom runtime.vgetrandom
|
||||||
|
//go:noescape
|
||||||
|
func vgetrandom(p []byte, flags uint32) (ret int, supported bool)
|
||||||
11
vendor/golang.org/x/sys/unix/vgetrandom_unsupported.go
generated
vendored
Normal file
11
vendor/golang.org/x/sys/unix/vgetrandom_unsupported.go
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
// Copyright 2024 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build !linux || !go1.24
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
func vgetrandom(p []byte, flags uint32) (ret int, supported bool) {
|
||||||
|
return -1, false
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user