From 080a3e2396031cd40f3a1801ff7f50a76f20b167 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 31 Jan 2023 11:03:20 -0800 Subject: [PATCH] vendor: `make vendor-update` --- go.mod | 18 +- go.sum | 36 +- .../github.com/aws/aws-sdk-go/aws/version.go | 2 +- .../github.com/go-logfmt/logfmt/CHANGELOG.md | 48 +- vendor/github.com/go-logfmt/logfmt/README.md | 30 +- vendor/github.com/go-logfmt/logfmt/decode.go | 17 + vendor/github.com/urfave/cli/v2/README.md | 8 +- vendor/github.com/urfave/cli/v2/app.go | 33 +- vendor/github.com/urfave/cli/v2/category.go | 17 +- vendor/github.com/urfave/cli/v2/command.go | 4 +- .../github.com/urfave/cli/v2/flag-spec.yaml | 12 + vendor/github.com/urfave/cli/v2/flag.go | 31 +- .../urfave/cli/v2/flag_float64_slice.go | 14 +- .../urfave/cli/v2/flag_int64_slice.go | 14 +- .../urfave/cli/v2/flag_int_slice.go | 14 +- .../urfave/cli/v2/flag_string_slice.go | 14 +- .../urfave/cli/v2/flag_uint64_slice.go | 14 +- .../urfave/cli/v2/flag_uint_slice.go | 14 +- .../urfave/cli/v2/godoc-current.txt | 24 + .../urfave/cli/v2/zz_generated.flags.go | 12 + .../net/http/otelhttp/config.go | 9 + .../net/http/otelhttp/handler.go | 48 +- .../net/http/otelhttp/transport.go | 8 +- .../net/http/otelhttp/version.go | 2 +- vendor/go.opentelemetry.io/otel/.lycheeignore | 1 + vendor/go.opentelemetry.io/otel/CHANGELOG.md | 138 ++- vendor/go.opentelemetry.io/otel/Makefile | 10 +- vendor/go.opentelemetry.io/otel/RELEASING.md | 11 +- vendor/go.opentelemetry.io/otel/handler.go | 25 +- .../otel/internal/global/internal_logging.go | 30 +- .../otel/metric/instrument/asyncfloat64.go | 131 +++ .../instrument/asyncfloat64/asyncfloat64.go | 80 -- .../otel/metric/instrument/asyncint64.go | 131 +++ .../instrument/asyncint64/asyncint64.go | 80 -- .../otel/metric/instrument/config.go | 69 -- .../otel/metric/instrument/instrument.go | 60 ++ .../otel/metric/instrument/syncfloat64.go | 86 ++ .../instrument/syncfloat64/syncfloat64.go | 64 -- .../instrument/{syncint64 => }/syncint64.go | 68 +- .../metric/internal/global/instruments.go | 213 ++-- .../otel/metric/internal/global/meter.go | 335 +++--- .../go.opentelemetry.io/otel/metric/meter.go | 116 ++- .../go.opentelemetry.io/otel/metric/noop.go | 127 ++- .../otel/semconv/internal/http.go | 336 ------ .../otel/semconv/internal/v2/http.go | 405 ++++++++ .../otel/semconv/internal/v2/net.go | 324 ++++++ .../otel/semconv/v1.12.0/http.go | 114 -- .../otel/semconv/{v1.12.0 => v1.17.0}/doc.go | 4 +- .../semconv/{v1.12.0 => v1.17.0}/exception.go | 2 +- .../otel/semconv/v1.17.0/http.go | 21 + .../otel/semconv/v1.17.0/httpconv/http.go | 150 +++ .../semconv/{v1.12.0 => v1.17.0}/resource.go | 264 +++-- .../semconv/{v1.12.0 => v1.17.0}/schema.go | 4 +- .../semconv/{v1.12.0 => v1.17.0}/trace.go | 972 +++++++++++------- vendor/go.opentelemetry.io/otel/version.go | 2 +- vendor/go.opentelemetry.io/otel/versions.yaml | 4 +- .../google.golang.org/api/internal/version.go | 2 +- vendor/modules.txt | 27 +- 58 files changed, 3074 insertions(+), 1775 deletions(-) create mode 100644 vendor/go.opentelemetry.io/otel/metric/instrument/asyncfloat64.go delete mode 100644 vendor/go.opentelemetry.io/otel/metric/instrument/asyncfloat64/asyncfloat64.go create mode 100644 vendor/go.opentelemetry.io/otel/metric/instrument/asyncint64.go delete mode 100644 vendor/go.opentelemetry.io/otel/metric/instrument/asyncint64/asyncint64.go delete mode 100644 vendor/go.opentelemetry.io/otel/metric/instrument/config.go create mode 100644 vendor/go.opentelemetry.io/otel/metric/instrument/syncfloat64.go delete mode 100644 vendor/go.opentelemetry.io/otel/metric/instrument/syncfloat64/syncfloat64.go rename vendor/go.opentelemetry.io/otel/metric/instrument/{syncint64 => }/syncint64.go (50%) delete mode 100644 vendor/go.opentelemetry.io/otel/semconv/internal/http.go create mode 100644 vendor/go.opentelemetry.io/otel/semconv/internal/v2/http.go create mode 100644 vendor/go.opentelemetry.io/otel/semconv/internal/v2/net.go delete mode 100644 vendor/go.opentelemetry.io/otel/semconv/v1.12.0/http.go rename vendor/go.opentelemetry.io/otel/semconv/{v1.12.0 => v1.17.0}/doc.go (92%) rename vendor/go.opentelemetry.io/otel/semconv/{v1.12.0 => v1.17.0}/exception.go (99%) create mode 100644 vendor/go.opentelemetry.io/otel/semconv/v1.17.0/http.go create mode 100644 vendor/go.opentelemetry.io/otel/semconv/v1.17.0/httpconv/http.go rename vendor/go.opentelemetry.io/otel/semconv/{v1.12.0 => v1.17.0}/resource.go (84%) rename vendor/go.opentelemetry.io/otel/semconv/{v1.12.0 => v1.17.0}/schema.go (93%) rename vendor/go.opentelemetry.io/otel/semconv/{v1.12.0 => v1.17.0}/trace.go (71%) diff --git a/go.mod b/go.mod index 28d3fa5a0..b612a6239 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/influxdata/influxdb v1.11.0 github.com/klauspost/compress v1.15.15 github.com/prometheus/prometheus v0.41.0 - github.com/urfave/cli/v2 v2.24.1 + github.com/urfave/cli/v2 v2.24.2 github.com/valyala/fastjson v1.6.4 github.com/valyala/fastrand v1.1.0 github.com/valyala/fasttemplate v1.2.2 @@ -35,7 +35,7 @@ require ( golang.org/x/net v0.5.0 golang.org/x/oauth2 v0.4.0 golang.org/x/sys v0.4.0 - google.golang.org/api v0.108.0 + google.golang.org/api v0.109.0 gopkg.in/yaml.v2 v2.4.0 ) @@ -47,7 +47,7 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2 // indirect github.com/VividCortex/ewma v1.2.0 // indirect github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect - github.com/aws/aws-sdk-go v1.44.189 // indirect + github.com/aws/aws-sdk-go v1.44.190 // indirect github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 // indirect github.com/aws/aws-sdk-go-v2/credentials v1.13.10 // indirect github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.21 // indirect @@ -70,7 +70,7 @@ require ( github.com/fatih/color v1.14.1 // indirect github.com/felixge/httpsnoop v1.0.3 // indirect github.com/go-kit/log v0.2.1 // indirect - github.com/go-logfmt/logfmt v0.5.1 // indirect + github.com/go-logfmt/logfmt v0.6.0 // indirect github.com/go-logr/logr v1.2.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect @@ -100,13 +100,13 @@ require ( github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect go.opencensus.io v0.24.0 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.37.0 // indirect - go.opentelemetry.io/otel v1.11.2 // indirect - go.opentelemetry.io/otel/metric v0.34.0 // indirect - go.opentelemetry.io/otel/trace v1.11.2 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.38.0 // indirect + go.opentelemetry.io/otel v1.12.0 // indirect + go.opentelemetry.io/otel/metric v0.35.0 // indirect + go.opentelemetry.io/otel/trace v1.12.0 // indirect go.uber.org/atomic v1.10.0 // indirect go.uber.org/goleak v1.2.0 // indirect - golang.org/x/exp v0.0.0-20230127193734-31bee513bff7 // indirect + golang.org/x/exp v0.0.0-20230131160201-f062dba9d201 // indirect golang.org/x/sync v0.1.0 // indirect golang.org/x/text v0.6.0 // indirect golang.org/x/time v0.3.0 // indirect diff --git a/go.sum b/go.sum index e8bd4d261..a1d984912 100644 --- a/go.sum +++ b/go.sum @@ -87,8 +87,8 @@ github.com/andybalholm/brotli v1.0.2/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu github.com/andybalholm/brotli v1.0.3/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/armon/go-metrics v0.3.10 h1:FR+drcQStOe+32sYyJYyZ7FIdgoGGBnwLl+flodp8Uo= github.com/aws/aws-sdk-go v1.38.35/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= -github.com/aws/aws-sdk-go v1.44.189 h1:9PBrjndH1uL5AN8818qI3duhQ4hgkMuLvqkJlg9MRyk= -github.com/aws/aws-sdk-go v1.44.189/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.190 h1:QC+Pf/Ooj7Waf2obOPZbIQOqr00hy4h54j3ZK9mvHcc= +github.com/aws/aws-sdk-go v1.44.190/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.17.3 h1:shN7NlnVzvDUgPQ+1rLMSxY8OWRNDRYtiqe0p/PgrhY= github.com/aws/aws-sdk-go-v2 v1.17.3/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 h1:dK82zF6kkPeCo8J1e+tGx4JdvDIQzj7ygIoLg8WMuGs= @@ -182,8 +182,8 @@ github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBj github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= -github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= +github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= +github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -419,8 +419,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/urfave/cli/v2 v2.24.1 h1:/QYYr7g0EhwXEML8jO+8OYt5trPnLHS0p3mrgExJ5NU= -github.com/urfave/cli/v2 v2.24.1/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= +github.com/urfave/cli/v2 v2.24.2 h1:q1VA+ofZ8SWfEKB9xXHUD4QZaeI9e+ItEqSbfH2JBXk= +github.com/urfave/cli/v2 v2.24.2/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasthttp v1.30.0/go.mod h1:2rsYD01CKFrjjsvFxx75KlEUNpWNBY9JWD3K/7o2Cus= @@ -452,14 +452,14 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.37.0 h1:yt2NKzK7Vyo6h0+X8BA4FpreZQTlVEIarnsBP/H5mzs= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.37.0/go.mod h1:+ARmXlUlc51J7sZeCBkBJNdHGySrdOzgzxp6VWRWM1U= -go.opentelemetry.io/otel v1.11.2 h1:YBZcQlsVekzFsFbjygXMOXSs6pialIZxcjfO/mBDmR0= -go.opentelemetry.io/otel v1.11.2/go.mod h1:7p4EUV+AqgdlNV9gL97IgUZiVR3yrFXYo53f9BM3tRI= -go.opentelemetry.io/otel/metric v0.34.0 h1:MCPoQxcg/26EuuJwpYN1mZTeCYAUGx8ABxfW07YkjP8= -go.opentelemetry.io/otel/metric v0.34.0/go.mod h1:ZFuI4yQGNCupurTXCwkeD/zHBt+C2bR7bw5JqUm/AP8= -go.opentelemetry.io/otel/trace v1.11.2 h1:Xf7hWSF2Glv0DE3MH7fBHvtpSBsjcBUe5MYAmZM/+y0= -go.opentelemetry.io/otel/trace v1.11.2/go.mod h1:4N+yC7QEz7TTsG9BSRLNAa63eg5E06ObSbKPmxQ/pKA= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.38.0 h1:rTxmym+VN9f6ajzNtITVgyvZrNbpLt3NHr3suLLHLEQ= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.38.0/go.mod h1:w6xNm+kC506KNs5cknSHal6dtdRnc4uema0uN9GSQc0= +go.opentelemetry.io/otel v1.12.0 h1:IgfC7kqQrRccIKuB7Cl+SRUmsKbEwSGPr0Eu+/ht1SQ= +go.opentelemetry.io/otel v1.12.0/go.mod h1:geaoz0L0r1BEOR81k7/n9W4TCXYCJ7bPO7K374jQHG0= +go.opentelemetry.io/otel/metric v0.35.0 h1:aPT5jk/w7F9zW51L7WgRqNKDElBdyRLGuBtI5MX34e8= +go.opentelemetry.io/otel/metric v0.35.0/go.mod h1:qAcbhaTRFU6uG8QM7dDo7XvFsWcugziq/5YI065TokQ= +go.opentelemetry.io/otel/trace v1.12.0 h1:p28in++7Kd0r2d8gSt931O57fdjUyWxkVbESuILAeUc= +go.opentelemetry.io/otel/trace v1.12.0/go.mod h1:pHlgBynn6s25qJ2szD+Bv+iwKJttjHSI3lUAyf0GNuQ= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= @@ -483,8 +483,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20230127193734-31bee513bff7 h1:pXR8mGh4q8ooBT7HXruL4Xa2IxoL8XZ6lOgXY/0Ryg8= -golang.org/x/exp v0.0.0-20230127193734-31bee513bff7/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/exp v0.0.0-20230131160201-f062dba9d201 h1:BEABXpNXLEz0WxtA+6CQIz2xkg80e+1zrhWyMcq8VzE= +golang.org/x/exp v0.0.0-20230131160201-f062dba9d201/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -698,8 +698,8 @@ google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0M google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/api v0.108.0 h1:WVBc/faN0DkKtR43Q/7+tPny9ZoLZdIiAyG5Q9vFClg= -google.golang.org/api v0.108.0/go.mod h1:2Ts0XTHNVWxypznxWOYUeI4g3WdP9Pk2Qk58+a/O9MY= +google.golang.org/api v0.109.0 h1:sW9hgHyX497PP5//NUM7nqfV8D0iDfBApqq7sOh1XR8= +google.golang.org/api v0.109.0/go.mod h1:2Ts0XTHNVWxypznxWOYUeI4g3WdP9Pk2Qk58+a/O9MY= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= diff --git a/vendor/github.com/aws/aws-sdk-go/aws/version.go b/vendor/github.com/aws/aws-sdk-go/aws/version.go index 9e8856ba5..261a071a6 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/version.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/version.go @@ -5,4 +5,4 @@ package aws const SDKName = "aws-sdk-go" // SDKVersion is the version of this SDK -const SDKVersion = "1.44.189" +const SDKVersion = "1.44.190" diff --git a/vendor/github.com/go-logfmt/logfmt/CHANGELOG.md b/vendor/github.com/go-logfmt/logfmt/CHANGELOG.md index 1a9a27bcf..8f349c4b8 100644 --- a/vendor/github.com/go-logfmt/logfmt/CHANGELOG.md +++ b/vendor/github.com/go-logfmt/logfmt/CHANGELOG.md @@ -1,48 +1,82 @@ # Changelog + All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.5.0] - 2020-01-03 +## [0.6.0] - 2023-01-30 + +[0.6.0]: https://github.com/go-logfmt/logfmt/compare/v0.5.1...v0.6.0 + +### Added + +- NewDecoderSize by [@alexanderjophus] + +## [0.5.1] - 2021-08-18 + +[0.5.1]: https://github.com/go-logfmt/logfmt/compare/v0.5.0...v0.5.1 ### Changed + +- Update the `go.mod` file for Go 1.17 as described in the [Go 1.17 release + notes](https://golang.org/doc/go1.17#go-command) + +## [0.5.0] - 2020-01-03 + +[0.5.0]: https://github.com/go-logfmt/logfmt/compare/v0.4.0...v0.5.0 + +### Changed + - Remove the dependency on github.com/kr/logfmt by [@ChrisHines] - Move fuzz code to github.com/go-logfmt/fuzzlogfmt by [@ChrisHines] ## [0.4.0] - 2018-11-21 +[0.4.0]: https://github.com/go-logfmt/logfmt/compare/v0.3.0...v0.4.0 + ### Added + - Go module support by [@ChrisHines] - CHANGELOG by [@ChrisHines] ### Changed + - Drop invalid runes from keys instead of returning ErrInvalidKey by [@ChrisHines] - On panic while printing, attempt to print panic value by [@bboreham] ## [0.3.0] - 2016-11-15 + +[0.3.0]: https://github.com/go-logfmt/logfmt/compare/v0.2.0...v0.3.0 + ### Added + - Pool buffers for quoted strings and byte slices by [@nussjustin] + ### Fixed + - Fuzz fix, quote invalid UTF-8 values by [@judwhite] ## [0.2.0] - 2016-05-08 + +[0.2.0]: https://github.com/go-logfmt/logfmt/compare/v0.1.0...v0.2.0 + ### Added + - Encoder.EncodeKeyvals by [@ChrisHines] ## [0.1.0] - 2016-03-28 + +[0.1.0]: https://github.com/go-logfmt/logfmt/commits/v0.1.0 + ### Added + - Encoder by [@ChrisHines] - Decoder by [@ChrisHines] - MarshalKeyvals by [@ChrisHines] -[0.5.0]: https://github.com/go-logfmt/logfmt/compare/v0.4.0...v0.5.0 -[0.4.0]: https://github.com/go-logfmt/logfmt/compare/v0.3.0...v0.4.0 -[0.3.0]: https://github.com/go-logfmt/logfmt/compare/v0.2.0...v0.3.0 -[0.2.0]: https://github.com/go-logfmt/logfmt/compare/v0.1.0...v0.2.0 -[0.1.0]: https://github.com/go-logfmt/logfmt/commits/v0.1.0 - [@ChrisHines]: https://github.com/ChrisHines [@bboreham]: https://github.com/bboreham [@judwhite]: https://github.com/judwhite [@nussjustin]: https://github.com/nussjustin +[@alexanderjophus]: https://github.com/alexanderjophus diff --git a/vendor/github.com/go-logfmt/logfmt/README.md b/vendor/github.com/go-logfmt/logfmt/README.md index 8e48fcd3a..71c57944e 100644 --- a/vendor/github.com/go-logfmt/logfmt/README.md +++ b/vendor/github.com/go-logfmt/logfmt/README.md @@ -1,20 +1,25 @@ +# logfmt + [![Go Reference](https://pkg.go.dev/badge/github.com/go-logfmt/logfmt.svg)](https://pkg.go.dev/github.com/go-logfmt/logfmt) [![Go Report Card](https://goreportcard.com/badge/go-logfmt/logfmt)](https://goreportcard.com/report/go-logfmt/logfmt) [![Github Actions](https://github.com/go-logfmt/logfmt/actions/workflows/test.yml/badge.svg)](https://github.com/go-logfmt/logfmt/actions/workflows/test.yml) -[![Coverage Status](https://coveralls.io/repos/github/go-logfmt/logfmt/badge.svg?branch=master)](https://coveralls.io/github/go-logfmt/logfmt?branch=master) - -# logfmt +[![Coverage Status](https://coveralls.io/repos/github/go-logfmt/logfmt/badge.svg?branch=master)](https://coveralls.io/github/go-logfmt/logfmt?branch=main) Package logfmt implements utilities to marshal and unmarshal data in the [logfmt -format](https://brandur.org/logfmt). It provides an API similar to -[encoding/json](http://golang.org/pkg/encoding/json/) and -[encoding/xml](http://golang.org/pkg/encoding/xml/). +format][fmt]. It provides an API similar to [encoding/json][json] and +[encoding/xml][xml]. + +[fmt]: https://brandur.org/logfmt +[json]: https://pkg.go.dev/encoding/json +[xml]: https://pkg.go.dev/encoding/xml The logfmt format was first documented by Brandur Leach in [this -article](https://brandur.org/logfmt). The format has not been formally -standardized. The most authoritative public specification to date has been the -documentation of a Go Language [package](http://godoc.org/github.com/kr/logfmt) -written by Blake Mizerany and Keith Rarick. +article][origin]. The format has not been formally standardized. The most +authoritative public specification to date has been the documentation of a Go +Language [package][parser] written by Blake Mizerany and Keith Rarick. + +[origin]: https://brandur.org/logfmt +[parser]: https://pkg.go.dev/github.com/kr/logfmt ## Goals @@ -30,4 +35,7 @@ standard as a goal. ## Versioning -Package logfmt publishes releases via [semver](http://semver.org/) compatible Git tags prefixed with a single 'v'. +This project publishes releases according to the Go language guidelines for +[developing and publishing modules][pub]. + +[pub]: https://go.dev/doc/modules/developing diff --git a/vendor/github.com/go-logfmt/logfmt/decode.go b/vendor/github.com/go-logfmt/logfmt/decode.go index 2013708e4..a1c22dcbd 100644 --- a/vendor/github.com/go-logfmt/logfmt/decode.go +++ b/vendor/github.com/go-logfmt/logfmt/decode.go @@ -29,6 +29,23 @@ func NewDecoder(r io.Reader) *Decoder { return dec } +// NewDecoderSize returns a new decoder that reads from r. +// +// The decoder introduces its own buffering and may read data from r beyond +// the logfmt records requested. +// The size argument specifies the size of the initial buffer that the +// Decoder will use to read records from r. +// If a log line is longer than the size argument, the Decoder will return +// a bufio.ErrTooLong error. +func NewDecoderSize(r io.Reader, size int) *Decoder { + scanner := bufio.NewScanner(r) + scanner.Buffer(make([]byte, 0, size), size) + dec := &Decoder{ + s: scanner, + } + return dec +} + // ScanRecord advances the Decoder to the next record, which can then be // parsed with the ScanKeyval method. It returns false when decoding stops, // either by reaching the end of the input or an error. After ScanRecord diff --git a/vendor/github.com/urfave/cli/v2/README.md b/vendor/github.com/urfave/cli/v2/README.md index eaed35630..9080aee41 100644 --- a/vendor/github.com/urfave/cli/v2/README.md +++ b/vendor/github.com/urfave/cli/v2/README.md @@ -1,9 +1,9 @@ # cli -[![GoDoc](https://godoc.org/github.com/urfave/cli?status.svg)](https://pkg.go.dev/github.com/urfave/cli/v2) -[![codebeat](https://codebeat.co/badges/0a8f30aa-f975-404b-b878-5fab3ae1cc5f)](https://codebeat.co/projects/github-com-urfave-cli) -[![Go Report Card](https://goreportcard.com/badge/urfave/cli)](https://goreportcard.com/report/urfave/cli) -[![codecov](https://codecov.io/gh/urfave/cli/branch/main/graph/badge.svg)](https://codecov.io/gh/urfave/cli) +[![Run Tests](https://github.com/urfave/cli/actions/workflows/cli.yml/badge.svg?branch=v2-maint)](https://github.com/urfave/cli/actions/workflows/cli.yml) +[![Go Reference](https://pkg.go.dev/badge/github.com/urfave/cli/v2.svg)](https://pkg.go.dev/github.com/urfave/cli/v2) +[![Go Report Card](https://goreportcard.com/badge/github.com/urfave/cli/v2)](https://goreportcard.com/report/github.com/urfave/cli/v2) +[![codecov](https://codecov.io/gh/urfave/cli/branch/v2-maint/graph/badge.svg?token=t9YGWLh05g)](https://app.codecov.io/gh/urfave/cli/tree/v2-maint) cli is a simple, fast, and fun package for building command line apps in Go. The goal is to enable developers to write fast and distributable command line diff --git a/vendor/github.com/urfave/cli/v2/app.go b/vendor/github.com/urfave/cli/v2/app.go index 10198f433..4b6675a2d 100644 --- a/vendor/github.com/urfave/cli/v2/app.go +++ b/vendor/github.com/urfave/cli/v2/app.go @@ -121,7 +121,8 @@ type App struct { // Treat all flags as normal arguments if true SkipFlagParsing bool - didSetup bool + didSetup bool + separator separatorSpec rootCommand *Command } @@ -216,6 +217,16 @@ func (a *App) Setup() { }) } + if len(a.SliceFlagSeparator) != 0 { + a.separator.customized = true + a.separator.sep = a.SliceFlagSeparator + } + + if a.DisableSliceFlagSeparator { + a.separator.customized = true + a.separator.disabled = true + } + var newCommands []*Command for _, c := range a.Commands { @@ -223,8 +234,8 @@ func (a *App) Setup() { if c.HelpName != "" { cname = c.HelpName } + c.separator = a.separator c.HelpName = fmt.Sprintf("%s %s", a.HelpName, cname) - c.flagCategories = newFlagCategoriesFromFlags(c.Flags) newCommands = append(newCommands, c) } @@ -250,24 +261,11 @@ func (a *App) Setup() { } sort.Sort(a.categories.(*commandCategories)) - a.flagCategories = newFlagCategories() - for _, fl := range a.Flags { - if cf, ok := fl.(CategorizableFlag); ok { - if cf.GetCategory() != "" { - a.flagCategories.AddFlag(cf.GetCategory(), cf) - } - } - } + a.flagCategories = newFlagCategoriesFromFlags(a.Flags) if a.Metadata == nil { a.Metadata = make(map[string]interface{}) } - - if len(a.SliceFlagSeparator) != 0 { - defaultSliceFlagSeparator = a.SliceFlagSeparator - } - - disableSliceFlagSeparator = a.DisableSliceFlagSeparator } func (a *App) newRootCommand() *Command { @@ -293,11 +291,12 @@ func (a *App) newRootCommand() *Command { categories: a.categories, SkipFlagParsing: a.SkipFlagParsing, isRoot: true, + separator: a.separator, } } func (a *App) newFlagSet() (*flag.FlagSet, error) { - return flagSet(a.Name, a.Flags) + return flagSet(a.Name, a.Flags, a.separator) } func (a *App) useShortOptionHandling() bool { diff --git a/vendor/github.com/urfave/cli/v2/category.go b/vendor/github.com/urfave/cli/v2/category.go index 7aca0c768..ccc043c25 100644 --- a/vendor/github.com/urfave/cli/v2/category.go +++ b/vendor/github.com/urfave/cli/v2/category.go @@ -100,10 +100,23 @@ func newFlagCategories() FlagCategories { func newFlagCategoriesFromFlags(fs []Flag) FlagCategories { fc := newFlagCategories() + + var categorized bool for _, fl := range fs { if cf, ok := fl.(CategorizableFlag); ok { - if cf.GetCategory() != "" { - fc.AddFlag(cf.GetCategory(), cf) + if cat := cf.GetCategory(); cat != "" { + fc.AddFlag(cat, cf) + categorized = true + } + } + } + + if categorized == true { + for _, fl := range fs { + if cf, ok := fl.(CategorizableFlag); ok { + if cf.GetCategory() == "" { + fc.AddFlag("", fl) + } } } } diff --git a/vendor/github.com/urfave/cli/v2/command.go b/vendor/github.com/urfave/cli/v2/command.go index da9cf5302..f978b4a43 100644 --- a/vendor/github.com/urfave/cli/v2/command.go +++ b/vendor/github.com/urfave/cli/v2/command.go @@ -69,6 +69,8 @@ type Command struct { // if this is a root "special" command isRoot bool + + separator separatorSpec } type Commands []*Command @@ -275,7 +277,7 @@ func (c *Command) Run(cCtx *Context, arguments ...string) (err error) { } func (c *Command) newFlagSet() (*flag.FlagSet, error) { - return flagSet(c.Name, c.Flags) + return flagSet(c.Name, c.Flags, c.separator) } func (c *Command) useShortOptionHandling() bool { diff --git a/vendor/github.com/urfave/cli/v2/flag-spec.yaml b/vendor/github.com/urfave/cli/v2/flag-spec.yaml index cfe47df06..ed4db985d 100644 --- a/vendor/github.com/urfave/cli/v2/flag-spec.yaml +++ b/vendor/github.com/urfave/cli/v2/flag-spec.yaml @@ -20,6 +20,8 @@ flag_types: skip_interfaces: - fmt.Stringer struct_fields: + - name: separator + type: separatorSpec - name: Action type: "func(*Context, []float64) error" int: @@ -33,6 +35,8 @@ flag_types: skip_interfaces: - fmt.Stringer struct_fields: + - name: separator + type: separatorSpec - name: Action type: "func(*Context, []int) error" int64: @@ -46,6 +50,8 @@ flag_types: skip_interfaces: - fmt.Stringer struct_fields: + - name: separator + type: separatorSpec - name: Action type: "func(*Context, []int64) error" uint: @@ -59,6 +65,8 @@ flag_types: skip_interfaces: - fmt.Stringer struct_fields: + - name: separator + type: separatorSpec - name: Action type: "func(*Context, []uint) error" uint64: @@ -72,6 +80,8 @@ flag_types: skip_interfaces: - fmt.Stringer struct_fields: + - name: separator + type: separatorSpec - name: Action type: "func(*Context, []uint64) error" string: @@ -85,6 +95,8 @@ flag_types: skip_interfaces: - fmt.Stringer struct_fields: + - name: separator + type: separatorSpec - name: TakesFile type: bool - name: Action diff --git a/vendor/github.com/urfave/cli/v2/flag.go b/vendor/github.com/urfave/cli/v2/flag.go index 5260f7f9e..fc3744ec8 100644 --- a/vendor/github.com/urfave/cli/v2/flag.go +++ b/vendor/github.com/urfave/cli/v2/flag.go @@ -15,7 +15,7 @@ import ( const defaultPlaceholder = "value" -var ( +const ( defaultSliceFlagSeparator = "," disableSliceFlagSeparator = false ) @@ -167,10 +167,13 @@ type Countable interface { Count() int } -func flagSet(name string, flags []Flag) (*flag.FlagSet, error) { +func flagSet(name string, flags []Flag, spec separatorSpec) (*flag.FlagSet, error) { set := flag.NewFlagSet(name, flag.ContinueOnError) for _, f := range flags { + if c, ok := f.(customizedSeparator); ok { + c.WithSeparatorSpec(spec) + } if err := f.Apply(set); err != nil { return nil, err } @@ -389,10 +392,28 @@ func flagFromEnvOrFile(envVars []string, filePath string) (value string, fromWhe return "", "", false } -func flagSplitMultiValues(val string) []string { - if disableSliceFlagSeparator { +type customizedSeparator interface { + WithSeparatorSpec(separatorSpec) +} + +type separatorSpec struct { + sep string + disabled bool + customized bool +} + +func (s separatorSpec) flagSplitMultiValues(val string) []string { + var ( + disabled bool = s.disabled + sep string = s.sep + ) + if !s.customized { + disabled = disableSliceFlagSeparator + sep = defaultSliceFlagSeparator + } + if disabled { return []string{val} } - return strings.Split(val, defaultSliceFlagSeparator) + return strings.Split(val, sep) } diff --git a/vendor/github.com/urfave/cli/v2/flag_float64_slice.go b/vendor/github.com/urfave/cli/v2/flag_float64_slice.go index 413aa50e9..0bc4612c8 100644 --- a/vendor/github.com/urfave/cli/v2/flag_float64_slice.go +++ b/vendor/github.com/urfave/cli/v2/flag_float64_slice.go @@ -11,6 +11,7 @@ import ( // Float64Slice wraps []float64 to satisfy flag.Value type Float64Slice struct { slice []float64 + separator separatorSpec hasBeenSet bool } @@ -29,6 +30,10 @@ func (f *Float64Slice) clone() *Float64Slice { return n } +func (f *Float64Slice) WithSeparatorSpec(spec separatorSpec) { + f.separator = spec +} + // Set parses the value into a float64 and appends it to the list of values func (f *Float64Slice) Set(value string) error { if !f.hasBeenSet { @@ -43,7 +48,7 @@ func (f *Float64Slice) Set(value string) error { return nil } - for _, s := range flagSplitMultiValues(value) { + for _, s := range f.separator.flagSplitMultiValues(value) { tmp, err := strconv.ParseFloat(strings.TrimSpace(s), 64) if err != nil { return err @@ -148,11 +153,12 @@ func (f *Float64SliceFlag) Apply(set *flag.FlagSet) error { setValue = f.Value.clone() default: setValue = new(Float64Slice) + setValue.WithSeparatorSpec(f.separator) } if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found { if val != "" { - for _, s := range flagSplitMultiValues(val) { + for _, s := range f.separator.flagSplitMultiValues(val) { if err := setValue.Set(strings.TrimSpace(s)); err != nil { return fmt.Errorf("could not parse %q as float64 slice value from %s for flag %s: %s", val, source, f.Name, err) } @@ -172,6 +178,10 @@ func (f *Float64SliceFlag) Apply(set *flag.FlagSet) error { return nil } +func (f *Float64SliceFlag) WithSeparatorSpec(spec separatorSpec) { + f.separator = spec +} + // Get returns the flag’s value in the given Context. func (f *Float64SliceFlag) Get(ctx *Context) []float64 { return ctx.Float64Slice(f.Name) diff --git a/vendor/github.com/urfave/cli/v2/flag_int64_slice.go b/vendor/github.com/urfave/cli/v2/flag_int64_slice.go index c45c43d3a..d45c2dd44 100644 --- a/vendor/github.com/urfave/cli/v2/flag_int64_slice.go +++ b/vendor/github.com/urfave/cli/v2/flag_int64_slice.go @@ -11,6 +11,7 @@ import ( // Int64Slice wraps []int64 to satisfy flag.Value type Int64Slice struct { slice []int64 + separator separatorSpec hasBeenSet bool } @@ -29,6 +30,10 @@ func (i *Int64Slice) clone() *Int64Slice { return n } +func (i *Int64Slice) WithSeparatorSpec(spec separatorSpec) { + i.separator = spec +} + // Set parses the value into an integer and appends it to the list of values func (i *Int64Slice) Set(value string) error { if !i.hasBeenSet { @@ -43,7 +48,7 @@ func (i *Int64Slice) Set(value string) error { return nil } - for _, s := range flagSplitMultiValues(value) { + for _, s := range i.separator.flagSplitMultiValues(value) { tmp, err := strconv.ParseInt(strings.TrimSpace(s), 0, 64) if err != nil { return err @@ -149,10 +154,11 @@ func (f *Int64SliceFlag) Apply(set *flag.FlagSet) error { setValue = f.Value.clone() default: setValue = new(Int64Slice) + setValue.WithSeparatorSpec(f.separator) } if val, source, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok && val != "" { - for _, s := range flagSplitMultiValues(val) { + for _, s := range f.separator.flagSplitMultiValues(val) { if err := setValue.Set(strings.TrimSpace(s)); err != nil { return fmt.Errorf("could not parse %q as int64 slice value from %s for flag %s: %s", val, source, f.Name, err) } @@ -171,6 +177,10 @@ func (f *Int64SliceFlag) Apply(set *flag.FlagSet) error { return nil } +func (f *Int64SliceFlag) WithSeparatorSpec(spec separatorSpec) { + f.separator = spec +} + // Get returns the flag’s value in the given Context. func (f *Int64SliceFlag) Get(ctx *Context) []int64 { return ctx.Int64Slice(f.Name) diff --git a/vendor/github.com/urfave/cli/v2/flag_int_slice.go b/vendor/github.com/urfave/cli/v2/flag_int_slice.go index d4006e594..da9c09bc7 100644 --- a/vendor/github.com/urfave/cli/v2/flag_int_slice.go +++ b/vendor/github.com/urfave/cli/v2/flag_int_slice.go @@ -11,6 +11,7 @@ import ( // IntSlice wraps []int to satisfy flag.Value type IntSlice struct { slice []int + separator separatorSpec hasBeenSet bool } @@ -40,6 +41,10 @@ func (i *IntSlice) SetInt(value int) { i.slice = append(i.slice, value) } +func (i *IntSlice) WithSeparatorSpec(spec separatorSpec) { + i.separator = spec +} + // Set parses the value into an integer and appends it to the list of values func (i *IntSlice) Set(value string) error { if !i.hasBeenSet { @@ -54,7 +59,7 @@ func (i *IntSlice) Set(value string) error { return nil } - for _, s := range flagSplitMultiValues(value) { + for _, s := range i.separator.flagSplitMultiValues(value) { tmp, err := strconv.ParseInt(strings.TrimSpace(s), 0, 64) if err != nil { return err @@ -160,10 +165,11 @@ func (f *IntSliceFlag) Apply(set *flag.FlagSet) error { setValue = f.Value.clone() default: setValue = new(IntSlice) + setValue.WithSeparatorSpec(f.separator) } if val, source, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok && val != "" { - for _, s := range flagSplitMultiValues(val) { + for _, s := range f.separator.flagSplitMultiValues(val) { if err := setValue.Set(strings.TrimSpace(s)); err != nil { return fmt.Errorf("could not parse %q as int slice value from %s for flag %s: %s", val, source, f.Name, err) } @@ -182,6 +188,10 @@ func (f *IntSliceFlag) Apply(set *flag.FlagSet) error { return nil } +func (f *IntSliceFlag) WithSeparatorSpec(spec separatorSpec) { + f.separator = spec +} + // Get returns the flag’s value in the given Context. func (f *IntSliceFlag) Get(ctx *Context) []int { return ctx.IntSlice(f.Name) diff --git a/vendor/github.com/urfave/cli/v2/flag_string_slice.go b/vendor/github.com/urfave/cli/v2/flag_string_slice.go index 82eeac06d..82410dbc8 100644 --- a/vendor/github.com/urfave/cli/v2/flag_string_slice.go +++ b/vendor/github.com/urfave/cli/v2/flag_string_slice.go @@ -11,6 +11,7 @@ import ( // StringSlice wraps a []string to satisfy flag.Value type StringSlice struct { slice []string + separator separatorSpec hasBeenSet bool } @@ -43,13 +44,17 @@ func (s *StringSlice) Set(value string) error { return nil } - for _, t := range flagSplitMultiValues(value) { + for _, t := range s.separator.flagSplitMultiValues(value) { s.slice = append(s.slice, t) } return nil } +func (s *StringSlice) WithSeparatorSpec(spec separatorSpec) { + s.separator = spec +} + // String returns a readable representation of this value (for usage defaults) func (s *StringSlice) String() string { return fmt.Sprintf("%s", s.slice) @@ -141,10 +146,11 @@ func (f *StringSliceFlag) Apply(set *flag.FlagSet) error { setValue = f.Value.clone() default: setValue = new(StringSlice) + setValue.WithSeparatorSpec(f.separator) } if val, source, found := flagFromEnvOrFile(f.EnvVars, f.FilePath); found { - for _, s := range flagSplitMultiValues(val) { + for _, s := range f.separator.flagSplitMultiValues(val) { if err := setValue.Set(strings.TrimSpace(s)); err != nil { return fmt.Errorf("could not parse %q as string value from %s for flag %s: %s", val, source, f.Name, err) } @@ -163,6 +169,10 @@ func (f *StringSliceFlag) Apply(set *flag.FlagSet) error { return nil } +func (f *StringSliceFlag) WithSeparatorSpec(spec separatorSpec) { + f.separator = spec +} + // Get returns the flag’s value in the given Context. func (f *StringSliceFlag) Get(ctx *Context) []string { return ctx.StringSlice(f.Name) diff --git a/vendor/github.com/urfave/cli/v2/flag_uint64_slice.go b/vendor/github.com/urfave/cli/v2/flag_uint64_slice.go index 61bb30b55..e845dd525 100644 --- a/vendor/github.com/urfave/cli/v2/flag_uint64_slice.go +++ b/vendor/github.com/urfave/cli/v2/flag_uint64_slice.go @@ -11,6 +11,7 @@ import ( // Uint64Slice wraps []int64 to satisfy flag.Value type Uint64Slice struct { slice []uint64 + separator separatorSpec hasBeenSet bool } @@ -43,7 +44,7 @@ func (i *Uint64Slice) Set(value string) error { return nil } - for _, s := range flagSplitMultiValues(value) { + for _, s := range i.separator.flagSplitMultiValues(value) { tmp, err := strconv.ParseUint(strings.TrimSpace(s), 0, 64) if err != nil { return err @@ -55,6 +56,10 @@ func (i *Uint64Slice) Set(value string) error { return nil } +func (i *Uint64Slice) WithSeparatorSpec(spec separatorSpec) { + i.separator = spec +} + // String returns a readable representation of this value (for usage defaults) func (i *Uint64Slice) String() string { v := i.slice @@ -153,10 +158,11 @@ func (f *Uint64SliceFlag) Apply(set *flag.FlagSet) error { setValue = f.Value.clone() default: setValue = new(Uint64Slice) + setValue.WithSeparatorSpec(f.separator) } if val, source, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok && val != "" { - for _, s := range flagSplitMultiValues(val) { + for _, s := range f.separator.flagSplitMultiValues(val) { if err := setValue.Set(strings.TrimSpace(s)); err != nil { return fmt.Errorf("could not parse %q as uint64 slice value from %s for flag %s: %s", val, source, f.Name, err) } @@ -175,6 +181,10 @@ func (f *Uint64SliceFlag) Apply(set *flag.FlagSet) error { return nil } +func (f *Uint64SliceFlag) WithSeparatorSpec(spec separatorSpec) { + f.separator = spec +} + // Get returns the flag’s value in the given Context. func (f *Uint64SliceFlag) Get(ctx *Context) []uint64 { return ctx.Uint64Slice(f.Name) diff --git a/vendor/github.com/urfave/cli/v2/flag_uint_slice.go b/vendor/github.com/urfave/cli/v2/flag_uint_slice.go index 363aa657f..d2aed480d 100644 --- a/vendor/github.com/urfave/cli/v2/flag_uint_slice.go +++ b/vendor/github.com/urfave/cli/v2/flag_uint_slice.go @@ -11,6 +11,7 @@ import ( // UintSlice wraps []int to satisfy flag.Value type UintSlice struct { slice []uint + separator separatorSpec hasBeenSet bool } @@ -54,7 +55,7 @@ func (i *UintSlice) Set(value string) error { return nil } - for _, s := range flagSplitMultiValues(value) { + for _, s := range i.separator.flagSplitMultiValues(value) { tmp, err := strconv.ParseUint(strings.TrimSpace(s), 0, 32) if err != nil { return err @@ -66,6 +67,10 @@ func (i *UintSlice) Set(value string) error { return nil } +func (i *UintSlice) WithSeparatorSpec(spec separatorSpec) { + i.separator = spec +} + // String returns a readable representation of this value (for usage defaults) func (i *UintSlice) String() string { v := i.slice @@ -164,10 +169,11 @@ func (f *UintSliceFlag) Apply(set *flag.FlagSet) error { setValue = f.Value.clone() default: setValue = new(UintSlice) + setValue.WithSeparatorSpec(f.separator) } if val, source, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok && val != "" { - for _, s := range flagSplitMultiValues(val) { + for _, s := range f.separator.flagSplitMultiValues(val) { if err := setValue.Set(strings.TrimSpace(s)); err != nil { return fmt.Errorf("could not parse %q as uint slice value from %s for flag %s: %s", val, source, f.Name, err) } @@ -186,6 +192,10 @@ func (f *UintSliceFlag) Apply(set *flag.FlagSet) error { return nil } +func (f *UintSliceFlag) WithSeparatorSpec(spec separatorSpec) { + f.separator = spec +} + // Get returns the flag’s value in the given Context. func (f *UintSliceFlag) Get(ctx *Context) []uint { return ctx.UintSlice(f.Name) diff --git a/vendor/github.com/urfave/cli/v2/godoc-current.txt b/vendor/github.com/urfave/cli/v2/godoc-current.txt index c1eb17057..599332b4f 100644 --- a/vendor/github.com/urfave/cli/v2/godoc-current.txt +++ b/vendor/github.com/urfave/cli/v2/godoc-current.txt @@ -1038,6 +1038,8 @@ func (f *Float64Slice) String() string func (f *Float64Slice) Value() []float64 Value returns the slice of float64s set by this flag +func (f *Float64Slice) WithSeparatorSpec(spec separatorSpec) + type Float64SliceFlag struct { Name string @@ -1113,6 +1115,8 @@ func (f *Float64SliceFlag) String() string func (f *Float64SliceFlag) TakesValue() bool TakesValue returns true if the flag takes a value, otherwise false +func (f *Float64SliceFlag) WithSeparatorSpec(spec separatorSpec) + type Generic interface { Set(value string) error String() string @@ -1279,6 +1283,8 @@ func (i *Int64Slice) String() string func (i *Int64Slice) Value() []int64 Value returns the slice of ints set by this flag +func (i *Int64Slice) WithSeparatorSpec(spec separatorSpec) + type Int64SliceFlag struct { Name string @@ -1354,6 +1360,8 @@ func (f *Int64SliceFlag) String() string func (f *Int64SliceFlag) TakesValue() bool TakesValue returns true of the flag takes a value, otherwise false +func (f *Int64SliceFlag) WithSeparatorSpec(spec separatorSpec) + type IntFlag struct { Name string @@ -1449,6 +1457,8 @@ func (i *IntSlice) String() string func (i *IntSlice) Value() []int Value returns the slice of ints set by this flag +func (i *IntSlice) WithSeparatorSpec(spec separatorSpec) + type IntSliceFlag struct { Name string @@ -1524,6 +1534,8 @@ func (f *IntSliceFlag) String() string func (f *IntSliceFlag) TakesValue() bool TakesValue returns true of the flag takes a value, otherwise false +func (f *IntSliceFlag) WithSeparatorSpec(spec separatorSpec) + type InvalidFlagAccessFunc func(*Context, string) InvalidFlagAccessFunc is executed when an invalid flag is accessed from the context. @@ -1792,6 +1804,8 @@ func (s *StringSlice) String() string func (s *StringSlice) Value() []string Value returns the slice of strings set by this flag +func (s *StringSlice) WithSeparatorSpec(spec separatorSpec) + type StringSliceFlag struct { Name string @@ -1869,6 +1883,8 @@ func (f *StringSliceFlag) String() string func (f *StringSliceFlag) TakesValue() bool TakesValue returns true of the flag takes a value, otherwise false +func (f *StringSliceFlag) WithSeparatorSpec(spec separatorSpec) + type SuggestCommandFunc func(commands []*Command, provided string) string type SuggestFlagFunc func(flags []Flag, provided string, hideHelp bool) string @@ -2063,6 +2079,8 @@ func (i *Uint64Slice) String() string func (i *Uint64Slice) Value() []uint64 Value returns the slice of ints set by this flag +func (i *Uint64Slice) WithSeparatorSpec(spec separatorSpec) + type Uint64SliceFlag struct { Name string @@ -2129,6 +2147,8 @@ func (f *Uint64SliceFlag) String() string func (f *Uint64SliceFlag) TakesValue() bool TakesValue returns true of the flag takes a value, otherwise false +func (f *Uint64SliceFlag) WithSeparatorSpec(spec separatorSpec) + type UintFlag struct { Name string @@ -2224,6 +2244,8 @@ func (i *UintSlice) String() string func (i *UintSlice) Value() []uint Value returns the slice of ints set by this flag +func (i *UintSlice) WithSeparatorSpec(spec separatorSpec) + type UintSliceFlag struct { Name string @@ -2290,6 +2312,8 @@ func (f *UintSliceFlag) String() string func (f *UintSliceFlag) TakesValue() bool TakesValue returns true of the flag takes a value, otherwise false +func (f *UintSliceFlag) WithSeparatorSpec(spec separatorSpec) + type VisibleFlag interface { Flag diff --git a/vendor/github.com/urfave/cli/v2/zz_generated.flags.go b/vendor/github.com/urfave/cli/v2/zz_generated.flags.go index 016951a3f..8c29f6ee0 100644 --- a/vendor/github.com/urfave/cli/v2/zz_generated.flags.go +++ b/vendor/github.com/urfave/cli/v2/zz_generated.flags.go @@ -25,6 +25,8 @@ type Float64SliceFlag struct { defaultValue *Float64Slice + separator separatorSpec + Action func(*Context, []float64) error } @@ -120,6 +122,8 @@ type Int64SliceFlag struct { defaultValue *Int64Slice + separator separatorSpec + Action func(*Context, []int64) error } @@ -164,6 +168,8 @@ type IntSliceFlag struct { defaultValue *IntSlice + separator separatorSpec + Action func(*Context, []int) error } @@ -259,6 +265,8 @@ type StringSliceFlag struct { defaultValue *StringSlice + separator separatorSpec + TakesFile bool Action func(*Context, []string) error @@ -358,6 +366,8 @@ type Uint64SliceFlag struct { defaultValue *Uint64Slice + separator separatorSpec + Action func(*Context, []uint64) error } @@ -402,6 +412,8 @@ type UintSliceFlag struct { defaultValue *UintSlice + separator separatorSpec + Action func(*Context, []uint) error } diff --git a/vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/config.go b/vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/config.go index d0337f3a5..0c3e48d55 100644 --- a/vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/config.go +++ b/vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/config.go @@ -33,6 +33,7 @@ const ( // config represents the configuration options available for the http.Handler // and http.Transport types. type config struct { + ServerName string Tracer trace.Tracer Meter metric.Meter Propagators propagation.TextMapPropagator @@ -198,3 +199,11 @@ func WithClientTrace(f func(context.Context) *httptrace.ClientTrace) Option { c.ClientTrace = f }) } + +// WithServerName returns an Option that sets the name of the (virtual) server +// handling requests. +func WithServerName(server string) Option { + return optionFunc(func(c *config) { + c.ServerName = server + }) +} diff --git a/vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/handler.go b/vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/handler.go index fd91e4162..60945801b 100644 --- a/vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/handler.go +++ b/vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/handler.go @@ -24,10 +24,10 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric" - "go.opentelemetry.io/otel/metric/instrument/syncfloat64" - "go.opentelemetry.io/otel/metric/instrument/syncint64" + "go.opentelemetry.io/otel/metric/instrument" "go.opentelemetry.io/otel/propagation" - semconv "go.opentelemetry.io/otel/semconv/v1.12.0" + semconv "go.opentelemetry.io/otel/semconv/v1.17.0" + "go.opentelemetry.io/otel/semconv/v1.17.0/httpconv" "go.opentelemetry.io/otel/trace" ) @@ -39,6 +39,7 @@ var _ http.Handler = &Handler{} // to the span using the attribute.Keys defined in this package. type Handler struct { operation string + server string handler http.Handler tracer trace.Tracer @@ -49,8 +50,8 @@ type Handler struct { writeEvent bool filters []Filter spanNameFormatter func(string, *http.Request) string - counters map[string]syncint64.Counter - valueRecorders map[string]syncfloat64.Histogram + counters map[string]instrument.Int64Counter + valueRecorders map[string]instrument.Float64Histogram publicEndpoint bool publicEndpointFn func(*http.Request) bool } @@ -90,6 +91,7 @@ func (h *Handler) configure(c *config) { h.spanNameFormatter = c.SpanNameFormatter h.publicEndpoint = c.PublicEndpoint h.publicEndpointFn = c.PublicEndpointFn + h.server = c.ServerName } func handleErr(err error) { @@ -99,16 +101,16 @@ func handleErr(err error) { } func (h *Handler) createMeasures() { - h.counters = make(map[string]syncint64.Counter) - h.valueRecorders = make(map[string]syncfloat64.Histogram) + h.counters = make(map[string]instrument.Int64Counter) + h.valueRecorders = make(map[string]instrument.Float64Histogram) - requestBytesCounter, err := h.meter.SyncInt64().Counter(RequestContentLength) + requestBytesCounter, err := h.meter.Int64Counter(RequestContentLength) handleErr(err) - responseBytesCounter, err := h.meter.SyncInt64().Counter(ResponseContentLength) + responseBytesCounter, err := h.meter.Int64Counter(ResponseContentLength) handleErr(err) - serverLatencyMeasure, err := h.meter.SyncFloat64().Histogram(ServerLatency) + serverLatencyMeasure, err := h.meter.Float64Histogram(ServerLatency) handleErr(err) h.counters[RequestContentLength] = requestBytesCounter @@ -128,7 +130,14 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } ctx := h.propagators.Extract(r.Context(), propagation.HeaderCarrier(r.Header)) - opts := h.spanStartOptions + opts := []trace.SpanStartOption{ + trace.WithAttributes(httpconv.ServerRequest(h.server, r)...), + } + if h.server != "" { + hostAttr := semconv.NetHostNameKey.String(h.server) + opts = append(opts, trace.WithAttributes(hostAttr)) + } + opts = append(opts, h.spanStartOptions...) if h.publicEndpoint || (h.publicEndpointFn != nil && h.publicEndpointFn(r.WithContext(ctx))) { opts = append(opts, trace.WithNewRoot()) // Linking incoming span context if any for public endpoint. @@ -137,12 +146,6 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } } - opts = append([]trace.SpanStartOption{ - trace.WithAttributes(semconv.NetAttributesFromHTTPRequest("tcp", r)...), - trace.WithAttributes(semconv.EndUserAttributesFromHTTPRequest(r)...), - trace.WithAttributes(semconv.HTTPServerAttributesFromHTTPRequest(h.operation, "", r)...), - }, opts...) // start with the configured options - tracer := h.tracer if tracer == nil { @@ -212,7 +215,10 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { setAfterServeAttributes(span, bw.read, rww.written, rww.statusCode, bw.err, rww.err) // Add metrics - attributes := append(labeler.Get(), semconv.HTTPServerMetricAttributesFromHTTPRequest(h.operation, r)...) + attributes := append(labeler.Get(), httpconv.ServerRequest(h.server, r)...) + if rww.statusCode > 0 { + attributes = append(attributes, semconv.HTTPStatusCodeKey.Int(rww.statusCode)) + } h.counters[RequestContentLength].Add(ctx, bw.read, attributes...) h.counters[ResponseContentLength].Add(ctx, rww.written, attributes...) @@ -236,8 +242,10 @@ func setAfterServeAttributes(span trace.Span, read, wrote int64, statusCode int, if wrote > 0 { attributes = append(attributes, WroteBytesKey.Int64(wrote)) } - attributes = append(attributes, semconv.HTTPAttributesFromHTTPStatusCode(statusCode)...) - span.SetStatus(semconv.SpanStatusFromHTTPStatusCodeAndSpanKind(statusCode, trace.SpanKindServer)) + if statusCode > 0 { + attributes = append(attributes, semconv.HTTPStatusCodeKey.Int(statusCode)) + } + span.SetStatus(httpconv.ServerStatus(statusCode)) if werr != nil && werr != io.EOF { attributes = append(attributes, WriteErrorKey.String(werr.Error())) diff --git a/vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/transport.go b/vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/transport.go index fd5e1e9bc..9dda7e1a9 100644 --- a/vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/transport.go +++ b/vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/transport.go @@ -23,7 +23,7 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/codes" "go.opentelemetry.io/otel/propagation" - semconv "go.opentelemetry.io/otel/semconv/v1.12.0" + "go.opentelemetry.io/otel/semconv/v1.17.0/httpconv" "go.opentelemetry.io/otel/trace" ) @@ -110,7 +110,7 @@ func (t *Transport) RoundTrip(r *http.Request) (*http.Response, error) { } r = r.WithContext(ctx) - span.SetAttributes(semconv.HTTPClientAttributesFromHTTPRequest(r)...) + span.SetAttributes(httpconv.ClientRequest(r)...) t.propagators.Inject(ctx, propagation.HeaderCarrier(r.Header)) res, err := t.rt.RoundTrip(r) @@ -121,8 +121,8 @@ func (t *Transport) RoundTrip(r *http.Request) (*http.Response, error) { return res, err } - span.SetAttributes(semconv.HTTPAttributesFromHTTPStatusCode(res.StatusCode)...) - span.SetStatus(semconv.SpanStatusFromHTTPStatusCode(res.StatusCode)) + span.SetAttributes(httpconv.ClientResponse(res)...) + span.SetStatus(httpconv.ClientStatus(res.StatusCode)) res.Body = newWrappedBody(span, res.Body) return res, err diff --git a/vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/version.go b/vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/version.go index 822491db0..9475e49bd 100644 --- a/vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/version.go +++ b/vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/version.go @@ -16,7 +16,7 @@ package otelhttp // import "go.opentelemetry.io/contrib/instrumentation/net/http // Version is the current release version of the otelhttp instrumentation. func Version() string { - return "0.37.0" + return "0.38.0" // This string is updated by the pre_release.sh script during release } diff --git a/vendor/go.opentelemetry.io/otel/.lycheeignore b/vendor/go.opentelemetry.io/otel/.lycheeignore index 545d63452..32e481275 100644 --- a/vendor/go.opentelemetry.io/otel/.lycheeignore +++ b/vendor/go.opentelemetry.io/otel/.lycheeignore @@ -1,3 +1,4 @@ http://localhost http://jaeger-collector https://github.com/open-telemetry/opentelemetry-go/milestone/ +https://github.com/open-telemetry/opentelemetry-go/projects diff --git a/vendor/go.opentelemetry.io/otel/CHANGELOG.md b/vendor/go.opentelemetry.io/otel/CHANGELOG.md index 9f130b8be..2bfe0a941 100644 --- a/vendor/go.opentelemetry.io/otel/CHANGELOG.md +++ b/vendor/go.opentelemetry.io/otel/CHANGELOG.md @@ -8,6 +8,139 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Unreleased] +## [1.12.0/0.35.0] 2023-01-28 + +### Added + +- The `WithInt64Callback` option to `go.opentelemetry.io/otel/metric/instrument`. + This options is used to configure `int64` Observer callbacks during their creation. (#3507) +- The `WithFloat64Callback` option to `go.opentelemetry.io/otel/metric/instrument`. + This options is used to configure `float64` Observer callbacks during their creation. (#3507) +- The `Producer` interface and `Reader.RegisterProducer(Producer)` to `go.opentelemetry.io/otel/sdk/metric`. + These additions are used to enable external metric Producers. (#3524) +- The `Callback` function type to `go.opentelemetry.io/otel/metric`. + This new named function type is registered with a `Meter`. (#3564) +- The `go.opentelemetry.io/otel/semconv/v1.13.0` package. + The package contains semantic conventions from the `v1.13.0` version of the OpenTelemetry specification. (#3499) + - The `EndUserAttributesFromHTTPRequest` function in `go.opentelemetry.io/otel/semconv/v1.12.0` is merged into `ClientRequest` and `ServerRequest` in `go.opentelemetry.io/otel/semconv/v1.13.0/httpconv`. + - The `HTTPAttributesFromHTTPStatusCode` function in `go.opentelemetry.io/otel/semconv/v1.12.0` is merged into `ClientResponse` in `go.opentelemetry.io/otel/semconv/v1.13.0/httpconv`. + - The `HTTPClientAttributesFromHTTPRequest` function in `go.opentelemetry.io/otel/semconv/v1.12.0` is replaced by `ClientRequest` in `go.opentelemetry.io/otel/semconv/v1.13.0/httpconv`. + - The `HTTPServerAttributesFromHTTPRequest` function in `go.opentelemetry.io/otel/semconv/v1.12.0` is replaced by `ServerRequest` in `go.opentelemetry.io/otel/semconv/v1.13.0/httpconv`. + - The `HTTPServerMetricAttributesFromHTTPRequest` function in `go.opentelemetry.io/otel/semconv/v1.12.0` is replaced by `ServerRequest` in `go.opentelemetry.io/otel/semconv/v1.13.0/httpconv`. + - The `NetAttributesFromHTTPRequest` function in `go.opentelemetry.io/otel/semconv/v1.12.0` is split into `Transport` in `go.opentelemetry.io/otel/semconv/v1.13.0/netconv` and `ClientRequest` or `ServerRequest` in `go.opentelemetry.io/otel/semconv/v1.13.0/httpconv`. + - The `SpanStatusFromHTTPStatusCode` function in `go.opentelemetry.io/otel/semconv/v1.12.0` is replaced by `ClientStatus` in `go.opentelemetry.io/otel/semconv/v1.13.0/httpconv`. + - The `SpanStatusFromHTTPStatusCodeAndSpanKind` function in `go.opentelemetry.io/otel/semconv/v1.12.0` is split into `ClientStatus` and `ServerStatus` in `go.opentelemetry.io/otel/semconv/v1.13.0/httpconv`. + - The `Client` function is included in `go.opentelemetry.io/otel/semconv/v1.13.0/netconv` to generate attributes for a `net.Conn`. + - The `Server` function is included in `go.opentelemetry.io/otel/semconv/v1.13.0/netconv` to generate attributes for a `net.Listener`. +- The `go.opentelemetry.io/otel/semconv/v1.14.0` package. + The package contains semantic conventions from the `v1.14.0` version of the OpenTelemetry specification. (#3566) +- The `go.opentelemetry.io/otel/semconv/v1.15.0` package. + The package contains semantic conventions from the `v1.15.0` version of the OpenTelemetry specification. (#3578) +- The `go.opentelemetry.io/otel/semconv/v1.16.0` package. + The package contains semantic conventions from the `v1.16.0` version of the OpenTelemetry specification. (#3579) +- Metric instruments to `go.opentelemetry.io/otel/metric/instrument`. + These instruments are use as replacements of the depreacted `go.opentelemetry.io/otel/metric/instrument/{asyncfloat64,asyncint64,syncfloat64,syncint64}` packages.(#3575, #3586) + - `Float64ObservableCounter` replaces the `asyncfloat64.Counter` + - `Float64ObservableUpDownCounter` replaces the `asyncfloat64.UpDownCounter` + - `Float64ObservableGauge` replaces the `asyncfloat64.Gauge` + - `Int64ObservableCounter` replaces the `asyncint64.Counter` + - `Int64ObservableUpDownCounter` replaces the `asyncint64.UpDownCounter` + - `Int64ObservableGauge` replaces the `asyncint64.Gauge` + - `Float64Counter` replaces the `syncfloat64.Counter` + - `Float64UpDownCounter` replaces the `syncfloat64.UpDownCounter` + - `Float64Histogram` replaces the `syncfloat64.Histogram` + - `Int64Counter` replaces the `syncint64.Counter` + - `Int64UpDownCounter` replaces the `syncint64.UpDownCounter` + - `Int64Histogram` replaces the `syncint64.Histogram` +- `NewTracerProvider` to `go.opentelemetry.io/otel/bridge/opentracing`. + This is used to create `WrapperTracer` instances from a `TracerProvider`. (#3116) +- The `Extrema` type to `go.opentelemetry.io/otel/sdk/metric/metricdata`. + This type is used to represent min/max values and still be able to distinguish unset and zero values. (#3487) +- The `go.opentelemetry.io/otel/semconv/v1.17.0` package. + The package contains semantic conventions from the `v1.17.0` version of the OpenTelemetry specification. (#3599) + +### Changed + +- Jaeger and Zipkin exporter use `github.com/go-logr/logr` as the logging interface, and add the `WithLogr` option. (#3497, #3500) +- Instrument configuration in `go.opentelemetry.io/otel/metric/instrument` is split into specific options and confguration based on the instrument type. (#3507) + - Use the added `Int64Option` type to configure instruments from `go.opentelemetry.io/otel/metric/instrument/syncint64`. + - Use the added `Float64Option` type to configure instruments from `go.opentelemetry.io/otel/metric/instrument/syncfloat64`. + - Use the added `Int64ObserverOption` type to configure instruments from `go.opentelemetry.io/otel/metric/instrument/asyncint64`. + - Use the added `Float64ObserverOption` type to configure instruments from `go.opentelemetry.io/otel/metric/instrument/asyncfloat64`. +- Return a `Registration` from the `RegisterCallback` method of a `Meter` in the `go.opentelemetry.io/otel/metric` package. + This `Registration` can be used to unregister callbacks. (#3522) +- Global error handler uses an atomic value instead of a mutex. (#3543) +- Add `NewMetricProducer` to `go.opentelemetry.io/otel/bridge/opencensus`, which can be used to pass OpenCensus metrics to an OpenTelemetry Reader. (#3541) +- Global logger uses an atomic value instead of a mutex. (#3545) +- The `Shutdown` method of the `"go.opentelemetry.io/otel/sdk/trace".TracerProvider` releases all computational resources when called the first time. (#3551) +- The `Sampler` returned from `TraceIDRatioBased` `go.opentelemetry.io/otel/sdk/trace` now uses the rightmost bits for sampling decisions. + This fixes random sampling when using ID generators like `xray.IDGenerator` and increasing parity with other language implementations. (#3557) +- Errors from `go.opentelemetry.io/otel/exporters/otlp/otlptrace` exporters are wrapped in erros identifying their signal name. + Existing users of the exporters attempting to identify specific errors will need to use `errors.Unwrap()` to get the underlying error. (#3516) +- Exporters from `go.opentelemetry.io/otel/exporters/otlp` will print the final retryable error message when attempts to retry time out. (#3514) +- The instrument kind names in `go.opentelemetry.io/otel/sdk/metric` are updated to match the API. (#3562) + - `InstrumentKindSyncCounter` is renamed to `InstrumentKindCounter` + - `InstrumentKindSyncUpDownCounter` is renamed to `InstrumentKindUpDownCounter` + - `InstrumentKindSyncHistogram` is renamed to `InstrumentKindHistogram` + - `InstrumentKindAsyncCounter` is renamed to `InstrumentKindObservableCounter` + - `InstrumentKindAsyncUpDownCounter` is renamed to `InstrumentKindObservableUpDownCounter` + - `InstrumentKindAsyncGauge` is renamed to `InstrumentKindObservableGauge` +- The `RegisterCallback` method of the `Meter` in `go.opentelemetry.io/otel/metric` changed. + - The named `Callback` replaces the inline function parameter. (#3564) + - `Callback` is required to return an error. (#3576) + - `Callback` accepts the added `Observer` parameter added. + This new parameter is used by `Callback` implementations to observe values for asynchronous instruments instead of calling the `Observe` method of the instrument directly. (#3584) + - The slice of `instrument.Asynchronous` is now passed as a variadic argument. (#3587) +- The exporter from `go.opentelemetry.io/otel/exporters/zipkin` is updated to use the `v1.16.0` version of semantic conventions. + This means it no longer uses the removed `net.peer.ip` or `http.host` attributes to determine the remote endpoint. + Instead it uses the `net.sock.peer` attributes. (#3581) +- The `Min` and `Max` fields of the `HistogramDataPoint` in `go.opentelemetry.io/otel/sdk/metric/metricdata` are now defined with the added `Extrema` type instead of a `*float64`. (#3487) + +### Fixed + +- Asynchronous instruments that use sum aggregators and attribute filters correctly add values from equivalent attribute sets that have been filtered. (#3439, #3549) +- The `RegisterCallback` method of the `Meter` from `go.opentelemetry.io/otel/sdk/metric` only registers a callback for instruments created by that meter. + Trying to register a callback with instruments from a different meter will result in an error being returned. (#3584) + +### Deprecated + +- The `NewMetricExporter` in `go.opentelemetry.io/otel/bridge/opencensus` is deprecated. + Use `NewMetricProducer` instead. (#3541) +- The `go.opentelemetry.io/otel/metric/instrument/asyncfloat64` package is deprecated. + Use the instruments from `go.opentelemetry.io/otel/metric/instrument` instead. (#3575) +- The `go.opentelemetry.io/otel/metric/instrument/asyncint64` package is deprecated. + Use the instruments from `go.opentelemetry.io/otel/metric/instrument` instead. (#3575) +- The `go.opentelemetry.io/otel/metric/instrument/syncfloat64` package is deprecated. + Use the instruments from `go.opentelemetry.io/otel/metric/instrument` instead. (#3575) +- The `go.opentelemetry.io/otel/metric/instrument/syncint64` package is deprecated. + Use the instruments from `go.opentelemetry.io/otel/metric/instrument` instead. (#3575) +- The `NewWrappedTracerProvider` in `go.opentelemetry.io/otel/bridge/opentracing` is now deprecated. + Use `NewTracerProvider` instead. (#3116) + +### Removed + +- The deprecated `go.opentelemetry.io/otel/sdk/metric/view` package is removed. (#3520) +- The `InstrumentProvider` from `go.opentelemetry.io/otel/sdk/metric/asyncint64` is removed. + Use the new creation methods of the `Meter` in `go.opentelemetry.io/otel/sdk/metric` instead. (#3530) + - The `Counter` method is replaced by `Meter.Int64ObservableCounter` + - The `UpDownCounter` method is replaced by `Meter.Int64ObservableUpDownCounter` + - The `Gauge` method is replaced by `Meter.Int64ObservableGauge` +- The `InstrumentProvider` from `go.opentelemetry.io/otel/sdk/metric/asyncfloat64` is removed. + Use the new creation methods of the `Meter` in `go.opentelemetry.io/otel/sdk/metric` instead. (#3530) + - The `Counter` method is replaced by `Meter.Float64ObservableCounter` + - The `UpDownCounter` method is replaced by `Meter.Float64ObservableUpDownCounter` + - The `Gauge` method is replaced by `Meter.Float64ObservableGauge` +- The `InstrumentProvider` from `go.opentelemetry.io/otel/sdk/metric/syncint64` is removed. + Use the new creation methods of the `Meter` in `go.opentelemetry.io/otel/sdk/metric` instead. (#3530) + - The `Counter` method is replaced by `Meter.Int64Counter` + - The `UpDownCounter` method is replaced by `Meter.Int64UpDownCounter` + - The `Histogram` method is replaced by `Meter.Int64Histogram` +- The `InstrumentProvider` from `go.opentelemetry.io/otel/sdk/metric/syncfloat64` is removed. + Use the new creation methods of the `Meter` in `go.opentelemetry.io/otel/sdk/metric` instead. (#3530) + - The `Counter` method is replaced by `Meter.Float64Counter` + - The `UpDownCounter` method is replaced by `Meter.Float64UpDownCounter` + - The `Histogram` method is replaced by `Meter.Float64Histogram` + ## [1.11.2/0.34.0] 2022-12-05 ### Added @@ -58,7 +191,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Prevent duplicate Prometheus description, unit, and type. (#3469) - Prevents panic when using incorrect `attribute.Value.As[Type]Slice()`. (#3489) -## Removed +### Removed - The `go.opentelemetry.io/otel/exporters/otlp/otlpmetric.Client` interface is removed. (#3486) - The `go.opentelemetry.io/otel/exporters/otlp/otlpmetric.New` function is removed. Use the `otlpmetric[http|grpc].New` directly. (#3486) @@ -2087,7 +2220,8 @@ It contains api and sdk for trace and meter. - CircleCI build CI manifest files. - CODEOWNERS file to track owners of this project. -[Unreleased]: https://github.com/open-telemetry/opentelemetry-go/compare/v1.11.2...HEAD +[Unreleased]: https://github.com/open-telemetry/opentelemetry-go/compare/v1.12.0...HEAD +[1.12.0/0.35.0]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.12.0 [1.11.2/0.34.0]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.11.2 [1.11.1/0.33.0]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.11.1 [1.11.0/0.32.3]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.11.0 diff --git a/vendor/go.opentelemetry.io/otel/Makefile b/vendor/go.opentelemetry.io/otel/Makefile index 68cdfef7d..befb040a7 100644 --- a/vendor/go.opentelemetry.io/otel/Makefile +++ b/vendor/go.opentelemetry.io/otel/Makefile @@ -208,11 +208,11 @@ check-clean-work-tree: SEMCONVPKG ?= "semconv/" .PHONY: semconv-generate semconv-generate: | $(SEMCONVGEN) $(SEMCONVKIT) - @[ "$(TAG)" ] || ( echo "TAG unset: missing opentelemetry specification tag"; exit 1 ) - @[ "$(OTEL_SPEC_REPO)" ] || ( echo "OTEL_SPEC_REPO unset: missing path to opentelemetry specification repo"; exit 1 ) - @$(SEMCONVGEN) -i "$(OTEL_SPEC_REPO)/semantic_conventions/trace" -t "$(SEMCONVPKG)/template.j2" -s "$(TAG)" - @$(SEMCONVGEN) -i "$(OTEL_SPEC_REPO)/semantic_conventions/resource" -t "$(SEMCONVPKG)/template.j2" -s "$(TAG)" - @$(SEMCONVKIT) -output "$(SEMCONVPKG)/$(TAG)" -tag "$(TAG)" + [ "$(TAG)" ] || ( echo "TAG unset: missing opentelemetry specification tag"; exit 1 ) + [ "$(OTEL_SPEC_REPO)" ] || ( echo "OTEL_SPEC_REPO unset: missing path to opentelemetry specification repo"; exit 1 ) + $(SEMCONVGEN) -i "$(OTEL_SPEC_REPO)/semantic_conventions/." --only=span -p conventionType=trace -p conventionType=trace -f trace.go -t "$(SEMCONVPKG)/template.j2" -s "$(TAG)" + $(SEMCONVGEN) -i "$(OTEL_SPEC_REPO)/semantic_conventions/." --only=resource -p conventionType=resource -p conventionType=resource -f resource.go -t "$(SEMCONVPKG)/template.j2" -s "$(TAG)" + $(SEMCONVKIT) -output "$(SEMCONVPKG)/$(TAG)" -tag "$(TAG)" .PHONY: prerelease prerelease: | $(MULTIMOD) diff --git a/vendor/go.opentelemetry.io/otel/RELEASING.md b/vendor/go.opentelemetry.io/otel/RELEASING.md index 71e576254..77d56c936 100644 --- a/vendor/go.opentelemetry.io/otel/RELEASING.md +++ b/vendor/go.opentelemetry.io/otel/RELEASING.md @@ -6,20 +6,25 @@ New versions of the [OpenTelemetry specification] mean new versions of the `semc The `semconv-generate` make target is used for this. 1. Checkout a local copy of the [OpenTelemetry specification] to the desired release tag. -2. Run the `make semconv-generate ...` target from this repository. +2. Pull the latest `otel/semconvgen` image: `docker pull otel/semconvgen:latest` +3. Run the `make semconv-generate ...` target from this repository. For example, ```sh -export TAG="v1.7.0" # Change to the release version you are generating. +export TAG="v1.13.0" # Change to the release version you are generating. export OTEL_SPEC_REPO="/absolute/path/to/opentelemetry-specification" -git -C "$OTEL_SPEC_REPO" checkout "tags/$TAG" +git -C "$OTEL_SPEC_REPO" checkout "tags/$TAG" -b "$TAG" +docker pull otel/semconvgen:latest make semconv-generate # Uses the exported TAG and OTEL_SPEC_REPO. ``` This should create a new sub-package of [`semconv`](./semconv). Ensure things look correct before submitting a pull request to include the addition. +**Note**, the generation code was changed to generate versions >= 1.13. +To generate versions prior to this, checkout the old release of this repository (i.e. [2fe8861](https://github.com/open-telemetry/opentelemetry-go/commit/2fe8861a24e20088c065b116089862caf9e3cd8b)). + ## Pre-Release First, decide which module sets will be released and update their versions diff --git a/vendor/go.opentelemetry.io/otel/handler.go b/vendor/go.opentelemetry.io/otel/handler.go index 36cf09f72..ecd363ab5 100644 --- a/vendor/go.opentelemetry.io/otel/handler.go +++ b/vendor/go.opentelemetry.io/otel/handler.go @@ -17,7 +17,8 @@ package otel // import "go.opentelemetry.io/otel" import ( "log" "os" - "sync" + "sync/atomic" + "unsafe" ) var ( @@ -34,28 +35,26 @@ var ( ) type delegator struct { - lock *sync.RWMutex - eh ErrorHandler + delegate unsafe.Pointer } func (d *delegator) Handle(err error) { - d.lock.RLock() - defer d.lock.RUnlock() - d.eh.Handle(err) + d.getDelegate().Handle(err) +} + +func (d *delegator) getDelegate() ErrorHandler { + return *(*ErrorHandler)(atomic.LoadPointer(&d.delegate)) } // setDelegate sets the ErrorHandler delegate. func (d *delegator) setDelegate(eh ErrorHandler) { - d.lock.Lock() - defer d.lock.Unlock() - d.eh = eh + atomic.StorePointer(&d.delegate, unsafe.Pointer(&eh)) } func defaultErrorHandler() *delegator { - return &delegator{ - lock: &sync.RWMutex{}, - eh: &errLogger{l: log.New(os.Stderr, "", log.LstdFlags)}, - } + d := &delegator{} + d.setDelegate(&errLogger{l: log.New(os.Stderr, "", log.LstdFlags)}) + return d } // errLogger logs errors if no delegate is set, otherwise they are delegated. diff --git a/vendor/go.opentelemetry.io/otel/internal/global/internal_logging.go b/vendor/go.opentelemetry.io/otel/internal/global/internal_logging.go index ccb325871..293c08961 100644 --- a/vendor/go.opentelemetry.io/otel/internal/global/internal_logging.go +++ b/vendor/go.opentelemetry.io/otel/internal/global/internal_logging.go @@ -17,7 +17,8 @@ package global // import "go.opentelemetry.io/otel/internal/global" import ( "log" "os" - "sync" + "sync/atomic" + "unsafe" "github.com/go-logr/logr" "github.com/go-logr/stdr" @@ -27,37 +28,36 @@ import ( // // The default logger uses stdr which is backed by the standard `log.Logger` // interface. This logger will only show messages at the Error Level. -var globalLogger logr.Logger = stdr.New(log.New(os.Stderr, "", log.LstdFlags|log.Lshortfile)) -var globalLoggerLock = &sync.RWMutex{} +var globalLogger unsafe.Pointer + +func init() { + SetLogger(stdr.New(log.New(os.Stderr, "", log.LstdFlags|log.Lshortfile))) +} // SetLogger overrides the globalLogger with l. // // To see Info messages use a logger with `l.V(1).Enabled() == true` // To see Debug messages use a logger with `l.V(5).Enabled() == true`. func SetLogger(l logr.Logger) { - globalLoggerLock.Lock() - defer globalLoggerLock.Unlock() - globalLogger = l + atomic.StorePointer(&globalLogger, unsafe.Pointer(&l)) +} + +func getLogger() logr.Logger { + return *(*logr.Logger)(atomic.LoadPointer(&globalLogger)) } // Info prints messages about the general state of the API or SDK. // This should usually be less then 5 messages a minute. func Info(msg string, keysAndValues ...interface{}) { - globalLoggerLock.RLock() - defer globalLoggerLock.RUnlock() - globalLogger.V(1).Info(msg, keysAndValues...) + getLogger().V(1).Info(msg, keysAndValues...) } // Error prints messages about exceptional states of the API or SDK. func Error(err error, msg string, keysAndValues ...interface{}) { - globalLoggerLock.RLock() - defer globalLoggerLock.RUnlock() - globalLogger.Error(err, msg, keysAndValues...) + getLogger().Error(err, msg, keysAndValues...) } // Debug prints messages about all internal changes in the API or SDK. func Debug(msg string, keysAndValues ...interface{}) { - globalLoggerLock.RLock() - defer globalLoggerLock.RUnlock() - globalLogger.V(5).Info(msg, keysAndValues...) + getLogger().V(5).Info(msg, keysAndValues...) } diff --git a/vendor/go.opentelemetry.io/otel/metric/instrument/asyncfloat64.go b/vendor/go.opentelemetry.io/otel/metric/instrument/asyncfloat64.go new file mode 100644 index 000000000..2f624bfe0 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/metric/instrument/asyncfloat64.go @@ -0,0 +1,131 @@ +// Copyright The OpenTelemetry 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. + +package instrument // import "go.opentelemetry.io/otel/metric/instrument" + +import ( + "context" + + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/metric/unit" +) + +// Float64Observable describes a set of instruments used asynchronously to +// record float64 measurements once per collection cycle. Observations of +// these instruments are only made within a callback. +// +// Warning: methods may be added to this interface in minor releases. +type Float64Observable interface { + Asynchronous + + float64Observable() +} + +// Float64ObservableCounter is an instrument used to asynchronously record +// increasing float64 measurements once per collection cycle. Observations are +// only made within a callback for this instrument. The value observed is +// assumed the to be the cumulative sum of the count. +// +// Warning: methods may be added to this interface in minor releases. +type Float64ObservableCounter interface{ Float64Observable } + +// Float64ObservableUpDownCounter is an instrument used to asynchronously +// record float64 measurements once per collection cycle. Observations are only +// made within a callback for this instrument. The value observed is assumed +// the to be the cumulative sum of the count. +// +// Warning: methods may be added to this interface in minor releases. +type Float64ObservableUpDownCounter interface{ Float64Observable } + +// Float64ObservableGauge is an instrument used to asynchronously record +// instantaneous float64 measurements once per collection cycle. Observations +// are only made within a callback for this instrument. +// +// Warning: methods may be added to this interface in minor releases. +type Float64ObservableGauge interface{ Float64Observable } + +// Float64Observer is a recorder of float64 measurements. +// +// Warning: methods may be added to this interface in minor releases. +type Float64Observer interface { + Observe(value float64, attributes ...attribute.KeyValue) +} + +// Float64Callback is a function registered with a Meter that makes +// observations for a Float64Observerable instrument it is registered with. +// Calls to the Float64Observer record measurement values for the +// Float64Observable. +// +// The function needs to complete in a finite amount of time and the deadline +// of the passed context is expected to be honored. +// +// The function needs to make unique observations across all registered +// Float64Callbacks. Meaning, it should not report measurements with the same +// attributes as another Float64Callbacks also registered for the same +// instrument. +// +// The function needs to be concurrent safe. +type Float64Callback func(context.Context, Float64Observer) error + +// Float64ObserverConfig contains options for Asynchronous instruments that +// observe float64 values. +type Float64ObserverConfig struct { + description string + unit unit.Unit + callbacks []Float64Callback +} + +// NewFloat64ObserverConfig returns a new Float64ObserverConfig with all opts +// applied. +func NewFloat64ObserverConfig(opts ...Float64ObserverOption) Float64ObserverConfig { + var config Float64ObserverConfig + for _, o := range opts { + config = o.applyFloat64Observer(config) + } + return config +} + +// Description returns the Config description. +func (c Float64ObserverConfig) Description() string { + return c.description +} + +// Unit returns the Config unit. +func (c Float64ObserverConfig) Unit() unit.Unit { + return c.unit +} + +// Callbacks returns the Config callbacks. +func (c Float64ObserverConfig) Callbacks() []Float64Callback { + return c.callbacks +} + +// Float64ObserverOption applies options to float64 Observer instruments. +type Float64ObserverOption interface { + applyFloat64Observer(Float64ObserverConfig) Float64ObserverConfig +} + +type float64ObserverOptionFunc func(Float64ObserverConfig) Float64ObserverConfig + +func (fn float64ObserverOptionFunc) applyFloat64Observer(cfg Float64ObserverConfig) Float64ObserverConfig { + return fn(cfg) +} + +// WithFloat64Callback adds callback to be called for an instrument. +func WithFloat64Callback(callback Float64Callback) Float64ObserverOption { + return float64ObserverOptionFunc(func(cfg Float64ObserverConfig) Float64ObserverConfig { + cfg.callbacks = append(cfg.callbacks, callback) + return cfg + }) +} diff --git a/vendor/go.opentelemetry.io/otel/metric/instrument/asyncfloat64/asyncfloat64.go b/vendor/go.opentelemetry.io/otel/metric/instrument/asyncfloat64/asyncfloat64.go deleted file mode 100644 index 330a14c2f..000000000 --- a/vendor/go.opentelemetry.io/otel/metric/instrument/asyncfloat64/asyncfloat64.go +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright The OpenTelemetry 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. - -package asyncfloat64 // import "go.opentelemetry.io/otel/metric/instrument/asyncfloat64" - -import ( - "context" - - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/metric/instrument" -) - -// InstrumentProvider provides access to individual instruments. -// -// Warning: methods may be added to this interface in minor releases. -type InstrumentProvider interface { - // Counter creates an instrument for recording increasing values. - Counter(name string, opts ...instrument.Option) (Counter, error) - - // UpDownCounter creates an instrument for recording changes of a value. - UpDownCounter(name string, opts ...instrument.Option) (UpDownCounter, error) - - // Gauge creates an instrument for recording the current value. - Gauge(name string, opts ...instrument.Option) (Gauge, error) -} - -// Counter is an instrument that records increasing values. -// -// Warning: methods may be added to this interface in minor releases. -type Counter interface { - // Observe records the state of the instrument to be x. Implementations - // will assume x to be the cumulative sum of the count. - // - // It is only valid to call this within a callback. If called outside of the - // registered callback it should have no effect on the instrument, and an - // error will be reported via the error handler. - Observe(ctx context.Context, x float64, attrs ...attribute.KeyValue) - - instrument.Asynchronous -} - -// UpDownCounter is an instrument that records increasing or decreasing values. -// -// Warning: methods may be added to this interface in minor releases. -type UpDownCounter interface { - // Observe records the state of the instrument to be x. Implementations - // will assume x to be the cumulative sum of the count. - // - // It is only valid to call this within a callback. If called outside of the - // registered callback it should have no effect on the instrument, and an - // error will be reported via the error handler. - Observe(ctx context.Context, x float64, attrs ...attribute.KeyValue) - - instrument.Asynchronous -} - -// Gauge is an instrument that records independent readings. -// -// Warning: methods may be added to this interface in minor releases. -type Gauge interface { - // Observe records the state of the instrument to be x. - // - // It is only valid to call this within a callback. If called outside of the - // registered callback it should have no effect on the instrument, and an - // error will be reported via the error handler. - Observe(ctx context.Context, x float64, attrs ...attribute.KeyValue) - - instrument.Asynchronous -} diff --git a/vendor/go.opentelemetry.io/otel/metric/instrument/asyncint64.go b/vendor/go.opentelemetry.io/otel/metric/instrument/asyncint64.go new file mode 100644 index 000000000..ac0d09d90 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/metric/instrument/asyncint64.go @@ -0,0 +1,131 @@ +// Copyright The OpenTelemetry 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. + +package instrument // import "go.opentelemetry.io/otel/metric/instrument" + +import ( + "context" + + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/metric/unit" +) + +// Int64Observable describes a set of instruments used asynchronously to record +// int64 measurements once per collection cycle. Observations of these +// instruments are only made within a callback. +// +// Warning: methods may be added to this interface in minor releases. +type Int64Observable interface { + Asynchronous + + int64Observable() +} + +// Int64ObservableCounter is an instrument used to asynchronously record +// increasing int64 measurements once per collection cycle. Observations are +// only made within a callback for this instrument. The value observed is +// assumed the to be the cumulative sum of the count. +// +// Warning: methods may be added to this interface in minor releases. +type Int64ObservableCounter interface{ Int64Observable } + +// Int64ObservableUpDownCounter is an instrument used to asynchronously record +// int64 measurements once per collection cycle. Observations are only made +// within a callback for this instrument. The value observed is assumed the to +// be the cumulative sum of the count. +// +// Warning: methods may be added to this interface in minor releases. +type Int64ObservableUpDownCounter interface{ Int64Observable } + +// Int64ObservableGauge is an instrument used to asynchronously record +// instantaneous int64 measurements once per collection cycle. Observations are +// only made within a callback for this instrument. +// +// Warning: methods may be added to this interface in minor releases. +type Int64ObservableGauge interface{ Int64Observable } + +// Int64Observer is a recorder of int64 measurements. +// +// Warning: methods may be added to this interface in minor releases. +type Int64Observer interface { + Observe(value int64, attributes ...attribute.KeyValue) +} + +// Int64Callback is a function registered with a Meter that makes +// observations for a Int64Observerable instrument it is registered with. +// Calls to the Int64Observer record measurement values for the +// Int64Observable. +// +// The function needs to complete in a finite amount of time and the deadline +// of the passed context is expected to be honored. +// +// The function needs to make unique observations across all registered +// Int64Callback. Meaning, it should not report measurements with the same +// attributes as another Int64Callbacks also registered for the same +// instrument. +// +// The function needs to be concurrent safe. +type Int64Callback func(context.Context, Int64Observer) error + +// Int64ObserverConfig contains options for Asynchronous instruments that +// observe int64 values. +type Int64ObserverConfig struct { + description string + unit unit.Unit + callbacks []Int64Callback +} + +// NewInt64ObserverConfig returns a new Int64ObserverConfig with all opts +// applied. +func NewInt64ObserverConfig(opts ...Int64ObserverOption) Int64ObserverConfig { + var config Int64ObserverConfig + for _, o := range opts { + config = o.applyInt64Observer(config) + } + return config +} + +// Description returns the Config description. +func (c Int64ObserverConfig) Description() string { + return c.description +} + +// Unit returns the Config unit. +func (c Int64ObserverConfig) Unit() unit.Unit { + return c.unit +} + +// Callbacks returns the Config callbacks. +func (c Int64ObserverConfig) Callbacks() []Int64Callback { + return c.callbacks +} + +// Int64ObserverOption applies options to int64 Observer instruments. +type Int64ObserverOption interface { + applyInt64Observer(Int64ObserverConfig) Int64ObserverConfig +} + +type int64ObserverOptionFunc func(Int64ObserverConfig) Int64ObserverConfig + +func (fn int64ObserverOptionFunc) applyInt64Observer(cfg Int64ObserverConfig) Int64ObserverConfig { + return fn(cfg) +} + +// WithInt64Callback adds callback to be called for an instrument. +func WithInt64Callback(callback Int64Callback) Int64ObserverOption { + return int64ObserverOptionFunc(func(cfg Int64ObserverConfig) Int64ObserverConfig { + cfg.callbacks = append(cfg.callbacks, callback) + return cfg + }) +} diff --git a/vendor/go.opentelemetry.io/otel/metric/instrument/asyncint64/asyncint64.go b/vendor/go.opentelemetry.io/otel/metric/instrument/asyncint64/asyncint64.go deleted file mode 100644 index 4fce9963c..000000000 --- a/vendor/go.opentelemetry.io/otel/metric/instrument/asyncint64/asyncint64.go +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright The OpenTelemetry 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. - -package asyncint64 // import "go.opentelemetry.io/otel/metric/instrument/asyncint64" - -import ( - "context" - - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/metric/instrument" -) - -// InstrumentProvider provides access to individual instruments. -// -// Warning: methods may be added to this interface in minor releases. -type InstrumentProvider interface { - // Counter creates an instrument for recording increasing values. - Counter(name string, opts ...instrument.Option) (Counter, error) - - // UpDownCounter creates an instrument for recording changes of a value. - UpDownCounter(name string, opts ...instrument.Option) (UpDownCounter, error) - - // Gauge creates an instrument for recording the current value. - Gauge(name string, opts ...instrument.Option) (Gauge, error) -} - -// Counter is an instrument that records increasing values. -// -// Warning: methods may be added to this interface in minor releases. -type Counter interface { - // Observe records the state of the instrument to be x. Implementations - // will assume x to be the cumulative sum of the count. - // - // It is only valid to call this within a callback. If called outside of the - // registered callback it should have no effect on the instrument, and an - // error will be reported via the error handler. - Observe(ctx context.Context, x int64, attrs ...attribute.KeyValue) - - instrument.Asynchronous -} - -// UpDownCounter is an instrument that records increasing or decreasing values. -// -// Warning: methods may be added to this interface in minor releases. -type UpDownCounter interface { - // Observe records the state of the instrument to be x. Implementations - // will assume x to be the cumulative sum of the count. - // - // It is only valid to call this within a callback. If called outside of the - // registered callback it should have no effect on the instrument, and an - // error will be reported via the error handler. - Observe(ctx context.Context, x int64, attrs ...attribute.KeyValue) - - instrument.Asynchronous -} - -// Gauge is an instrument that records independent readings. -// -// Warning: methods may be added to this interface in minor releases. -type Gauge interface { - // Observe records the state of the instrument to be x. - // - // It is only valid to call this within a callback. If called outside of the - // registered callback it should have no effect on the instrument, and an - // error will be reported via the error handler. - Observe(ctx context.Context, x int64, attrs ...attribute.KeyValue) - - instrument.Asynchronous -} diff --git a/vendor/go.opentelemetry.io/otel/metric/instrument/config.go b/vendor/go.opentelemetry.io/otel/metric/instrument/config.go deleted file mode 100644 index 8778bce16..000000000 --- a/vendor/go.opentelemetry.io/otel/metric/instrument/config.go +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright The OpenTelemetry 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. - -package instrument // import "go.opentelemetry.io/otel/metric/instrument" - -import "go.opentelemetry.io/otel/metric/unit" - -// Config contains options for metric instrument descriptors. -type Config struct { - description string - unit unit.Unit -} - -// Description describes the instrument in human-readable terms. -func (cfg Config) Description() string { - return cfg.description -} - -// Unit describes the measurement unit for an instrument. -func (cfg Config) Unit() unit.Unit { - return cfg.unit -} - -// Option is an interface for applying metric instrument options. -type Option interface { - applyInstrument(Config) Config -} - -// NewConfig creates a new Config and applies all the given options. -func NewConfig(opts ...Option) Config { - var config Config - for _, o := range opts { - config = o.applyInstrument(config) - } - return config -} - -type optionFunc func(Config) Config - -func (fn optionFunc) applyInstrument(cfg Config) Config { - return fn(cfg) -} - -// WithDescription applies provided description. -func WithDescription(desc string) Option { - return optionFunc(func(cfg Config) Config { - cfg.description = desc - return cfg - }) -} - -// WithUnit applies provided unit. -func WithUnit(u unit.Unit) Option { - return optionFunc(func(cfg Config) Config { - cfg.unit = u - return cfg - }) -} diff --git a/vendor/go.opentelemetry.io/otel/metric/instrument/instrument.go b/vendor/go.opentelemetry.io/otel/metric/instrument/instrument.go index e1bbb850d..c583be6fb 100644 --- a/vendor/go.opentelemetry.io/otel/metric/instrument/instrument.go +++ b/vendor/go.opentelemetry.io/otel/metric/instrument/instrument.go @@ -14,6 +14,8 @@ package instrument // import "go.opentelemetry.io/otel/metric/instrument" +import "go.opentelemetry.io/otel/metric/unit" + // Asynchronous instruments are instruments that are updated within a Callback. // If an instrument is observed outside of it's callback it should be an error. // @@ -28,3 +30,61 @@ type Asynchronous interface { type Synchronous interface { synchronous() } + +// Option applies options to all instruments. +type Option interface { + Float64ObserverOption + Int64ObserverOption + Float64Option + Int64Option +} + +type descOpt string + +func (o descOpt) applyFloat64(c Float64Config) Float64Config { + c.description = string(o) + return c +} + +func (o descOpt) applyInt64(c Int64Config) Int64Config { + c.description = string(o) + return c +} + +func (o descOpt) applyFloat64Observer(c Float64ObserverConfig) Float64ObserverConfig { + c.description = string(o) + return c +} + +func (o descOpt) applyInt64Observer(c Int64ObserverConfig) Int64ObserverConfig { + c.description = string(o) + return c +} + +// WithDescription sets the instrument description. +func WithDescription(desc string) Option { return descOpt(desc) } + +type unitOpt unit.Unit + +func (o unitOpt) applyFloat64(c Float64Config) Float64Config { + c.unit = unit.Unit(o) + return c +} + +func (o unitOpt) applyInt64(c Int64Config) Int64Config { + c.unit = unit.Unit(o) + return c +} + +func (o unitOpt) applyFloat64Observer(c Float64ObserverConfig) Float64ObserverConfig { + c.unit = unit.Unit(o) + return c +} + +func (o unitOpt) applyInt64Observer(c Int64ObserverConfig) Int64ObserverConfig { + c.unit = unit.Unit(o) + return c +} + +// WithUnit sets the instrument unit. +func WithUnit(u unit.Unit) Option { return unitOpt(u) } diff --git a/vendor/go.opentelemetry.io/otel/metric/instrument/syncfloat64.go b/vendor/go.opentelemetry.io/otel/metric/instrument/syncfloat64.go new file mode 100644 index 000000000..d8f6ba9f4 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/metric/instrument/syncfloat64.go @@ -0,0 +1,86 @@ +// Copyright The OpenTelemetry 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. + +package instrument // import "go.opentelemetry.io/otel/metric/instrument" + +import ( + "context" + + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/metric/unit" +) + +// Float64Counter is an instrument that records increasing float64 values. +// +// Warning: methods may be added to this interface in minor releases. +type Float64Counter interface { + // Add records a change to the counter. + Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue) + + Synchronous +} + +// Float64UpDownCounter is an instrument that records increasing or decreasing +// float64 values. +// +// Warning: methods may be added to this interface in minor releases. +type Float64UpDownCounter interface { + // Add records a change to the counter. + Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue) + + Synchronous +} + +// Float64Histogram is an instrument that records a distribution of float64 +// values. +// +// Warning: methods may be added to this interface in minor releases. +type Float64Histogram interface { + // Record adds an additional value to the distribution. + Record(ctx context.Context, incr float64, attrs ...attribute.KeyValue) + + Synchronous +} + +// Float64Config contains options for Asynchronous instruments that +// observe float64 values. +type Float64Config struct { + description string + unit unit.Unit +} + +// Float64Config contains options for Synchronous instruments that record +// float64 values. +func NewFloat64Config(opts ...Float64Option) Float64Config { + var config Float64Config + for _, o := range opts { + config = o.applyFloat64(config) + } + return config +} + +// Description returns the Config description. +func (c Float64Config) Description() string { + return c.description +} + +// Unit returns the Config unit. +func (c Float64Config) Unit() unit.Unit { + return c.unit +} + +// Float64Option applies options to synchronous float64 instruments. +type Float64Option interface { + applyFloat64(Float64Config) Float64Config +} diff --git a/vendor/go.opentelemetry.io/otel/metric/instrument/syncfloat64/syncfloat64.go b/vendor/go.opentelemetry.io/otel/metric/instrument/syncfloat64/syncfloat64.go deleted file mode 100644 index 2ec192f70..000000000 --- a/vendor/go.opentelemetry.io/otel/metric/instrument/syncfloat64/syncfloat64.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright The OpenTelemetry 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. - -package syncfloat64 // import "go.opentelemetry.io/otel/metric/instrument/syncfloat64" - -import ( - "context" - - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/metric/instrument" -) - -// InstrumentProvider provides access to individual instruments. -// -// Warning: methods may be added to this interface in minor releases. -type InstrumentProvider interface { - // Counter creates an instrument for recording increasing values. - Counter(name string, opts ...instrument.Option) (Counter, error) - // UpDownCounter creates an instrument for recording changes of a value. - UpDownCounter(name string, opts ...instrument.Option) (UpDownCounter, error) - // Histogram creates an instrument for recording a distribution of values. - Histogram(name string, opts ...instrument.Option) (Histogram, error) -} - -// Counter is an instrument that records increasing values. -// -// Warning: methods may be added to this interface in minor releases. -type Counter interface { - // Add records a change to the counter. - Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue) - - instrument.Synchronous -} - -// UpDownCounter is an instrument that records increasing or decreasing values. -// -// Warning: methods may be added to this interface in minor releases. -type UpDownCounter interface { - // Add records a change to the counter. - Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue) - - instrument.Synchronous -} - -// Histogram is an instrument that records a distribution of values. -// -// Warning: methods may be added to this interface in minor releases. -type Histogram interface { - // Record adds an additional value to the distribution. - Record(ctx context.Context, incr float64, attrs ...attribute.KeyValue) - - instrument.Synchronous -} diff --git a/vendor/go.opentelemetry.io/otel/metric/instrument/syncint64/syncint64.go b/vendor/go.opentelemetry.io/otel/metric/instrument/syncint64.go similarity index 50% rename from vendor/go.opentelemetry.io/otel/metric/instrument/syncint64/syncint64.go rename to vendor/go.opentelemetry.io/otel/metric/instrument/syncint64.go index 03b5d53e6..96bf730e4 100644 --- a/vendor/go.opentelemetry.io/otel/metric/instrument/syncint64/syncint64.go +++ b/vendor/go.opentelemetry.io/otel/metric/instrument/syncint64.go @@ -12,53 +12,75 @@ // See the License for the specific language governing permissions and // limitations under the License. -package syncint64 // import "go.opentelemetry.io/otel/metric/instrument/syncint64" +package instrument // import "go.opentelemetry.io/otel/metric/instrument" import ( "context" "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/metric/instrument" + "go.opentelemetry.io/otel/metric/unit" ) -// InstrumentProvider provides access to individual instruments. +// Int64Counter is an instrument that records increasing int64 values. // // Warning: methods may be added to this interface in minor releases. -type InstrumentProvider interface { - // Counter creates an instrument for recording increasing values. - Counter(name string, opts ...instrument.Option) (Counter, error) - // UpDownCounter creates an instrument for recording changes of a value. - UpDownCounter(name string, opts ...instrument.Option) (UpDownCounter, error) - // Histogram creates an instrument for recording a distribution of values. - Histogram(name string, opts ...instrument.Option) (Histogram, error) -} - -// Counter is an instrument that records increasing values. -// -// Warning: methods may be added to this interface in minor releases. -type Counter interface { +type Int64Counter interface { // Add records a change to the counter. Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) - instrument.Synchronous + Synchronous } -// UpDownCounter is an instrument that records increasing or decreasing values. +// Int64UpDownCounter is an instrument that records increasing or decreasing +// int64 values. // // Warning: methods may be added to this interface in minor releases. -type UpDownCounter interface { +type Int64UpDownCounter interface { // Add records a change to the counter. Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) - instrument.Synchronous + Synchronous } -// Histogram is an instrument that records a distribution of values. +// Int64Histogram is an instrument that records a distribution of int64 +// values. // // Warning: methods may be added to this interface in minor releases. -type Histogram interface { +type Int64Histogram interface { // Record adds an additional value to the distribution. Record(ctx context.Context, incr int64, attrs ...attribute.KeyValue) - instrument.Synchronous + Synchronous +} + +// Int64Config contains options for Synchronous instruments that record int64 +// values. +type Int64Config struct { + description string + unit unit.Unit +} + +// NewInt64Config returns a new Int64Config with all opts +// applied. +func NewInt64Config(opts ...Int64Option) Int64Config { + var config Int64Config + for _, o := range opts { + config = o.applyInt64(config) + } + return config +} + +// Description returns the Config description. +func (c Int64Config) Description() string { + return c.description +} + +// Unit returns the Config unit. +func (c Int64Config) Unit() unit.Unit { + return c.unit +} + +// Int64Option applies options to synchronous int64 instruments. +type Int64Option interface { + applyInt64(Int64Config) Int64Config } diff --git a/vendor/go.opentelemetry.io/otel/metric/internal/global/instruments.go b/vendor/go.opentelemetry.io/otel/metric/internal/global/instruments.go index 7cce2bd15..d1480fa5f 100644 --- a/vendor/go.opentelemetry.io/otel/metric/internal/global/instruments.go +++ b/vendor/go.opentelemetry.io/otel/metric/internal/global/instruments.go @@ -22,23 +22,27 @@ import ( "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/instrument/asyncfloat64" - "go.opentelemetry.io/otel/metric/instrument/asyncint64" - "go.opentelemetry.io/otel/metric/instrument/syncfloat64" - "go.opentelemetry.io/otel/metric/instrument/syncint64" ) -type afCounter struct { - name string - opts []instrument.Option - - delegate atomic.Value //asyncfloat64.Counter - - instrument.Asynchronous +// unwrapper unwraps to return the underlying instrument implementation. +type unwrapper interface { + Unwrap() instrument.Asynchronous } +type afCounter struct { + instrument.Float64Observable + + name string + opts []instrument.Float64ObserverOption + + delegate atomic.Value //instrument.Float64ObservableCounter +} + +var _ unwrapper = (*afCounter)(nil) +var _ instrument.Float64ObservableCounter = (*afCounter)(nil) + func (i *afCounter) setDelegate(m metric.Meter) { - ctr, err := m.AsyncFloat64().Counter(i.name, i.opts...) + ctr, err := m.Float64ObservableCounter(i.name, i.opts...) if err != nil { otel.Handle(err) return @@ -46,30 +50,27 @@ func (i *afCounter) setDelegate(m metric.Meter) { i.delegate.Store(ctr) } -func (i *afCounter) Observe(ctx context.Context, x float64, attrs ...attribute.KeyValue) { +func (i *afCounter) Unwrap() instrument.Asynchronous { if ctr := i.delegate.Load(); ctr != nil { - ctr.(asyncfloat64.Counter).Observe(ctx, x, attrs...) - } -} - -func (i *afCounter) unwrap() instrument.Asynchronous { - if ctr := i.delegate.Load(); ctr != nil { - return ctr.(asyncfloat64.Counter) + return ctr.(instrument.Float64ObservableCounter) } return nil } type afUpDownCounter struct { + instrument.Float64Observable + name string - opts []instrument.Option + opts []instrument.Float64ObserverOption - delegate atomic.Value //asyncfloat64.UpDownCounter - - instrument.Asynchronous + delegate atomic.Value //instrument.Float64ObservableUpDownCounter } +var _ unwrapper = (*afUpDownCounter)(nil) +var _ instrument.Float64ObservableUpDownCounter = (*afUpDownCounter)(nil) + func (i *afUpDownCounter) setDelegate(m metric.Meter) { - ctr, err := m.AsyncFloat64().UpDownCounter(i.name, i.opts...) + ctr, err := m.Float64ObservableUpDownCounter(i.name, i.opts...) if err != nil { otel.Handle(err) return @@ -77,30 +78,27 @@ func (i *afUpDownCounter) setDelegate(m metric.Meter) { i.delegate.Store(ctr) } -func (i *afUpDownCounter) Observe(ctx context.Context, x float64, attrs ...attribute.KeyValue) { +func (i *afUpDownCounter) Unwrap() instrument.Asynchronous { if ctr := i.delegate.Load(); ctr != nil { - ctr.(asyncfloat64.UpDownCounter).Observe(ctx, x, attrs...) - } -} - -func (i *afUpDownCounter) unwrap() instrument.Asynchronous { - if ctr := i.delegate.Load(); ctr != nil { - return ctr.(asyncfloat64.UpDownCounter) + return ctr.(instrument.Float64ObservableUpDownCounter) } return nil } type afGauge struct { + instrument.Float64Observable + name string - opts []instrument.Option + opts []instrument.Float64ObserverOption - delegate atomic.Value //asyncfloat64.Gauge - - instrument.Asynchronous + delegate atomic.Value //instrument.Float64ObservableGauge } +var _ unwrapper = (*afGauge)(nil) +var _ instrument.Float64ObservableGauge = (*afGauge)(nil) + func (i *afGauge) setDelegate(m metric.Meter) { - ctr, err := m.AsyncFloat64().Gauge(i.name, i.opts...) + ctr, err := m.Float64ObservableGauge(i.name, i.opts...) if err != nil { otel.Handle(err) return @@ -108,30 +106,27 @@ func (i *afGauge) setDelegate(m metric.Meter) { i.delegate.Store(ctr) } -func (i *afGauge) Observe(ctx context.Context, x float64, attrs ...attribute.KeyValue) { +func (i *afGauge) Unwrap() instrument.Asynchronous { if ctr := i.delegate.Load(); ctr != nil { - ctr.(asyncfloat64.Gauge).Observe(ctx, x, attrs...) - } -} - -func (i *afGauge) unwrap() instrument.Asynchronous { - if ctr := i.delegate.Load(); ctr != nil { - return ctr.(asyncfloat64.Gauge) + return ctr.(instrument.Float64ObservableGauge) } return nil } type aiCounter struct { + instrument.Int64Observable + name string - opts []instrument.Option + opts []instrument.Int64ObserverOption - delegate atomic.Value //asyncint64.Counter - - instrument.Asynchronous + delegate atomic.Value //instrument.Int64ObservableCounter } +var _ unwrapper = (*aiCounter)(nil) +var _ instrument.Int64ObservableCounter = (*aiCounter)(nil) + func (i *aiCounter) setDelegate(m metric.Meter) { - ctr, err := m.AsyncInt64().Counter(i.name, i.opts...) + ctr, err := m.Int64ObservableCounter(i.name, i.opts...) if err != nil { otel.Handle(err) return @@ -139,30 +134,27 @@ func (i *aiCounter) setDelegate(m metric.Meter) { i.delegate.Store(ctr) } -func (i *aiCounter) Observe(ctx context.Context, x int64, attrs ...attribute.KeyValue) { +func (i *aiCounter) Unwrap() instrument.Asynchronous { if ctr := i.delegate.Load(); ctr != nil { - ctr.(asyncint64.Counter).Observe(ctx, x, attrs...) - } -} - -func (i *aiCounter) unwrap() instrument.Asynchronous { - if ctr := i.delegate.Load(); ctr != nil { - return ctr.(asyncint64.Counter) + return ctr.(instrument.Int64ObservableCounter) } return nil } type aiUpDownCounter struct { + instrument.Int64Observable + name string - opts []instrument.Option + opts []instrument.Int64ObserverOption - delegate atomic.Value //asyncint64.UpDownCounter - - instrument.Asynchronous + delegate atomic.Value //instrument.Int64ObservableUpDownCounter } +var _ unwrapper = (*aiUpDownCounter)(nil) +var _ instrument.Int64ObservableUpDownCounter = (*aiUpDownCounter)(nil) + func (i *aiUpDownCounter) setDelegate(m metric.Meter) { - ctr, err := m.AsyncInt64().UpDownCounter(i.name, i.opts...) + ctr, err := m.Int64ObservableUpDownCounter(i.name, i.opts...) if err != nil { otel.Handle(err) return @@ -170,30 +162,27 @@ func (i *aiUpDownCounter) setDelegate(m metric.Meter) { i.delegate.Store(ctr) } -func (i *aiUpDownCounter) Observe(ctx context.Context, x int64, attrs ...attribute.KeyValue) { +func (i *aiUpDownCounter) Unwrap() instrument.Asynchronous { if ctr := i.delegate.Load(); ctr != nil { - ctr.(asyncint64.UpDownCounter).Observe(ctx, x, attrs...) - } -} - -func (i *aiUpDownCounter) unwrap() instrument.Asynchronous { - if ctr := i.delegate.Load(); ctr != nil { - return ctr.(asyncint64.UpDownCounter) + return ctr.(instrument.Int64ObservableUpDownCounter) } return nil } type aiGauge struct { + instrument.Int64Observable + name string - opts []instrument.Option + opts []instrument.Int64ObserverOption - delegate atomic.Value //asyncint64.Gauge - - instrument.Asynchronous + delegate atomic.Value //instrument.Int64ObservableGauge } +var _ unwrapper = (*aiGauge)(nil) +var _ instrument.Int64ObservableGauge = (*aiGauge)(nil) + func (i *aiGauge) setDelegate(m metric.Meter) { - ctr, err := m.AsyncInt64().Gauge(i.name, i.opts...) + ctr, err := m.Int64ObservableGauge(i.name, i.opts...) if err != nil { otel.Handle(err) return @@ -201,15 +190,9 @@ func (i *aiGauge) setDelegate(m metric.Meter) { i.delegate.Store(ctr) } -func (i *aiGauge) Observe(ctx context.Context, x int64, attrs ...attribute.KeyValue) { +func (i *aiGauge) Unwrap() instrument.Asynchronous { if ctr := i.delegate.Load(); ctr != nil { - ctr.(asyncint64.Gauge).Observe(ctx, x, attrs...) - } -} - -func (i *aiGauge) unwrap() instrument.Asynchronous { - if ctr := i.delegate.Load(); ctr != nil { - return ctr.(asyncint64.Gauge) + return ctr.(instrument.Int64ObservableGauge) } return nil } @@ -217,15 +200,17 @@ func (i *aiGauge) unwrap() instrument.Asynchronous { // Sync Instruments. type sfCounter struct { name string - opts []instrument.Option + opts []instrument.Float64Option - delegate atomic.Value //syncfloat64.Counter + delegate atomic.Value //instrument.Float64Counter instrument.Synchronous } +var _ instrument.Float64Counter = (*sfCounter)(nil) + func (i *sfCounter) setDelegate(m metric.Meter) { - ctr, err := m.SyncFloat64().Counter(i.name, i.opts...) + ctr, err := m.Float64Counter(i.name, i.opts...) if err != nil { otel.Handle(err) return @@ -235,21 +220,23 @@ func (i *sfCounter) setDelegate(m metric.Meter) { func (i *sfCounter) Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue) { if ctr := i.delegate.Load(); ctr != nil { - ctr.(syncfloat64.Counter).Add(ctx, incr, attrs...) + ctr.(instrument.Float64Counter).Add(ctx, incr, attrs...) } } type sfUpDownCounter struct { name string - opts []instrument.Option + opts []instrument.Float64Option - delegate atomic.Value //syncfloat64.UpDownCounter + delegate atomic.Value //instrument.Float64UpDownCounter instrument.Synchronous } +var _ instrument.Float64UpDownCounter = (*sfUpDownCounter)(nil) + func (i *sfUpDownCounter) setDelegate(m metric.Meter) { - ctr, err := m.SyncFloat64().UpDownCounter(i.name, i.opts...) + ctr, err := m.Float64UpDownCounter(i.name, i.opts...) if err != nil { otel.Handle(err) return @@ -259,21 +246,23 @@ func (i *sfUpDownCounter) setDelegate(m metric.Meter) { func (i *sfUpDownCounter) Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue) { if ctr := i.delegate.Load(); ctr != nil { - ctr.(syncfloat64.UpDownCounter).Add(ctx, incr, attrs...) + ctr.(instrument.Float64UpDownCounter).Add(ctx, incr, attrs...) } } type sfHistogram struct { name string - opts []instrument.Option + opts []instrument.Float64Option - delegate atomic.Value //syncfloat64.Histogram + delegate atomic.Value //instrument.Float64Histogram instrument.Synchronous } +var _ instrument.Float64Histogram = (*sfHistogram)(nil) + func (i *sfHistogram) setDelegate(m metric.Meter) { - ctr, err := m.SyncFloat64().Histogram(i.name, i.opts...) + ctr, err := m.Float64Histogram(i.name, i.opts...) if err != nil { otel.Handle(err) return @@ -283,21 +272,23 @@ func (i *sfHistogram) setDelegate(m metric.Meter) { func (i *sfHistogram) Record(ctx context.Context, x float64, attrs ...attribute.KeyValue) { if ctr := i.delegate.Load(); ctr != nil { - ctr.(syncfloat64.Histogram).Record(ctx, x, attrs...) + ctr.(instrument.Float64Histogram).Record(ctx, x, attrs...) } } type siCounter struct { name string - opts []instrument.Option + opts []instrument.Int64Option - delegate atomic.Value //syncint64.Counter + delegate atomic.Value //instrument.Int64Counter instrument.Synchronous } +var _ instrument.Int64Counter = (*siCounter)(nil) + func (i *siCounter) setDelegate(m metric.Meter) { - ctr, err := m.SyncInt64().Counter(i.name, i.opts...) + ctr, err := m.Int64Counter(i.name, i.opts...) if err != nil { otel.Handle(err) return @@ -307,21 +298,23 @@ func (i *siCounter) setDelegate(m metric.Meter) { func (i *siCounter) Add(ctx context.Context, x int64, attrs ...attribute.KeyValue) { if ctr := i.delegate.Load(); ctr != nil { - ctr.(syncint64.Counter).Add(ctx, x, attrs...) + ctr.(instrument.Int64Counter).Add(ctx, x, attrs...) } } type siUpDownCounter struct { name string - opts []instrument.Option + opts []instrument.Int64Option - delegate atomic.Value //syncint64.UpDownCounter + delegate atomic.Value //instrument.Int64UpDownCounter instrument.Synchronous } +var _ instrument.Int64UpDownCounter = (*siUpDownCounter)(nil) + func (i *siUpDownCounter) setDelegate(m metric.Meter) { - ctr, err := m.SyncInt64().UpDownCounter(i.name, i.opts...) + ctr, err := m.Int64UpDownCounter(i.name, i.opts...) if err != nil { otel.Handle(err) return @@ -331,21 +324,23 @@ func (i *siUpDownCounter) setDelegate(m metric.Meter) { func (i *siUpDownCounter) Add(ctx context.Context, x int64, attrs ...attribute.KeyValue) { if ctr := i.delegate.Load(); ctr != nil { - ctr.(syncint64.UpDownCounter).Add(ctx, x, attrs...) + ctr.(instrument.Int64UpDownCounter).Add(ctx, x, attrs...) } } type siHistogram struct { name string - opts []instrument.Option + opts []instrument.Int64Option - delegate atomic.Value //syncint64.Histogram + delegate atomic.Value //instrument.Int64Histogram instrument.Synchronous } +var _ instrument.Int64Histogram = (*siHistogram)(nil) + func (i *siHistogram) setDelegate(m metric.Meter) { - ctr, err := m.SyncInt64().Histogram(i.name, i.opts...) + ctr, err := m.Int64Histogram(i.name, i.opts...) if err != nil { otel.Handle(err) return @@ -355,6 +350,6 @@ func (i *siHistogram) setDelegate(m metric.Meter) { func (i *siHistogram) Record(ctx context.Context, x int64, attrs ...attribute.KeyValue) { if ctr := i.delegate.Load(); ctr != nil { - ctr.(syncint64.Histogram).Record(ctx, x, attrs...) + ctr.(instrument.Int64Histogram).Record(ctx, x, attrs...) } } diff --git a/vendor/go.opentelemetry.io/otel/metric/internal/global/meter.go b/vendor/go.opentelemetry.io/otel/metric/internal/global/meter.go index 0fa924f39..8acf63286 100644 --- a/vendor/go.opentelemetry.io/otel/metric/internal/global/meter.go +++ b/vendor/go.opentelemetry.io/otel/metric/internal/global/meter.go @@ -15,17 +15,13 @@ package global // import "go.opentelemetry.io/otel/metric/internal/global" import ( - "context" + "container/list" "sync" "sync/atomic" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/instrument/asyncfloat64" - "go.opentelemetry.io/otel/metric/instrument/asyncint64" - "go.opentelemetry.io/otel/metric/instrument/syncfloat64" - "go.opentelemetry.io/otel/metric/instrument/syncint64" ) // meterProvider is a placeholder for a configured SDK MeterProvider. @@ -109,7 +105,8 @@ type meter struct { mtx sync.Mutex instruments []delegatedInstrument - callbacks []delegatedCallback + + registry list.List delegate atomic.Value // metric.Meter } @@ -135,52 +132,167 @@ func (m *meter) setDelegate(provider metric.MeterProvider) { inst.setDelegate(meter) } - for _, callback := range m.callbacks { - callback.setDelegate(meter) + for e := m.registry.Front(); e != nil; e = e.Next() { + r := e.Value.(*registration) + r.setDelegate(meter) + m.registry.Remove(e) } m.instruments = nil - m.callbacks = nil + m.registry.Init() } -// AsyncInt64 is the namespace for the Asynchronous Integer instruments. -// -// To Observe data with instruments it must be registered in a callback. -func (m *meter) AsyncInt64() asyncint64.InstrumentProvider { +func (m *meter) Int64Counter(name string, options ...instrument.Int64Option) (instrument.Int64Counter, error) { if del, ok := m.delegate.Load().(metric.Meter); ok { - return del.AsyncInt64() + return del.Int64Counter(name, options...) } - return (*aiInstProvider)(m) + m.mtx.Lock() + defer m.mtx.Unlock() + i := &siCounter{name: name, opts: options} + m.instruments = append(m.instruments, i) + return i, nil } -// AsyncFloat64 is the namespace for the Asynchronous Float instruments. -// -// To Observe data with instruments it must be registered in a callback. -func (m *meter) AsyncFloat64() asyncfloat64.InstrumentProvider { +func (m *meter) Int64UpDownCounter(name string, options ...instrument.Int64Option) (instrument.Int64UpDownCounter, error) { if del, ok := m.delegate.Load().(metric.Meter); ok { - return del.AsyncFloat64() + return del.Int64UpDownCounter(name, options...) } - return (*afInstProvider)(m) + m.mtx.Lock() + defer m.mtx.Unlock() + i := &siUpDownCounter{name: name, opts: options} + m.instruments = append(m.instruments, i) + return i, nil +} + +func (m *meter) Int64Histogram(name string, options ...instrument.Int64Option) (instrument.Int64Histogram, error) { + if del, ok := m.delegate.Load().(metric.Meter); ok { + return del.Int64Histogram(name, options...) + } + m.mtx.Lock() + defer m.mtx.Unlock() + i := &siHistogram{name: name, opts: options} + m.instruments = append(m.instruments, i) + return i, nil +} + +func (m *meter) Int64ObservableCounter(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableCounter, error) { + if del, ok := m.delegate.Load().(metric.Meter); ok { + return del.Int64ObservableCounter(name, options...) + } + m.mtx.Lock() + defer m.mtx.Unlock() + i := &aiCounter{name: name, opts: options} + m.instruments = append(m.instruments, i) + return i, nil +} + +func (m *meter) Int64ObservableUpDownCounter(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableUpDownCounter, error) { + if del, ok := m.delegate.Load().(metric.Meter); ok { + return del.Int64ObservableUpDownCounter(name, options...) + } + m.mtx.Lock() + defer m.mtx.Unlock() + i := &aiUpDownCounter{name: name, opts: options} + m.instruments = append(m.instruments, i) + return i, nil +} + +func (m *meter) Int64ObservableGauge(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableGauge, error) { + if del, ok := m.delegate.Load().(metric.Meter); ok { + return del.Int64ObservableGauge(name, options...) + } + m.mtx.Lock() + defer m.mtx.Unlock() + i := &aiGauge{name: name, opts: options} + m.instruments = append(m.instruments, i) + return i, nil +} + +func (m *meter) Float64Counter(name string, options ...instrument.Float64Option) (instrument.Float64Counter, error) { + if del, ok := m.delegate.Load().(metric.Meter); ok { + return del.Float64Counter(name, options...) + } + m.mtx.Lock() + defer m.mtx.Unlock() + i := &sfCounter{name: name, opts: options} + m.instruments = append(m.instruments, i) + return i, nil +} + +func (m *meter) Float64UpDownCounter(name string, options ...instrument.Float64Option) (instrument.Float64UpDownCounter, error) { + if del, ok := m.delegate.Load().(metric.Meter); ok { + return del.Float64UpDownCounter(name, options...) + } + m.mtx.Lock() + defer m.mtx.Unlock() + i := &sfUpDownCounter{name: name, opts: options} + m.instruments = append(m.instruments, i) + return i, nil +} + +func (m *meter) Float64Histogram(name string, options ...instrument.Float64Option) (instrument.Float64Histogram, error) { + if del, ok := m.delegate.Load().(metric.Meter); ok { + return del.Float64Histogram(name, options...) + } + m.mtx.Lock() + defer m.mtx.Unlock() + i := &sfHistogram{name: name, opts: options} + m.instruments = append(m.instruments, i) + return i, nil +} + +func (m *meter) Float64ObservableCounter(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableCounter, error) { + if del, ok := m.delegate.Load().(metric.Meter); ok { + return del.Float64ObservableCounter(name, options...) + } + m.mtx.Lock() + defer m.mtx.Unlock() + i := &afCounter{name: name, opts: options} + m.instruments = append(m.instruments, i) + return i, nil +} + +func (m *meter) Float64ObservableUpDownCounter(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableUpDownCounter, error) { + if del, ok := m.delegate.Load().(metric.Meter); ok { + return del.Float64ObservableUpDownCounter(name, options...) + } + m.mtx.Lock() + defer m.mtx.Unlock() + i := &afUpDownCounter{name: name, opts: options} + m.instruments = append(m.instruments, i) + return i, nil +} + +func (m *meter) Float64ObservableGauge(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableGauge, error) { + if del, ok := m.delegate.Load().(metric.Meter); ok { + return del.Float64ObservableGauge(name, options...) + } + m.mtx.Lock() + defer m.mtx.Unlock() + i := &afGauge{name: name, opts: options} + m.instruments = append(m.instruments, i) + return i, nil } // RegisterCallback captures the function that will be called during Collect. -// -// It is only valid to call Observe within the scope of the passed function, -// and only on the instruments that were registered with this call. -func (m *meter) RegisterCallback(insts []instrument.Asynchronous, function func(context.Context)) error { +func (m *meter) RegisterCallback(f metric.Callback, insts ...instrument.Asynchronous) (metric.Registration, error) { if del, ok := m.delegate.Load().(metric.Meter); ok { insts = unwrapInstruments(insts) - return del.RegisterCallback(insts, function) + return del.RegisterCallback(f, insts...) } m.mtx.Lock() defer m.mtx.Unlock() - m.callbacks = append(m.callbacks, delegatedCallback{ - instruments: insts, - function: function, - }) - return nil + reg := ®istration{instruments: insts, function: f} + e := m.registry.PushBack(reg) + reg.unreg = func() error { + m.mtx.Lock() + _ = m.registry.Remove(e) + m.mtx.Unlock() + return nil + } + return reg, nil } type wrapped interface { @@ -201,147 +313,42 @@ func unwrapInstruments(instruments []instrument.Asynchronous) []instrument.Async return out } -// SyncInt64 is the namespace for the Synchronous Integer instruments. -func (m *meter) SyncInt64() syncint64.InstrumentProvider { - if del, ok := m.delegate.Load().(metric.Meter); ok { - return del.SyncInt64() - } - return (*siInstProvider)(m) -} - -// SyncFloat64 is the namespace for the Synchronous Float instruments. -func (m *meter) SyncFloat64() syncfloat64.InstrumentProvider { - if del, ok := m.delegate.Load().(metric.Meter); ok { - return del.SyncFloat64() - } - return (*sfInstProvider)(m) -} - -type delegatedCallback struct { +type registration struct { instruments []instrument.Asynchronous - function func(context.Context) + function metric.Callback + + unreg func() error + unregMu sync.Mutex } -func (c *delegatedCallback) setDelegate(m metric.Meter) { +func (c *registration) setDelegate(m metric.Meter) { insts := unwrapInstruments(c.instruments) - err := m.RegisterCallback(insts, c.function) + + c.unregMu.Lock() + defer c.unregMu.Unlock() + + if c.unreg == nil { + // Unregister already called. + return + } + + reg, err := m.RegisterCallback(c.function, insts...) if err != nil { otel.Handle(err) } + + c.unreg = reg.Unregister } -type afInstProvider meter +func (c *registration) Unregister() error { + c.unregMu.Lock() + defer c.unregMu.Unlock() + if c.unreg == nil { + // Unregister already called. + return nil + } -// Counter creates an instrument for recording increasing values. -func (ip *afInstProvider) Counter(name string, opts ...instrument.Option) (asyncfloat64.Counter, error) { - ip.mtx.Lock() - defer ip.mtx.Unlock() - ctr := &afCounter{name: name, opts: opts} - ip.instruments = append(ip.instruments, ctr) - return ctr, nil -} - -// UpDownCounter creates an instrument for recording changes of a value. -func (ip *afInstProvider) UpDownCounter(name string, opts ...instrument.Option) (asyncfloat64.UpDownCounter, error) { - ip.mtx.Lock() - defer ip.mtx.Unlock() - ctr := &afUpDownCounter{name: name, opts: opts} - ip.instruments = append(ip.instruments, ctr) - return ctr, nil -} - -// Gauge creates an instrument for recording the current value. -func (ip *afInstProvider) Gauge(name string, opts ...instrument.Option) (asyncfloat64.Gauge, error) { - ip.mtx.Lock() - defer ip.mtx.Unlock() - ctr := &afGauge{name: name, opts: opts} - ip.instruments = append(ip.instruments, ctr) - return ctr, nil -} - -type aiInstProvider meter - -// Counter creates an instrument for recording increasing values. -func (ip *aiInstProvider) Counter(name string, opts ...instrument.Option) (asyncint64.Counter, error) { - ip.mtx.Lock() - defer ip.mtx.Unlock() - ctr := &aiCounter{name: name, opts: opts} - ip.instruments = append(ip.instruments, ctr) - return ctr, nil -} - -// UpDownCounter creates an instrument for recording changes of a value. -func (ip *aiInstProvider) UpDownCounter(name string, opts ...instrument.Option) (asyncint64.UpDownCounter, error) { - ip.mtx.Lock() - defer ip.mtx.Unlock() - ctr := &aiUpDownCounter{name: name, opts: opts} - ip.instruments = append(ip.instruments, ctr) - return ctr, nil -} - -// Gauge creates an instrument for recording the current value. -func (ip *aiInstProvider) Gauge(name string, opts ...instrument.Option) (asyncint64.Gauge, error) { - ip.mtx.Lock() - defer ip.mtx.Unlock() - ctr := &aiGauge{name: name, opts: opts} - ip.instruments = append(ip.instruments, ctr) - return ctr, nil -} - -type sfInstProvider meter - -// Counter creates an instrument for recording increasing values. -func (ip *sfInstProvider) Counter(name string, opts ...instrument.Option) (syncfloat64.Counter, error) { - ip.mtx.Lock() - defer ip.mtx.Unlock() - ctr := &sfCounter{name: name, opts: opts} - ip.instruments = append(ip.instruments, ctr) - return ctr, nil -} - -// UpDownCounter creates an instrument for recording changes of a value. -func (ip *sfInstProvider) UpDownCounter(name string, opts ...instrument.Option) (syncfloat64.UpDownCounter, error) { - ip.mtx.Lock() - defer ip.mtx.Unlock() - ctr := &sfUpDownCounter{name: name, opts: opts} - ip.instruments = append(ip.instruments, ctr) - return ctr, nil -} - -// Histogram creates an instrument for recording a distribution of values. -func (ip *sfInstProvider) Histogram(name string, opts ...instrument.Option) (syncfloat64.Histogram, error) { - ip.mtx.Lock() - defer ip.mtx.Unlock() - ctr := &sfHistogram{name: name, opts: opts} - ip.instruments = append(ip.instruments, ctr) - return ctr, nil -} - -type siInstProvider meter - -// Counter creates an instrument for recording increasing values. -func (ip *siInstProvider) Counter(name string, opts ...instrument.Option) (syncint64.Counter, error) { - ip.mtx.Lock() - defer ip.mtx.Unlock() - ctr := &siCounter{name: name, opts: opts} - ip.instruments = append(ip.instruments, ctr) - return ctr, nil -} - -// UpDownCounter creates an instrument for recording changes of a value. -func (ip *siInstProvider) UpDownCounter(name string, opts ...instrument.Option) (syncint64.UpDownCounter, error) { - ip.mtx.Lock() - defer ip.mtx.Unlock() - ctr := &siUpDownCounter{name: name, opts: opts} - ip.instruments = append(ip.instruments, ctr) - return ctr, nil -} - -// Histogram creates an instrument for recording a distribution of values. -func (ip *siInstProvider) Histogram(name string, opts ...instrument.Option) (syncint64.Histogram, error) { - ip.mtx.Lock() - defer ip.mtx.Unlock() - ctr := &siHistogram{name: name, opts: opts} - ip.instruments = append(ip.instruments, ctr) - return ctr, nil + var err error + err, c.unreg = c.unreg(), nil + return err } diff --git a/vendor/go.opentelemetry.io/otel/metric/meter.go b/vendor/go.opentelemetry.io/otel/metric/meter.go index 23e6853af..f1e917e93 100644 --- a/vendor/go.opentelemetry.io/otel/metric/meter.go +++ b/vendor/go.opentelemetry.io/otel/metric/meter.go @@ -17,11 +17,8 @@ package metric // import "go.opentelemetry.io/otel/metric" import ( "context" + "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/instrument/asyncfloat64" - "go.opentelemetry.io/otel/metric/instrument/asyncint64" - "go.opentelemetry.io/otel/metric/instrument/syncfloat64" - "go.opentelemetry.io/otel/metric/instrument/syncint64" ) // MeterProvider provides access to named Meter instances, for instrumenting @@ -41,24 +38,101 @@ type MeterProvider interface { // // Warning: methods may be added to this interface in minor releases. type Meter interface { - // AsyncInt64 is the namespace for the Asynchronous Integer instruments. - // - // To Observe data with instruments it must be registered in a callback. - AsyncInt64() asyncint64.InstrumentProvider + // Int64Counter returns a new instrument identified by name and configured + // with options. The instrument is used to synchronously record increasing + // int64 measurements during a computational operation. + Int64Counter(name string, options ...instrument.Int64Option) (instrument.Int64Counter, error) + // Int64UpDownCounter returns a new instrument identified by name and + // configured with options. The instrument is used to synchronously record + // int64 measurements during a computational operation. + Int64UpDownCounter(name string, options ...instrument.Int64Option) (instrument.Int64UpDownCounter, error) + // Int64Histogram returns a new instrument identified by name and + // configured with options. The instrument is used to synchronously record + // the distribution of int64 measurements during a computational operation. + Int64Histogram(name string, options ...instrument.Int64Option) (instrument.Int64Histogram, error) + // Int64ObservableCounter returns a new instrument identified by name and + // configured with options. The instrument is used to asynchronously record + // increasing int64 measurements once per a measurement collection cycle. + Int64ObservableCounter(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableCounter, error) + // Int64ObservableUpDownCounter returns a new instrument identified by name + // and configured with options. The instrument is used to asynchronously + // record int64 measurements once per a measurement collection cycle. + Int64ObservableUpDownCounter(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableUpDownCounter, error) + // Int64ObservableGauge returns a new instrument identified by name and + // configured with options. The instrument is used to asynchronously record + // instantaneous int64 measurements once per a measurement collection + // cycle. + Int64ObservableGauge(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableGauge, error) - // AsyncFloat64 is the namespace for the Asynchronous Float instruments - // - // To Observe data with instruments it must be registered in a callback. - AsyncFloat64() asyncfloat64.InstrumentProvider + // Float64Counter returns a new instrument identified by name and + // configured with options. The instrument is used to synchronously record + // increasing float64 measurements during a computational operation. + Float64Counter(name string, options ...instrument.Float64Option) (instrument.Float64Counter, error) + // Float64UpDownCounter returns a new instrument identified by name and + // configured with options. The instrument is used to synchronously record + // float64 measurements during a computational operation. + Float64UpDownCounter(name string, options ...instrument.Float64Option) (instrument.Float64UpDownCounter, error) + // Float64Histogram returns a new instrument identified by name and + // configured with options. The instrument is used to synchronously record + // the distribution of float64 measurements during a computational + // operation. + Float64Histogram(name string, options ...instrument.Float64Option) (instrument.Float64Histogram, error) + // Float64ObservableCounter returns a new instrument identified by name and + // configured with options. The instrument is used to asynchronously record + // increasing float64 measurements once per a measurement collection cycle. + Float64ObservableCounter(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableCounter, error) + // Float64ObservableUpDownCounter returns a new instrument identified by + // name and configured with options. The instrument is used to + // asynchronously record float64 measurements once per a measurement + // collection cycle. + Float64ObservableUpDownCounter(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableUpDownCounter, error) + // Float64ObservableGauge returns a new instrument identified by name and + // configured with options. The instrument is used to asynchronously record + // instantaneous float64 measurements once per a measurement collection + // cycle. + Float64ObservableGauge(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableGauge, error) - // RegisterCallback captures the function that will be called during Collect. + // RegisterCallback registers f to be called during the collection of a + // measurement cycle. // - // It is only valid to call Observe within the scope of the passed function, - // and only on the instruments that were registered with this call. - RegisterCallback(insts []instrument.Asynchronous, function func(context.Context)) error - - // SyncInt64 is the namespace for the Synchronous Integer instruments - SyncInt64() syncint64.InstrumentProvider - // SyncFloat64 is the namespace for the Synchronous Float instruments - SyncFloat64() syncfloat64.InstrumentProvider + // If Unregister of the returned Registration is called, f needs to be + // unregistered and not called during collection. + // + // The instruments f is registered with are the only instruments that f may + // observe values for. + // + // If no instruments are passed, f should not be registered nor called + // during collection. + RegisterCallback(f Callback, instruments ...instrument.Asynchronous) (Registration, error) +} + +// Callback is a function registered with a Meter that makes observations for +// the set of instruments it is registered with. The Observer parameter is used +// to record measurment observations for these instruments. +// +// The function needs to complete in a finite amount of time and the deadline +// of the passed context is expected to be honored. +// +// The function needs to make unique observations across all registered +// Callbacks. Meaning, it should not report measurements for an instrument with +// the same attributes as another Callback will report. +// +// The function needs to be concurrent safe. +type Callback func(context.Context, Observer) error + +// Observer records measurements for multiple instruments in a Callback. +type Observer interface { + // ObserveFloat64 records the float64 value with attributes for obsrv. + ObserveFloat64(obsrv instrument.Float64Observable, value float64, attributes ...attribute.KeyValue) + // ObserveInt64 records the int64 value with attributes for obsrv. + ObserveInt64(obsrv instrument.Int64Observable, value int64, attributes ...attribute.KeyValue) +} + +// Registration is an token representing the unique registration of a callback +// for a set of instruments with a Meter. +type Registration interface { + // Unregister removes the callback registration from a Meter. + // + // This method needs to be idempotent and concurrent safe. + Unregister() error } diff --git a/vendor/go.opentelemetry.io/otel/metric/noop.go b/vendor/go.opentelemetry.io/otel/metric/noop.go index e8b9a9a14..c586627ae 100644 --- a/vendor/go.opentelemetry.io/otel/metric/noop.go +++ b/vendor/go.opentelemetry.io/otel/metric/noop.go @@ -19,10 +19,6 @@ import ( "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/instrument/asyncfloat64" - "go.opentelemetry.io/otel/metric/instrument/asyncint64" - "go.opentelemetry.io/otel/metric/instrument/syncfloat64" - "go.opentelemetry.io/otel/metric/instrument/syncint64" ) // NewNoopMeterProvider creates a MeterProvider that does not record any metrics. @@ -43,104 +39,126 @@ func NewNoopMeter() Meter { type noopMeter struct{} -// AsyncInt64 creates an instrument that does not record any metrics. -func (noopMeter) AsyncInt64() asyncint64.InstrumentProvider { - return nonrecordingAsyncInt64Instrument{} +func (noopMeter) Int64Counter(string, ...instrument.Int64Option) (instrument.Int64Counter, error) { + return nonrecordingSyncInt64Instrument{}, nil } -// AsyncFloat64 creates an instrument that does not record any metrics. -func (noopMeter) AsyncFloat64() asyncfloat64.InstrumentProvider { - return nonrecordingAsyncFloat64Instrument{} +func (noopMeter) Int64UpDownCounter(string, ...instrument.Int64Option) (instrument.Int64UpDownCounter, error) { + return nonrecordingSyncInt64Instrument{}, nil } -// SyncInt64 creates an instrument that does not record any metrics. -func (noopMeter) SyncInt64() syncint64.InstrumentProvider { - return nonrecordingSyncInt64Instrument{} +func (noopMeter) Int64Histogram(string, ...instrument.Int64Option) (instrument.Int64Histogram, error) { + return nonrecordingSyncInt64Instrument{}, nil } -// SyncFloat64 creates an instrument that does not record any metrics. -func (noopMeter) SyncFloat64() syncfloat64.InstrumentProvider { - return nonrecordingSyncFloat64Instrument{} +func (noopMeter) Int64ObservableCounter(string, ...instrument.Int64ObserverOption) (instrument.Int64ObservableCounter, error) { + return nonrecordingAsyncInt64Instrument{}, nil +} + +func (noopMeter) Int64ObservableUpDownCounter(string, ...instrument.Int64ObserverOption) (instrument.Int64ObservableUpDownCounter, error) { + return nonrecordingAsyncInt64Instrument{}, nil +} + +func (noopMeter) Int64ObservableGauge(string, ...instrument.Int64ObserverOption) (instrument.Int64ObservableGauge, error) { + return nonrecordingAsyncInt64Instrument{}, nil +} + +func (noopMeter) Float64Counter(string, ...instrument.Float64Option) (instrument.Float64Counter, error) { + return nonrecordingSyncFloat64Instrument{}, nil +} + +func (noopMeter) Float64UpDownCounter(string, ...instrument.Float64Option) (instrument.Float64UpDownCounter, error) { + return nonrecordingSyncFloat64Instrument{}, nil +} + +func (noopMeter) Float64Histogram(string, ...instrument.Float64Option) (instrument.Float64Histogram, error) { + return nonrecordingSyncFloat64Instrument{}, nil +} + +func (noopMeter) Float64ObservableCounter(string, ...instrument.Float64ObserverOption) (instrument.Float64ObservableCounter, error) { + return nonrecordingAsyncFloat64Instrument{}, nil +} + +func (noopMeter) Float64ObservableUpDownCounter(string, ...instrument.Float64ObserverOption) (instrument.Float64ObservableUpDownCounter, error) { + return nonrecordingAsyncFloat64Instrument{}, nil +} + +func (noopMeter) Float64ObservableGauge(string, ...instrument.Float64ObserverOption) (instrument.Float64ObservableGauge, error) { + return nonrecordingAsyncFloat64Instrument{}, nil } // RegisterCallback creates a register callback that does not record any metrics. -func (noopMeter) RegisterCallback([]instrument.Asynchronous, func(context.Context)) error { - return nil +func (noopMeter) RegisterCallback(Callback, ...instrument.Asynchronous) (Registration, error) { + return noopReg{}, nil } +type noopReg struct{} + +func (noopReg) Unregister() error { return nil } + type nonrecordingAsyncFloat64Instrument struct { - instrument.Asynchronous + instrument.Float64Observable } var ( - _ asyncfloat64.InstrumentProvider = nonrecordingAsyncFloat64Instrument{} - _ asyncfloat64.Counter = nonrecordingAsyncFloat64Instrument{} - _ asyncfloat64.UpDownCounter = nonrecordingAsyncFloat64Instrument{} - _ asyncfloat64.Gauge = nonrecordingAsyncFloat64Instrument{} + _ instrument.Float64ObservableCounter = nonrecordingAsyncFloat64Instrument{} + _ instrument.Float64ObservableUpDownCounter = nonrecordingAsyncFloat64Instrument{} + _ instrument.Float64ObservableGauge = nonrecordingAsyncFloat64Instrument{} ) -func (n nonrecordingAsyncFloat64Instrument) Counter(string, ...instrument.Option) (asyncfloat64.Counter, error) { +func (n nonrecordingAsyncFloat64Instrument) Counter(string, ...instrument.Float64ObserverOption) (instrument.Float64ObservableCounter, error) { return n, nil } -func (n nonrecordingAsyncFloat64Instrument) UpDownCounter(string, ...instrument.Option) (asyncfloat64.UpDownCounter, error) { +func (n nonrecordingAsyncFloat64Instrument) UpDownCounter(string, ...instrument.Float64ObserverOption) (instrument.Float64ObservableUpDownCounter, error) { return n, nil } -func (n nonrecordingAsyncFloat64Instrument) Gauge(string, ...instrument.Option) (asyncfloat64.Gauge, error) { +func (n nonrecordingAsyncFloat64Instrument) Gauge(string, ...instrument.Float64ObserverOption) (instrument.Float64ObservableGauge, error) { return n, nil } -func (nonrecordingAsyncFloat64Instrument) Observe(context.Context, float64, ...attribute.KeyValue) { - -} - type nonrecordingAsyncInt64Instrument struct { - instrument.Asynchronous + instrument.Int64Observable } var ( - _ asyncint64.InstrumentProvider = nonrecordingAsyncInt64Instrument{} - _ asyncint64.Counter = nonrecordingAsyncInt64Instrument{} - _ asyncint64.UpDownCounter = nonrecordingAsyncInt64Instrument{} - _ asyncint64.Gauge = nonrecordingAsyncInt64Instrument{} + _ instrument.Int64ObservableCounter = nonrecordingAsyncInt64Instrument{} + _ instrument.Int64ObservableUpDownCounter = nonrecordingAsyncInt64Instrument{} + _ instrument.Int64ObservableGauge = nonrecordingAsyncInt64Instrument{} ) -func (n nonrecordingAsyncInt64Instrument) Counter(string, ...instrument.Option) (asyncint64.Counter, error) { +func (n nonrecordingAsyncInt64Instrument) Counter(string, ...instrument.Int64ObserverOption) (instrument.Int64ObservableCounter, error) { return n, nil } -func (n nonrecordingAsyncInt64Instrument) UpDownCounter(string, ...instrument.Option) (asyncint64.UpDownCounter, error) { +func (n nonrecordingAsyncInt64Instrument) UpDownCounter(string, ...instrument.Int64ObserverOption) (instrument.Int64ObservableUpDownCounter, error) { return n, nil } -func (n nonrecordingAsyncInt64Instrument) Gauge(string, ...instrument.Option) (asyncint64.Gauge, error) { +func (n nonrecordingAsyncInt64Instrument) Gauge(string, ...instrument.Int64ObserverOption) (instrument.Int64ObservableGauge, error) { return n, nil } -func (nonrecordingAsyncInt64Instrument) Observe(context.Context, int64, ...attribute.KeyValue) { -} - type nonrecordingSyncFloat64Instrument struct { instrument.Synchronous } var ( - _ syncfloat64.InstrumentProvider = nonrecordingSyncFloat64Instrument{} - _ syncfloat64.Counter = nonrecordingSyncFloat64Instrument{} - _ syncfloat64.UpDownCounter = nonrecordingSyncFloat64Instrument{} - _ syncfloat64.Histogram = nonrecordingSyncFloat64Instrument{} + _ instrument.Float64Counter = nonrecordingSyncFloat64Instrument{} + _ instrument.Float64UpDownCounter = nonrecordingSyncFloat64Instrument{} + _ instrument.Float64Histogram = nonrecordingSyncFloat64Instrument{} ) -func (n nonrecordingSyncFloat64Instrument) Counter(string, ...instrument.Option) (syncfloat64.Counter, error) { +func (n nonrecordingSyncFloat64Instrument) Counter(string, ...instrument.Float64Option) (instrument.Float64Counter, error) { return n, nil } -func (n nonrecordingSyncFloat64Instrument) UpDownCounter(string, ...instrument.Option) (syncfloat64.UpDownCounter, error) { +func (n nonrecordingSyncFloat64Instrument) UpDownCounter(string, ...instrument.Float64Option) (instrument.Float64UpDownCounter, error) { return n, nil } -func (n nonrecordingSyncFloat64Instrument) Histogram(string, ...instrument.Option) (syncfloat64.Histogram, error) { +func (n nonrecordingSyncFloat64Instrument) Histogram(string, ...instrument.Float64Option) (instrument.Float64Histogram, error) { return n, nil } @@ -157,21 +175,20 @@ type nonrecordingSyncInt64Instrument struct { } var ( - _ syncint64.InstrumentProvider = nonrecordingSyncInt64Instrument{} - _ syncint64.Counter = nonrecordingSyncInt64Instrument{} - _ syncint64.UpDownCounter = nonrecordingSyncInt64Instrument{} - _ syncint64.Histogram = nonrecordingSyncInt64Instrument{} + _ instrument.Int64Counter = nonrecordingSyncInt64Instrument{} + _ instrument.Int64UpDownCounter = nonrecordingSyncInt64Instrument{} + _ instrument.Int64Histogram = nonrecordingSyncInt64Instrument{} ) -func (n nonrecordingSyncInt64Instrument) Counter(string, ...instrument.Option) (syncint64.Counter, error) { +func (n nonrecordingSyncInt64Instrument) Counter(string, ...instrument.Int64Option) (instrument.Int64Counter, error) { return n, nil } -func (n nonrecordingSyncInt64Instrument) UpDownCounter(string, ...instrument.Option) (syncint64.UpDownCounter, error) { +func (n nonrecordingSyncInt64Instrument) UpDownCounter(string, ...instrument.Int64Option) (instrument.Int64UpDownCounter, error) { return n, nil } -func (n nonrecordingSyncInt64Instrument) Histogram(string, ...instrument.Option) (syncint64.Histogram, error) { +func (n nonrecordingSyncInt64Instrument) Histogram(string, ...instrument.Int64Option) (instrument.Int64Histogram, error) { return n, nil } diff --git a/vendor/go.opentelemetry.io/otel/semconv/internal/http.go b/vendor/go.opentelemetry.io/otel/semconv/internal/http.go deleted file mode 100644 index b580eedef..000000000 --- a/vendor/go.opentelemetry.io/otel/semconv/internal/http.go +++ /dev/null @@ -1,336 +0,0 @@ -// Copyright The OpenTelemetry 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. - -package internal // import "go.opentelemetry.io/otel/semconv/internal" - -import ( - "fmt" - "net" - "net/http" - "strconv" - "strings" - - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/codes" - "go.opentelemetry.io/otel/trace" -) - -// SemanticConventions are the semantic convention values defined for a -// version of the OpenTelemetry specification. -type SemanticConventions struct { - EnduserIDKey attribute.Key - HTTPClientIPKey attribute.Key - HTTPFlavorKey attribute.Key - HTTPHostKey attribute.Key - HTTPMethodKey attribute.Key - HTTPRequestContentLengthKey attribute.Key - HTTPRouteKey attribute.Key - HTTPSchemeHTTP attribute.KeyValue - HTTPSchemeHTTPS attribute.KeyValue - HTTPServerNameKey attribute.Key - HTTPStatusCodeKey attribute.Key - HTTPTargetKey attribute.Key - HTTPURLKey attribute.Key - HTTPUserAgentKey attribute.Key - NetHostIPKey attribute.Key - NetHostNameKey attribute.Key - NetHostPortKey attribute.Key - NetPeerIPKey attribute.Key - NetPeerNameKey attribute.Key - NetPeerPortKey attribute.Key - NetTransportIP attribute.KeyValue - NetTransportOther attribute.KeyValue - NetTransportTCP attribute.KeyValue - NetTransportUDP attribute.KeyValue - NetTransportUnix attribute.KeyValue -} - -// NetAttributesFromHTTPRequest generates attributes of the net -// namespace as specified by the OpenTelemetry specification for a -// span. The network parameter is a string that net.Dial function -// from standard library can understand. -func (sc *SemanticConventions) NetAttributesFromHTTPRequest(network string, request *http.Request) []attribute.KeyValue { - attrs := []attribute.KeyValue{} - - switch network { - case "tcp", "tcp4", "tcp6": - attrs = append(attrs, sc.NetTransportTCP) - case "udp", "udp4", "udp6": - attrs = append(attrs, sc.NetTransportUDP) - case "ip", "ip4", "ip6": - attrs = append(attrs, sc.NetTransportIP) - case "unix", "unixgram", "unixpacket": - attrs = append(attrs, sc.NetTransportUnix) - default: - attrs = append(attrs, sc.NetTransportOther) - } - - peerIP, peerName, peerPort := hostIPNamePort(request.RemoteAddr) - if peerIP != "" { - attrs = append(attrs, sc.NetPeerIPKey.String(peerIP)) - } - if peerName != "" { - attrs = append(attrs, sc.NetPeerNameKey.String(peerName)) - } - if peerPort != 0 { - attrs = append(attrs, sc.NetPeerPortKey.Int(peerPort)) - } - - hostIP, hostName, hostPort := "", "", 0 - for _, someHost := range []string{request.Host, request.Header.Get("Host"), request.URL.Host} { - hostIP, hostName, hostPort = hostIPNamePort(someHost) - if hostIP != "" || hostName != "" || hostPort != 0 { - break - } - } - if hostIP != "" { - attrs = append(attrs, sc.NetHostIPKey.String(hostIP)) - } - if hostName != "" { - attrs = append(attrs, sc.NetHostNameKey.String(hostName)) - } - if hostPort != 0 { - attrs = append(attrs, sc.NetHostPortKey.Int(hostPort)) - } - - return attrs -} - -// hostIPNamePort extracts the IP address, name and (optional) port from hostWithPort. -// It handles both IPv4 and IPv6 addresses. If the host portion is not recognized -// as a valid IPv4 or IPv6 address, the `ip` result will be empty and the -// host portion will instead be returned in `name`. -func hostIPNamePort(hostWithPort string) (ip string, name string, port int) { - var ( - hostPart, portPart string - parsedPort uint64 - err error - ) - if hostPart, portPart, err = net.SplitHostPort(hostWithPort); err != nil { - hostPart, portPart = hostWithPort, "" - } - if parsedIP := net.ParseIP(hostPart); parsedIP != nil { - ip = parsedIP.String() - } else { - name = hostPart - } - if parsedPort, err = strconv.ParseUint(portPart, 10, 16); err == nil { - port = int(parsedPort) - } - return -} - -// EndUserAttributesFromHTTPRequest generates attributes of the -// enduser namespace as specified by the OpenTelemetry specification -// for a span. -func (sc *SemanticConventions) EndUserAttributesFromHTTPRequest(request *http.Request) []attribute.KeyValue { - if username, _, ok := request.BasicAuth(); ok { - return []attribute.KeyValue{sc.EnduserIDKey.String(username)} - } - return nil -} - -// HTTPClientAttributesFromHTTPRequest generates attributes of the -// http namespace as specified by the OpenTelemetry specification for -// a span on the client side. -func (sc *SemanticConventions) HTTPClientAttributesFromHTTPRequest(request *http.Request) []attribute.KeyValue { - attrs := []attribute.KeyValue{} - - // remove any username/password info that may be in the URL - // before adding it to the attributes - userinfo := request.URL.User - request.URL.User = nil - - attrs = append(attrs, sc.HTTPURLKey.String(request.URL.String())) - - // restore any username/password info that was removed - request.URL.User = userinfo - - return append(attrs, sc.httpCommonAttributesFromHTTPRequest(request)...) -} - -func (sc *SemanticConventions) httpCommonAttributesFromHTTPRequest(request *http.Request) []attribute.KeyValue { - attrs := []attribute.KeyValue{} - if ua := request.UserAgent(); ua != "" { - attrs = append(attrs, sc.HTTPUserAgentKey.String(ua)) - } - if request.ContentLength > 0 { - attrs = append(attrs, sc.HTTPRequestContentLengthKey.Int64(request.ContentLength)) - } - - return append(attrs, sc.httpBasicAttributesFromHTTPRequest(request)...) -} - -func (sc *SemanticConventions) httpBasicAttributesFromHTTPRequest(request *http.Request) []attribute.KeyValue { - // as these attributes are used by HTTPServerMetricAttributesFromHTTPRequest, they should be low-cardinality - attrs := []attribute.KeyValue{} - - if request.TLS != nil { - attrs = append(attrs, sc.HTTPSchemeHTTPS) - } else { - attrs = append(attrs, sc.HTTPSchemeHTTP) - } - - if request.Host != "" { - attrs = append(attrs, sc.HTTPHostKey.String(request.Host)) - } else if request.URL != nil && request.URL.Host != "" { - attrs = append(attrs, sc.HTTPHostKey.String(request.URL.Host)) - } - - flavor := "" - if request.ProtoMajor == 1 { - flavor = fmt.Sprintf("1.%d", request.ProtoMinor) - } else if request.ProtoMajor == 2 { - flavor = "2" - } - if flavor != "" { - attrs = append(attrs, sc.HTTPFlavorKey.String(flavor)) - } - - if request.Method != "" { - attrs = append(attrs, sc.HTTPMethodKey.String(request.Method)) - } else { - attrs = append(attrs, sc.HTTPMethodKey.String(http.MethodGet)) - } - - return attrs -} - -// HTTPServerMetricAttributesFromHTTPRequest generates low-cardinality attributes -// to be used with server-side HTTP metrics. -func (sc *SemanticConventions) HTTPServerMetricAttributesFromHTTPRequest(serverName string, request *http.Request) []attribute.KeyValue { - attrs := []attribute.KeyValue{} - if serverName != "" { - attrs = append(attrs, sc.HTTPServerNameKey.String(serverName)) - } - return append(attrs, sc.httpBasicAttributesFromHTTPRequest(request)...) -} - -// HTTPServerAttributesFromHTTPRequest generates attributes of the -// http namespace as specified by the OpenTelemetry specification for -// a span on the server side. Currently, only basic authentication is -// supported. -func (sc *SemanticConventions) HTTPServerAttributesFromHTTPRequest(serverName, route string, request *http.Request) []attribute.KeyValue { - attrs := []attribute.KeyValue{ - sc.HTTPTargetKey.String(request.RequestURI), - } - - if serverName != "" { - attrs = append(attrs, sc.HTTPServerNameKey.String(serverName)) - } - if route != "" { - attrs = append(attrs, sc.HTTPRouteKey.String(route)) - } - if values, ok := request.Header["X-Forwarded-For"]; ok && len(values) > 0 { - if addresses := strings.SplitN(values[0], ",", 2); len(addresses) > 0 { - attrs = append(attrs, sc.HTTPClientIPKey.String(addresses[0])) - } - } - - return append(attrs, sc.httpCommonAttributesFromHTTPRequest(request)...) -} - -// HTTPAttributesFromHTTPStatusCode generates attributes of the http -// namespace as specified by the OpenTelemetry specification for a -// span. -func (sc *SemanticConventions) HTTPAttributesFromHTTPStatusCode(code int) []attribute.KeyValue { - attrs := []attribute.KeyValue{ - sc.HTTPStatusCodeKey.Int(code), - } - return attrs -} - -type codeRange struct { - fromInclusive int - toInclusive int -} - -func (r codeRange) contains(code int) bool { - return r.fromInclusive <= code && code <= r.toInclusive -} - -var validRangesPerCategory = map[int][]codeRange{ - 1: { - {http.StatusContinue, http.StatusEarlyHints}, - }, - 2: { - {http.StatusOK, http.StatusAlreadyReported}, - {http.StatusIMUsed, http.StatusIMUsed}, - }, - 3: { - {http.StatusMultipleChoices, http.StatusUseProxy}, - {http.StatusTemporaryRedirect, http.StatusPermanentRedirect}, - }, - 4: { - {http.StatusBadRequest, http.StatusTeapot}, // yes, teapot is so useful… - {http.StatusMisdirectedRequest, http.StatusUpgradeRequired}, - {http.StatusPreconditionRequired, http.StatusTooManyRequests}, - {http.StatusRequestHeaderFieldsTooLarge, http.StatusRequestHeaderFieldsTooLarge}, - {http.StatusUnavailableForLegalReasons, http.StatusUnavailableForLegalReasons}, - }, - 5: { - {http.StatusInternalServerError, http.StatusLoopDetected}, - {http.StatusNotExtended, http.StatusNetworkAuthenticationRequired}, - }, -} - -// SpanStatusFromHTTPStatusCode generates a status code and a message -// as specified by the OpenTelemetry specification for a span. -func SpanStatusFromHTTPStatusCode(code int) (codes.Code, string) { - spanCode, valid := validateHTTPStatusCode(code) - if !valid { - return spanCode, fmt.Sprintf("Invalid HTTP status code %d", code) - } - return spanCode, "" -} - -// SpanStatusFromHTTPStatusCodeAndSpanKind generates a status code and a message -// as specified by the OpenTelemetry specification for a span. -// Exclude 4xx for SERVER to set the appropriate status. -func SpanStatusFromHTTPStatusCodeAndSpanKind(code int, spanKind trace.SpanKind) (codes.Code, string) { - spanCode, valid := validateHTTPStatusCode(code) - if !valid { - return spanCode, fmt.Sprintf("Invalid HTTP status code %d", code) - } - category := code / 100 - if spanKind == trace.SpanKindServer && category == 4 { - return codes.Unset, "" - } - return spanCode, "" -} - -// validateHTTPStatusCode validates the HTTP status code and returns -// corresponding span status code. If the `code` is not a valid HTTP status -// code, returns span status Error and false. -func validateHTTPStatusCode(code int) (codes.Code, bool) { - category := code / 100 - ranges, ok := validRangesPerCategory[category] - if !ok { - return codes.Error, false - } - ok = false - for _, crange := range ranges { - ok = crange.contains(code) - if ok { - break - } - } - if !ok { - return codes.Error, false - } - if category > 0 && category < 4 { - return codes.Unset, true - } - return codes.Error, true -} diff --git a/vendor/go.opentelemetry.io/otel/semconv/internal/v2/http.go b/vendor/go.opentelemetry.io/otel/semconv/internal/v2/http.go new file mode 100644 index 000000000..c7c47fa88 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/semconv/internal/v2/http.go @@ -0,0 +1,405 @@ +// Copyright The OpenTelemetry 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. + +package internal // import "go.opentelemetry.io/otel/semconv/internal/v2" + +import ( + "fmt" + "net/http" + "strings" + + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" +) + +// HTTPConv are the HTTP semantic convention attributes defined for a version +// of the OpenTelemetry specification. +type HTTPConv struct { + NetConv *NetConv + + EnduserIDKey attribute.Key + HTTPClientIPKey attribute.Key + HTTPFlavorKey attribute.Key + HTTPMethodKey attribute.Key + HTTPRequestContentLengthKey attribute.Key + HTTPResponseContentLengthKey attribute.Key + HTTPRouteKey attribute.Key + HTTPSchemeHTTP attribute.KeyValue + HTTPSchemeHTTPS attribute.KeyValue + HTTPStatusCodeKey attribute.Key + HTTPTargetKey attribute.Key + HTTPURLKey attribute.Key + HTTPUserAgentKey attribute.Key +} + +// ClientResponse returns attributes for an HTTP response received by a client +// from a server. The following attributes are returned if the related values +// are defined in resp: "http.status.code", "http.response_content_length". +// +// This does not add all OpenTelemetry required attributes for an HTTP event, +// it assumes ClientRequest was used to create the span with a complete set of +// attributes. If a complete set of attributes can be generated using the +// request contained in resp. For example: +// +// append(ClientResponse(resp), ClientRequest(resp.Request)...) +func (c *HTTPConv) ClientResponse(resp *http.Response) []attribute.KeyValue { + var n int + if resp.StatusCode > 0 { + n++ + } + if resp.ContentLength > 0 { + n++ + } + + attrs := make([]attribute.KeyValue, 0, n) + if resp.StatusCode > 0 { + attrs = append(attrs, c.HTTPStatusCodeKey.Int(resp.StatusCode)) + } + if resp.ContentLength > 0 { + attrs = append(attrs, c.HTTPResponseContentLengthKey.Int(int(resp.ContentLength))) + } + return attrs +} + +// ClientRequest returns attributes for an HTTP request made by a client. The +// following attributes are always returned: "http.url", "http.flavor", +// "http.method", "net.peer.name". The following attributes are returned if the +// related values are defined in req: "net.peer.port", "http.user_agent", +// "http.request_content_length", "enduser.id". +func (c *HTTPConv) ClientRequest(req *http.Request) []attribute.KeyValue { + n := 3 // URL, peer name, proto, and method. + var h string + if req.URL != nil { + h = req.URL.Host + } + peer, p := firstHostPort(h, req.Header.Get("Host")) + port := requiredHTTPPort(req.URL != nil && req.URL.Scheme == "https", p) + if port > 0 { + n++ + } + useragent := req.UserAgent() + if useragent != "" { + n++ + } + if req.ContentLength > 0 { + n++ + } + userID, _, hasUserID := req.BasicAuth() + if hasUserID { + n++ + } + attrs := make([]attribute.KeyValue, 0, n) + + attrs = append(attrs, c.method(req.Method)) + attrs = append(attrs, c.proto(req.Proto)) + + var u string + if req.URL != nil { + // Remove any username/password info that may be in the URL. + userinfo := req.URL.User + req.URL.User = nil + u = req.URL.String() + // Restore any username/password info that was removed. + req.URL.User = userinfo + } + attrs = append(attrs, c.HTTPURLKey.String(u)) + + attrs = append(attrs, c.NetConv.PeerName(peer)) + if port > 0 { + attrs = append(attrs, c.NetConv.PeerPort(port)) + } + + if useragent != "" { + attrs = append(attrs, c.HTTPUserAgentKey.String(useragent)) + } + + if l := req.ContentLength; l > 0 { + attrs = append(attrs, c.HTTPRequestContentLengthKey.Int64(l)) + } + + if hasUserID { + attrs = append(attrs, c.EnduserIDKey.String(userID)) + } + + return attrs +} + +// ServerRequest returns attributes for an HTTP request received by a server. +// +// The server must be the primary server name if it is known. For example this +// would be the ServerName directive +// (https://httpd.apache.org/docs/2.4/mod/core.html#servername) for an Apache +// server, and the server_name directive +// (http://nginx.org/en/docs/http/ngx_http_core_module.html#server_name) for an +// nginx server. More generically, the primary server name would be the host +// header value that matches the default virtual host of an HTTP server. It +// should include the host identifier and if a port is used to route to the +// server that port identifier should be included as an appropriate port +// suffix. +// +// If the primary server name is not known, server should be an empty string. +// The req Host will be used to determine the server instead. +// +// The following attributes are always returned: "http.method", "http.scheme", +// "http.flavor", "http.target", "net.host.name". The following attributes are +// returned if they related values are defined in req: "net.host.port", +// "net.sock.peer.addr", "net.sock.peer.port", "http.user_agent", "enduser.id", +// "http.client_ip". +func (c *HTTPConv) ServerRequest(server string, req *http.Request) []attribute.KeyValue { + n := 5 // Method, scheme, target, proto, and host name. + var host string + var p int + if server == "" { + host, p = splitHostPort(req.Host) + } else { + // Prioritize the primary server name. + host, p = splitHostPort(server) + if p < 0 { + _, p = splitHostPort(req.Host) + } + } + hostPort := requiredHTTPPort(req.TLS != nil, p) + if hostPort > 0 { + n++ + } + peer, peerPort := splitHostPort(req.RemoteAddr) + if peer != "" { + n++ + if peerPort > 0 { + n++ + } + } + useragent := req.UserAgent() + if useragent != "" { + n++ + } + userID, _, hasUserID := req.BasicAuth() + if hasUserID { + n++ + } + clientIP := serverClientIP(req.Header.Get("X-Forwarded-For")) + if clientIP != "" { + n++ + } + attrs := make([]attribute.KeyValue, 0, n) + + attrs = append(attrs, c.method(req.Method)) + attrs = append(attrs, c.scheme(req.TLS != nil)) + attrs = append(attrs, c.proto(req.Proto)) + attrs = append(attrs, c.NetConv.HostName(host)) + + if req.URL != nil { + attrs = append(attrs, c.HTTPTargetKey.String(req.URL.RequestURI())) + } else { + // This should never occur if the request was generated by the net/http + // package. Fail gracefully, if it does though. + attrs = append(attrs, c.HTTPTargetKey.String(req.RequestURI)) + } + + if hostPort > 0 { + attrs = append(attrs, c.NetConv.HostPort(hostPort)) + } + + if peer != "" { + // The Go HTTP server sets RemoteAddr to "IP:port", this will not be a + // file-path that would be interpreted with a sock family. + attrs = append(attrs, c.NetConv.SockPeerAddr(peer)) + if peerPort > 0 { + attrs = append(attrs, c.NetConv.SockPeerPort(peerPort)) + } + } + + if useragent != "" { + attrs = append(attrs, c.HTTPUserAgentKey.String(useragent)) + } + + if hasUserID { + attrs = append(attrs, c.EnduserIDKey.String(userID)) + } + + if clientIP != "" { + attrs = append(attrs, c.HTTPClientIPKey.String(clientIP)) + } + + return attrs +} + +func (c *HTTPConv) method(method string) attribute.KeyValue { + if method == "" { + return c.HTTPMethodKey.String(http.MethodGet) + } + return c.HTTPMethodKey.String(method) +} + +func (c *HTTPConv) scheme(https bool) attribute.KeyValue { // nolint:revive + if https { + return c.HTTPSchemeHTTPS + } + return c.HTTPSchemeHTTP +} + +func (c *HTTPConv) proto(proto string) attribute.KeyValue { + switch proto { + case "HTTP/1.0": + return c.HTTPFlavorKey.String("1.0") + case "HTTP/1.1": + return c.HTTPFlavorKey.String("1.1") + case "HTTP/2": + return c.HTTPFlavorKey.String("2.0") + case "HTTP/3": + return c.HTTPFlavorKey.String("3.0") + default: + return c.HTTPFlavorKey.String(proto) + } +} + +func serverClientIP(xForwardedFor string) string { + if idx := strings.Index(xForwardedFor, ","); idx >= 0 { + xForwardedFor = xForwardedFor[:idx] + } + return xForwardedFor +} + +func requiredHTTPPort(https bool, port int) int { // nolint:revive + if https { + if port > 0 && port != 443 { + return port + } + } else { + if port > 0 && port != 80 { + return port + } + } + return -1 +} + +// Return the request host and port from the first non-empty source. +func firstHostPort(source ...string) (host string, port int) { + for _, hostport := range source { + host, port = splitHostPort(hostport) + if host != "" || port > 0 { + break + } + } + return +} + +// RequestHeader returns the contents of h as OpenTelemetry attributes. +func (c *HTTPConv) RequestHeader(h http.Header) []attribute.KeyValue { + return c.header("http.request.header", h) +} + +// ResponseHeader returns the contents of h as OpenTelemetry attributes. +func (c *HTTPConv) ResponseHeader(h http.Header) []attribute.KeyValue { + return c.header("http.response.header", h) +} + +func (c *HTTPConv) header(prefix string, h http.Header) []attribute.KeyValue { + key := func(k string) attribute.Key { + k = strings.ToLower(k) + k = strings.ReplaceAll(k, "-", "_") + k = fmt.Sprintf("%s.%s", prefix, k) + return attribute.Key(k) + } + + attrs := make([]attribute.KeyValue, 0, len(h)) + for k, v := range h { + attrs = append(attrs, key(k).StringSlice(v)) + } + return attrs +} + +// ClientStatus returns a span status code and message for an HTTP status code +// value received by a client. +func (c *HTTPConv) ClientStatus(code int) (codes.Code, string) { + stat, valid := validateHTTPStatusCode(code) + if !valid { + return stat, fmt.Sprintf("Invalid HTTP status code %d", code) + } + return stat, "" +} + +// ServerStatus returns a span status code and message for an HTTP status code +// value returned by a server. Status codes in the 400-499 range are not +// returned as errors. +func (c *HTTPConv) ServerStatus(code int) (codes.Code, string) { + stat, valid := validateHTTPStatusCode(code) + if !valid { + return stat, fmt.Sprintf("Invalid HTTP status code %d", code) + } + + if code/100 == 4 { + return codes.Unset, "" + } + return stat, "" +} + +type codeRange struct { + fromInclusive int + toInclusive int +} + +func (r codeRange) contains(code int) bool { + return r.fromInclusive <= code && code <= r.toInclusive +} + +var validRangesPerCategory = map[int][]codeRange{ + 1: { + {http.StatusContinue, http.StatusEarlyHints}, + }, + 2: { + {http.StatusOK, http.StatusAlreadyReported}, + {http.StatusIMUsed, http.StatusIMUsed}, + }, + 3: { + {http.StatusMultipleChoices, http.StatusUseProxy}, + {http.StatusTemporaryRedirect, http.StatusPermanentRedirect}, + }, + 4: { + {http.StatusBadRequest, http.StatusTeapot}, // yes, teapot is so useful… + {http.StatusMisdirectedRequest, http.StatusUpgradeRequired}, + {http.StatusPreconditionRequired, http.StatusTooManyRequests}, + {http.StatusRequestHeaderFieldsTooLarge, http.StatusRequestHeaderFieldsTooLarge}, + {http.StatusUnavailableForLegalReasons, http.StatusUnavailableForLegalReasons}, + }, + 5: { + {http.StatusInternalServerError, http.StatusLoopDetected}, + {http.StatusNotExtended, http.StatusNetworkAuthenticationRequired}, + }, +} + +// validateHTTPStatusCode validates the HTTP status code and returns +// corresponding span status code. If the `code` is not a valid HTTP status +// code, returns span status Error and false. +func validateHTTPStatusCode(code int) (codes.Code, bool) { + category := code / 100 + ranges, ok := validRangesPerCategory[category] + if !ok { + return codes.Error, false + } + ok = false + for _, crange := range ranges { + ok = crange.contains(code) + if ok { + break + } + } + if !ok { + return codes.Error, false + } + if category > 0 && category < 4 { + return codes.Unset, true + } + return codes.Error, true +} diff --git a/vendor/go.opentelemetry.io/otel/semconv/internal/v2/net.go b/vendor/go.opentelemetry.io/otel/semconv/internal/v2/net.go new file mode 100644 index 000000000..4a711133a --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/semconv/internal/v2/net.go @@ -0,0 +1,324 @@ +// Copyright The OpenTelemetry 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. + +package internal // import "go.opentelemetry.io/otel/semconv/internal/v2" + +import ( + "net" + "strconv" + "strings" + + "go.opentelemetry.io/otel/attribute" +) + +// NetConv are the network semantic convention attributes defined for a version +// of the OpenTelemetry specification. +type NetConv struct { + NetHostNameKey attribute.Key + NetHostPortKey attribute.Key + NetPeerNameKey attribute.Key + NetPeerPortKey attribute.Key + NetSockFamilyKey attribute.Key + NetSockPeerAddrKey attribute.Key + NetSockPeerPortKey attribute.Key + NetSockHostAddrKey attribute.Key + NetSockHostPortKey attribute.Key + NetTransportOther attribute.KeyValue + NetTransportTCP attribute.KeyValue + NetTransportUDP attribute.KeyValue + NetTransportInProc attribute.KeyValue +} + +func (c *NetConv) Transport(network string) attribute.KeyValue { + switch network { + case "tcp", "tcp4", "tcp6": + return c.NetTransportTCP + case "udp", "udp4", "udp6": + return c.NetTransportUDP + case "unix", "unixgram", "unixpacket": + return c.NetTransportInProc + default: + // "ip:*", "ip4:*", and "ip6:*" all are considered other. + return c.NetTransportOther + } +} + +// Host returns attributes for a network host address. +func (c *NetConv) Host(address string) []attribute.KeyValue { + h, p := splitHostPort(address) + var n int + if h != "" { + n++ + if p > 0 { + n++ + } + } + + if n == 0 { + return nil + } + + attrs := make([]attribute.KeyValue, 0, n) + attrs = append(attrs, c.HostName(h)) + if p > 0 { + attrs = append(attrs, c.HostPort(int(p))) + } + return attrs +} + +// Server returns attributes for a network listener listening at address. See +// net.Listen for information about acceptable address values, address should +// be the same as the one used to create ln. If ln is nil, only network host +// attributes will be returned that describe address. Otherwise, the socket +// level information about ln will also be included. +func (c *NetConv) Server(address string, ln net.Listener) []attribute.KeyValue { + if ln == nil { + return c.Host(address) + } + + lAddr := ln.Addr() + if lAddr == nil { + return c.Host(address) + } + + hostName, hostPort := splitHostPort(address) + sockHostAddr, sockHostPort := splitHostPort(lAddr.String()) + network := lAddr.Network() + sockFamily := family(network, sockHostAddr) + + n := nonZeroStr(hostName, network, sockHostAddr, sockFamily) + n += positiveInt(hostPort, sockHostPort) + attr := make([]attribute.KeyValue, 0, n) + if hostName != "" { + attr = append(attr, c.HostName(hostName)) + if hostPort > 0 { + // Only if net.host.name is set should net.host.port be. + attr = append(attr, c.HostPort(hostPort)) + } + } + if network != "" { + attr = append(attr, c.Transport(network)) + } + if sockFamily != "" { + attr = append(attr, c.NetSockFamilyKey.String(sockFamily)) + } + if sockHostAddr != "" { + attr = append(attr, c.NetSockHostAddrKey.String(sockHostAddr)) + if sockHostPort > 0 { + // Only if net.sock.host.addr is set should net.sock.host.port be. + attr = append(attr, c.NetSockHostPortKey.Int(sockHostPort)) + } + } + return attr +} + +func (c *NetConv) HostName(name string) attribute.KeyValue { + return c.NetHostNameKey.String(name) +} + +func (c *NetConv) HostPort(port int) attribute.KeyValue { + return c.NetHostPortKey.Int(port) +} + +// Client returns attributes for a client network connection to address. See +// net.Dial for information about acceptable address values, address should be +// the same as the one used to create conn. If conn is nil, only network peer +// attributes will be returned that describe address. Otherwise, the socket +// level information about conn will also be included. +func (c *NetConv) Client(address string, conn net.Conn) []attribute.KeyValue { + if conn == nil { + return c.Peer(address) + } + + lAddr, rAddr := conn.LocalAddr(), conn.RemoteAddr() + + var network string + switch { + case lAddr != nil: + network = lAddr.Network() + case rAddr != nil: + network = rAddr.Network() + default: + return c.Peer(address) + } + + peerName, peerPort := splitHostPort(address) + var ( + sockFamily string + sockPeerAddr string + sockPeerPort int + sockHostAddr string + sockHostPort int + ) + + if lAddr != nil { + sockHostAddr, sockHostPort = splitHostPort(lAddr.String()) + } + + if rAddr != nil { + sockPeerAddr, sockPeerPort = splitHostPort(rAddr.String()) + } + + switch { + case sockHostAddr != "": + sockFamily = family(network, sockHostAddr) + case sockPeerAddr != "": + sockFamily = family(network, sockPeerAddr) + } + + n := nonZeroStr(peerName, network, sockPeerAddr, sockHostAddr, sockFamily) + n += positiveInt(peerPort, sockPeerPort, sockHostPort) + attr := make([]attribute.KeyValue, 0, n) + if peerName != "" { + attr = append(attr, c.PeerName(peerName)) + if peerPort > 0 { + // Only if net.peer.name is set should net.peer.port be. + attr = append(attr, c.PeerPort(peerPort)) + } + } + if network != "" { + attr = append(attr, c.Transport(network)) + } + if sockFamily != "" { + attr = append(attr, c.NetSockFamilyKey.String(sockFamily)) + } + if sockPeerAddr != "" { + attr = append(attr, c.NetSockPeerAddrKey.String(sockPeerAddr)) + if sockPeerPort > 0 { + // Only if net.sock.peer.addr is set should net.sock.peer.port be. + attr = append(attr, c.NetSockPeerPortKey.Int(sockPeerPort)) + } + } + if sockHostAddr != "" { + attr = append(attr, c.NetSockHostAddrKey.String(sockHostAddr)) + if sockHostPort > 0 { + // Only if net.sock.host.addr is set should net.sock.host.port be. + attr = append(attr, c.NetSockHostPortKey.Int(sockHostPort)) + } + } + return attr +} + +func family(network, address string) string { + switch network { + case "unix", "unixgram", "unixpacket": + return "unix" + default: + if ip := net.ParseIP(address); ip != nil { + if ip.To4() == nil { + return "inet6" + } + return "inet" + } + } + return "" +} + +func nonZeroStr(strs ...string) int { + var n int + for _, str := range strs { + if str != "" { + n++ + } + } + return n +} + +func positiveInt(ints ...int) int { + var n int + for _, i := range ints { + if i > 0 { + n++ + } + } + return n +} + +// Peer returns attributes for a network peer address. +func (c *NetConv) Peer(address string) []attribute.KeyValue { + h, p := splitHostPort(address) + var n int + if h != "" { + n++ + if p > 0 { + n++ + } + } + + if n == 0 { + return nil + } + + attrs := make([]attribute.KeyValue, 0, n) + attrs = append(attrs, c.PeerName(h)) + if p > 0 { + attrs = append(attrs, c.PeerPort(int(p))) + } + return attrs +} + +func (c *NetConv) PeerName(name string) attribute.KeyValue { + return c.NetPeerNameKey.String(name) +} + +func (c *NetConv) PeerPort(port int) attribute.KeyValue { + return c.NetPeerPortKey.Int(port) +} + +func (c *NetConv) SockPeerAddr(addr string) attribute.KeyValue { + return c.NetSockPeerAddrKey.String(addr) +} + +func (c *NetConv) SockPeerPort(port int) attribute.KeyValue { + return c.NetSockPeerPortKey.Int(port) +} + +// splitHostPort splits a network address hostport of the form "host", +// "host%zone", "[host]", "[host%zone], "host:port", "host%zone:port", +// "[host]:port", "[host%zone]:port", or ":port" into host or host%zone and +// port. +// +// An empty host is returned if it is not provided or unparsable. A negative +// port is returned if it is not provided or unparsable. +func splitHostPort(hostport string) (host string, port int) { + port = -1 + + if strings.HasPrefix(hostport, "[") { + addrEnd := strings.LastIndex(hostport, "]") + if addrEnd < 0 { + // Invalid hostport. + return + } + if i := strings.LastIndex(hostport[addrEnd:], ":"); i < 0 { + host = hostport[1:addrEnd] + return + } + } else { + if i := strings.LastIndex(hostport, ":"); i < 0 { + host = hostport + return + } + } + + host, pStr, err := net.SplitHostPort(hostport) + if err != nil { + return + } + + p, err := strconv.ParseUint(pStr, 10, 16) + if err != nil { + return + } + return host, int(p) +} diff --git a/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/http.go b/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/http.go deleted file mode 100644 index 4b4f3cbaf..000000000 --- a/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/http.go +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright The OpenTelemetry 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. - -package semconv // import "go.opentelemetry.io/otel/semconv/v1.12.0" - -import ( - "net/http" - - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/codes" - "go.opentelemetry.io/otel/semconv/internal" - "go.opentelemetry.io/otel/trace" -) - -// HTTP scheme attributes. -var ( - HTTPSchemeHTTP = HTTPSchemeKey.String("http") - HTTPSchemeHTTPS = HTTPSchemeKey.String("https") -) - -var sc = &internal.SemanticConventions{ - EnduserIDKey: EnduserIDKey, - HTTPClientIPKey: HTTPClientIPKey, - HTTPFlavorKey: HTTPFlavorKey, - HTTPHostKey: HTTPHostKey, - HTTPMethodKey: HTTPMethodKey, - HTTPRequestContentLengthKey: HTTPRequestContentLengthKey, - HTTPRouteKey: HTTPRouteKey, - HTTPSchemeHTTP: HTTPSchemeHTTP, - HTTPSchemeHTTPS: HTTPSchemeHTTPS, - HTTPServerNameKey: HTTPServerNameKey, - HTTPStatusCodeKey: HTTPStatusCodeKey, - HTTPTargetKey: HTTPTargetKey, - HTTPURLKey: HTTPURLKey, - HTTPUserAgentKey: HTTPUserAgentKey, - NetHostIPKey: NetHostIPKey, - NetHostNameKey: NetHostNameKey, - NetHostPortKey: NetHostPortKey, - NetPeerIPKey: NetPeerIPKey, - NetPeerNameKey: NetPeerNameKey, - NetPeerPortKey: NetPeerPortKey, - NetTransportIP: NetTransportIP, - NetTransportOther: NetTransportOther, - NetTransportTCP: NetTransportTCP, - NetTransportUDP: NetTransportUDP, - NetTransportUnix: NetTransportUnix, -} - -// NetAttributesFromHTTPRequest generates attributes of the net -// namespace as specified by the OpenTelemetry specification for a -// span. The network parameter is a string that net.Dial function -// from standard library can understand. -func NetAttributesFromHTTPRequest(network string, request *http.Request) []attribute.KeyValue { - return sc.NetAttributesFromHTTPRequest(network, request) -} - -// EndUserAttributesFromHTTPRequest generates attributes of the -// enduser namespace as specified by the OpenTelemetry specification -// for a span. -func EndUserAttributesFromHTTPRequest(request *http.Request) []attribute.KeyValue { - return sc.EndUserAttributesFromHTTPRequest(request) -} - -// HTTPClientAttributesFromHTTPRequest generates attributes of the -// http namespace as specified by the OpenTelemetry specification for -// a span on the client side. -func HTTPClientAttributesFromHTTPRequest(request *http.Request) []attribute.KeyValue { - return sc.HTTPClientAttributesFromHTTPRequest(request) -} - -// HTTPServerMetricAttributesFromHTTPRequest generates low-cardinality attributes -// to be used with server-side HTTP metrics. -func HTTPServerMetricAttributesFromHTTPRequest(serverName string, request *http.Request) []attribute.KeyValue { - return sc.HTTPServerMetricAttributesFromHTTPRequest(serverName, request) -} - -// HTTPServerAttributesFromHTTPRequest generates attributes of the -// http namespace as specified by the OpenTelemetry specification for -// a span on the server side. Currently, only basic authentication is -// supported. -func HTTPServerAttributesFromHTTPRequest(serverName, route string, request *http.Request) []attribute.KeyValue { - return sc.HTTPServerAttributesFromHTTPRequest(serverName, route, request) -} - -// HTTPAttributesFromHTTPStatusCode generates attributes of the http -// namespace as specified by the OpenTelemetry specification for a -// span. -func HTTPAttributesFromHTTPStatusCode(code int) []attribute.KeyValue { - return sc.HTTPAttributesFromHTTPStatusCode(code) -} - -// SpanStatusFromHTTPStatusCode generates a status code and a message -// as specified by the OpenTelemetry specification for a span. -func SpanStatusFromHTTPStatusCode(code int) (codes.Code, string) { - return internal.SpanStatusFromHTTPStatusCode(code) -} - -// SpanStatusFromHTTPStatusCodeAndSpanKind generates a status code and a message -// as specified by the OpenTelemetry specification for a span. -// Exclude 4xx for SERVER to set the appropriate status. -func SpanStatusFromHTTPStatusCodeAndSpanKind(code int, spanKind trace.SpanKind) (codes.Code, string) { - return internal.SpanStatusFromHTTPStatusCodeAndSpanKind(code, spanKind) -} diff --git a/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/doc.go b/vendor/go.opentelemetry.io/otel/semconv/v1.17.0/doc.go similarity index 92% rename from vendor/go.opentelemetry.io/otel/semconv/v1.12.0/doc.go rename to vendor/go.opentelemetry.io/otel/semconv/v1.17.0/doc.go index 181fcc9c5..71a1f7748 100644 --- a/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/doc.go +++ b/vendor/go.opentelemetry.io/otel/semconv/v1.17.0/doc.go @@ -16,5 +16,5 @@ // // OpenTelemetry semantic conventions are agreed standardized naming // patterns for OpenTelemetry things. This package represents the conventions -// as of the v1.12.0 version of the OpenTelemetry specification. -package semconv // import "go.opentelemetry.io/otel/semconv/v1.12.0" +// as of the v1.17.0 version of the OpenTelemetry specification. +package semconv // import "go.opentelemetry.io/otel/semconv/v1.17.0" diff --git a/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/exception.go b/vendor/go.opentelemetry.io/otel/semconv/v1.17.0/exception.go similarity index 99% rename from vendor/go.opentelemetry.io/otel/semconv/v1.12.0/exception.go rename to vendor/go.opentelemetry.io/otel/semconv/v1.17.0/exception.go index d68927094..9b8c559de 100644 --- a/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/exception.go +++ b/vendor/go.opentelemetry.io/otel/semconv/v1.17.0/exception.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package semconv // import "go.opentelemetry.io/otel/semconv/v1.12.0" +package semconv // import "go.opentelemetry.io/otel/semconv/v1.17.0" const ( // ExceptionEventName is the name of the Span event representing an exception. diff --git a/vendor/go.opentelemetry.io/otel/semconv/v1.17.0/http.go b/vendor/go.opentelemetry.io/otel/semconv/v1.17.0/http.go new file mode 100644 index 000000000..d5c4b5c13 --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/semconv/v1.17.0/http.go @@ -0,0 +1,21 @@ +// Copyright The OpenTelemetry 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. + +package semconv // import "go.opentelemetry.io/otel/semconv/v1.17.0" + +// HTTP scheme attributes. +var ( + HTTPSchemeHTTP = HTTPSchemeKey.String("http") + HTTPSchemeHTTPS = HTTPSchemeKey.String("https") +) diff --git a/vendor/go.opentelemetry.io/otel/semconv/v1.17.0/httpconv/http.go b/vendor/go.opentelemetry.io/otel/semconv/v1.17.0/httpconv/http.go new file mode 100644 index 000000000..c60b2a6bb --- /dev/null +++ b/vendor/go.opentelemetry.io/otel/semconv/v1.17.0/httpconv/http.go @@ -0,0 +1,150 @@ +// Copyright The OpenTelemetry 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. + +// Package httpconv provides OpenTelemetry semantic convetions for the net/http +// package from the standard library. +package httpconv // import "go.opentelemetry.io/otel/semconv/v1.17.0/httpconv" + +import ( + "net/http" + + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/semconv/internal/v2" + semconv "go.opentelemetry.io/otel/semconv/v1.17.0" +) + +var ( + nc = &internal.NetConv{ + NetHostNameKey: semconv.NetHostNameKey, + NetHostPortKey: semconv.NetHostPortKey, + NetPeerNameKey: semconv.NetPeerNameKey, + NetPeerPortKey: semconv.NetPeerPortKey, + NetSockPeerAddrKey: semconv.NetSockPeerAddrKey, + NetSockPeerPortKey: semconv.NetSockPeerPortKey, + NetTransportOther: semconv.NetTransportOther, + NetTransportTCP: semconv.NetTransportTCP, + NetTransportUDP: semconv.NetTransportUDP, + NetTransportInProc: semconv.NetTransportInProc, + } + + hc = &internal.HTTPConv{ + NetConv: nc, + + EnduserIDKey: semconv.EnduserIDKey, + HTTPClientIPKey: semconv.HTTPClientIPKey, + HTTPFlavorKey: semconv.HTTPFlavorKey, + HTTPMethodKey: semconv.HTTPMethodKey, + HTTPRequestContentLengthKey: semconv.HTTPRequestContentLengthKey, + HTTPResponseContentLengthKey: semconv.HTTPResponseContentLengthKey, + HTTPRouteKey: semconv.HTTPRouteKey, + HTTPSchemeHTTP: semconv.HTTPSchemeHTTP, + HTTPSchemeHTTPS: semconv.HTTPSchemeHTTPS, + HTTPStatusCodeKey: semconv.HTTPStatusCodeKey, + HTTPTargetKey: semconv.HTTPTargetKey, + HTTPURLKey: semconv.HTTPURLKey, + HTTPUserAgentKey: semconv.HTTPUserAgentKey, + } +) + +// ClientResponse returns attributes for an HTTP response received by a client +// from a server. It will return the following attributes if the related values +// are defined in resp: "http.status.code", "http.response_content_length". +// +// This does not add all OpenTelemetry required attributes for an HTTP event, +// it assumes ClientRequest was used to create the span with a complete set of +// attributes. If a complete set of attributes can be generated using the +// request contained in resp. For example: +// +// append(ClientResponse(resp), ClientRequest(resp.Request)...) +func ClientResponse(resp *http.Response) []attribute.KeyValue { + return hc.ClientResponse(resp) +} + +// ClientRequest returns attributes for an HTTP request made by a client. The +// following attributes are always returned: "http.url", "http.flavor", +// "http.method", "net.peer.name". The following attributes are returned if the +// related values are defined in req: "net.peer.port", "http.user_agent", +// "http.request_content_length", "enduser.id". +func ClientRequest(req *http.Request) []attribute.KeyValue { + return hc.ClientRequest(req) +} + +// ClientStatus returns a span status code and message for an HTTP status code +// value received by a client. +func ClientStatus(code int) (codes.Code, string) { + return hc.ClientStatus(code) +} + +// ServerRequest returns attributes for an HTTP request received by a server. +// +// The server must be the primary server name if it is known. For example this +// would be the ServerName directive +// (https://httpd.apache.org/docs/2.4/mod/core.html#servername) for an Apache +// server, and the server_name directive +// (http://nginx.org/en/docs/http/ngx_http_core_module.html#server_name) for an +// nginx server. More generically, the primary server name would be the host +// header value that matches the default virtual host of an HTTP server. It +// should include the host identifier and if a port is used to route to the +// server that port identifier should be included as an appropriate port +// suffix. +// +// If the primary server name is not known, server should be an empty string. +// The req Host will be used to determine the server instead. +// +// The following attributes are always returned: "http.method", "http.scheme", +// "http.flavor", "http.target", "net.host.name". The following attributes are +// returned if they related values are defined in req: "net.host.port", +// "net.sock.peer.addr", "net.sock.peer.port", "http.user_agent", "enduser.id", +// "http.client_ip". +func ServerRequest(server string, req *http.Request) []attribute.KeyValue { + return hc.ServerRequest(server, req) +} + +// ServerStatus returns a span status code and message for an HTTP status code +// value returned by a server. Status codes in the 400-499 range are not +// returned as errors. +func ServerStatus(code int) (codes.Code, string) { + return hc.ServerStatus(code) +} + +// RequestHeader returns the contents of h as attributes. +// +// Instrumentation should require an explicit configuration of which headers to +// captured and then prune what they pass here. Including all headers can be a +// security risk - explicit configuration helps avoid leaking sensitive +// information. +// +// The User-Agent header is already captured in the http.user_agent attribute +// from ClientRequest and ServerRequest. Instrumentation may provide an option +// to capture that header here even though it is not recommended. Otherwise, +// instrumentation should filter that out of what is passed. +func RequestHeader(h http.Header) []attribute.KeyValue { + return hc.RequestHeader(h) +} + +// ResponseHeader returns the contents of h as attributes. +// +// Instrumentation should require an explicit configuration of which headers to +// captured and then prune what they pass here. Including all headers can be a +// security risk - explicit configuration helps avoid leaking sensitive +// information. +// +// The User-Agent header is already captured in the http.user_agent attribute +// from ClientRequest and ServerRequest. Instrumentation may provide an option +// to capture that header here even though it is not recommended. Otherwise, +// instrumentation should filter that out of what is passed. +func ResponseHeader(h http.Header) []attribute.KeyValue { + return hc.ResponseHeader(h) +} diff --git a/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/resource.go b/vendor/go.opentelemetry.io/otel/semconv/v1.17.0/resource.go similarity index 84% rename from vendor/go.opentelemetry.io/otel/semconv/v1.12.0/resource.go rename to vendor/go.opentelemetry.io/otel/semconv/v1.17.0/resource.go index b2155676f..add7987a2 100644 --- a/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/resource.go +++ b/vendor/go.opentelemetry.io/otel/semconv/v1.17.0/resource.go @@ -14,7 +14,7 @@ // Code generated from semantic convention specification. DO NOT EDIT. -package semconv // import "go.opentelemetry.io/otel/semconv/v1.12.0" +package semconv // import "go.opentelemetry.io/otel/semconv/v1.17.0" import "go.opentelemetry.io/otel/attribute" @@ -23,35 +23,45 @@ const ( // Array of brand name and version separated by a space // // Type: string[] - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: ' Not A;Brand 99', 'Chromium 99', 'Chrome 99' // Note: This value is intended to be taken from the [UA client hints // API](https://wicg.github.io/ua-client-hints/#interface) - // (navigator.userAgentData.brands). + // (`navigator.userAgentData.brands`). BrowserBrandsKey = attribute.Key("browser.brands") // The platform on which the browser is running // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'Windows', 'macOS', 'Android' // Note: This value is intended to be taken from the [UA client hints // API](https://wicg.github.io/ua-client-hints/#interface) - // (navigator.userAgentData.platform). If unavailable, the legacy + // (`navigator.userAgentData.platform`). If unavailable, the legacy // `navigator.platform` API SHOULD NOT be used instead and this attribute SHOULD // be left unset in order for the values to be consistent. // The list of possible values is defined in the [W3C User-Agent Client Hints // specification](https://wicg.github.io/ua-client-hints/#sec-ch-ua-platform). // Note that some (but not all) of these values can overlap with values in the - // [os.type and os.name attributes](./os.md). However, for consistency, the values - // in the `browser.platform` attribute should capture the exact value that the - // user agent provides. + // [`os.type` and `os.name` attributes](./os.md). However, for consistency, the + // values in the `browser.platform` attribute should capture the exact value that + // the user agent provides. BrowserPlatformKey = attribute.Key("browser.platform") + // A boolean that is true if the browser is running on a mobile device + // + // Type: boolean + // RequirementLevel: Optional + // Stability: stable + // Note: This value is intended to be taken from the [UA client hints + // API](https://wicg.github.io/ua-client-hints/#interface) + // (`navigator.userAgentData.mobile`). If unavailable, this attribute SHOULD be + // left unset. + BrowserMobileKey = attribute.Key("browser.mobile") // Full user-agent string provided by the browser // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 // (KHTML, ' @@ -61,6 +71,15 @@ const ( // Agent Client Hints API. To retrieve the value, the legacy `navigator.userAgent` // API can be used. BrowserUserAgentKey = attribute.Key("browser.user_agent") + // Preferred language of the user using the browser + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'en', 'en-US', 'fr', 'fr-FR' + // Note: This value is intended to be taken from the Navigator API + // `navigator.language`. + BrowserLanguageKey = attribute.Key("browser.language") ) // A cloud environment (e.g. GCP, Azure, AWS) @@ -68,20 +87,20 @@ const ( // Name of the cloud provider. // // Type: Enum - // Required: No + // RequirementLevel: Optional // Stability: stable CloudProviderKey = attribute.Key("cloud.provider") // The cloud account ID the resource is assigned to. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '111111111111', 'opentelemetry' CloudAccountIDKey = attribute.Key("cloud.account.id") // The geographical region the resource is running. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'us-central1', 'us-east-1' // Note: Refer to your provider's docs to see the available regions, for example @@ -97,7 +116,7 @@ const ( // is running. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'us-east-1c' // Note: Availability zones are called "zones" on Alibaba Cloud and Google Cloud. @@ -105,7 +124,7 @@ const ( // The cloud platform in use. // // Type: Enum - // Required: No + // RequirementLevel: Optional // Stability: stable // Note: The prefix of the service SHOULD match the one specified in // `cloud.provider`. @@ -121,6 +140,8 @@ var ( CloudProviderAzure = CloudProviderKey.String("azure") // Google Cloud Platform CloudProviderGCP = CloudProviderKey.String("gcp") + // IBM Cloud + CloudProviderIbmCloud = CloudProviderKey.String("ibm_cloud") // Tencent Cloud CloudProviderTencentCloud = CloudProviderKey.String("tencent_cloud") ) @@ -130,6 +151,8 @@ var ( CloudPlatformAlibabaCloudECS = CloudPlatformKey.String("alibaba_cloud_ecs") // Alibaba Cloud Function Compute CloudPlatformAlibabaCloudFc = CloudPlatformKey.String("alibaba_cloud_fc") + // Red Hat OpenShift on Alibaba Cloud + CloudPlatformAlibabaCloudOpenshift = CloudPlatformKey.String("alibaba_cloud_openshift") // AWS Elastic Compute Cloud CloudPlatformAWSEC2 = CloudPlatformKey.String("aws_ec2") // AWS Elastic Container Service @@ -142,6 +165,8 @@ var ( CloudPlatformAWSElasticBeanstalk = CloudPlatformKey.String("aws_elastic_beanstalk") // AWS App Runner CloudPlatformAWSAppRunner = CloudPlatformKey.String("aws_app_runner") + // Red Hat OpenShift on AWS (ROSA) + CloudPlatformAWSOpenshift = CloudPlatformKey.String("aws_openshift") // Azure Virtual Machines CloudPlatformAzureVM = CloudPlatformKey.String("azure_vm") // Azure Container Instances @@ -152,6 +177,8 @@ var ( CloudPlatformAzureFunctions = CloudPlatformKey.String("azure_functions") // Azure App Service CloudPlatformAzureAppService = CloudPlatformKey.String("azure_app_service") + // Azure Red Hat OpenShift + CloudPlatformAzureOpenshift = CloudPlatformKey.String("azure_openshift") // Google Cloud Compute Engine (GCE) CloudPlatformGCPComputeEngine = CloudPlatformKey.String("gcp_compute_engine") // Google Cloud Run @@ -162,6 +189,10 @@ var ( CloudPlatformGCPCloudFunctions = CloudPlatformKey.String("gcp_cloud_functions") // Google Cloud App Engine (GAE) CloudPlatformGCPAppEngine = CloudPlatformKey.String("gcp_app_engine") + // Red Hat OpenShift on Google Cloud + CloudPlatformGoogleCloudOpenshift = CloudPlatformKey.String("google_cloud_openshift") + // Red Hat OpenShift on IBM Cloud + CloudPlatformIbmCloudOpenshift = CloudPlatformKey.String("ibm_cloud_openshift") // Tencent Cloud Cloud Virtual Machine (CVM) CloudPlatformTencentCloudCvm = CloudPlatformKey.String("tencent_cloud_cvm") // Tencent Cloud Elastic Kubernetes Service (EKS) @@ -176,7 +207,7 @@ const ( // amazon.com/AmazonECS/latest/developerguide/ECS_instances.html). // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'arn:aws:ecs:us- // west-1:123456789123:container/32624152-9086-4f0e-acae-1a75b14fe4d9' @@ -185,7 +216,7 @@ const ( // perguide/clusters.html). // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'arn:aws:ecs:us-west-2:123456789123:cluster/my-cluster' AWSECSClusterARNKey = attribute.Key("aws.ecs.cluster.arn") @@ -193,14 +224,14 @@ const ( // aunch_types.html) for an ECS task. // // Type: Enum - // Required: No + // RequirementLevel: Optional // Stability: stable AWSECSLaunchtypeKey = attribute.Key("aws.ecs.launchtype") // The ARN of an [ECS task definition](https://docs.aws.amazon.com/AmazonECS/lates // t/developerguide/task_definitions.html). // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'arn:aws:ecs:us- // west-1:123456789123:task/10838bed-421f-43ef-870a-f43feacbbb5b' @@ -208,14 +239,14 @@ const ( // The task definition family this task definition is a member of. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'opentelemetry-family' AWSECSTaskFamilyKey = attribute.Key("aws.ecs.task.family") // The revision for this task definition. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '8', '26' AWSECSTaskRevisionKey = attribute.Key("aws.ecs.task.revision") @@ -233,7 +264,7 @@ const ( // The ARN of an EKS cluster. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'arn:aws:ecs:us-west-2:123456789123:cluster/my-cluster' AWSEKSClusterARNKey = attribute.Key("aws.eks.cluster.arn") @@ -244,7 +275,7 @@ const ( // The name(s) of the AWS log group(s) an application is writing to. // // Type: string[] - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '/aws/lambda/my-function', 'opentelemetry-service' // Note: Multiple log groups must be supported for cases like multi-container @@ -254,7 +285,7 @@ const ( // The Amazon Resource Name(s) (ARN) of the AWS log group(s). // // Type: string[] - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'arn:aws:logs:us-west-1:123456789012:log-group:/aws/my/group:*' // Note: See the [log group ARN format @@ -264,14 +295,14 @@ const ( // The name(s) of the AWS log stream(s) an application is writing to. // // Type: string[] - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'logs/main/10838bed-421f-43ef-870a-f43feacbbb5b' AWSLogStreamNamesKey = attribute.Key("aws.log.stream.names") // The ARN(s) of the AWS log stream(s). // // Type: string[] - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'arn:aws:logs:us-west-1:123456789012:log-group:/aws/my/group:log- // stream:logs/main/10838bed-421f-43ef-870a-f43feacbbb5b' @@ -288,7 +319,7 @@ const ( // Container name used by container runtime. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'opentelemetry-autoconf' ContainerNameKey = attribute.Key("container.name") @@ -297,28 +328,28 @@ const ( // identification). The UUID might be abbreviated. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'a3bf90e006b2' ContainerIDKey = attribute.Key("container.id") // The container runtime managing this container. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'docker', 'containerd', 'rkt' ContainerRuntimeKey = attribute.Key("container.runtime") // Name of the image the container was built on. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'gcr.io/opentelemetry/operator' ContainerImageNameKey = attribute.Key("container.image.name") // Container image tag. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '0.1' ContainerImageTagKey = attribute.Key("container.image.tag") @@ -331,7 +362,7 @@ const ( // deployment tier). // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'staging', 'production' DeploymentEnvironmentKey = attribute.Key("deployment.environment") @@ -342,7 +373,7 @@ const ( // A unique identifier representing the device // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '2ab2916d-a51f-4ac8-80ee-45ac31a28092' // Note: The device identifier MUST only be defined using the values outlined @@ -360,7 +391,7 @@ const ( // The model identifier for the device // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'iPhone3,4', 'SM-G920F' // Note: It's recommended this value represents a machine readable version of the @@ -370,7 +401,7 @@ const ( // The marketing name for the device model // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'iPhone 6s Plus', 'Samsung Galaxy S6' // Note: It's recommended this value represents a human readable version of the @@ -379,7 +410,7 @@ const ( // The name of the device manufacturer // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'Apple', 'Samsung' // Note: The Android OS provides this field via @@ -393,7 +424,7 @@ const ( // The name of the single function that this runtime instance executes. // // Type: string - // Required: Always + // RequirementLevel: Required // Stability: stable // Examples: 'my-function', 'myazurefunctionapp/some-function-name' // Note: This is the name of the function as configured/deployed on the FaaS @@ -417,7 +448,7 @@ const ( // The unique ID of the single function that this runtime instance executes. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'arn:aws:lambda:us-west-2:123456789012:function:my-function' // Note: On some cloud providers, it may not be possible to determine the full ID @@ -449,7 +480,7 @@ const ( // The immutable version of the function being executed. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '26', 'pinkfroid-00002' // Note: Depending on the cloud provider and platform, use: @@ -471,7 +502,7 @@ const ( // other invocations to the same function/function version. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '2021/06/28/[$LATEST]2f399eb14537447da05ab2a2e39309de' // Note: * **AWS Lambda:** Use the (full) log stream name. @@ -479,7 +510,7 @@ const ( // The amount of memory available to the serverless function in MiB. // // Type: int - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 128 // Note: It's recommended to set this attribute since e.g. too little memory can @@ -492,46 +523,47 @@ const ( // A host is defined as a general computing instance. const ( // Unique host ID. For Cloud, this must be the instance_id assigned by the cloud - // provider. + // provider. For non-containerized Linux systems, the `machine-id` located in + // `/etc/machine-id` or `/var/lib/dbus/machine-id` may be used. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable - // Examples: 'opentelemetry-test' + // Examples: 'fdbf79e8af94cb7f9e8df36789187052' HostIDKey = attribute.Key("host.id") // Name of the host. On Unix systems, it may contain what the hostname command // returns, or the fully qualified hostname, or another name specified by the // user. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'opentelemetry-test' HostNameKey = attribute.Key("host.name") // Type of host. For Cloud, this must be the machine type. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'n1-standard-1' HostTypeKey = attribute.Key("host.type") // The CPU architecture the host system is running on. // // Type: Enum - // Required: No + // RequirementLevel: Optional // Stability: stable HostArchKey = attribute.Key("host.arch") // Name of the VM image or OS install the host was instantiated from. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'infra-ami-eks-worker-node-7d4ec78312', 'CentOS-8-x86_64-1905' HostImageNameKey = attribute.Key("host.image.name") // VM image ID. For Cloud, this value is from the provider. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'ami-07b06b442921831e5' HostImageIDKey = attribute.Key("host.image.id") @@ -539,7 +571,7 @@ const ( // Attributes](README.md#version-attributes). // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '0.1' HostImageVersionKey = attribute.Key("host.image.version") @@ -569,7 +601,7 @@ const ( // The name of the cluster. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'opentelemetry-cluster' K8SClusterNameKey = attribute.Key("k8s.cluster.name") @@ -580,14 +612,14 @@ const ( // The name of the Node. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'node-1' K8SNodeNameKey = attribute.Key("k8s.node.name") // The UID of the Node. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '1eb3a0c6-0477-4080-a9cb-0cb7db65c6a2' K8SNodeUIDKey = attribute.Key("k8s.node.uid") @@ -598,7 +630,7 @@ const ( // The name of the namespace that the pod is running in. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'default' K8SNamespaceNameKey = attribute.Key("k8s.namespace.name") @@ -609,14 +641,14 @@ const ( // The UID of the Pod. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' K8SPodUIDKey = attribute.Key("k8s.pod.uid") // The name of the Pod. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'opentelemetry-pod-autoconf' K8SPodNameKey = attribute.Key("k8s.pod.name") @@ -629,7 +661,7 @@ const ( // (`container.name`). // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'redis' K8SContainerNameKey = attribute.Key("k8s.container.name") @@ -637,7 +669,7 @@ const ( // identify a particular container (running or stopped) within a container spec. // // Type: int - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 0, 2 K8SContainerRestartCountKey = attribute.Key("k8s.container.restart_count") @@ -648,14 +680,14 @@ const ( // The UID of the ReplicaSet. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' K8SReplicaSetUIDKey = attribute.Key("k8s.replicaset.uid") // The name of the ReplicaSet. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'opentelemetry' K8SReplicaSetNameKey = attribute.Key("k8s.replicaset.name") @@ -666,14 +698,14 @@ const ( // The UID of the Deployment. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' K8SDeploymentUIDKey = attribute.Key("k8s.deployment.uid") // The name of the Deployment. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'opentelemetry' K8SDeploymentNameKey = attribute.Key("k8s.deployment.name") @@ -684,14 +716,14 @@ const ( // The UID of the StatefulSet. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' K8SStatefulSetUIDKey = attribute.Key("k8s.statefulset.uid") // The name of the StatefulSet. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'opentelemetry' K8SStatefulSetNameKey = attribute.Key("k8s.statefulset.name") @@ -702,14 +734,14 @@ const ( // The UID of the DaemonSet. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' K8SDaemonSetUIDKey = attribute.Key("k8s.daemonset.uid") // The name of the DaemonSet. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'opentelemetry' K8SDaemonSetNameKey = attribute.Key("k8s.daemonset.name") @@ -720,14 +752,14 @@ const ( // The UID of the Job. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' K8SJobUIDKey = attribute.Key("k8s.job.uid") // The name of the Job. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'opentelemetry' K8SJobNameKey = attribute.Key("k8s.job.name") @@ -738,14 +770,14 @@ const ( // The UID of the CronJob. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '275ecb36-5aa8-4c2a-9c47-d8bb681b9aff' K8SCronJobUIDKey = attribute.Key("k8s.cronjob.uid") // The name of the CronJob. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'opentelemetry' K8SCronJobNameKey = attribute.Key("k8s.cronjob.name") @@ -756,21 +788,21 @@ const ( // The operating system type. // // Type: Enum - // Required: Always + // RequirementLevel: Required // Stability: stable OSTypeKey = attribute.Key("os.type") // Human readable (not intended to be parsed) OS version information, like e.g. // reported by `ver` or `lsb_release -a` commands. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'Microsoft Windows [Version 10.0.18363.778]', 'Ubuntu 18.04.1 LTS' OSDescriptionKey = attribute.Key("os.description") // Human readable operating system name. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'iOS', 'Android', 'Ubuntu' OSNameKey = attribute.Key("os.name") @@ -778,7 +810,7 @@ const ( // Attributes](../../resource/semantic_conventions/README.md#version-attributes). // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '14.2.1', '18.04.1' OSVersionKey = attribute.Key("os.version") @@ -814,16 +846,23 @@ const ( // Process identifier (PID). // // Type: int - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 1234 ProcessPIDKey = attribute.Key("process.pid") + // Parent Process identifier (PID). + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 111 + ProcessParentPIDKey = attribute.Key("process.parent_pid") // The name of the process executable. On Linux based systems, can be set to the // `Name` in `proc/[pid]/status`. On Windows, can be set to the base name of // `GetProcessImageFileNameW`. // // Type: string - // Required: See below + // RequirementLevel: ConditionallyRequired (See alternative attributes below.) // Stability: stable // Examples: 'otelcol' ProcessExecutableNameKey = attribute.Key("process.executable.name") @@ -832,7 +871,7 @@ const ( // `GetProcessImageFileNameW`. // // Type: string - // Required: See below + // RequirementLevel: ConditionallyRequired (See alternative attributes below.) // Stability: stable // Examples: '/usr/bin/cmd/otelcol' ProcessExecutablePathKey = attribute.Key("process.executable.path") @@ -841,7 +880,7 @@ const ( // can be set to the first parameter extracted from `GetCommandLineW`. // // Type: string - // Required: See below + // RequirementLevel: ConditionallyRequired (See alternative attributes below.) // Stability: stable // Examples: 'cmd/otelcol' ProcessCommandKey = attribute.Key("process.command") @@ -851,7 +890,7 @@ const ( // `process.command_args` instead. // // Type: string - // Required: See below + // RequirementLevel: ConditionallyRequired (See alternative attributes below.) // Stability: stable // Examples: 'C:\\cmd\\otecol --config="my directory\\config.yaml"' ProcessCommandLineKey = attribute.Key("process.command_line") @@ -862,14 +901,14 @@ const ( // the full argv vector passed to `main`. // // Type: string[] - // Required: See below + // RequirementLevel: ConditionallyRequired (See alternative attributes below.) // Stability: stable // Examples: 'cmd/otecol', '--config=config.yaml' ProcessCommandArgsKey = attribute.Key("process.command_args") // The username of the user that owns the process. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'root' ProcessOwnerKey = attribute.Key("process.owner") @@ -881,7 +920,7 @@ const ( // SHOULD be the name of the compiler. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'OpenJDK Runtime Environment' ProcessRuntimeNameKey = attribute.Key("process.runtime.name") @@ -889,7 +928,7 @@ const ( // modification. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '14.0.2' ProcessRuntimeVersionKey = attribute.Key("process.runtime.version") @@ -897,7 +936,7 @@ const ( // specific vendor customization of the runtime environment. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'Eclipse OpenJ9 Eclipse OpenJ9 VM openj9-0.21.0' ProcessRuntimeDescriptionKey = attribute.Key("process.runtime.description") @@ -908,7 +947,7 @@ const ( // Logical name of the service. // // Type: string - // Required: Always + // RequirementLevel: Required // Stability: stable // Examples: 'shoppingcart' // Note: MUST be the same for all instances of horizontally scaled services. If @@ -920,7 +959,7 @@ const ( // A namespace for `service.name`. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'Shop' // Note: A string value having a meaning that helps to distinguish a group of @@ -934,7 +973,7 @@ const ( // The string ID of the service instance. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '627cc493-f310-47de-96bd-71410b7dec09' // Note: MUST be unique for each instance of the same @@ -953,7 +992,7 @@ const ( // The version string of the service API or implementation. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '2.0.0' ServiceVersionKey = attribute.Key("service.version") @@ -964,27 +1003,27 @@ const ( // The name of the telemetry SDK as defined above. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'opentelemetry' TelemetrySDKNameKey = attribute.Key("telemetry.sdk.name") // The language of the telemetry SDK. // // Type: Enum - // Required: No + // RequirementLevel: Optional // Stability: stable TelemetrySDKLanguageKey = attribute.Key("telemetry.sdk.language") // The version string of the telemetry SDK. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '1.2.3' TelemetrySDKVersionKey = attribute.Key("telemetry.sdk.version") // The version string of the auto instrumentation agent, if used. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '1.2.3' TelemetryAutoVersionKey = attribute.Key("telemetry.auto.version") @@ -1020,14 +1059,14 @@ const ( // The name of the web engine. // // Type: string - // Required: Always + // RequirementLevel: Required // Stability: stable // Examples: 'WildFly' WebEngineNameKey = attribute.Key("webengine.name") // The version of the web engine. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '21.0.0' WebEngineVersionKey = attribute.Key("webengine.version") @@ -1035,8 +1074,45 @@ const ( // information). // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'WildFly Full 21.0.0.Final (WildFly Core 13.0.1.Final) - 2.2.2.Final' WebEngineDescriptionKey = attribute.Key("webengine.description") ) + +// Attributes used by non-OTLP exporters to represent OpenTelemetry Scope's concepts. +const ( + // The name of the instrumentation scope - (`InstrumentationScope.Name` in OTLP). + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'io.opentelemetry.contrib.mongodb' + OtelScopeNameKey = attribute.Key("otel.scope.name") + // The version of the instrumentation scope - (`InstrumentationScope.Version` in + // OTLP). + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '1.0.0' + OtelScopeVersionKey = attribute.Key("otel.scope.version") +) + +// Span attributes used by non-OTLP exporters to represent OpenTelemetry Scope's concepts. +const ( + // Deprecated, use the `otel.scope.name` attribute. + // + // Type: string + // RequirementLevel: Optional + // Stability: deprecated + // Examples: 'io.opentelemetry.contrib.mongodb' + OtelLibraryNameKey = attribute.Key("otel.library.name") + // Deprecated, use the `otel.scope.version` attribute. + // + // Type: string + // RequirementLevel: Optional + // Stability: deprecated + // Examples: '1.0.0' + OtelLibraryVersionKey = attribute.Key("otel.library.version") +) diff --git a/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/schema.go b/vendor/go.opentelemetry.io/otel/semconv/v1.17.0/schema.go similarity index 93% rename from vendor/go.opentelemetry.io/otel/semconv/v1.12.0/schema.go rename to vendor/go.opentelemetry.io/otel/semconv/v1.17.0/schema.go index 2f2a019e4..42fc525d1 100644 --- a/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/schema.go +++ b/vendor/go.opentelemetry.io/otel/semconv/v1.17.0/schema.go @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -package semconv // import "go.opentelemetry.io/otel/semconv/v1.12.0" +package semconv // import "go.opentelemetry.io/otel/semconv/v1.17.0" // SchemaURL is the schema URL that matches the version of the semantic conventions // that this package defines. Semconv packages starting from v1.4.0 must declare // non-empty schema URL in the form https://opentelemetry.io/schemas/ -const SchemaURL = "https://opentelemetry.io/schemas/1.12.0" +const SchemaURL = "https://opentelemetry.io/schemas/1.17.0" diff --git a/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/trace.go b/vendor/go.opentelemetry.io/otel/semconv/v1.17.0/trace.go similarity index 71% rename from vendor/go.opentelemetry.io/otel/semconv/v1.12.0/trace.go rename to vendor/go.opentelemetry.io/otel/semconv/v1.17.0/trace.go index 047d8e95c..01e5f072a 100644 --- a/vendor/go.opentelemetry.io/otel/semconv/v1.12.0/trace.go +++ b/vendor/go.opentelemetry.io/otel/semconv/v1.17.0/trace.go @@ -14,10 +14,71 @@ // Code generated from semantic convention specification. DO NOT EDIT. -package semconv // import "go.opentelemetry.io/otel/semconv/v1.12.0" +package semconv // import "go.opentelemetry.io/otel/semconv/v1.17.0" import "go.opentelemetry.io/otel/attribute" +// This document defines the shared attributes used to report a single exception associated with a span or log. +const ( + // The type of the exception (its fully-qualified class name, if applicable). The + // dynamic type of the exception should be preferred over the static type in + // languages that support it. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'java.net.ConnectException', 'OSError' + ExceptionTypeKey = attribute.Key("exception.type") + // The exception message. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'Division by zero', "Can't convert 'int' object to str implicitly" + ExceptionMessageKey = attribute.Key("exception.message") + // A stacktrace as a string in the natural representation for the language + // runtime. The representation is to be determined and documented by each language + // SIG. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'Exception in thread "main" java.lang.RuntimeException: Test + // exception\\n at ' + // 'com.example.GenerateTrace.methodB(GenerateTrace.java:13)\\n at ' + // 'com.example.GenerateTrace.methodA(GenerateTrace.java:9)\\n at ' + // 'com.example.GenerateTrace.main(GenerateTrace.java:5)' + ExceptionStacktraceKey = attribute.Key("exception.stacktrace") +) + +// This document defines attributes for Events represented using Log Records. +const ( + // The name identifies the event. + // + // Type: string + // RequirementLevel: Required + // Stability: stable + // Examples: 'click', 'exception' + EventNameKey = attribute.Key("event.name") + // The domain identifies the business context for the events. + // + // Type: Enum + // RequirementLevel: Required + // Stability: stable + // Note: Events across different domains may have same `event.name`, yet be + // unrelated events. + EventDomainKey = attribute.Key("event.domain") +) + +var ( + // Events from browser apps + EventDomainBrowser = EventDomainKey.String("browser") + // Events from mobile apps + EventDomainDevice = EventDomainKey.String("device") + // Events from Kubernetes + EventDomainK8S = EventDomainKey.String("k8s") +) + // Span attributes used by AWS Lambda (in addition to general `faas` attributes). const ( // The full invoked ARN as provided on the `Context` passed to the function @@ -25,7 +86,7 @@ const ( // applicable). // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'arn:aws:lambda:us-east-1:123456:function:myfunction:myalias' // Note: This may be different from `faas.id` if an alias is involved. @@ -38,7 +99,7 @@ const ( // .md#id) uniquely identifies the event. // // Type: string - // Required: Always + // RequirementLevel: Required // Stability: stable // Examples: '123e4567-e89b-12d3-a456-426614174000', '0001' CloudeventsEventIDKey = attribute.Key("cloudevents.event_id") @@ -46,7 +107,7 @@ const ( // d#source-1) identifies the context in which an event happened. // // Type: string - // Required: Always + // RequirementLevel: Required // Stability: stable // Examples: 'https://github.com/cloudevents', '/cloudevents/spec/pull/123', 'my- // service' @@ -55,7 +116,7 @@ const ( // pec/blob/v1.0.2/cloudevents/spec.md#specversion) which the event uses. // // Type: string - // Required: Always + // RequirementLevel: Optional // Stability: stable // Examples: '1.0' CloudeventsEventSpecVersionKey = attribute.Key("cloudevents.event_spec_version") @@ -64,7 +125,7 @@ const ( // originating occurrence. // // Type: string - // Required: Always + // RequirementLevel: Optional // Stability: stable // Examples: 'com.github.pull_request.opened', 'com.example.object.deleted.v2' CloudeventsEventTypeKey = attribute.Key("cloudevents.event_type") @@ -73,7 +134,7 @@ const ( // source). // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'mynewfile.jpg' CloudeventsEventSubjectKey = attribute.Key("cloudevents.event_subject") @@ -84,7 +145,7 @@ const ( // Parent-child Reference type // // Type: Enum - // Required: No + // RequirementLevel: Optional // Stability: stable // Note: The causal relationship between a child Span and a parent Span. OpentracingRefTypeKey = attribute.Key("opentracing.ref_type") @@ -103,21 +164,21 @@ const ( // below for a list of well-known identifiers. // // Type: Enum - // Required: Always + // RequirementLevel: Required // Stability: stable DBSystemKey = attribute.Key("db.system") // The connection string used to connect to the database. It is recommended to // remove embedded credentials. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'Server=(localdb)\\v11.0;Integrated Security=true;' DBConnectionStringKey = attribute.Key("db.connection_string") // Username for accessing the database. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'readonly_user', 'reporting_user' DBUserKey = attribute.Key("db.user") @@ -126,7 +187,7 @@ const ( // used to connect. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'org.postgresql.Driver', // 'com.microsoft.sqlserver.jdbc.SQLServerDriver' @@ -136,7 +197,7 @@ const ( // (even if the command fails). // // Type: string - // Required: Required, if applicable. + // RequirementLevel: ConditionallyRequired (If applicable.) // Stability: stable // Examples: 'customers', 'main' // Note: In some SQL databases, the database name to be used is called "schema @@ -147,8 +208,8 @@ const ( // The database statement being executed. // // Type: string - // Required: Required if applicable and not explicitly disabled via - // instrumentation configuration. + // RequirementLevel: ConditionallyRequired (If applicable and not explicitly + // disabled via instrumentation configuration.) // Stability: stable // Examples: 'SELECT * FROM wuser_table', 'SET mykey "WuValue"' // Note: The value may be sanitized to exclude sensitive information. @@ -158,7 +219,7 @@ const ( // such as `findAndModify`, or the SQL keyword. // // Type: string - // Required: Required, if `db.statement` is not applicable. + // RequirementLevel: ConditionallyRequired (If `db.statement` is not applicable.) // Stability: stable // Examples: 'findAndModify', 'HMSET', 'SELECT' // Note: When setting this to an SQL keyword, it is not recommended to attempt any @@ -264,6 +325,10 @@ var ( DBSystemMemcached = DBSystemKey.String("memcached") // CockroachDB DBSystemCockroachdb = DBSystemKey.String("cockroachdb") + // OpenSearch + DBSystemOpensearch = DBSystemKey.String("opensearch") + // ClickHouse + DBSystemClickhouse = DBSystemKey.String("clickhouse") ) // Connection-level attributes for Microsoft SQL Server @@ -273,7 +338,7 @@ const ( // connecting to. This name is used to determine the port of a named instance. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'MSSQLSERVER' // Note: If setting a `db.mssql.instance_name`, `net.peer.port` is no longer @@ -286,7 +351,7 @@ const ( // The fetch size used for paging, i.e. how many rows will be returned at once. // // Type: int - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 5000 DBCassandraPageSizeKey = attribute.Key("db.cassandra.page_size") @@ -295,14 +360,14 @@ const ( // oss/3.0/cassandra/dml/dmlConfigConsistency.html). // // Type: Enum - // Required: No + // RequirementLevel: Optional // Stability: stable DBCassandraConsistencyLevelKey = attribute.Key("db.cassandra.consistency_level") // The name of the primary table that the operation is acting upon, including the // keyspace name (if applicable). // // Type: string - // Required: Recommended if available. + // RequirementLevel: Recommended // Stability: stable // Examples: 'mytable' // Note: This mirrors the db.sql.table attribute but references cassandra rather @@ -314,28 +379,28 @@ const ( // Whether or not the query is idempotent. // // Type: boolean - // Required: No + // RequirementLevel: Optional // Stability: stable DBCassandraIdempotenceKey = attribute.Key("db.cassandra.idempotence") // The number of times a query was speculatively executed. Not set or `0` if the // query was not executed speculatively. // // Type: int - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 0, 2 DBCassandraSpeculativeExecutionCountKey = attribute.Key("db.cassandra.speculative_execution_count") // The ID of the coordinating node for a query. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'be13faa2-8574-4d71-926d-27f16cf8a7af' DBCassandraCoordinatorIDKey = attribute.Key("db.cassandra.coordinator.id") // The data center of the coordinating node for a query. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'us-west-2' DBCassandraCoordinatorDCKey = attribute.Key("db.cassandra.coordinator.dc") @@ -373,7 +438,8 @@ const ( // instead of the generic `db.name` attribute. // // Type: int - // Required: Required, if other than the default database (`0`). + // RequirementLevel: ConditionallyRequired (If other than the default database + // (`0`).) // Stability: stable // Examples: 0, 1, 15 DBRedisDBIndexKey = attribute.Key("db.redis.database_index") @@ -384,7 +450,7 @@ const ( // The collection being accessed within the database stated in `db.name`. // // Type: string - // Required: Always + // RequirementLevel: Required // Stability: stable // Examples: 'customers', 'products' DBMongoDBCollectionKey = attribute.Key("db.mongodb.collection") @@ -396,7 +462,7 @@ const ( // database name (if applicable). // // Type: string - // Required: Recommended if available. + // RequirementLevel: Recommended // Stability: stable // Examples: 'public.users', 'customers' // Note: It is not recommended to attempt any client-side parsing of @@ -406,61 +472,29 @@ const ( DBSQLTableKey = attribute.Key("db.sql.table") ) -// This document defines the attributes used to report a single exception associated with a span. +// Span attributes used by non-OTLP exporters to represent OpenTelemetry Span's concepts. const ( - // The type of the exception (its fully-qualified class name, if applicable). The - // dynamic type of the exception should be preferred over the static type in - // languages that support it. + // Name of the code, either "OK" or "ERROR". MUST NOT be set if the status code is + // UNSET. + // + // Type: Enum + // RequirementLevel: Optional + // Stability: stable + OtelStatusCodeKey = attribute.Key("otel.status_code") + // Description of the Status if it has a value, otherwise not set. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable - // Examples: 'java.net.ConnectException', 'OSError' - ExceptionTypeKey = attribute.Key("exception.type") - // The exception message. - // - // Type: string - // Required: No - // Stability: stable - // Examples: 'Division by zero', "Can't convert 'int' object to str implicitly" - ExceptionMessageKey = attribute.Key("exception.message") - // A stacktrace as a string in the natural representation for the language - // runtime. The representation is to be determined and documented by each language - // SIG. - // - // Type: string - // Required: No - // Stability: stable - // Examples: 'Exception in thread "main" java.lang.RuntimeException: Test - // exception\\n at ' - // 'com.example.GenerateTrace.methodB(GenerateTrace.java:13)\\n at ' - // 'com.example.GenerateTrace.methodA(GenerateTrace.java:9)\\n at ' - // 'com.example.GenerateTrace.main(GenerateTrace.java:5)' - ExceptionStacktraceKey = attribute.Key("exception.stacktrace") - // SHOULD be set to true if the exception event is recorded at a point where it is - // known that the exception is escaping the scope of the span. - // - // Type: boolean - // Required: No - // Stability: stable - // Note: An exception is considered to have escaped (or left) the scope of a span, - // if that span is ended while the exception is still logically "in flight". - // This may be actually "in flight" in some languages (e.g. if the exception - // is passed to a Context manager's `__exit__` method in Python) but will - // usually be caught at the point of recording the exception in most languages. + // Examples: 'resource not found' + OtelStatusDescriptionKey = attribute.Key("otel.status_description") +) - // It is usually not possible to determine at the point where an exception is - // thrown - // whether it will escape the scope of a span. - // However, it is trivial to know that an exception - // will escape, if one checks for an active exception just before ending the span, - // as done in the [example above](#recording-an-exception). - - // It follows that an exception may still escape the scope of the span - // even if the `exception.escaped` attribute was not set or set to false, - // since the event might have been recorded at a time where it was not - // clear whether the exception will escape. - ExceptionEscapedKey = attribute.Key("exception.escaped") +var ( + // The operation has been validated by an Application developer or Operator to have completed successfully + OtelStatusCodeOk = OtelStatusCodeKey.String("OK") + // The operation contains an error + OtelStatusCodeError = OtelStatusCodeKey.String("ERROR") ) // This semantic convention describes an instance of a function that runs without provisioning or managing of servers (also known as serverless functions or Function as a Service (FaaS)) with spans. @@ -468,7 +502,7 @@ const ( // Type of the trigger which caused this function execution. // // Type: Enum - // Required: No + // RequirementLevel: Optional // Stability: stable // Note: For the server/consumer span on the incoming side, // `faas.trigger` MUST be set. @@ -483,7 +517,7 @@ const ( // The execution ID of the current function execution. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'af9d5aa4-a685-4c5f-a22b-444f80b3cc28' FaaSExecutionKey = attribute.Key("faas.execution") @@ -509,14 +543,14 @@ const ( // DB to the database name. // // Type: string - // Required: Always + // RequirementLevel: Required // Stability: stable // Examples: 'myBucketName', 'myDBName' FaaSDocumentCollectionKey = attribute.Key("faas.document.collection") // Describes the type of the operation that was performed on the data. // // Type: Enum - // Required: Always + // RequirementLevel: Required // Stability: stable FaaSDocumentOperationKey = attribute.Key("faas.document.operation") // A string containing the time when the data was accessed in the [ISO @@ -524,7 +558,7 @@ const ( // in [UTC](https://www.w3.org/TR/NOTE-datetime). // // Type: string - // Required: Always + // RequirementLevel: Optional // Stability: stable // Examples: '2020-01-23T13:47:06Z' FaaSDocumentTimeKey = attribute.Key("faas.document.time") @@ -532,7 +566,7 @@ const ( // Storage or S3 is the name of the file, and in Cosmos DB the table name. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'myFile.txt', 'myTableName' FaaSDocumentNameKey = attribute.Key("faas.document.name") @@ -554,7 +588,7 @@ const ( // in [UTC](https://www.w3.org/TR/NOTE-datetime). // // Type: string - // Required: Always + // RequirementLevel: Optional // Stability: stable // Examples: '2020-01-23T13:47:06Z' FaaSTimeKey = attribute.Key("faas.time") @@ -562,7 +596,7 @@ const ( // e.com/cd/E12058_01/doc/doc.1014/e12030/cron_expressions.htm). // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '0/5 * * * ? *' FaaSCronKey = attribute.Key("faas.cron") @@ -574,7 +608,7 @@ const ( // time (aka cold-start). // // Type: boolean - // Required: No + // RequirementLevel: Optional // Stability: stable FaaSColdstartKey = attribute.Key("faas.coldstart") ) @@ -584,7 +618,7 @@ const ( // The name of the invoked function. // // Type: string - // Required: Always + // RequirementLevel: Required // Stability: stable // Examples: 'my-function' // Note: SHOULD be equal to the `faas.name` resource attribute of the invoked @@ -593,7 +627,7 @@ const ( // The cloud provider of the invoked function. // // Type: Enum - // Required: Always + // RequirementLevel: Required // Stability: stable // Note: SHOULD be equal to the `cloud.provider` resource attribute of the invoked // function. @@ -601,12 +635,13 @@ const ( // The cloud region of the invoked function. // // Type: string - // Required: For some cloud providers, like AWS or GCP, the region in which a - // function is hosted is essential to uniquely identify the function and also part - // of its endpoint. Since it's part of the endpoint being called, the region is - // always known to clients. In these cases, `faas.invoked_region` MUST be set - // accordingly. If the region is unknown to the client or not required for - // identifying the invoked function, setting `faas.invoked_region` is optional. + // RequirementLevel: ConditionallyRequired (For some cloud providers, like AWS or + // GCP, the region in which a function is hosted is essential to uniquely identify + // the function and also part of its endpoint. Since it's part of the endpoint + // being called, the region is always known to clients. In these cases, + // `faas.invoked_region` MUST be set accordingly. If the region is unknown to the + // client or not required for identifying the invoked function, setting + // `faas.invoked_region` is optional.) // Stability: stable // Examples: 'eu-central-1' // Note: SHOULD be equal to the `cloud.region` resource attribute of the invoked @@ -632,58 +667,113 @@ const ( // Transport protocol used. See note below. // // Type: Enum - // Required: No + // RequirementLevel: Optional // Stability: stable NetTransportKey = attribute.Key("net.transport") - // Remote address of the peer (dotted decimal for IPv4 or - // [RFC5952](https://tools.ietf.org/html/rfc5952) for IPv6) + // Application layer protocol used. The value SHOULD be normalized to lowercase. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable - // Examples: '127.0.0.1' - NetPeerIPKey = attribute.Key("net.peer.ip") - // Remote port number. + // Examples: 'amqp', 'http', 'mqtt' + NetAppProtocolNameKey = attribute.Key("net.app.protocol.name") + // Version of the application layer protocol used. See note below. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '3.1.1' + // Note: `net.app.protocol.version` refers to the version of the protocol used and + // might be different from the protocol client's version. If the HTTP client used + // has a version of `0.27.2`, but sends HTTP version `1.1`, this attribute should + // be set to `1.1`. + NetAppProtocolVersionKey = attribute.Key("net.app.protocol.version") + // Remote socket peer name. + // + // Type: string + // RequirementLevel: Recommended (If available and different from `net.peer.name` + // and if `net.sock.peer.addr` is set.) + // Stability: stable + // Examples: 'proxy.example.com' + NetSockPeerNameKey = attribute.Key("net.sock.peer.name") + // Remote socket peer address: IPv4 or IPv6 for internet protocols, path for local + // communication, [etc](https://man7.org/linux/man- + // pages/man7/address_families.7.html). + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '127.0.0.1', '/tmp/mysql.sock' + NetSockPeerAddrKey = attribute.Key("net.sock.peer.addr") + // Remote socket peer port. // // Type: int - // Required: No + // RequirementLevel: Recommended (If defined for the address family and if + // different than `net.peer.port` and if `net.sock.peer.addr` is set.) // Stability: stable - // Examples: 80, 8080, 443 - NetPeerPortKey = attribute.Key("net.peer.port") - // Remote hostname or similar, see note below. + // Examples: 16456 + NetSockPeerPortKey = attribute.Key("net.sock.peer.port") + // Protocol [address family](https://man7.org/linux/man- + // pages/man7/address_families.7.html) which is used for communication. + // + // Type: Enum + // RequirementLevel: ConditionallyRequired (If different than `inet` and if any of + // `net.sock.peer.addr` or `net.sock.host.addr` are set. Consumers of telemetry + // SHOULD accept both IPv4 and IPv6 formats for the address in + // `net.sock.peer.addr` if `net.sock.family` is not set. This is to support + // instrumentations that follow previous versions of this document.) + // Stability: stable + // Examples: 'inet6', 'bluetooth' + NetSockFamilyKey = attribute.Key("net.sock.family") + // Logical remote hostname, see note below. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'example.com' // Note: `net.peer.name` SHOULD NOT be set if capturing it would require an extra // DNS lookup. NetPeerNameKey = attribute.Key("net.peer.name") - // Like `net.peer.ip` but for the host IP. Useful in case of a multi-IP host. - // - // Type: string - // Required: No - // Stability: stable - // Examples: '192.168.0.1' - NetHostIPKey = attribute.Key("net.host.ip") - // Like `net.peer.port` but for the host port. + // Logical remote port number // // Type: int - // Required: No + // RequirementLevel: Optional // Stability: stable - // Examples: 35555 - NetHostPortKey = attribute.Key("net.host.port") - // Local hostname or similar, see note below. + // Examples: 80, 8080, 443 + NetPeerPortKey = attribute.Key("net.peer.port") + // Logical local hostname or similar, see note below. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'localhost' NetHostNameKey = attribute.Key("net.host.name") + // Logical local port number, preferably the one that the peer used to connect + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 8080 + NetHostPortKey = attribute.Key("net.host.port") + // Local socket address. Useful in case of a multi-IP host. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '192.168.0.1' + NetSockHostAddrKey = attribute.Key("net.sock.host.addr") + // Local socket port number. + // + // Type: int + // RequirementLevel: Recommended (If defined for the address family and if + // different than `net.host.port` and if `net.sock.host.addr` is set.) + // Stability: stable + // Examples: 35555 + NetSockHostPortKey = attribute.Key("net.sock.host.port") // The internet connection type currently being used by the host. // // Type: Enum - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'wifi' NetHostConnectionTypeKey = attribute.Key("net.host.connection.type") @@ -692,28 +782,28 @@ const ( // about a wifi connection. // // Type: Enum - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'LTE' NetHostConnectionSubtypeKey = attribute.Key("net.host.connection.subtype") // The name of the mobile carrier. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'sprint' NetHostCarrierNameKey = attribute.Key("net.host.carrier.name") // The mobile carrier country code. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '310' NetHostCarrierMccKey = attribute.Key("net.host.carrier.mcc") // The mobile carrier network code. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '001' NetHostCarrierMncKey = attribute.Key("net.host.carrier.mnc") @@ -721,7 +811,7 @@ const ( // carrier network. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'DE' NetHostCarrierIccKey = attribute.Key("net.host.carrier.icc") @@ -732,10 +822,6 @@ var ( NetTransportTCP = NetTransportKey.String("ip_tcp") // ip_udp NetTransportUDP = NetTransportKey.String("ip_udp") - // Another IP-based protocol - NetTransportIP = NetTransportKey.String("ip") - // Unix Domain socket. See below - NetTransportUnix = NetTransportKey.String("unix") // Named or anonymous pipe. See note below NetTransportPipe = NetTransportKey.String("pipe") // In-process communication @@ -744,6 +830,15 @@ var ( NetTransportOther = NetTransportKey.String("other") ) +var ( + // IPv4 address + NetSockFamilyInet = NetSockFamilyKey.String("inet") + // IPv6 address + NetSockFamilyInet6 = NetSockFamilyKey.String("inet6") + // Unix domain socket path + NetSockFamilyUnix = NetSockFamilyKey.String("unix") +) + var ( // wifi NetHostConnectionTypeWifi = NetHostConnectionTypeKey.String("wifi") @@ -809,7 +904,7 @@ const ( // attribute of the remote service if any. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'AuthTokenCache' PeerServiceKey = attribute.Key("peer.service") @@ -822,7 +917,7 @@ const ( // inbound request from outside the system. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'username' EnduserIDKey = attribute.Key("enduser.id") @@ -830,7 +925,7 @@ const ( // or application security context. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'admin' EnduserRoleKey = attribute.Key("enduser.role") @@ -842,7 +937,7 @@ const ( // open.org/security/saml/Post2.0/sstc-saml-tech-overview-2.0.html). // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'read:message, write:files' EnduserScopeKey = attribute.Key("enduser.scope") @@ -853,14 +948,14 @@ const ( // Current "managed" thread ID (as opposed to OS thread ID). // // Type: int - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 42 ThreadIDKey = attribute.Key("thread.id") // Current thread name. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'main' ThreadNameKey = attribute.Key("thread.name") @@ -872,7 +967,7 @@ const ( // unit's name). // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'serveRequest' CodeFunctionKey = attribute.Key("code.function") @@ -881,7 +976,7 @@ const ( // `code.function` form a unique identifier for the code unit. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'com.example.MyHTTPService' CodeNamespaceKey = attribute.Key("code.namespace") @@ -889,7 +984,7 @@ const ( // (preferably an absolute file path). // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '/usr/local/MyApplication/content_root/app/index.php' CodeFilepathKey = attribute.Key("code.filepath") @@ -897,10 +992,18 @@ const ( // point within the code unit named in `code.function`. // // Type: int - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 42 CodeLineNumberKey = attribute.Key("code.lineno") + // The column number in `code.filepath` best representing the operation. It SHOULD + // point within the code unit named in `code.function`. + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 16 + CodeColumnKey = attribute.Key("code.column") ) // This document defines semantic conventions for HTTP client and server Spans. @@ -908,117 +1011,55 @@ const ( // HTTP request method. // // Type: string - // Required: Always + // RequirementLevel: Required // Stability: stable // Examples: 'GET', 'POST', 'HEAD' HTTPMethodKey = attribute.Key("http.method") - // Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]`. - // Usually the fragment is not transmitted over HTTP, but if it is known, it - // should be included nevertheless. - // - // Type: string - // Required: No - // Stability: stable - // Examples: 'https://www.foo.bar/search?q=OpenTelemetry#SemConv' - // Note: `http.url` MUST NOT contain credentials passed via URL in form of - // `https://username:password@www.example.com/`. In such case the attribute's - // value should be `https://www.example.com/`. - HTTPURLKey = attribute.Key("http.url") - // The full request target as passed in a HTTP request line or equivalent. - // - // Type: string - // Required: No - // Stability: stable - // Examples: '/path/12314/?q=ddds#123' - HTTPTargetKey = attribute.Key("http.target") - // The value of the [HTTP host - // header](https://tools.ietf.org/html/rfc7230#section-5.4). An empty Host header - // should also be reported, see note. - // - // Type: string - // Required: No - // Stability: stable - // Examples: 'www.example.org' - // Note: When the header is present but empty the attribute SHOULD be set to the - // empty string. Note that this is a valid situation that is expected in certain - // cases, according the aforementioned [section of RFC - // 7230](https://tools.ietf.org/html/rfc7230#section-5.4). When the header is not - // set the attribute MUST NOT be set. - HTTPHostKey = attribute.Key("http.host") - // The URI scheme identifying the used protocol. - // - // Type: string - // Required: No - // Stability: stable - // Examples: 'http', 'https' - HTTPSchemeKey = attribute.Key("http.scheme") // [HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). // // Type: int - // Required: If and only if one was received/sent. + // RequirementLevel: ConditionallyRequired (If and only if one was received/sent.) // Stability: stable // Examples: 200 HTTPStatusCodeKey = attribute.Key("http.status_code") // Kind of HTTP protocol used. // // Type: Enum - // Required: No + // RequirementLevel: Optional // Stability: stable // Note: If `net.transport` is not specified, it can be assumed to be `IP.TCP` // except if `http.flavor` is `QUIC`, in which case `IP.UDP` is assumed. HTTPFlavorKey = attribute.Key("http.flavor") - // Value of the [HTTP User- - // Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) header sent by the - // client. + // Value of the [HTTP User-Agent](https://www.rfc- + // editor.org/rfc/rfc9110.html#field.user-agent) header sent by the client. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'CERN-LineMode/2.15 libwww/2.17b3' HTTPUserAgentKey = attribute.Key("http.user_agent") // The size of the request payload body in bytes. This is the number of bytes // transferred excluding headers and is often, but not always, present as the - // [Content-Length](https://tools.ietf.org/html/rfc7230#section-3.3.2) header. For - // requests using transport encoding, this should be the compressed size. + // [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content- + // length) header. For requests using transport encoding, this should be the + // compressed size. // // Type: int - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 3495 HTTPRequestContentLengthKey = attribute.Key("http.request_content_length") - // The size of the uncompressed request payload body after transport decoding. Not - // set if transport encoding not used. - // - // Type: int - // Required: No - // Stability: stable - // Examples: 5493 - HTTPRequestContentLengthUncompressedKey = attribute.Key("http.request_content_length_uncompressed") // The size of the response payload body in bytes. This is the number of bytes // transferred excluding headers and is often, but not always, present as the - // [Content-Length](https://tools.ietf.org/html/rfc7230#section-3.3.2) header. For - // requests using transport encoding, this should be the compressed size. + // [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content- + // length) header. For requests using transport encoding, this should be the + // compressed size. // // Type: int - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 3495 HTTPResponseContentLengthKey = attribute.Key("http.response_content_length") - // The size of the uncompressed response payload body after transport decoding. - // Not set if transport encoding not used. - // - // Type: int - // Required: No - // Stability: stable - // Examples: 5493 - HTTPResponseContentLengthUncompressedKey = attribute.Key("http.response_content_length_uncompressed") - // The ordinal number of request re-sending attempt. - // - // Type: int - // Required: If and only if a request was retried. - // Stability: stable - // Examples: 3 - HTTPRetryCountKey = attribute.Key("http.retry_count") ) var ( @@ -1036,45 +1077,78 @@ var ( HTTPFlavorQUIC = HTTPFlavorKey.String("QUIC") ) +// Semantic Convention for HTTP Client +const ( + // Full HTTP request URL in the form `scheme://host[:port]/path?query[#fragment]`. + // Usually the fragment is not transmitted over HTTP, but if it is known, it + // should be included nevertheless. + // + // Type: string + // RequirementLevel: Required + // Stability: stable + // Examples: 'https://www.foo.bar/search?q=OpenTelemetry#SemConv' + // Note: `http.url` MUST NOT contain credentials passed via URL in form of + // `https://username:password@www.example.com/`. In such case the attribute's + // value should be `https://www.example.com/`. + HTTPURLKey = attribute.Key("http.url") + // The ordinal number of request resending attempt (for any reason, including + // redirects). + // + // Type: int + // RequirementLevel: Recommended (if and only if request was retried.) + // Stability: stable + // Examples: 3 + // Note: The resend count SHOULD be updated each time an HTTP request gets resent + // by the client, regardless of what was the cause of the resending (e.g. + // redirection, authorization failure, 503 Server Unavailable, network issues, or + // any other). + HTTPResendCountKey = attribute.Key("http.resend_count") +) + // Semantic Convention for HTTP Server const ( - // The primary server name of the matched virtual host. This should be obtained - // via configuration. If no such configuration can be obtained, this attribute - // MUST NOT be set ( `net.host.name` should be used instead). + // The URI scheme identifying the used protocol. // // Type: string - // Required: No + // RequirementLevel: Required // Stability: stable - // Examples: 'example.com' - // Note: `http.url` is usually not readily available on the server side but would - // have to be assembled in a cumbersome and sometimes lossy process from other - // information (see e.g. open-telemetry/opentelemetry-python/pull/148). It is thus - // preferred to supply the raw data that is available. - HTTPServerNameKey = attribute.Key("http.server_name") - // The matched route (path template). + // Examples: 'http', 'https' + HTTPSchemeKey = attribute.Key("http.scheme") + // The full request target as passed in a HTTP request line or equivalent. // // Type: string - // Required: No + // RequirementLevel: Required // Stability: stable - // Examples: '/users/:userID?' + // Examples: '/path/12314/?q=ddds' + HTTPTargetKey = attribute.Key("http.target") + // The matched route (path template in the format used by the respective server + // framework). See note below + // + // Type: string + // RequirementLevel: ConditionallyRequired (If and only if it's available) + // Stability: stable + // Examples: '/users/:userID?', '{controller}/{action}/{id?}' + // Note: 'http.route' MUST NOT be populated when this is not supported by the HTTP + // server framework as the route attribute should have low-cardinality and the URI + // path can NOT substitute it. HTTPRouteKey = attribute.Key("http.route") // The IP address of the original client behind all proxies, if known (e.g. from // [X-Forwarded-For](https://developer.mozilla.org/en- // US/docs/Web/HTTP/Headers/X-Forwarded-For)). // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '83.164.160.102' - // Note: This is not necessarily the same as `net.peer.ip`, which would + // Note: This is not necessarily the same as `net.sock.peer.addr`, which would // identify the network-level peer, which may be a proxy. // This attribute should be set when a source of information different - // from the one used for `net.peer.ip`, is available even if that other - // source just confirms the same value as `net.peer.ip`. - // Rationale: For `net.peer.ip`, one typically does not know if it + // from the one used for `net.sock.peer.addr`, is available even if that other + // source just confirms the same value as `net.sock.peer.addr`. + // Rationale: For `net.sock.peer.addr`, one typically does not know if it // comes from a proxy, reverse proxy, or the actual client. Setting - // `http.client_ip` when it's the same as `net.peer.ip` means that + // `http.client_ip` when it's the same as `net.sock.peer.addr` means that // one is at least somewhat confident that the address is not that of // the closest proxy. HTTPClientIPKey = attribute.Key("http.client_ip") @@ -1085,7 +1159,7 @@ const ( // The keys in the `RequestItems` object field. // // Type: string[] - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'Users', 'Cats' AWSDynamoDBTableNamesKey = attribute.Key("aws.dynamodb.table_names") @@ -1093,7 +1167,7 @@ const ( // field. // // Type: string[] - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '{ "CapacityUnits": number, "GlobalSecondaryIndexes": { "string" : { // "CapacityUnits": number, "ReadCapacityUnits": number, "WriteCapacityUnits": @@ -1106,7 +1180,7 @@ const ( // The JSON-serialized value of the `ItemCollectionMetrics` response field. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '{ "string" : [ { "ItemCollectionKey": { "string" : { "B": blob, // "BOOL": boolean, "BS": [ blob ], "L": [ "AttributeValue" ], "M": { "string" : @@ -1116,27 +1190,27 @@ const ( // The value of the `ProvisionedThroughput.ReadCapacityUnits` request parameter. // // Type: double - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 1.0, 2.0 AWSDynamoDBProvisionedReadCapacityKey = attribute.Key("aws.dynamodb.provisioned_read_capacity") // The value of the `ProvisionedThroughput.WriteCapacityUnits` request parameter. // // Type: double - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 1.0, 2.0 AWSDynamoDBProvisionedWriteCapacityKey = attribute.Key("aws.dynamodb.provisioned_write_capacity") // The value of the `ConsistentRead` request parameter. // // Type: boolean - // Required: No + // RequirementLevel: Optional // Stability: stable AWSDynamoDBConsistentReadKey = attribute.Key("aws.dynamodb.consistent_read") // The value of the `ProjectionExpression` request parameter. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'Title', 'Title, Price, Color', 'Title, Description, RelatedItems, // ProductReviews' @@ -1144,28 +1218,28 @@ const ( // The value of the `Limit` request parameter. // // Type: int - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 10 AWSDynamoDBLimitKey = attribute.Key("aws.dynamodb.limit") // The value of the `AttributesToGet` request parameter. // // Type: string[] - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'lives', 'id' AWSDynamoDBAttributesToGetKey = attribute.Key("aws.dynamodb.attributes_to_get") // The value of the `IndexName` request parameter. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'name_to_group' AWSDynamoDBIndexNameKey = attribute.Key("aws.dynamodb.index_name") // The value of the `Select` request parameter. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'ALL_ATTRIBUTES', 'COUNT' AWSDynamoDBSelectKey = attribute.Key("aws.dynamodb.select") @@ -1177,7 +1251,7 @@ const ( // field // // Type: string[] - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '{ "IndexName": "string", "KeySchema": [ { "AttributeName": "string", // "KeyType": "string" } ], "Projection": { "NonKeyAttributes": [ "string" ], @@ -1188,7 +1262,7 @@ const ( // field. // // Type: string[] - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '{ "IndexARN": "string", "IndexName": "string", "IndexSizeBytes": // number, "ItemCount": number, "KeySchema": [ { "AttributeName": "string", @@ -1202,14 +1276,14 @@ const ( // The value of the `ExclusiveStartTableName` request parameter. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'Users', 'CatsTable' AWSDynamoDBExclusiveStartTableKey = attribute.Key("aws.dynamodb.exclusive_start_table") // The the number of items in the `TableNames` response parameter. // // Type: int - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 20 AWSDynamoDBTableCountKey = attribute.Key("aws.dynamodb.table_count") @@ -1220,7 +1294,7 @@ const ( // The value of the `ScanIndexForward` request parameter. // // Type: boolean - // Required: No + // RequirementLevel: Optional // Stability: stable AWSDynamoDBScanForwardKey = attribute.Key("aws.dynamodb.scan_forward") ) @@ -1230,28 +1304,28 @@ const ( // The value of the `Segment` request parameter. // // Type: int - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 10 AWSDynamoDBSegmentKey = attribute.Key("aws.dynamodb.segment") // The value of the `TotalSegments` request parameter. // // Type: int - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 100 AWSDynamoDBTotalSegmentsKey = attribute.Key("aws.dynamodb.total_segments") // The value of the `Count` response parameter. // // Type: int - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 10 AWSDynamoDBCountKey = attribute.Key("aws.dynamodb.count") // The value of the `ScannedCount` response parameter. // // Type: int - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 50 AWSDynamoDBScannedCountKey = attribute.Key("aws.dynamodb.scanned_count") @@ -1263,7 +1337,7 @@ const ( // field. // // Type: string[] - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '{ "AttributeName": "string", "AttributeType": "string" }' AWSDynamoDBAttributeDefinitionsKey = attribute.Key("aws.dynamodb.attribute_definitions") @@ -1271,7 +1345,7 @@ const ( // request field. // // Type: string[] - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '{ "Create": { "IndexName": "string", "KeySchema": [ { // "AttributeName": "string", "KeyType": "string" } ], "Projection": { @@ -1281,90 +1355,121 @@ const ( AWSDynamoDBGlobalSecondaryIndexUpdatesKey = attribute.Key("aws.dynamodb.global_secondary_index_updates") ) -// This document defines the attributes used in messaging systems. +// This document defines semantic conventions to apply when instrumenting the GraphQL implementation. They map GraphQL operations to attributes on a Span. const ( - // A string identifying the messaging system. + // The name of the operation being executed. // // Type: string - // Required: Always + // RequirementLevel: Optional // Stability: stable - // Examples: 'kafka', 'rabbitmq', 'rocketmq', 'activemq', 'AmazonSQS' - MessagingSystemKey = attribute.Key("messaging.system") - // The message destination name. This might be equal to the span name but is - // required nevertheless. - // - // Type: string - // Required: Always - // Stability: stable - // Examples: 'MyQueue', 'MyTopic' - MessagingDestinationKey = attribute.Key("messaging.destination") - // The kind of message destination + // Examples: 'findBookByID' + GraphqlOperationNameKey = attribute.Key("graphql.operation.name") + // The type of the operation being executed. // // Type: Enum - // Required: Required only if the message destination is either a `queue` or - // `topic`. + // RequirementLevel: Optional // Stability: stable - MessagingDestinationKindKey = attribute.Key("messaging.destination_kind") - // A boolean that is true if the message destination is temporary. - // - // Type: boolean - // Required: If missing, it is assumed to be false. - // Stability: stable - MessagingTempDestinationKey = attribute.Key("messaging.temp_destination") - // The name of the transport protocol. + // Examples: 'query', 'mutation', 'subscription' + GraphqlOperationTypeKey = attribute.Key("graphql.operation.type") + // The GraphQL document being executed. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable - // Examples: 'AMQP', 'MQTT' - MessagingProtocolKey = attribute.Key("messaging.protocol") - // The version of the transport protocol. - // - // Type: string - // Required: No - // Stability: stable - // Examples: '0.9.1' - MessagingProtocolVersionKey = attribute.Key("messaging.protocol_version") - // Connection string. - // - // Type: string - // Required: No - // Stability: stable - // Examples: 'tibjmsnaming://localhost:7222', - // 'https://queue.amazonaws.com/80398EXAMPLE/MyQueue' - MessagingURLKey = attribute.Key("messaging.url") + // Examples: 'query findBookByID { bookByID(id: ?) { name } }' + // Note: The value may be sanitized to exclude sensitive information. + GraphqlDocumentKey = attribute.Key("graphql.document") +) + +var ( + // GraphQL query + GraphqlOperationTypeQuery = GraphqlOperationTypeKey.String("query") + // GraphQL mutation + GraphqlOperationTypeMutation = GraphqlOperationTypeKey.String("mutation") + // GraphQL subscription + GraphqlOperationTypeSubscription = GraphqlOperationTypeKey.String("subscription") +) + +// Semantic convention describing per-message attributes populated on messaging spans or links. +const ( // A value used by the messaging system as an identifier for the message, // represented as a string. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '452a7c7c7c7048c2f887f61572b18fc2' - MessagingMessageIDKey = attribute.Key("messaging.message_id") + MessagingMessageIDKey = attribute.Key("messaging.message.id") // The [conversation ID](#conversations) identifying the conversation to which the // message belongs, represented as a string. Sometimes called "Correlation ID". // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'MyConversationID' - MessagingConversationIDKey = attribute.Key("messaging.conversation_id") + MessagingMessageConversationIDKey = attribute.Key("messaging.message.conversation_id") // The (uncompressed) size of the message payload in bytes. Also use this // attribute if it is unknown whether the compressed or uncompressed payload size // is reported. // // Type: int - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 2738 - MessagingMessagePayloadSizeBytesKey = attribute.Key("messaging.message_payload_size_bytes") + MessagingMessagePayloadSizeBytesKey = attribute.Key("messaging.message.payload_size_bytes") // The compressed size of the message payload in bytes. // // Type: int - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 2048 - MessagingMessagePayloadCompressedSizeBytesKey = attribute.Key("messaging.message_payload_compressed_size_bytes") + MessagingMessagePayloadCompressedSizeBytesKey = attribute.Key("messaging.message.payload_compressed_size_bytes") +) + +// Semantic convention for attributes that describe messaging destination on broker +const ( + // The message destination name + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'MyQueue', 'MyTopic' + // Note: Destination name SHOULD uniquely identify a specific queue, topic or + // other entity within the broker. If + // the broker does not have such notion, the destination name SHOULD uniquely + // identify the broker. + MessagingDestinationNameKey = attribute.Key("messaging.destination.name") + // The kind of message destination + // + // Type: Enum + // RequirementLevel: Optional + // Stability: stable + MessagingDestinationKindKey = attribute.Key("messaging.destination.kind") + // Low cardinality representation of the messaging destination name + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '/customers/{customerID}' + // Note: Destination names could be constructed from templates. An example would + // be a destination name involving a user name or product id. Although the + // destination name in this case is of high cardinality, the underlying template + // is of low cardinality and can be effectively used for grouping and aggregation. + MessagingDestinationTemplateKey = attribute.Key("messaging.destination.template") + // A boolean that is true if the message destination is temporary and might not + // exist anymore after messages are processed. + // + // Type: boolean + // RequirementLevel: Optional + // Stability: stable + MessagingDestinationTemporaryKey = attribute.Key("messaging.destination.temporary") + // A boolean that is true if the message destination is anonymous (could be + // unnamed or have auto-generated name). + // + // Type: boolean + // RequirementLevel: Optional + // Stability: stable + MessagingDestinationAnonymousKey = attribute.Key("messaging.destination.anonymous") ) var ( @@ -1374,90 +1479,184 @@ var ( MessagingDestinationKindTopic = MessagingDestinationKindKey.String("topic") ) -// Semantic convention for a consumer of messages received from a messaging system +// Semantic convention for attributes that describe messaging source on broker const ( - // A string identifying the kind of message consumption as defined in the - // [Operation names](#operation-names) section above. If the operation is "send", - // this attribute MUST NOT be set, since the operation can be inferred from the - // span kind in that case. - // - // Type: Enum - // Required: No - // Stability: stable - MessagingOperationKey = attribute.Key("messaging.operation") - // The identifier for the consumer receiving a message. For Kafka, set it to - // `{messaging.kafka.consumer_group} - {messaging.kafka.client_id}`, if both are - // present, or only `messaging.kafka.consumer_group`. For brokers, such as - // RabbitMQ and Artemis, set it to the `client_id` of the client consuming the - // message. + // The message source name // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable - // Examples: 'mygroup - client-6' - MessagingConsumerIDKey = attribute.Key("messaging.consumer_id") + // Examples: 'MyQueue', 'MyTopic' + // Note: Source name SHOULD uniquely identify a specific queue, topic, or other + // entity within the broker. If + // the broker does not have such notion, the source name SHOULD uniquely identify + // the broker. + MessagingSourceNameKey = attribute.Key("messaging.source.name") + // The kind of message source + // + // Type: Enum + // RequirementLevel: Optional + // Stability: stable + MessagingSourceKindKey = attribute.Key("messaging.source.kind") + // Low cardinality representation of the messaging source name + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: '/customers/{customerID}' + // Note: Source names could be constructed from templates. An example would be a + // source name involving a user name or product id. Although the source name in + // this case is of high cardinality, the underlying template is of low cardinality + // and can be effectively used for grouping and aggregation. + MessagingSourceTemplateKey = attribute.Key("messaging.source.template") + // A boolean that is true if the message source is temporary and might not exist + // anymore after messages are processed. + // + // Type: boolean + // RequirementLevel: Optional + // Stability: stable + MessagingSourceTemporaryKey = attribute.Key("messaging.source.temporary") + // A boolean that is true if the message source is anonymous (could be unnamed or + // have auto-generated name). + // + // Type: boolean + // RequirementLevel: Optional + // Stability: stable + MessagingSourceAnonymousKey = attribute.Key("messaging.source.anonymous") ) var ( + // A message received from a queue + MessagingSourceKindQueue = MessagingSourceKindKey.String("queue") + // A message received from a topic + MessagingSourceKindTopic = MessagingSourceKindKey.String("topic") +) + +// This document defines general attributes used in messaging systems. +const ( + // A string identifying the messaging system. + // + // Type: string + // RequirementLevel: Required + // Stability: stable + // Examples: 'kafka', 'rabbitmq', 'rocketmq', 'activemq', 'AmazonSQS' + MessagingSystemKey = attribute.Key("messaging.system") + // A string identifying the kind of messaging operation as defined in the + // [Operation names](#operation-names) section above. + // + // Type: Enum + // RequirementLevel: Required + // Stability: stable + // Note: If a custom value is used, it MUST be of low cardinality. + MessagingOperationKey = attribute.Key("messaging.operation") + // The number of messages sent, received, or processed in the scope of the + // batching operation. + // + // Type: int + // RequirementLevel: ConditionallyRequired (If the span describes an operation on + // a batch of messages.) + // Stability: stable + // Examples: 0, 1, 2 + // Note: Instrumentations SHOULD NOT set `messaging.batch.message_count` on spans + // that operate with a single message. When a messaging client library supports + // both batch and single-message API for the same operation, instrumentations + // SHOULD use `messaging.batch.message_count` for batching APIs and SHOULD NOT use + // it for single-message APIs. + MessagingBatchMessageCountKey = attribute.Key("messaging.batch.message_count") +) + +var ( + // publish + MessagingOperationPublish = MessagingOperationKey.String("publish") // receive MessagingOperationReceive = MessagingOperationKey.String("receive") // process MessagingOperationProcess = MessagingOperationKey.String("process") ) +// Semantic convention for a consumer of messages received from a messaging system +const ( + // The identifier for the consumer receiving a message. For Kafka, set it to + // `{messaging.kafka.consumer.group} - {messaging.kafka.client_id}`, if both are + // present, or only `messaging.kafka.consumer.group`. For brokers, such as + // RabbitMQ and Artemis, set it to the `client_id` of the client consuming the + // message. + // + // Type: string + // RequirementLevel: Optional + // Stability: stable + // Examples: 'mygroup - client-6' + MessagingConsumerIDKey = attribute.Key("messaging.consumer.id") +) + // Attributes for RabbitMQ const ( // RabbitMQ message routing key. // // Type: string - // Required: Unless it is empty. + // RequirementLevel: ConditionallyRequired (If not empty.) // Stability: stable // Examples: 'myKey' - MessagingRabbitmqRoutingKeyKey = attribute.Key("messaging.rabbitmq.routing_key") + MessagingRabbitmqDestinationRoutingKeyKey = attribute.Key("messaging.rabbitmq.destination.routing_key") ) // Attributes for Apache Kafka const ( // Message keys in Kafka are used for grouping alike messages to ensure they're - // processed on the same partition. They differ from `messaging.message_id` in + // processed on the same partition. They differ from `messaging.message.id` in // that they're not unique. If the key is `null`, the attribute MUST NOT be set. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'myKey' // Note: If the key type is not string, it's string representation has to be // supplied for the attribute. If the key has no unambiguous, canonical string // form, don't include its value. - MessagingKafkaMessageKeyKey = attribute.Key("messaging.kafka.message_key") + MessagingKafkaMessageKeyKey = attribute.Key("messaging.kafka.message.key") // Name of the Kafka Consumer Group that is handling the message. Only applies to // consumers, not producers. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'my-group' - MessagingKafkaConsumerGroupKey = attribute.Key("messaging.kafka.consumer_group") + MessagingKafkaConsumerGroupKey = attribute.Key("messaging.kafka.consumer.group") // Client ID for the Consumer or Producer that is handling the message. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'client-5' MessagingKafkaClientIDKey = attribute.Key("messaging.kafka.client_id") // Partition the message is sent to. // // Type: int - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 2 - MessagingKafkaPartitionKey = attribute.Key("messaging.kafka.partition") + MessagingKafkaDestinationPartitionKey = attribute.Key("messaging.kafka.destination.partition") + // Partition the message is received from. + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 2 + MessagingKafkaSourcePartitionKey = attribute.Key("messaging.kafka.source.partition") + // The offset of a record in the corresponding Kafka partition. + // + // Type: int + // RequirementLevel: Optional + // Stability: stable + // Examples: 42 + MessagingKafkaMessageOffsetKey = attribute.Key("messaging.kafka.message.offset") // A boolean that is true if the message is a tombstone. // // Type: boolean - // Required: If missing, it is assumed to be false. + // RequirementLevel: ConditionallyRequired (If value is `true`. When missing, the + // value is assumed to be `false`.) // Stability: stable - MessagingKafkaTombstoneKey = attribute.Key("messaging.kafka.tombstone") + MessagingKafkaMessageTombstoneKey = attribute.Key("messaging.kafka.message.tombstone") ) // Attributes for Apache RocketMQ @@ -1466,7 +1665,7 @@ const ( // individual. // // Type: string - // Required: Always + // RequirementLevel: Required // Stability: stable // Examples: 'myNamespace' MessagingRocketmqNamespaceKey = attribute.Key("messaging.rocketmq.namespace") @@ -1474,41 +1673,67 @@ const ( // client type is identified by the SpanKind. // // Type: string - // Required: Always + // RequirementLevel: Required // Stability: stable // Examples: 'myConsumerGroup' MessagingRocketmqClientGroupKey = attribute.Key("messaging.rocketmq.client_group") // The unique identifier for each client. // // Type: string - // Required: Always + // RequirementLevel: Required // Stability: stable // Examples: 'myhost@8742@s8083jm' MessagingRocketmqClientIDKey = attribute.Key("messaging.rocketmq.client_id") + // The timestamp in milliseconds that the delay message is expected to be + // delivered to consumer. + // + // Type: int + // RequirementLevel: ConditionallyRequired (If the message type is delay and delay + // time level is not specified.) + // Stability: stable + // Examples: 1665987217045 + MessagingRocketmqMessageDeliveryTimestampKey = attribute.Key("messaging.rocketmq.message.delivery_timestamp") + // The delay time level for delay message, which determines the message delay + // time. + // + // Type: int + // RequirementLevel: ConditionallyRequired (If the message type is delay and + // delivery timestamp is not specified.) + // Stability: stable + // Examples: 3 + MessagingRocketmqMessageDelayTimeLevelKey = attribute.Key("messaging.rocketmq.message.delay_time_level") + // It is essential for FIFO message. Messages that belong to the same message + // group are always processed one by one within the same consumer group. + // + // Type: string + // RequirementLevel: ConditionallyRequired (If the message type is FIFO.) + // Stability: stable + // Examples: 'myMessageGroup' + MessagingRocketmqMessageGroupKey = attribute.Key("messaging.rocketmq.message.group") // Type of message. // // Type: Enum - // Required: No + // RequirementLevel: Optional // Stability: stable - MessagingRocketmqMessageTypeKey = attribute.Key("messaging.rocketmq.message_type") + MessagingRocketmqMessageTypeKey = attribute.Key("messaging.rocketmq.message.type") // The secondary classifier of message besides topic. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'tagA' - MessagingRocketmqMessageTagKey = attribute.Key("messaging.rocketmq.message_tag") + MessagingRocketmqMessageTagKey = attribute.Key("messaging.rocketmq.message.tag") // Key(s) of message, another way to mark message besides message id. // // Type: string[] - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'keyA', 'keyB' - MessagingRocketmqMessageKeysKey = attribute.Key("messaging.rocketmq.message_keys") + MessagingRocketmqMessageKeysKey = attribute.Key("messaging.rocketmq.message.keys") // Model of message consumption. This only applies to consumer spans. // // Type: Enum - // Required: No + // RequirementLevel: Optional // Stability: stable MessagingRocketmqConsumptionModelKey = attribute.Key("messaging.rocketmq.consumption_model") ) @@ -1537,14 +1762,14 @@ const ( // identifiers. // // Type: Enum - // Required: Always + // RequirementLevel: Required // Stability: stable RPCSystemKey = attribute.Key("rpc.system") // The full (logical) name of the service being called, including its package // name, if applicable. // // Type: string - // Required: No, but recommended + // RequirementLevel: Recommended // Stability: stable // Examples: 'myservice.EchoService' // Note: This is the logical name of the service from the RPC interface @@ -1558,7 +1783,7 @@ const ( // part in the span name. // // Type: string - // Required: No, but recommended + // RequirementLevel: Recommended // Stability: stable // Examples: 'exampleMethod' // Note: This is the logical name of the method from the RPC interface @@ -1587,7 +1812,7 @@ const ( // request. // // Type: Enum - // Required: Always + // RequirementLevel: Required // Stability: stable RPCGRPCStatusCodeKey = attribute.Key("rpc.grpc.status_code") ) @@ -1635,7 +1860,8 @@ const ( // 1.0 does not specify this, the value can be omitted. // // Type: string - // Required: If missing, it is assumed to be "1.0". + // RequirementLevel: ConditionallyRequired (If other than the default version + // (`1.0`)) // Stability: stable // Examples: '2.0', '1.0' RPCJsonrpcVersionKey = attribute.Key("rpc.jsonrpc.version") @@ -1645,60 +1871,22 @@ const ( // if this is a notification. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: '10', 'request-7', '' RPCJsonrpcRequestIDKey = attribute.Key("rpc.jsonrpc.request_id") // `error.code` property of response if it is an error response. // // Type: int - // Required: If missing, response is assumed to be successful. + // RequirementLevel: ConditionallyRequired (If response is not successful.) // Stability: stable // Examples: -32700, 100 RPCJsonrpcErrorCodeKey = attribute.Key("rpc.jsonrpc.error_code") // `error.message` property of response if it is an error response. // // Type: string - // Required: No + // RequirementLevel: Optional // Stability: stable // Examples: 'Parse error', 'User already exists' RPCJsonrpcErrorMessageKey = attribute.Key("rpc.jsonrpc.error_message") ) - -// RPC received/sent message. -const ( - // Whether this is a received or sent message. - // - // Type: Enum - // Required: No - // Stability: stable - MessageTypeKey = attribute.Key("message.type") - // MUST be calculated as two different counters starting from `1` one for sent - // messages and one for received message. - // - // Type: int - // Required: No - // Stability: stable - // Note: This way we guarantee that the values will be consistent between - // different implementations. - MessageIDKey = attribute.Key("message.id") - // Compressed size of the message in bytes. - // - // Type: int - // Required: No - // Stability: stable - MessageCompressedSizeKey = attribute.Key("message.compressed_size") - // Uncompressed size of the message in bytes. - // - // Type: int - // Required: No - // Stability: stable - MessageUncompressedSizeKey = attribute.Key("message.uncompressed_size") -) - -var ( - // sent - MessageTypeSent = MessageTypeKey.String("SENT") - // received - MessageTypeReceived = MessageTypeKey.String("RECEIVED") -) diff --git a/vendor/go.opentelemetry.io/otel/version.go b/vendor/go.opentelemetry.io/otel/version.go index 00b79bcc2..bda8f7cbf 100644 --- a/vendor/go.opentelemetry.io/otel/version.go +++ b/vendor/go.opentelemetry.io/otel/version.go @@ -16,5 +16,5 @@ package otel // import "go.opentelemetry.io/otel" // Version is the current release version of OpenTelemetry in use. func Version() string { - return "1.11.2" + return "1.12.0" } diff --git a/vendor/go.opentelemetry.io/otel/versions.yaml b/vendor/go.opentelemetry.io/otel/versions.yaml index 611879def..66f456222 100644 --- a/vendor/go.opentelemetry.io/otel/versions.yaml +++ b/vendor/go.opentelemetry.io/otel/versions.yaml @@ -14,7 +14,7 @@ module-sets: stable-v1: - version: v1.11.2 + version: v1.12.0 modules: - go.opentelemetry.io/otel - go.opentelemetry.io/otel/bridge/opentracing @@ -34,7 +34,7 @@ module-sets: - go.opentelemetry.io/otel/trace - go.opentelemetry.io/otel/sdk experimental-metrics: - version: v0.34.0 + version: v0.35.0 modules: - go.opentelemetry.io/otel/example/opencensus - go.opentelemetry.io/otel/example/prometheus diff --git a/vendor/google.golang.org/api/internal/version.go b/vendor/google.golang.org/api/internal/version.go index 2c1b8c1ab..2d02a441a 100644 --- a/vendor/google.golang.org/api/internal/version.go +++ b/vendor/google.golang.org/api/internal/version.go @@ -5,4 +5,4 @@ package internal // Version is the current tagged release of the library. -const Version = "0.108.0" +const Version = "0.109.0" diff --git a/vendor/modules.txt b/vendor/modules.txt index a3147efe8..0af0d86a2 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -80,7 +80,7 @@ github.com/VividCortex/ewma # github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 ## explicit; go 1.15 github.com/alecthomas/units -# github.com/aws/aws-sdk-go v1.44.189 +# github.com/aws/aws-sdk-go v1.44.190 ## explicit; go 1.11 github.com/aws/aws-sdk-go/aws github.com/aws/aws-sdk-go/aws/awserr @@ -268,7 +268,7 @@ github.com/felixge/httpsnoop ## explicit; go 1.17 github.com/go-kit/log github.com/go-kit/log/level -# github.com/go-logfmt/logfmt v0.5.1 +# github.com/go-logfmt/logfmt v0.6.0 ## explicit; go 1.17 github.com/go-logfmt/logfmt # github.com/go-logr/logr v1.2.3 @@ -441,7 +441,7 @@ github.com/russross/blackfriday/v2 ## explicit; go 1.13 github.com/stretchr/testify/assert github.com/stretchr/testify/require -# github.com/urfave/cli/v2 v2.24.1 +# github.com/urfave/cli/v2 v2.24.2 ## explicit; go 1.18 github.com/urfave/cli/v2 # github.com/valyala/bytebufferpool v1.0.0 @@ -488,10 +488,10 @@ go.opencensus.io/trace go.opencensus.io/trace/internal go.opencensus.io/trace/propagation go.opencensus.io/trace/tracestate -# go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.37.0 +# go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.38.0 ## explicit; go 1.18 go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp -# go.opentelemetry.io/otel v1.11.2 +# go.opentelemetry.io/otel v1.12.0 ## explicit; go 1.18 go.opentelemetry.io/otel go.opentelemetry.io/otel/attribute @@ -502,20 +502,17 @@ go.opentelemetry.io/otel/internal/attribute go.opentelemetry.io/otel/internal/baggage go.opentelemetry.io/otel/internal/global go.opentelemetry.io/otel/propagation -go.opentelemetry.io/otel/semconv/internal -go.opentelemetry.io/otel/semconv/v1.12.0 -# go.opentelemetry.io/otel/metric v0.34.0 +go.opentelemetry.io/otel/semconv/internal/v2 +go.opentelemetry.io/otel/semconv/v1.17.0 +go.opentelemetry.io/otel/semconv/v1.17.0/httpconv +# go.opentelemetry.io/otel/metric v0.35.0 ## explicit; go 1.18 go.opentelemetry.io/otel/metric go.opentelemetry.io/otel/metric/global go.opentelemetry.io/otel/metric/instrument -go.opentelemetry.io/otel/metric/instrument/asyncfloat64 -go.opentelemetry.io/otel/metric/instrument/asyncint64 -go.opentelemetry.io/otel/metric/instrument/syncfloat64 -go.opentelemetry.io/otel/metric/instrument/syncint64 go.opentelemetry.io/otel/metric/internal/global go.opentelemetry.io/otel/metric/unit -# go.opentelemetry.io/otel/trace v1.11.2 +# go.opentelemetry.io/otel/trace v1.12.0 ## explicit; go 1.18 go.opentelemetry.io/otel/trace # go.uber.org/atomic v1.10.0 @@ -525,7 +522,7 @@ go.uber.org/atomic ## explicit; go 1.18 go.uber.org/goleak go.uber.org/goleak/internal/stack -# golang.org/x/exp v0.0.0-20230127193734-31bee513bff7 +# golang.org/x/exp v0.0.0-20230131160201-f062dba9d201 ## explicit; go 1.18 golang.org/x/exp/constraints golang.org/x/exp/slices @@ -572,7 +569,7 @@ golang.org/x/time/rate ## explicit; go 1.17 golang.org/x/xerrors golang.org/x/xerrors/internal -# google.golang.org/api v0.108.0 +# google.golang.org/api v0.109.0 ## explicit; go 1.19 google.golang.org/api/googleapi google.golang.org/api/googleapi/transport