vendor: vendor: upgrade OpenTelemetry to v1.19.0 / v0.45.0
Upgrade to the latest OpenTelemetry libraries; this will unblock a lot of downstream projects in the ecosystem to upgrade, as some of the parts here were pre-1.0/unstable. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
65973c6c40
commit
c14bd4f1ad
127 changed files with 12496 additions and 2209 deletions
21
vendor.mod
21
vendor.mod
|
@ -92,12 +92,12 @@ require (
|
|||
github.com/vishvananda/netlink v1.2.1-beta.2
|
||||
github.com/vishvananda/netns v0.0.4
|
||||
go.etcd.io/bbolt v1.3.7
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.40.0
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.40.0
|
||||
go.opentelemetry.io/otel v1.14.0
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.14.0
|
||||
go.opentelemetry.io/otel/sdk v1.14.0
|
||||
go.opentelemetry.io/otel/trace v1.14.0
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.45.0
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.42.0
|
||||
go.opentelemetry.io/otel v1.19.0
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0
|
||||
go.opentelemetry.io/otel/sdk v1.19.0
|
||||
go.opentelemetry.io/otel/trace v1.19.0
|
||||
golang.org/x/mod v0.11.0
|
||||
golang.org/x/net v0.17.0
|
||||
golang.org/x/sync v0.3.0
|
||||
|
@ -196,11 +196,10 @@ require (
|
|||
go.etcd.io/etcd/server/v3 v3.5.6 // indirect
|
||||
go.opencensus.io v0.24.0 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.40.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.14.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v0.37.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.19.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
|
||||
go.uber.org/atomic v1.9.0 // indirect
|
||||
go.uber.org/multierr v1.8.0 // indirect
|
||||
go.uber.org/zap v1.21.0 // indirect
|
||||
|
|
77
vendor.sum
77
vendor.sum
|
@ -19,8 +19,6 @@ cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6
|
|||
cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc=
|
||||
cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk=
|
||||
cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs=
|
||||
cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc=
|
||||
cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY=
|
||||
cloud.google.com/go v0.110.4 h1:1JYyxKMN9hd5dR2MYTPWkGUgcoxVVhg0LKNKEo0qvmk=
|
||||
cloud.google.com/go v0.110.4/go.mod h1:+EYjdK8e5RME/VY/qLCAtuyALQ9q67dvuum8i+H5xsI=
|
||||
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
|
||||
|
@ -28,7 +26,6 @@ cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNF
|
|||
cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc=
|
||||
cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg=
|
||||
cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc=
|
||||
cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ=
|
||||
cloud.google.com/go/compute v1.21.0 h1:JNBsyXVoOoNJtTQcnEY5uYpZIbeCTYIeDe0Xh1bySMk=
|
||||
cloud.google.com/go/compute v1.21.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM=
|
||||
cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY=
|
||||
|
@ -49,7 +46,6 @@ cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiy
|
|||
cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos=
|
||||
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
|
||||
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
|
||||
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
||||
code.cloudfoundry.org/clock v1.0.0 h1:kFXWQM4bxYvdBw2X8BbBeXwQNgfoWv1vqAk2ZZyBN2o=
|
||||
code.cloudfoundry.org/clock v1.0.0/go.mod h1:QD9Lzhd/ux6eNQVUDVRJX/RKTigpewimNYBi7ivZKY8=
|
||||
code.gitea.io/sdk/gitea v0.12.0/go.mod h1:z3uwDV/b9Ls47NGukYM9XhnHtqPh/J+t40lsUrR6JDY=
|
||||
|
@ -553,7 +549,6 @@ github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w
|
|||
github.com/golang/gddo v0.0.0-20190904175337-72a348e765d2 h1:xisWqjiKEff2B0KfFYGpCqc3M3zdTz+OHQHRc09FeYk=
|
||||
github.com/golang/gddo v0.0.0-20190904175337-72a348e765d2/go.mod h1:xEhNfoBDX1hzLm2Nf80qUvZ2sVwoMZ8d6IE2SrsQfh4=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4=
|
||||
github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE=
|
||||
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
|
@ -569,7 +564,6 @@ github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFU
|
|||
github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
|
||||
github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
|
@ -625,7 +619,6 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
|
|||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
|
@ -646,14 +639,12 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/
|
|||
github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||
github.com/google/martian v2.1.1-0.20190517191504-25dcb96d9e51+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
||||
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/rpmpack v0.0.0-20191226140753-aa36bfddb3a0/go.mod h1:RaTPr0KUf2K7fnZYLNDrr8rxAamWs3iNywJLtQ2AzBg=
|
||||
|
@ -716,7 +707,6 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t
|
|||
github.com/grpc-ecosystem/grpc-gateway v1.9.2/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg=
|
||||
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645/go.mod h1:6iZfnjpejD4L/4DwD7NryNaJyCQdzwWwH2MWhCA90Kw=
|
||||
|
@ -1112,7 +1102,7 @@ github.com/rogpeppe/fastuuid v1.1.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L
|
|||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.5.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
|
||||
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
||||
github.com/rootless-containers/rootlesskit v1.1.1 h1:F5psKWoWY9/VjZ3ifVcaosjvFZJOagX85U22M0/EQZE=
|
||||
github.com/rootless-containers/rootlesskit v1.1.1/go.mod h1:UD5GoA3dqKCJrnvnhVgQQnweMF2qZnf9KLw8EewcMZI=
|
||||
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
|
||||
|
@ -1334,41 +1324,38 @@ go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
|||
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
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/google.golang.org/grpc/otelgrpc v0.25.0/go.mod h1:E5NNboN0UqSAki0Atn9kVwaN7I+l25gGxDqBueo/74E=
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.40.0 h1:5jD3teb4Qh7mx/nfzq4jO2WFFpvXD0vYWFDrdvNWmXk=
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.40.0/go.mod h1:UMklln0+MRhZC4e3PwmN3pCtq4DyIadWw4yikh6bNrw=
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.45.0 h1:RsQi0qJ2imFfCvZabqzM9cNXBG8k6gXMv1A0cXRmH6A=
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.45.0/go.mod h1:vsh3ySueQCiKPxFLvjWC4Z135gIa34TQ/NSqkDTZYUM=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.40.0 h1:ZjF6qLnAVNq6xUh0sK2mCEqwnRrpgr0mLALQXJL34NI=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.40.0/go.mod h1:SD34NWTW0VMH2VvFVfArHPoF+L1ddT4MOQCTb2l8T5I=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.40.0 h1:lE9EJyw3/JhrjWH/hEy9FptnalDQgj7vpbgC2KCCCxE=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.40.0/go.mod h1:pcQ3MM3SWvrA71U4GDqv9UFDJ3HQsW7y5ZO3tDTlUdI=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.42.0 h1:pginetY7+onl4qN1vl0xW/V/v6OBZ0vVdH+esuJgvmM=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.42.0/go.mod h1:XiYsayHc36K3EByOO6nbAXnAWbrUxdjUROCEeeROOH8=
|
||||
go.opentelemetry.io/otel v1.0.1/go.mod h1:OPEOD4jIT2SlZPMmwT6FqZz2C0ZNdQqiWcoK6M0SNFU=
|
||||
go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM=
|
||||
go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU=
|
||||
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.14.0 h1:/fXHZHGvro6MVqV34fJzDhi7sHGpX3Ej/Qjmfn003ho=
|
||||
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.14.0/go.mod h1:UFG7EBMRdXyFstOwH028U0sVf+AvukSGhF0g8+dmNG8=
|
||||
go.opentelemetry.io/otel v1.19.0 h1:MuS/TNf4/j4IXsZuJegVzI1cwut7Qc00344rgH7p8bs=
|
||||
go.opentelemetry.io/otel v1.19.0/go.mod h1:i0QyjOq3UPoTzff0PJB2N66fb4S0+rSbSB15/oyH9fY=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.1/go.mod h1:Kv8liBeVNFkkkbilbgWRpV+wWuu+H5xdOT6HAgd30iw=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.14.0 h1:TKf2uAs2ueguzLaxOCBXNpHxfO/aC7PAdDsSH0IbeRQ=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.14.0/go.mod h1:HrbCVv40OOLTABmOn1ZWty6CHXkU8DK/Urc43tHug70=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 h1:Mne5On7VWdx7omSrSSZvM4Kw7cS7NQkOOmLcgscI51U=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0/go.mod h1:IPtUMKL4O3tH5y+iXVyAXqpAwMuzC1IrxVS81rummfE=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.1/go.mod h1:xOvWoTOrQjxjW61xtOmD/WKGRYb/P4NzRo3bs65U6Rk=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.14.0 h1:ap+y8RXX3Mu9apKVtOkM6WSFESLM8K3wNQyOU8sWHcc=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.14.0/go.mod h1:5w41DY6S9gZrbjuq6Y+753e96WfPha5IcsOSZTtullM=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.14.0 h1:3jAYbRHQAqzLjd9I4tzxwJ8Pk/N6AqBcF6m1ZHrxG94=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.14.0/go.mod h1:+N7zNjIJv4K+DeX67XXET0P+eIciESgaFDBqh+ZJFS4=
|
||||
go.opentelemetry.io/otel/metric v0.37.0 h1:pHDQuLQOZwYD+Km0eb657A25NaRzy0a+eLyKfDXedEs=
|
||||
go.opentelemetry.io/otel/metric v0.37.0/go.mod h1:DmdaHfGt54iV6UKxsV9slj2bBRJcKC1B1uvDLIioc1s=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 h1:3d+S281UTjM+AbF31XSOYn1qXn3BgIdWl8HNEpx08Jk=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0/go.mod h1:0+KuTDyKL4gjKCF75pHOX4wuzYDUZYfAQdSu43o+Z2I=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 h1:IeMeyr1aBvBiPVYihXIaeIZba6b8E1bYp7lbdxK8CQg=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0/go.mod h1:oVdCUtjq9MK9BlS7TtucsQwUcXcymNiEDjgDD2jMtZU=
|
||||
go.opentelemetry.io/otel/metric v1.19.0 h1:aTzpGtV0ar9wlV4Sna9sdJyII5jTVJEvKETPiOKwvpE=
|
||||
go.opentelemetry.io/otel/metric v1.19.0/go.mod h1:L5rUsV9kM1IxCj1MmSdS+JQAcVm319EUrDVLrt7jqt8=
|
||||
go.opentelemetry.io/otel/sdk v1.0.1/go.mod h1:HrdXne+BiwsOHYYkBE5ysIcv2bvdZstxzmCQhxTcZkI=
|
||||
go.opentelemetry.io/otel/sdk v1.14.0 h1:PDCppFRDq8A1jL9v6KMI6dYesaq+DFcDZvjsoGvxGzY=
|
||||
go.opentelemetry.io/otel/sdk v1.14.0/go.mod h1:bwIC5TjrNG6QDCHNWvW4HLHtUQ4I+VQDsnjhvyZCALM=
|
||||
go.opentelemetry.io/otel/sdk v1.19.0 h1:6USY6zH+L8uMH8L3t1enZPR3WFEmSTADlqldyHtJi3o=
|
||||
go.opentelemetry.io/otel/sdk v1.19.0/go.mod h1:NedEbbS4w3C6zElbLdPJKOpJQOrGUJ+GfzpjUvI0v1A=
|
||||
go.opentelemetry.io/otel/trace v1.0.1/go.mod h1:5g4i4fKLaX2BQpSBsxw8YYcgKpMMSW3x7ZTuYBr3sUk=
|
||||
go.opentelemetry.io/otel/trace v1.14.0 h1:wp2Mmvj41tDsyAJXiWDWpfNsOiIyd38fy85pyKcFq/M=
|
||||
go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8=
|
||||
go.opentelemetry.io/otel/trace v1.19.0 h1:DFVQmlVbfVeOuBRrwdtaehRrWiL1JoVs9CPIQ1Dzxpg=
|
||||
go.opentelemetry.io/otel/trace v1.19.0/go.mod h1:mfaSyvGyEJEI0nyV2I4qhNQnbBOUUmYZpYojqMnX2vo=
|
||||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||
go.opentelemetry.io/proto/otlp v0.9.0/go.mod h1:1vKfU9rv61e9EVGthD1zNvUbiwPcimSsOPU9brfSHJg=
|
||||
go.opentelemetry.io/proto/otlp v0.19.0 h1:IVN6GR+mhC4s5yfcTbmzHYODqvWAp3ZedA2SJPI1Nnw=
|
||||
go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U=
|
||||
go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I=
|
||||
go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM=
|
||||
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
|
@ -1491,9 +1478,7 @@ golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLL
|
|||
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
|
@ -1518,7 +1503,6 @@ golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4Iltr
|
|||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.10.0 h1:zHCpF2Khkwy4mMB4bv0U37YtJdTGW8jI0glAApi0Kh8=
|
||||
golang.org/x/oauth2 v0.10.0/go.mod h1:kTpgurOux7LqtuxjuyZa4Gj2gdezIt/jQtGnNFfypQI=
|
||||
golang.org/x/perf v0.0.0-20180704124530-6e6d33e29852/go.mod h1:JLpeXjPJfIyPr5TlbXLkXWLhP8nz10XfvxElABhCtcw=
|
||||
|
@ -1597,13 +1581,11 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
|
@ -1730,12 +1712,8 @@ golang.org/x/tools v0.0.0-20200426102838-f3a5411a4c3b/go.mod h1:EkVYQZoAsY45+roY
|
|||
golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200502202811-ed308ab3e770/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
|
@ -1774,9 +1752,6 @@ google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/
|
|||
google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
|
||||
google.golang.org/api v0.25.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
|
||||
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.126.0 h1:q4GJq+cAdMAC7XP7njvQ4tvohGLiSlytuL4BQxbIZ+o=
|
||||
google.golang.org/api v0.126.0/go.mod h1:mBwVAtz+87bEN6CbA1GtZPDOqY2R5ONPqJeIlvyo4Aw=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
|
@ -1822,15 +1797,9 @@ google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfG
|
|||
google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||
google.golang.org/genproto v0.0.0-20200527145253-8367513e4ece/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
|
||||
google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
|
||||
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
|
||||
google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
|
||||
google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 h1:Z0hjGZePRE0ZBWotvtrwxFNrNE9CUAGtplaDK5NNI/g=
|
||||
google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98/go.mod h1:S7mY02OqCJTD0E1OiQy1F72PWFB4bZJ87cAtLPYgDR0=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 h1:FmF5cCW94Ij59cfpoLiwTgodWmm60eEV0CjlsVg2fuw=
|
||||
|
@ -1853,8 +1822,6 @@ google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8
|
|||
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
|
||||
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
|
||||
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
|
||||
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
||||
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||
|
@ -1862,7 +1829,6 @@ google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQ
|
|||
google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
|
||||
google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
|
||||
google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k=
|
||||
google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
|
||||
google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ=
|
||||
google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ=
|
||||
google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
|
||||
|
@ -1932,7 +1898,6 @@ honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWh
|
|||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
honnef.co/go/tools v0.0.1-2020.1.5/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
k8s.io/api v0.0.0-20180904230853-4e7be11eab3f/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA=
|
||||
k8s.io/api v0.17.4/go.mod h1:5qxx6vjmwUVG2nHQTKGlLts8Tbok8PzHl4vHtVFuZCA=
|
||||
|
|
|
@ -18,8 +18,6 @@ import (
|
|||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/global"
|
||||
"go.opentelemetry.io/otel/metric/instrument"
|
||||
"go.opentelemetry.io/otel/propagation"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
|
@ -39,13 +37,17 @@ type Filter func(*InterceptorInfo) bool
|
|||
|
||||
// config is a group of options for this instrumentation.
|
||||
type config struct {
|
||||
Filter Filter
|
||||
Propagators propagation.TextMapPropagator
|
||||
TracerProvider trace.TracerProvider
|
||||
MeterProvider metric.MeterProvider
|
||||
Filter Filter
|
||||
Propagators propagation.TextMapPropagator
|
||||
TracerProvider trace.TracerProvider
|
||||
MeterProvider metric.MeterProvider
|
||||
SpanStartOptions []trace.SpanStartOption
|
||||
|
||||
ReceivedEvent bool
|
||||
SentEvent bool
|
||||
|
||||
meter metric.Meter
|
||||
rpcServerDuration instrument.Int64Histogram
|
||||
rpcServerDuration metric.Int64Histogram
|
||||
}
|
||||
|
||||
// Option applies an option value for a config.
|
||||
|
@ -58,7 +60,7 @@ func newConfig(opts []Option) *config {
|
|||
c := &config{
|
||||
Propagators: otel.GetTextMapPropagator(),
|
||||
TracerProvider: otel.GetTracerProvider(),
|
||||
MeterProvider: global.MeterProvider(),
|
||||
MeterProvider: otel.GetMeterProvider(),
|
||||
}
|
||||
for _, o := range opts {
|
||||
o.apply(c)
|
||||
|
@ -66,11 +68,14 @@ func newConfig(opts []Option) *config {
|
|||
|
||||
c.meter = c.MeterProvider.Meter(
|
||||
instrumentationName,
|
||||
metric.WithInstrumentationVersion(SemVersion()),
|
||||
metric.WithInstrumentationVersion(Version()),
|
||||
metric.WithSchemaURL(semconv.SchemaURL),
|
||||
)
|
||||
var err error
|
||||
if c.rpcServerDuration, err = c.meter.Int64Histogram("rpc.server.duration", instrument.WithUnit("ms")); err != nil {
|
||||
c.rpcServerDuration, err = c.meter.Int64Histogram("rpc.server.duration",
|
||||
metric.WithDescription("Measures the duration of inbound RPC."),
|
||||
metric.WithUnit("ms"))
|
||||
if err != nil {
|
||||
otel.Handle(err)
|
||||
}
|
||||
|
||||
|
@ -133,3 +138,50 @@ func (o meterProviderOption) apply(c *config) {
|
|||
func WithMeterProvider(mp metric.MeterProvider) Option {
|
||||
return meterProviderOption{mp: mp}
|
||||
}
|
||||
|
||||
// Event type that can be recorded, see WithMessageEvents.
|
||||
type Event int
|
||||
|
||||
// Different types of events that can be recorded, see WithMessageEvents.
|
||||
const (
|
||||
ReceivedEvents Event = iota
|
||||
SentEvents
|
||||
)
|
||||
|
||||
type messageEventsProviderOption struct {
|
||||
events []Event
|
||||
}
|
||||
|
||||
func (m messageEventsProviderOption) apply(c *config) {
|
||||
for _, e := range m.events {
|
||||
switch e {
|
||||
case ReceivedEvents:
|
||||
c.ReceivedEvent = true
|
||||
case SentEvents:
|
||||
c.SentEvent = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WithMessageEvents configures the Handler to record the specified events
|
||||
// (span.AddEvent) on spans. By default only summary attributes are added at the
|
||||
// end of the request.
|
||||
//
|
||||
// Valid events are:
|
||||
// - ReceivedEvents: Record the number of bytes read after every gRPC read operation.
|
||||
// - SentEvents: Record the number of bytes written after every gRPC write operation.
|
||||
func WithMessageEvents(events ...Event) Option {
|
||||
return messageEventsProviderOption{events: events}
|
||||
}
|
||||
|
||||
type spanStartOption struct{ opts []trace.SpanStartOption }
|
||||
|
||||
func (o spanStartOption) apply(c *config) {
|
||||
c.SpanStartOptions = append(c.SpanStartOptions, o.opts...)
|
||||
}
|
||||
|
||||
// WithSpanOptions configures an additional set of
|
||||
// trace.SpanOptions, which are applied to each new span.
|
||||
func WithSpanOptions(opts ...trace.SpanStartOption) Option {
|
||||
return spanStartOption{opts}
|
||||
}
|
||||
|
|
45
vendor/go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/doc.go
generated
vendored
Normal file
45
vendor/go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/doc.go
generated
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
// 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 otelgrpc is the instrumentation library for [google.golang.org/grpc]
|
||||
|
||||
For now you can instrument your program which use [google.golang.org/grpc] in two ways:
|
||||
|
||||
- by [grpc.UnaryClientInterceptor], [grpc.UnaryServerInterceptor], [grpc.StreamClientInterceptor], [grpc.StreamServerInterceptor]
|
||||
- by [stats.Handler]
|
||||
|
||||
Notice: Do not use both interceptors and [stats.Handler] at the same time! If so, you will get duplicated spans and the parent/child relationships between spans will also be broken.
|
||||
|
||||
We strongly still recommand you to use [stats.Handler], mainly for two reasons:
|
||||
|
||||
Functional advantages: [stats.Handler] has more information for user to build more flexible and granular metric, for example
|
||||
|
||||
- multiple different types of represent "data length": In [stats.InPayload], there exists "Length", "CompressedLength", "WireLength" to denote the size of uncompressed, compressed payload data, with or without framing data. But in interceptors, we can only got uncompressed data, and this feature is also removed due to performance problem.
|
||||
|
||||
- more accurate timestamp: [stats.InPayload]'s "RecvTime" and [stats.OutPayload]'s "SentTime" records more accurate timestamp that server got and sent the message, the timestamp recorded by interceptors depends on the location of this interceptors in the total interceptor chain.
|
||||
|
||||
- some other use cases: for example, catch failure of decoding message.
|
||||
|
||||
Performance advantages: If too many interceptors are registered in a service, the interceptor chain can become too long, which increases the latency and processing time of the entire RPC call.
|
||||
|
||||
[stats.Handler]: https://pkg.go.dev/google.golang.org/grpc/stats#Handler
|
||||
[grpc.UnaryClientInterceptor]: https://pkg.go.dev/google.golang.org/grpc#UnaryClientInterceptor
|
||||
[grpc.UnaryServerInterceptor]: https://pkg.go.dev/google.golang.org/grpc#UnaryServerInterceptor
|
||||
[grpc.StreamClientInterceptor]: https://pkg.go.dev/google.golang.org/grpc#StreamClientInterceptor
|
||||
[grpc.StreamServerInterceptor]: https://pkg.go.dev/google.golang.org/grpc#StreamServerInterceptor
|
||||
[stats.OutPayload]: https://pkg.go.dev/google.golang.org/grpc/stats#OutPayload
|
||||
[stats.InPayload]: https://pkg.go.dev/google.golang.org/grpc/stats#InPayload
|
||||
*/
|
||||
package otelgrpc // import "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
|
|
@ -33,6 +33,7 @@ import (
|
|||
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/internal"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
@ -63,7 +64,7 @@ func UnaryClientInterceptor(opts ...Option) grpc.UnaryClientInterceptor {
|
|||
cfg := newConfig(opts)
|
||||
tracer := cfg.TracerProvider.Tracer(
|
||||
instrumentationName,
|
||||
trace.WithInstrumentationVersion(SemVersion()),
|
||||
trace.WithInstrumentationVersion(Version()),
|
||||
)
|
||||
|
||||
return func(
|
||||
|
@ -83,22 +84,31 @@ func UnaryClientInterceptor(opts ...Option) grpc.UnaryClientInterceptor {
|
|||
}
|
||||
|
||||
name, attr := spanInfo(method, cc.Target())
|
||||
var span trace.Span
|
||||
ctx, span = tracer.Start(
|
||||
|
||||
startOpts := append([]trace.SpanStartOption{
|
||||
trace.WithSpanKind(trace.SpanKindClient),
|
||||
trace.WithAttributes(attr...)},
|
||||
cfg.SpanStartOptions...,
|
||||
)
|
||||
|
||||
ctx, span := tracer.Start(
|
||||
ctx,
|
||||
name,
|
||||
trace.WithSpanKind(trace.SpanKindClient),
|
||||
trace.WithAttributes(attr...),
|
||||
startOpts...,
|
||||
)
|
||||
defer span.End()
|
||||
|
||||
ctx = inject(ctx, cfg.Propagators)
|
||||
|
||||
messageSent.Event(ctx, 1, req)
|
||||
if cfg.SentEvent {
|
||||
messageSent.Event(ctx, 1, req)
|
||||
}
|
||||
|
||||
err := invoker(ctx, method, req, reply, cc, callOpts...)
|
||||
|
||||
messageReceived.Event(ctx, 1, reply)
|
||||
if cfg.ReceivedEvent {
|
||||
messageReceived.Event(ctx, 1, reply)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
s, _ := status.FromError(err)
|
||||
|
@ -134,6 +144,9 @@ type clientStream struct {
|
|||
eventsDone chan struct{}
|
||||
finished chan error
|
||||
|
||||
receivedEvent bool
|
||||
sentEvent bool
|
||||
|
||||
receivedMessageID int
|
||||
sentMessageID int
|
||||
}
|
||||
|
@ -151,7 +164,10 @@ func (w *clientStream) RecvMsg(m interface{}) error {
|
|||
w.sendStreamEvent(errorEvent, err)
|
||||
} else {
|
||||
w.receivedMessageID++
|
||||
messageReceived.Event(w.Context(), w.receivedMessageID, m)
|
||||
|
||||
if w.receivedEvent {
|
||||
messageReceived.Event(w.Context(), w.receivedMessageID, m)
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
|
@ -161,7 +177,10 @@ func (w *clientStream) SendMsg(m interface{}) error {
|
|||
err := w.ClientStream.SendMsg(m)
|
||||
|
||||
w.sentMessageID++
|
||||
messageSent.Event(w.Context(), w.sentMessageID, m)
|
||||
|
||||
if w.sentEvent {
|
||||
messageSent.Event(w.Context(), w.sentMessageID, m)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
w.sendStreamEvent(errorEvent, err)
|
||||
|
@ -190,7 +209,7 @@ func (w *clientStream) CloseSend() error {
|
|||
return err
|
||||
}
|
||||
|
||||
func wrapClientStream(ctx context.Context, s grpc.ClientStream, desc *grpc.StreamDesc) *clientStream {
|
||||
func wrapClientStream(ctx context.Context, s grpc.ClientStream, desc *grpc.StreamDesc, cfg *config) *clientStream {
|
||||
events := make(chan streamEvent)
|
||||
eventsDone := make(chan struct{})
|
||||
finished := make(chan error)
|
||||
|
@ -217,11 +236,13 @@ func wrapClientStream(ctx context.Context, s grpc.ClientStream, desc *grpc.Strea
|
|||
}()
|
||||
|
||||
return &clientStream{
|
||||
ClientStream: s,
|
||||
desc: desc,
|
||||
events: events,
|
||||
eventsDone: eventsDone,
|
||||
finished: finished,
|
||||
ClientStream: s,
|
||||
desc: desc,
|
||||
events: events,
|
||||
eventsDone: eventsDone,
|
||||
finished: finished,
|
||||
receivedEvent: cfg.ReceivedEvent,
|
||||
sentEvent: cfg.SentEvent,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -238,7 +259,7 @@ func StreamClientInterceptor(opts ...Option) grpc.StreamClientInterceptor {
|
|||
cfg := newConfig(opts)
|
||||
tracer := cfg.TracerProvider.Tracer(
|
||||
instrumentationName,
|
||||
trace.WithInstrumentationVersion(SemVersion()),
|
||||
trace.WithInstrumentationVersion(Version()),
|
||||
)
|
||||
|
||||
return func(
|
||||
|
@ -258,12 +279,17 @@ func StreamClientInterceptor(opts ...Option) grpc.StreamClientInterceptor {
|
|||
}
|
||||
|
||||
name, attr := spanInfo(method, cc.Target())
|
||||
var span trace.Span
|
||||
ctx, span = tracer.Start(
|
||||
|
||||
startOpts := append([]trace.SpanStartOption{
|
||||
trace.WithSpanKind(trace.SpanKindClient),
|
||||
trace.WithAttributes(attr...)},
|
||||
cfg.SpanStartOptions...,
|
||||
)
|
||||
|
||||
ctx, span := tracer.Start(
|
||||
ctx,
|
||||
name,
|
||||
trace.WithSpanKind(trace.SpanKindClient),
|
||||
trace.WithAttributes(attr...),
|
||||
startOpts...,
|
||||
)
|
||||
|
||||
ctx = inject(ctx, cfg.Propagators)
|
||||
|
@ -276,7 +302,7 @@ func StreamClientInterceptor(opts ...Option) grpc.StreamClientInterceptor {
|
|||
span.End()
|
||||
return s, err
|
||||
}
|
||||
stream := wrapClientStream(ctx, s, desc)
|
||||
stream := wrapClientStream(ctx, s, desc, cfg)
|
||||
|
||||
go func() {
|
||||
err := <-stream.finished
|
||||
|
@ -302,7 +328,7 @@ func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor {
|
|||
cfg := newConfig(opts)
|
||||
tracer := cfg.TracerProvider.Tracer(
|
||||
instrumentationName,
|
||||
trace.WithInstrumentationVersion(SemVersion()),
|
||||
trace.WithInstrumentationVersion(Version()),
|
||||
)
|
||||
|
||||
return func(
|
||||
|
@ -320,36 +346,48 @@ func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor {
|
|||
}
|
||||
|
||||
ctx = extract(ctx, cfg.Propagators)
|
||||
|
||||
name, attr := spanInfo(info.FullMethod, peerFromCtx(ctx))
|
||||
|
||||
startOpts := append([]trace.SpanStartOption{
|
||||
trace.WithSpanKind(trace.SpanKindServer),
|
||||
trace.WithAttributes(attr...)},
|
||||
cfg.SpanStartOptions...,
|
||||
)
|
||||
|
||||
ctx, span := tracer.Start(
|
||||
trace.ContextWithRemoteSpanContext(ctx, trace.SpanContextFromContext(ctx)),
|
||||
name,
|
||||
trace.WithSpanKind(trace.SpanKindServer),
|
||||
trace.WithAttributes(attr...),
|
||||
startOpts...,
|
||||
)
|
||||
defer span.End()
|
||||
|
||||
messageReceived.Event(ctx, 1, req)
|
||||
if cfg.ReceivedEvent {
|
||||
messageReceived.Event(ctx, 1, req)
|
||||
}
|
||||
|
||||
var statusCode grpc_codes.Code
|
||||
defer func(t time.Time) {
|
||||
elapsedTime := time.Since(t) / time.Millisecond
|
||||
attr = append(attr, semconv.RPCGRPCStatusCodeKey.Int64(int64(statusCode)))
|
||||
cfg.rpcServerDuration.Record(ctx, int64(elapsedTime), attr...)
|
||||
o := metric.WithAttributes(attr...)
|
||||
cfg.rpcServerDuration.Record(ctx, int64(elapsedTime), o)
|
||||
}(time.Now())
|
||||
|
||||
resp, err := handler(ctx, req)
|
||||
if err != nil {
|
||||
s, _ := status.FromError(err)
|
||||
statusCode = s.Code()
|
||||
span.SetStatus(codes.Error, s.Message())
|
||||
statusCode, msg := serverStatus(s)
|
||||
span.SetStatus(statusCode, msg)
|
||||
span.SetAttributes(statusCodeAttr(s.Code()))
|
||||
messageSent.Event(ctx, 1, s.Proto())
|
||||
if cfg.SentEvent {
|
||||
messageSent.Event(ctx, 1, s.Proto())
|
||||
}
|
||||
} else {
|
||||
statusCode = grpc_codes.OK
|
||||
span.SetAttributes(statusCodeAttr(grpc_codes.OK))
|
||||
messageSent.Event(ctx, 1, resp)
|
||||
if cfg.SentEvent {
|
||||
messageSent.Event(ctx, 1, resp)
|
||||
}
|
||||
}
|
||||
|
||||
return resp, err
|
||||
|
@ -364,6 +402,9 @@ type serverStream struct {
|
|||
|
||||
receivedMessageID int
|
||||
sentMessageID int
|
||||
|
||||
receivedEvent bool
|
||||
sentEvent bool
|
||||
}
|
||||
|
||||
func (w *serverStream) Context() context.Context {
|
||||
|
@ -375,7 +416,9 @@ func (w *serverStream) RecvMsg(m interface{}) error {
|
|||
|
||||
if err == nil {
|
||||
w.receivedMessageID++
|
||||
messageReceived.Event(w.Context(), w.receivedMessageID, m)
|
||||
if w.receivedEvent {
|
||||
messageReceived.Event(w.Context(), w.receivedMessageID, m)
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
|
@ -385,15 +428,19 @@ func (w *serverStream) SendMsg(m interface{}) error {
|
|||
err := w.ServerStream.SendMsg(m)
|
||||
|
||||
w.sentMessageID++
|
||||
messageSent.Event(w.Context(), w.sentMessageID, m)
|
||||
if w.sentEvent {
|
||||
messageSent.Event(w.Context(), w.sentMessageID, m)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func wrapServerStream(ctx context.Context, ss grpc.ServerStream) *serverStream {
|
||||
func wrapServerStream(ctx context.Context, ss grpc.ServerStream, cfg *config) *serverStream {
|
||||
return &serverStream{
|
||||
ServerStream: ss,
|
||||
ctx: ctx,
|
||||
ServerStream: ss,
|
||||
ctx: ctx,
|
||||
receivedEvent: cfg.ReceivedEvent,
|
||||
sentEvent: cfg.SentEvent,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -403,7 +450,7 @@ func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor {
|
|||
cfg := newConfig(opts)
|
||||
tracer := cfg.TracerProvider.Tracer(
|
||||
instrumentationName,
|
||||
trace.WithInstrumentationVersion(SemVersion()),
|
||||
trace.WithInstrumentationVersion(Version()),
|
||||
)
|
||||
|
||||
return func(
|
||||
|
@ -418,24 +465,30 @@ func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor {
|
|||
Type: StreamServer,
|
||||
}
|
||||
if cfg.Filter != nil && !cfg.Filter(i) {
|
||||
return handler(srv, wrapServerStream(ctx, ss))
|
||||
return handler(srv, wrapServerStream(ctx, ss, cfg))
|
||||
}
|
||||
|
||||
ctx = extract(ctx, cfg.Propagators)
|
||||
|
||||
name, attr := spanInfo(info.FullMethod, peerFromCtx(ctx))
|
||||
|
||||
startOpts := append([]trace.SpanStartOption{
|
||||
trace.WithSpanKind(trace.SpanKindServer),
|
||||
trace.WithAttributes(attr...)},
|
||||
cfg.SpanStartOptions...,
|
||||
)
|
||||
|
||||
ctx, span := tracer.Start(
|
||||
trace.ContextWithRemoteSpanContext(ctx, trace.SpanContextFromContext(ctx)),
|
||||
name,
|
||||
trace.WithSpanKind(trace.SpanKindServer),
|
||||
trace.WithAttributes(attr...),
|
||||
startOpts...,
|
||||
)
|
||||
defer span.End()
|
||||
|
||||
err := handler(srv, wrapServerStream(ctx, ss))
|
||||
err := handler(srv, wrapServerStream(ctx, ss, cfg))
|
||||
if err != nil {
|
||||
s, _ := status.FromError(err)
|
||||
span.SetStatus(codes.Error, s.Message())
|
||||
statusCode, msg := serverStatus(s)
|
||||
span.SetStatus(statusCode, msg)
|
||||
span.SetAttributes(statusCodeAttr(s.Code()))
|
||||
} else {
|
||||
span.SetAttributes(statusCodeAttr(grpc_codes.OK))
|
||||
|
@ -448,10 +501,13 @@ func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor {
|
|||
// spanInfo returns a span name and all appropriate attributes from the gRPC
|
||||
// method and peer address.
|
||||
func spanInfo(fullMethod, peerAddress string) (string, []attribute.KeyValue) {
|
||||
attrs := []attribute.KeyValue{RPCSystemGRPC}
|
||||
name, mAttrs := internal.ParseFullMethod(fullMethod)
|
||||
peerAttrs := peerAttr(peerAddress)
|
||||
|
||||
attrs := make([]attribute.KeyValue, 0, 1+len(mAttrs)+len(peerAttrs))
|
||||
attrs = append(attrs, RPCSystemGRPC)
|
||||
attrs = append(attrs, mAttrs...)
|
||||
attrs = append(attrs, peerAttr(peerAddress)...)
|
||||
attrs = append(attrs, peerAttrs...)
|
||||
return name, attrs
|
||||
}
|
||||
|
||||
|
@ -459,7 +515,7 @@ func spanInfo(fullMethod, peerAddress string) (string, []attribute.KeyValue) {
|
|||
func peerAttr(addr string) []attribute.KeyValue {
|
||||
host, p, err := net.SplitHostPort(addr)
|
||||
if err != nil {
|
||||
return []attribute.KeyValue(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
if host == "" {
|
||||
|
@ -467,7 +523,7 @@ func peerAttr(addr string) []attribute.KeyValue {
|
|||
}
|
||||
port, err := strconv.Atoi(p)
|
||||
if err != nil {
|
||||
return []attribute.KeyValue(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
var attr []attribute.KeyValue
|
||||
|
@ -499,3 +555,26 @@ func peerFromCtx(ctx context.Context) string {
|
|||
func statusCodeAttr(c grpc_codes.Code) attribute.KeyValue {
|
||||
return GRPCStatusCodeKey.Int64(int64(c))
|
||||
}
|
||||
|
||||
// serverStatus returns a span status code and message for a given gRPC
|
||||
// status code. It maps specific gRPC status codes to a corresponding span
|
||||
// status code and message. This function is intended for use on the server
|
||||
// side of a gRPC connection.
|
||||
//
|
||||
// If the gRPC status code is Unknown, DeadlineExceeded, Unimplemented,
|
||||
// Internal, Unavailable, or DataLoss, it returns a span status code of Error
|
||||
// and the message from the gRPC status. Otherwise, it returns a span status
|
||||
// code of Unset and an empty message.
|
||||
func serverStatus(grpcStatus *status.Status) (codes.Code, string) {
|
||||
switch grpcStatus.Code() {
|
||||
case grpc_codes.Unknown,
|
||||
grpc_codes.DeadlineExceeded,
|
||||
grpc_codes.Unimplemented,
|
||||
grpc_codes.Internal,
|
||||
grpc_codes.Unavailable,
|
||||
grpc_codes.DataLoss:
|
||||
return codes.Error, grpcStatus.Message()
|
||||
default:
|
||||
return codes.Unset, ""
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,19 +24,27 @@ import (
|
|||
// ParseFullMethod returns a span name following the OpenTelemetry semantic
|
||||
// conventions as well as all applicable span attribute.KeyValue attributes based
|
||||
// on a gRPC's FullMethod.
|
||||
//
|
||||
// Parsing is consistent with grpc-go implementation:
|
||||
// https://github.com/grpc/grpc-go/blob/v1.57.0/internal/grpcutil/method.go#L26-L39
|
||||
func ParseFullMethod(fullMethod string) (string, []attribute.KeyValue) {
|
||||
name := strings.TrimLeft(fullMethod, "/")
|
||||
parts := strings.SplitN(name, "/", 2)
|
||||
if len(parts) != 2 {
|
||||
if !strings.HasPrefix(fullMethod, "/") {
|
||||
// Invalid format, does not follow `/package.service/method`.
|
||||
return name, []attribute.KeyValue(nil)
|
||||
return fullMethod, nil
|
||||
}
|
||||
name := fullMethod[1:]
|
||||
pos := strings.LastIndex(name, "/")
|
||||
if pos < 0 {
|
||||
// Invalid format, does not follow `/package.service/method`.
|
||||
return name, nil
|
||||
}
|
||||
service, method := name[:pos], name[pos+1:]
|
||||
|
||||
var attrs []attribute.KeyValue
|
||||
if service := parts[0]; service != "" {
|
||||
if service != "" {
|
||||
attrs = append(attrs, semconv.RPCService(service))
|
||||
}
|
||||
if method := parts[1]; method != "" {
|
||||
if method != "" {
|
||||
attrs = append(attrs, semconv.RPCMethod(method))
|
||||
}
|
||||
return name, attrs
|
||||
|
|
187
vendor/go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/stats_handler.go
generated
vendored
Normal file
187
vendor/go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/stats_handler.go
generated
vendored
Normal file
|
@ -0,0 +1,187 @@
|
|||
// 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 otelgrpc // import "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync/atomic"
|
||||
|
||||
grpc_codes "google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/stats"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/internal"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
type gRPCContextKey struct{}
|
||||
|
||||
type gRPCContext struct {
|
||||
messagesReceived int64
|
||||
messagesSent int64
|
||||
}
|
||||
|
||||
// NewServerHandler creates a stats.Handler for gRPC server.
|
||||
func NewServerHandler(opts ...Option) stats.Handler {
|
||||
h := &serverHandler{
|
||||
config: newConfig(opts),
|
||||
}
|
||||
|
||||
h.tracer = h.config.TracerProvider.Tracer(
|
||||
instrumentationName,
|
||||
trace.WithInstrumentationVersion(SemVersion()),
|
||||
)
|
||||
return h
|
||||
}
|
||||
|
||||
type serverHandler struct {
|
||||
*config
|
||||
tracer trace.Tracer
|
||||
}
|
||||
|
||||
// TagRPC can attach some information to the given context.
|
||||
func (h *serverHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context {
|
||||
ctx = extract(ctx, h.config.Propagators)
|
||||
|
||||
name, attrs := internal.ParseFullMethod(info.FullMethodName)
|
||||
attrs = append(attrs, RPCSystemGRPC)
|
||||
ctx, _ = h.tracer.Start(
|
||||
trace.ContextWithRemoteSpanContext(ctx, trace.SpanContextFromContext(ctx)),
|
||||
name,
|
||||
trace.WithSpanKind(trace.SpanKindServer),
|
||||
trace.WithAttributes(attrs...),
|
||||
)
|
||||
|
||||
gctx := gRPCContext{}
|
||||
return context.WithValue(ctx, gRPCContextKey{}, &gctx)
|
||||
}
|
||||
|
||||
// HandleRPC processes the RPC stats.
|
||||
func (h *serverHandler) HandleRPC(ctx context.Context, rs stats.RPCStats) {
|
||||
handleRPC(ctx, rs)
|
||||
}
|
||||
|
||||
// TagConn can attach some information to the given context.
|
||||
func (h *serverHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context {
|
||||
span := trace.SpanFromContext(ctx)
|
||||
attrs := peerAttr(peerFromCtx(ctx))
|
||||
span.SetAttributes(attrs...)
|
||||
return ctx
|
||||
}
|
||||
|
||||
// HandleConn processes the Conn stats.
|
||||
func (h *serverHandler) HandleConn(ctx context.Context, info stats.ConnStats) {
|
||||
}
|
||||
|
||||
// NewClientHandler creates a stats.Handler for gRPC client.
|
||||
func NewClientHandler(opts ...Option) stats.Handler {
|
||||
h := &clientHandler{
|
||||
config: newConfig(opts),
|
||||
}
|
||||
|
||||
h.tracer = h.config.TracerProvider.Tracer(
|
||||
instrumentationName,
|
||||
trace.WithInstrumentationVersion(SemVersion()),
|
||||
)
|
||||
|
||||
return h
|
||||
}
|
||||
|
||||
type clientHandler struct {
|
||||
*config
|
||||
tracer trace.Tracer
|
||||
}
|
||||
|
||||
// TagRPC can attach some information to the given context.
|
||||
func (h *clientHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context {
|
||||
name, attrs := internal.ParseFullMethod(info.FullMethodName)
|
||||
attrs = append(attrs, RPCSystemGRPC)
|
||||
ctx, _ = h.tracer.Start(
|
||||
ctx,
|
||||
name,
|
||||
trace.WithSpanKind(trace.SpanKindClient),
|
||||
trace.WithAttributes(attrs...),
|
||||
)
|
||||
|
||||
gctx := gRPCContext{}
|
||||
|
||||
return inject(context.WithValue(ctx, gRPCContextKey{}, &gctx), h.config.Propagators)
|
||||
}
|
||||
|
||||
// HandleRPC processes the RPC stats.
|
||||
func (h *clientHandler) HandleRPC(ctx context.Context, rs stats.RPCStats) {
|
||||
handleRPC(ctx, rs)
|
||||
}
|
||||
|
||||
// TagConn can attach some information to the given context.
|
||||
func (h *clientHandler) TagConn(ctx context.Context, cti *stats.ConnTagInfo) context.Context {
|
||||
span := trace.SpanFromContext(ctx)
|
||||
attrs := peerAttr(cti.RemoteAddr.String())
|
||||
span.SetAttributes(attrs...)
|
||||
return ctx
|
||||
}
|
||||
|
||||
// HandleConn processes the Conn stats.
|
||||
func (h *clientHandler) HandleConn(context.Context, stats.ConnStats) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
func handleRPC(ctx context.Context, rs stats.RPCStats) {
|
||||
span := trace.SpanFromContext(ctx)
|
||||
gctx, _ := ctx.Value(gRPCContextKey{}).(*gRPCContext)
|
||||
var messageId int64
|
||||
|
||||
switch rs := rs.(type) {
|
||||
case *stats.Begin:
|
||||
case *stats.InPayload:
|
||||
if gctx != nil {
|
||||
messageId = atomic.AddInt64(&gctx.messagesReceived, 1)
|
||||
}
|
||||
span.AddEvent("message",
|
||||
trace.WithAttributes(
|
||||
semconv.MessageTypeReceived,
|
||||
semconv.MessageIDKey.Int64(messageId),
|
||||
semconv.MessageCompressedSizeKey.Int(rs.CompressedLength),
|
||||
semconv.MessageUncompressedSizeKey.Int(rs.Length),
|
||||
),
|
||||
)
|
||||
case *stats.OutPayload:
|
||||
if gctx != nil {
|
||||
messageId = atomic.AddInt64(&gctx.messagesSent, 1)
|
||||
}
|
||||
|
||||
span.AddEvent("message",
|
||||
trace.WithAttributes(
|
||||
semconv.MessageTypeSent,
|
||||
semconv.MessageIDKey.Int64(messageId),
|
||||
semconv.MessageCompressedSizeKey.Int(rs.CompressedLength),
|
||||
semconv.MessageUncompressedSizeKey.Int(rs.Length),
|
||||
),
|
||||
)
|
||||
case *stats.End:
|
||||
if rs.Error != nil {
|
||||
s, _ := status.FromError(rs.Error)
|
||||
span.SetStatus(codes.Error, s.Message())
|
||||
span.SetAttributes(statusCodeAttr(s.Code()))
|
||||
} else {
|
||||
span.SetAttributes(statusCodeAttr(grpc_codes.OK))
|
||||
}
|
||||
span.End()
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
|
@ -16,11 +16,13 @@ package otelgrpc // import "go.opentelemetry.io/contrib/instrumentation/google.g
|
|||
|
||||
// Version is the current release version of the gRPC instrumentation.
|
||||
func Version() string {
|
||||
return "0.40.0"
|
||||
return "0.45.0"
|
||||
// This string is updated by the pre_release.sh script during release
|
||||
}
|
||||
|
||||
// SemVersion is the semantic version to be supplied to tracer/meter creation.
|
||||
//
|
||||
// Deprecated: Use [Version] instead.
|
||||
func SemVersion() string {
|
||||
return "semver:" + Version()
|
||||
return Version()
|
||||
}
|
||||
|
|
2
vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/common.go
generated
vendored
2
vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/common.go
generated
vendored
|
@ -42,5 +42,5 @@ const (
|
|||
type Filter func(*http.Request) bool
|
||||
|
||||
func newTracer(tp trace.TracerProvider) trace.Tracer {
|
||||
return tp.Tracer(instrumentationName, trace.WithInstrumentationVersion(SemVersion()))
|
||||
return tp.Tracer(instrumentationName, trace.WithInstrumentationVersion(Version()))
|
||||
}
|
||||
|
|
5
vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/config.go
generated
vendored
5
vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/config.go
generated
vendored
|
@ -21,7 +21,6 @@ import (
|
|||
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/global"
|
||||
"go.opentelemetry.io/otel/propagation"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
@ -65,7 +64,7 @@ func (o optionFunc) apply(c *config) {
|
|||
func newConfig(opts ...Option) *config {
|
||||
c := &config{
|
||||
Propagators: otel.GetTextMapPropagator(),
|
||||
MeterProvider: global.MeterProvider(),
|
||||
MeterProvider: otel.GetMeterProvider(),
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt.apply(c)
|
||||
|
@ -78,7 +77,7 @@ func newConfig(opts ...Option) *config {
|
|||
|
||||
c.Meter = c.MeterProvider.Meter(
|
||||
instrumentationName,
|
||||
metric.WithInstrumentationVersion(SemVersion()),
|
||||
metric.WithInstrumentationVersion(Version()),
|
||||
)
|
||||
|
||||
return c
|
||||
|
|
16
vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/handler.go
generated
vendored
16
vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/handler.go
generated
vendored
|
@ -24,7 +24,6 @@ import (
|
|||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/instrument"
|
||||
"go.opentelemetry.io/otel/propagation"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
|
||||
"go.opentelemetry.io/otel/semconv/v1.17.0/httpconv"
|
||||
|
@ -50,8 +49,8 @@ type Handler struct {
|
|||
writeEvent bool
|
||||
filters []Filter
|
||||
spanNameFormatter func(string, *http.Request) string
|
||||
counters map[string]instrument.Int64Counter
|
||||
valueRecorders map[string]instrument.Float64Histogram
|
||||
counters map[string]metric.Int64Counter
|
||||
valueRecorders map[string]metric.Float64Histogram
|
||||
publicEndpoint bool
|
||||
publicEndpointFn func(*http.Request) bool
|
||||
}
|
||||
|
@ -101,8 +100,8 @@ func handleErr(err error) {
|
|||
}
|
||||
|
||||
func (h *Handler) createMeasures() {
|
||||
h.counters = make(map[string]instrument.Int64Counter)
|
||||
h.valueRecorders = make(map[string]instrument.Float64Histogram)
|
||||
h.counters = make(map[string]metric.Int64Counter)
|
||||
h.valueRecorders = make(map[string]metric.Float64Histogram)
|
||||
|
||||
requestBytesCounter, err := h.meter.Int64Counter(RequestContentLength)
|
||||
handleErr(err)
|
||||
|
@ -219,13 +218,14 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
if rww.statusCode > 0 {
|
||||
attributes = append(attributes, semconv.HTTPStatusCode(rww.statusCode))
|
||||
}
|
||||
h.counters[RequestContentLength].Add(ctx, bw.read, attributes...)
|
||||
h.counters[ResponseContentLength].Add(ctx, rww.written, attributes...)
|
||||
o := metric.WithAttributes(attributes...)
|
||||
h.counters[RequestContentLength].Add(ctx, bw.read, o)
|
||||
h.counters[ResponseContentLength].Add(ctx, rww.written, o)
|
||||
|
||||
// Use floating point division here for higher precision (instead of Millisecond method).
|
||||
elapsedTime := float64(time.Since(requestStartTime)) / float64(time.Millisecond)
|
||||
|
||||
h.valueRecorders[ServerLatency].Record(ctx, elapsedTime, attributes...)
|
||||
h.valueRecorders[ServerLatency].Record(ctx, elapsedTime, o)
|
||||
}
|
||||
|
||||
func setAfterServeAttributes(span trace.Span, read, wrote int64, statusCode int, rerr, werr error) {
|
||||
|
|
6
vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/version.go
generated
vendored
6
vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/version.go
generated
vendored
|
@ -16,11 +16,13 @@ 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.40.0"
|
||||
return "0.42.0"
|
||||
// This string is updated by the pre_release.sh script during release
|
||||
}
|
||||
|
||||
// SemVersion is the semantic version to be supplied to tracer/meter creation.
|
||||
//
|
||||
// Deprecated: Use [Version] instead.
|
||||
func SemVersion() string {
|
||||
return "semver:" + Version()
|
||||
return Version()
|
||||
}
|
||||
|
|
14
vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/wrap.go
generated
vendored
14
vendor/go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/wrap.go
generated
vendored
|
@ -50,7 +50,7 @@ func (w *bodyWrapper) Close() error {
|
|||
var _ http.ResponseWriter = &respWriterWrapper{}
|
||||
|
||||
// respWriterWrapper wraps a http.ResponseWriter in order to track the number of
|
||||
// bytes written, the last error, and to catch the returned statusCode
|
||||
// bytes written, the last error, and to catch the first written statusCode.
|
||||
// TODO: The wrapped http.ResponseWriter doesn't implement any of the optional
|
||||
// types (http.Hijacker, http.Pusher, http.CloseNotifier, http.Flusher, etc)
|
||||
// that may be useful when using it in real life situations.
|
||||
|
@ -85,11 +85,15 @@ func (w *respWriterWrapper) Write(p []byte) (int, error) {
|
|||
return n, err
|
||||
}
|
||||
|
||||
// WriteHeader persists initial statusCode for span attribution.
|
||||
// All calls to WriteHeader will be propagated to the underlying ResponseWriter
|
||||
// and will persist the statusCode from the first call.
|
||||
// Blocking consecutive calls to WriteHeader alters expected behavior and will
|
||||
// remove warning logs from net/http where developers will notice incorrect handler implementations.
|
||||
func (w *respWriterWrapper) WriteHeader(statusCode int) {
|
||||
if w.wroteHeader {
|
||||
return
|
||||
if !w.wroteHeader {
|
||||
w.wroteHeader = true
|
||||
w.statusCode = statusCode
|
||||
}
|
||||
w.wroteHeader = true
|
||||
w.statusCode = statusCode
|
||||
w.ResponseWriter.WriteHeader(statusCode)
|
||||
}
|
||||
|
|
5
vendor/go.opentelemetry.io/otel/.codespellignore
generated
vendored
Normal file
5
vendor/go.opentelemetry.io/otel/.codespellignore
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
ot
|
||||
fo
|
||||
te
|
||||
collison
|
||||
consequentially
|
10
vendor/go.opentelemetry.io/otel/.codespellrc
generated
vendored
Normal file
10
vendor/go.opentelemetry.io/otel/.codespellrc
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
# https://github.com/codespell-project/codespell
|
||||
[codespell]
|
||||
builtin = clear,rare,informal
|
||||
check-filenames =
|
||||
check-hidden =
|
||||
ignore-words = .codespellignore
|
||||
interactive = 1
|
||||
skip = .git,go.mod,go.sum,semconv,venv,.tools
|
||||
uri-ignore-words-list = *
|
||||
write =
|
4
vendor/go.opentelemetry.io/otel/.gitignore
generated
vendored
4
vendor/go.opentelemetry.io/otel/.gitignore
generated
vendored
|
@ -2,14 +2,18 @@
|
|||
Thumbs.db
|
||||
|
||||
.tools/
|
||||
venv/
|
||||
.idea/
|
||||
.vscode/
|
||||
*.iml
|
||||
*.so
|
||||
coverage.*
|
||||
go.work
|
||||
go.work.sum
|
||||
|
||||
gen/
|
||||
|
||||
/example/dice/dice
|
||||
/example/fib/fib
|
||||
/example/fib/traces.txt
|
||||
/example/jaeger/jaeger
|
||||
|
|
83
vendor/go.opentelemetry.io/otel/.golangci.yml
generated
vendored
83
vendor/go.opentelemetry.io/otel/.golangci.yml
generated
vendored
|
@ -61,30 +61,67 @@ issues:
|
|||
|
||||
linters-settings:
|
||||
depguard:
|
||||
# Check the list against standard lib.
|
||||
# Default: false
|
||||
include-go-root: true
|
||||
# A list of packages for the list type specified.
|
||||
# Default: []
|
||||
packages:
|
||||
- "crypto/md5"
|
||||
- "crypto/sha1"
|
||||
- "crypto/**/pkix"
|
||||
ignore-file-rules:
|
||||
- "**/*_test.go"
|
||||
additional-guards:
|
||||
# Do not allow testing packages in non-test files.
|
||||
- list-type: denylist
|
||||
include-go-root: true
|
||||
packages:
|
||||
- testing
|
||||
- github.com/stretchr/testify
|
||||
ignore-file-rules:
|
||||
- "**/*_test.go"
|
||||
- "**/*test/*.go"
|
||||
- "**/internal/matchers/*.go"
|
||||
rules:
|
||||
non-tests:
|
||||
files:
|
||||
- "!$test"
|
||||
- "!**/*test/*.go"
|
||||
- "!**/internal/matchers/*.go"
|
||||
deny:
|
||||
- pkg: "testing"
|
||||
- pkg: "github.com/stretchr/testify"
|
||||
- pkg: "crypto/md5"
|
||||
- pkg: "crypto/sha1"
|
||||
- pkg: "crypto/**/pkix"
|
||||
otlp-internal:
|
||||
files:
|
||||
- "!**/exporters/otlp/internal/**/*.go"
|
||||
deny:
|
||||
- pkg: "go.opentelemetry.io/otel/exporters/otlp/internal"
|
||||
desc: Do not use cross-module internal packages.
|
||||
otlptrace-internal:
|
||||
files:
|
||||
- "!**/exporters/otlp/otlptrace/*.go"
|
||||
- "!**/exporters/otlp/otlptrace/internal/**.go"
|
||||
deny:
|
||||
- pkg: "go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal"
|
||||
desc: Do not use cross-module internal packages.
|
||||
otlpmetric-internal:
|
||||
files:
|
||||
- "!**/exporters/otlp/otlpmetric/internal/*.go"
|
||||
- "!**/exporters/otlp/otlpmetric/internal/**/*.go"
|
||||
deny:
|
||||
- pkg: "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal"
|
||||
desc: Do not use cross-module internal packages.
|
||||
otel-internal:
|
||||
files:
|
||||
- "**/sdk/*.go"
|
||||
- "**/sdk/**/*.go"
|
||||
- "**/exporters/*.go"
|
||||
- "**/exporters/**/*.go"
|
||||
- "**/schema/*.go"
|
||||
- "**/schema/**/*.go"
|
||||
- "**/metric/*.go"
|
||||
- "**/metric/**/*.go"
|
||||
- "**/bridge/*.go"
|
||||
- "**/bridge/**/*.go"
|
||||
- "**/example/*.go"
|
||||
- "**/example/**/*.go"
|
||||
- "**/trace/*.go"
|
||||
- "**/trace/**/*.go"
|
||||
deny:
|
||||
- pkg: "go.opentelemetry.io/otel/internal$"
|
||||
desc: Do not use cross-module internal packages.
|
||||
- pkg: "go.opentelemetry.io/otel/internal/attribute"
|
||||
desc: Do not use cross-module internal packages.
|
||||
- pkg: "go.opentelemetry.io/otel/internal/internaltest"
|
||||
desc: Do not use cross-module internal packages.
|
||||
- pkg: "go.opentelemetry.io/otel/internal/matchers"
|
||||
desc: Do not use cross-module internal packages.
|
||||
godot:
|
||||
exclude:
|
||||
# Exclude links.
|
||||
- '^ *\[[^]]+\]:'
|
||||
# Exclude sentence fragments for lists.
|
||||
- '^[ ]*[-•]'
|
||||
# Exclude sentences prefixing a list.
|
||||
|
@ -111,7 +148,7 @@ linters-settings:
|
|||
- name: constant-logical-expr
|
||||
disabled: false
|
||||
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-as-argument
|
||||
# TODO (#3372) reenable linter when it is compatible. https://github.com/golangci/golangci-lint/issues/3280
|
||||
# TODO (#3372) re-enable linter when it is compatible. https://github.com/golangci/golangci-lint/issues/3280
|
||||
- name: context-as-argument
|
||||
disabled: true
|
||||
arguments:
|
||||
|
|
384
vendor/go.opentelemetry.io/otel/CHANGELOG.md
generated
vendored
384
vendor/go.opentelemetry.io/otel/CHANGELOG.md
generated
vendored
|
@ -8,6 +8,360 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
## [1.19.0/0.42.0/0.0.7] 2023-09-28
|
||||
|
||||
This release contains the first stable release of the OpenTelemetry Go [metric SDK].
|
||||
Our project stability guarantees now apply to the `go.opentelemetry.io/otel/sdk/metric` package.
|
||||
See our [versioning policy](VERSIONING.md) for more information about these stability guarantees.
|
||||
|
||||
### Added
|
||||
|
||||
- Add the "Roll the dice" getting started application example in `go.opentelemetry.io/otel/example/dice`. (#4539)
|
||||
- The `WithWriter` and `WithPrettyPrint` options to `go.opentelemetry.io/otel/exporters/stdout/stdoutmetric` to set a custom `io.Writer`, and allow displaying the output in human-readable JSON. (#4507)
|
||||
|
||||
### Changed
|
||||
|
||||
- Allow '/' characters in metric instrument names. (#4501)
|
||||
- The exporter in `go.opentelemetry.io/otel/exporters/stdout/stdoutmetric` does not prettify its output by default anymore. (#4507)
|
||||
- Upgrade `gopkg.io/yaml` from `v2` to `v3` in `go.opentelemetry.io/otel/schema`. (#4535)
|
||||
|
||||
### Fixed
|
||||
|
||||
- In `go.opentelemetry.op/otel/exporters/prometheus`, don't try to create the Prometheus metric on every `Collect` if we know the scope is invalid. (#4499)
|
||||
|
||||
### Removed
|
||||
|
||||
- Remove `"go.opentelemetry.io/otel/bridge/opencensus".NewMetricExporter`, which is replaced by `NewMetricProducer`. (#4566)
|
||||
|
||||
## [1.19.0-rc.1/0.42.0-rc.1] 2023-09-14
|
||||
|
||||
This is a release candidate for the v1.19.0/v0.42.0 release.
|
||||
That release is expected to include the `v1` release of the OpenTelemetry Go metric SDK and will provide stability guarantees of that SDK.
|
||||
See our [versioning policy](VERSIONING.md) for more information about these stability guarantees.
|
||||
|
||||
### Changed
|
||||
|
||||
- Allow '/' characters in metric instrument names. (#4501)
|
||||
|
||||
### Fixed
|
||||
|
||||
- In `go.opentelemetry.op/otel/exporters/prometheus`, don't try to create the prometheus metric on every `Collect` if we know the scope is invalid. (#4499)
|
||||
|
||||
## [1.18.0/0.41.0/0.0.6] 2023-09-12
|
||||
|
||||
This release drops the compatibility guarantee of [Go 1.19].
|
||||
|
||||
### Added
|
||||
|
||||
- Add `WithProducer` option in `go.opentelemetry.op/otel/exporters/prometheus` to restore the ability to register producers on the prometheus exporter's manual reader. (#4473)
|
||||
- Add `IgnoreValue` option in `go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest` to allow ignoring values when comparing metrics. (#4447)
|
||||
|
||||
### Changed
|
||||
|
||||
- Use a `TestingT` interface instead of `*testing.T` struct in `go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest`. (#4483)
|
||||
|
||||
### Deprecated
|
||||
|
||||
- The `NewMetricExporter` in `go.opentelemetry.io/otel/bridge/opencensus` was deprecated in `v0.35.0` (#3541).
|
||||
The deprecation notice format for the function has been corrected to trigger Go documentation and build tooling. (#4470)
|
||||
|
||||
### Removed
|
||||
|
||||
- Removed the deprecated `go.opentelemetry.io/otel/exporters/jaeger` package. (#4467)
|
||||
- Removed the deprecated `go.opentelemetry.io/otel/example/jaeger` package. (#4467)
|
||||
- Removed the deprecated `go.opentelemetry.io/otel/sdk/metric/aggregation` package. (#4468)
|
||||
- Removed the deprecated internal packages in `go.opentelemetry.io/otel/exporters/otlp` and its sub-packages. (#4469)
|
||||
- Dropped guaranteed support for versions of Go less than 1.20. (#4481)
|
||||
|
||||
## [1.17.0/0.40.0/0.0.5] 2023-08-28
|
||||
|
||||
### Added
|
||||
|
||||
- Export the `ManualReader` struct in `go.opentelemetry.io/otel/sdk/metric`. (#4244)
|
||||
- Export the `PeriodicReader` struct in `go.opentelemetry.io/otel/sdk/metric`. (#4244)
|
||||
- Add support for exponential histogram aggregations.
|
||||
A histogram can be configured as an exponential histogram using a view with `"go.opentelemetry.io/otel/sdk/metric".ExponentialHistogram` as the aggregation. (#4245)
|
||||
- Export the `Exporter` struct in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc`. (#4272)
|
||||
- Export the `Exporter` struct in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`. (#4272)
|
||||
- The exporters in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric` now support the `OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE` environment variable. (#4287)
|
||||
- Add `WithoutCounterSuffixes` option in `go.opentelemetry.io/otel/exporters/prometheus` to disable addition of `_total` suffixes. (#4306)
|
||||
- Add info and debug logging to the metric SDK in `go.opentelemetry.io/otel/sdk/metric`. (#4315)
|
||||
- The `go.opentelemetry.io/otel/semconv/v1.21.0` package.
|
||||
The package contains semantic conventions from the `v1.21.0` version of the OpenTelemetry Semantic Conventions. (#4362)
|
||||
- Accept 201 to 299 HTTP status as success in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp` and `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`. (#4365)
|
||||
- Document the `Temporality` and `Aggregation` methods of the `"go.opentelemetry.io/otel/sdk/metric".Exporter"` need to be concurrent safe. (#4381)
|
||||
- Expand the set of units supported by the Prometheus exporter, and don't add unit suffixes if they are already present in `go.opentelemetry.op/otel/exporters/prometheus` (#4374)
|
||||
- Move the `Aggregation` interface and its implementations from `go.opentelemetry.io/otel/sdk/metric/aggregation` to `go.opentelemetry.io/otel/sdk/metric`. (#4435)
|
||||
- The exporters in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric` now support the `OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION` environment variable. (#4437)
|
||||
- Add the `NewAllowKeysFilter` and `NewDenyKeysFilter` functions to `go.opentelemetry.io/otel/attribute` to allow convenient creation of allow-keys and deny-keys filters. (#4444)
|
||||
- Support Go 1.21. (#4463)
|
||||
|
||||
### Changed
|
||||
|
||||
- Starting from `v1.21.0` of semantic conventions, `go.opentelemetry.io/otel/semconv/{version}/httpconv` and `go.opentelemetry.io/otel/semconv/{version}/netconv` packages will no longer be published. (#4145)
|
||||
- Log duplicate instrument conflict at a warning level instead of info in `go.opentelemetry.io/otel/sdk/metric`. (#4202)
|
||||
- Return an error on the creation of new instruments in `go.opentelemetry.io/otel/sdk/metric` if their name doesn't pass regexp validation. (#4210)
|
||||
- `NewManualReader` in `go.opentelemetry.io/otel/sdk/metric` returns `*ManualReader` instead of `Reader`. (#4244)
|
||||
- `NewPeriodicReader` in `go.opentelemetry.io/otel/sdk/metric` returns `*PeriodicReader` instead of `Reader`. (#4244)
|
||||
- Count the Collect time in the `PeriodicReader` timeout in `go.opentelemetry.io/otel/sdk/metric`. (#4221)
|
||||
- The function `New` in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc` returns `*Exporter` instead of `"go.opentelemetry.io/otel/sdk/metric".Exporter`. (#4272)
|
||||
- The function `New` in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp` returns `*Exporter` instead of `"go.opentelemetry.io/otel/sdk/metric".Exporter`. (#4272)
|
||||
- If an attribute set is omitted from an async callback, the previous value will no longer be exported in `go.opentelemetry.io/otel/sdk/metric`. (#4290)
|
||||
- If an attribute set is observed multiple times in an async callback in `go.opentelemetry.io/otel/sdk/metric`, the values will be summed instead of the last observation winning. (#4289)
|
||||
- Allow the explicit bucket histogram aggregation to be used for the up-down counter, observable counter, observable up-down counter, and observable gauge in the `go.opentelemetry.io/otel/sdk/metric` package. (#4332)
|
||||
- Restrict `Meter`s in `go.opentelemetry.io/otel/sdk/metric` to only register and collect instruments it created. (#4333)
|
||||
- `PeriodicReader.Shutdown` and `PeriodicReader.ForceFlush` in `go.opentelemetry.io/otel/sdk/metric` now apply the periodic reader's timeout to the operation if the user provided context does not contain a deadline. (#4356, #4377)
|
||||
- Upgrade all use of `go.opentelemetry.io/otel/semconv` to use `v1.21.0`. (#4408)
|
||||
- Increase instrument name maximum length from 63 to 255 characters in `go.opentelemetry.io/otel/sdk/metric`. (#4434)
|
||||
- Add `go.opentelemetry.op/otel/sdk/metric.WithProducer` as an `Option` for `"go.opentelemetry.io/otel/sdk/metric".NewManualReader` and `"go.opentelemetry.io/otel/sdk/metric".NewPeriodicReader`. (#4346)
|
||||
|
||||
### Removed
|
||||
|
||||
- Remove `Reader.RegisterProducer` in `go.opentelemetry.io/otel/metric`.
|
||||
Use the added `WithProducer` option instead. (#4346)
|
||||
- Remove `Reader.ForceFlush` in `go.opentelemetry.io/otel/metric`.
|
||||
Notice that `PeriodicReader.ForceFlush` is still available. (#4375)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Correctly format log messages from the `go.opentelemetry.io/otel/exporters/zipkin` exporter. (#4143)
|
||||
- Log an error for calls to `NewView` in `go.opentelemetry.io/otel/sdk/metric` that have empty criteria. (#4307)
|
||||
- Fix `"go.opentelemetry.io/otel/sdk/resource".WithHostID()` to not set an empty `host.id`. (#4317)
|
||||
- Use the instrument identifying fields to cache aggregators and determine duplicate instrument registrations in `go.opentelemetry.io/otel/sdk/metric`. (#4337)
|
||||
- Detect duplicate instruments for case-insensitive names in `go.opentelemetry.io/otel/sdk/metric`. (#4338)
|
||||
- The `ManualReader` will not panic if `AggregationSelector` returns `nil` in `go.opentelemetry.io/otel/sdk/metric`. (#4350)
|
||||
- If a `Reader`'s `AggregationSelector` returns `nil` or `DefaultAggregation` the pipeline will use the default aggregation. (#4350)
|
||||
- Log a suggested view that fixes instrument conflicts in `go.opentelemetry.io/otel/sdk/metric`. (#4349)
|
||||
- Fix possible panic, deadlock and race condition in batch span processor in `go.opentelemetry.io/otel/sdk/trace`. (#4353)
|
||||
- Improve context cancellation handling in batch span processor's `ForceFlush` in `go.opentelemetry.io/otel/sdk/trace`. (#4369)
|
||||
- Decouple `go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal` from `go.opentelemetry.io/otel/exporters/otlp/internal` using gotmpl. (#4397, #3846)
|
||||
- Decouple `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc/internal` from `go.opentelemetry.io/otel/exporters/otlp/internal` and `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal` using gotmpl. (#4404, #3846)
|
||||
- Decouple `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp/internal` from `go.opentelemetry.io/otel/exporters/otlp/internal` and `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal` using gotmpl. (#4407, #3846)
|
||||
- Decouple `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal` from `go.opentelemetry.io/otel/exporters/otlp/internal` and `go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal` using gotmpl. (#4400, #3846)
|
||||
- Decouple `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal` from `go.opentelemetry.io/otel/exporters/otlp/internal` and `go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal` using gotmpl. (#4401, #3846)
|
||||
- Do not block the metric SDK when OTLP metric exports are blocked in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc` and `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`. (#3925, #4395)
|
||||
- Do not append `_total` if the counter already has that suffix for the Prometheus exproter in `go.opentelemetry.io/otel/exporter/prometheus`. (#4373)
|
||||
- Fix resource detection data race in `go.opentelemetry.io/otel/sdk/resource`. (#4409)
|
||||
- Use the first-seen instrument name during instrument name conflicts in `go.opentelemetry.io/otel/sdk/metric`. (#4428)
|
||||
|
||||
### Deprecated
|
||||
|
||||
- The `go.opentelemetry.io/otel/exporters/jaeger` package is deprecated.
|
||||
OpenTelemetry dropped support for Jaeger exporter in July 2023.
|
||||
Use `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`
|
||||
or `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc` instead. (#4423)
|
||||
- The `go.opentelemetry.io/otel/example/jaeger` package is deprecated. (#4423)
|
||||
- The `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal` package is deprecated. (#4420)
|
||||
- The `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/oconf` package is deprecated. (#4420)
|
||||
- The `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/otest` package is deprecated. (#4420)
|
||||
- The `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/transform` package is deprecated. (#4420)
|
||||
- The `go.opentelemetry.io/otel/exporters/otlp/internal` package is deprecated. (#4421)
|
||||
- The `go.opentelemetry.io/otel/exporters/otlp/internal/envconfig` package is deprecated. (#4421)
|
||||
- The `go.opentelemetry.io/otel/exporters/otlp/internal/retry` package is deprecated. (#4421)
|
||||
- The `go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal` package is deprecated. (#4425)
|
||||
- The `go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/envconfig` package is deprecated. (#4425)
|
||||
- The `go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlpconfig` package is deprecated. (#4425)
|
||||
- The `go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlptracetest` package is deprecated. (#4425)
|
||||
- The `go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/retry` package is deprecated. (#4425)
|
||||
- The `go.opentelemetry.io/otel/sdk/metric/aggregation` package is deprecated.
|
||||
Use the aggregation types added to `go.opentelemetry.io/otel/sdk/metric` instead. (#4435)
|
||||
|
||||
## [1.16.0/0.39.0] 2023-05-18
|
||||
|
||||
This release contains the first stable release of the OpenTelemetry Go [metric API].
|
||||
Our project stability guarantees now apply to the `go.opentelemetry.io/otel/metric` package.
|
||||
See our [versioning policy](VERSIONING.md) for more information about these stability guarantees.
|
||||
|
||||
### Added
|
||||
|
||||
- The `go.opentelemetry.io/otel/semconv/v1.19.0` package.
|
||||
The package contains semantic conventions from the `v1.19.0` version of the OpenTelemetry specification. (#3848)
|
||||
- The `go.opentelemetry.io/otel/semconv/v1.20.0` package.
|
||||
The package contains semantic conventions from the `v1.20.0` version of the OpenTelemetry specification. (#4078)
|
||||
- The Exponential Histogram data types in `go.opentelemetry.io/otel/sdk/metric/metricdata`. (#4165)
|
||||
- OTLP metrics exporter now supports the Exponential Histogram Data Type. (#4222)
|
||||
- Fix serialization of `time.Time` zero values in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc` and `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp` packages. (#4271)
|
||||
|
||||
### Changed
|
||||
|
||||
- Use `strings.Cut()` instead of `string.SplitN()` for better readability and memory use. (#4049)
|
||||
- `MeterProvider` returns noop meters once it has been shutdown. (#4154)
|
||||
|
||||
### Removed
|
||||
|
||||
- The deprecated `go.opentelemetry.io/otel/metric/instrument` package is removed.
|
||||
Use `go.opentelemetry.io/otel/metric` instead. (#4055)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix build for BSD based systems in `go.opentelemetry.io/otel/sdk/resource`. (#4077)
|
||||
|
||||
## [1.16.0-rc.1/0.39.0-rc.1] 2023-05-03
|
||||
|
||||
This is a release candidate for the v1.16.0/v0.39.0 release.
|
||||
That release is expected to include the `v1` release of the OpenTelemetry Go metric API and will provide stability guarantees of that API.
|
||||
See our [versioning policy](VERSIONING.md) for more information about these stability guarantees.
|
||||
|
||||
### Added
|
||||
|
||||
- Support global `MeterProvider` in `go.opentelemetry.io/otel`. (#4039)
|
||||
- Use `Meter` for a `metric.Meter` from the global `metric.MeterProvider`.
|
||||
- Use `GetMeterProivder` for a global `metric.MeterProvider`.
|
||||
- Use `SetMeterProivder` to set the global `metric.MeterProvider`.
|
||||
|
||||
### Changed
|
||||
|
||||
- Move the `go.opentelemetry.io/otel/metric` module to the `stable-v1` module set.
|
||||
This stages the metric API to be released as a stable module. (#4038)
|
||||
|
||||
### Removed
|
||||
|
||||
- The `go.opentelemetry.io/otel/metric/global` package is removed.
|
||||
Use `go.opentelemetry.io/otel` instead. (#4039)
|
||||
|
||||
## [1.15.1/0.38.1] 2023-05-02
|
||||
|
||||
### Fixed
|
||||
|
||||
- Remove unused imports from `sdk/resource/host_id_bsd.go` which caused build failures. (#4040, #4041)
|
||||
|
||||
## [1.15.0/0.38.0] 2023-04-27
|
||||
|
||||
### Added
|
||||
|
||||
- The `go.opentelemetry.io/otel/metric/embedded` package. (#3916)
|
||||
- The `Version` function to `go.opentelemetry.io/otel/sdk` to return the SDK version. (#3949)
|
||||
- Add a `WithNamespace` option to `go.opentelemetry.io/otel/exporters/prometheus` to allow users to prefix metrics with a namespace. (#3970)
|
||||
- The following configuration types were added to `go.opentelemetry.io/otel/metric/instrument` to be used in the configuration of measurement methods. (#3971)
|
||||
- The `AddConfig` used to hold configuration for addition measurements
|
||||
- `NewAddConfig` used to create a new `AddConfig`
|
||||
- `AddOption` used to configure an `AddConfig`
|
||||
- The `RecordConfig` used to hold configuration for recorded measurements
|
||||
- `NewRecordConfig` used to create a new `RecordConfig`
|
||||
- `RecordOption` used to configure a `RecordConfig`
|
||||
- The `ObserveConfig` used to hold configuration for observed measurements
|
||||
- `NewObserveConfig` used to create a new `ObserveConfig`
|
||||
- `ObserveOption` used to configure an `ObserveConfig`
|
||||
- `WithAttributeSet` and `WithAttributes` are added to `go.opentelemetry.io/otel/metric/instrument`.
|
||||
They return an option used during a measurement that defines the attribute Set associated with the measurement. (#3971)
|
||||
- The `Version` function to `go.opentelemetry.io/otel/exporters/otlp/otlpmetric` to return the OTLP metrics client version. (#3956)
|
||||
- The `Version` function to `go.opentelemetry.io/otel/exporters/otlp/otlptrace` to return the OTLP trace client version. (#3956)
|
||||
|
||||
### Changed
|
||||
|
||||
- The `Extrema` in `go.opentelemetry.io/otel/sdk/metric/metricdata` is redefined with a generic argument of `[N int64 | float64]`. (#3870)
|
||||
- Update all exported interfaces from `go.opentelemetry.io/otel/metric` to embed their corresponding interface from `go.opentelemetry.io/otel/metric/embedded`.
|
||||
This adds an implementation requirement to set the interface default behavior for unimplemented methods. (#3916)
|
||||
- Move No-Op implementation from `go.opentelemetry.io/otel/metric` into its own package `go.opentelemetry.io/otel/metric/noop`. (#3941)
|
||||
- `metric.NewNoopMeterProvider` is replaced with `noop.NewMeterProvider`
|
||||
- Add all the methods from `"go.opentelemetry.io/otel/trace".SpanContext` to `bridgeSpanContext` by embedding `otel.SpanContext` in `bridgeSpanContext`. (#3966)
|
||||
- Wrap `UploadMetrics` error in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/` to improve error message when encountering generic grpc errors. (#3974)
|
||||
- The measurement methods for all instruments in `go.opentelemetry.io/otel/metric/instrument` accept an option instead of the variadic `"go.opentelemetry.io/otel/attribute".KeyValue`. (#3971)
|
||||
- The `Int64Counter.Add` method now accepts `...AddOption`
|
||||
- The `Float64Counter.Add` method now accepts `...AddOption`
|
||||
- The `Int64UpDownCounter.Add` method now accepts `...AddOption`
|
||||
- The `Float64UpDownCounter.Add` method now accepts `...AddOption`
|
||||
- The `Int64Histogram.Record` method now accepts `...RecordOption`
|
||||
- The `Float64Histogram.Record` method now accepts `...RecordOption`
|
||||
- The `Int64Observer.Observe` method now accepts `...ObserveOption`
|
||||
- The `Float64Observer.Observe` method now accepts `...ObserveOption`
|
||||
- The `Observer` methods in `go.opentelemetry.io/otel/metric` accept an option instead of the variadic `"go.opentelemetry.io/otel/attribute".KeyValue`. (#3971)
|
||||
- The `Observer.ObserveInt64` method now accepts `...ObserveOption`
|
||||
- The `Observer.ObserveFloat64` method now accepts `...ObserveOption`
|
||||
- Move global metric back to `go.opentelemetry.io/otel/metric/global` from `go.opentelemetry.io/otel`. (#3986)
|
||||
|
||||
### Fixed
|
||||
|
||||
- `TracerProvider` allows calling `Tracer()` while it's shutting down.
|
||||
It used to deadlock. (#3924)
|
||||
- Use the SDK version for the Telemetry SDK resource detector in `go.opentelemetry.io/otel/sdk/resource`. (#3949)
|
||||
- Fix a data race in `SpanProcessor` returned by `NewSimpleSpanProcessor` in `go.opentelemetry.io/otel/sdk/trace`. (#3951)
|
||||
- Automatically figure out the default aggregation with `aggregation.Default`. (#3967)
|
||||
|
||||
### Deprecated
|
||||
|
||||
- The `go.opentelemetry.io/otel/metric/instrument` package is deprecated.
|
||||
Use the equivalent types added to `go.opentelemetry.io/otel/metric` instead. (#4018)
|
||||
|
||||
## [1.15.0-rc.2/0.38.0-rc.2] 2023-03-23
|
||||
|
||||
This is a release candidate for the v1.15.0/v0.38.0 release.
|
||||
That release will include the `v1` release of the OpenTelemetry Go metric API and will provide stability guarantees of that API.
|
||||
See our [versioning policy](VERSIONING.md) for more information about these stability guarantees.
|
||||
|
||||
### Added
|
||||
|
||||
- The `WithHostID` option to `go.opentelemetry.io/otel/sdk/resource`. (#3812)
|
||||
- The `WithoutTimestamps` option to `go.opentelemetry.io/otel/exporters/stdout/stdoutmetric` to sets all timestamps to zero. (#3828)
|
||||
- The new `Exemplar` type is added to `go.opentelemetry.io/otel/sdk/metric/metricdata`.
|
||||
Both the `DataPoint` and `HistogramDataPoint` types from that package have a new field of `Exemplars` containing the sampled exemplars for their timeseries. (#3849)
|
||||
- Configuration for each metric instrument in `go.opentelemetry.io/otel/sdk/metric/instrument`. (#3895)
|
||||
- The internal logging introduces a warning level verbosity equal to `V(1)`. (#3900)
|
||||
- Added a log message warning about usage of `SimpleSpanProcessor` in production environments. (#3854)
|
||||
|
||||
### Changed
|
||||
|
||||
- Optimize memory allocation when creation a new `Set` using `NewSet` or `NewSetWithFiltered` in `go.opentelemetry.io/otel/attribute`. (#3832)
|
||||
- Optimize memory allocation when creation new metric instruments in `go.opentelemetry.io/otel/sdk/metric`. (#3832)
|
||||
- Avoid creating new objects on all calls to `WithDeferredSetup` and `SkipContextSetup` in OpenTracing bridge. (#3833)
|
||||
- The `New` and `Detect` functions from `go.opentelemetry.io/otel/sdk/resource` return errors that wrap underlying errors instead of just containing the underlying error strings. (#3844)
|
||||
- Both the `Histogram` and `HistogramDataPoint` are redefined with a generic argument of `[N int64 | float64]` in `go.opentelemetry.io/otel/sdk/metric/metricdata`. (#3849)
|
||||
- The metric `Export` interface from `go.opentelemetry.io/otel/sdk/metric` accepts a `*ResourceMetrics` instead of `ResourceMetrics`. (#3853)
|
||||
- Rename `Asynchronous` to `Observable` in `go.opentelemetry.io/otel/metric/instrument`. (#3892)
|
||||
- Rename `Int64ObserverOption` to `Int64ObservableOption` in `go.opentelemetry.io/otel/metric/instrument`. (#3895)
|
||||
- Rename `Float64ObserverOption` to `Float64ObservableOption` in `go.opentelemetry.io/otel/metric/instrument`. (#3895)
|
||||
- The internal logging changes the verbosity level of info to `V(4)`, the verbosity level of debug to `V(8)`. (#3900)
|
||||
|
||||
### Fixed
|
||||
|
||||
- `TracerProvider` consistently doesn't allow to register a `SpanProcessor` after shutdown. (#3845)
|
||||
|
||||
### Removed
|
||||
|
||||
- The deprecated `go.opentelemetry.io/otel/metric/global` package is removed. (#3829)
|
||||
- The unneeded `Synchronous` interface in `go.opentelemetry.io/otel/metric/instrument` was removed. (#3892)
|
||||
- The `Float64ObserverConfig` and `NewFloat64ObserverConfig` in `go.opentelemetry.io/otel/sdk/metric/instrument`.
|
||||
Use the added `float64` instrument configuration instead. (#3895)
|
||||
- The `Int64ObserverConfig` and `NewInt64ObserverConfig` in `go.opentelemetry.io/otel/sdk/metric/instrument`.
|
||||
Use the added `int64` instrument configuration instead. (#3895)
|
||||
- The `NewNoopMeter` function in `go.opentelemetry.io/otel/metric`, use `NewMeterProvider().Meter("")` instead. (#3893)
|
||||
|
||||
## [1.15.0-rc.1/0.38.0-rc.1] 2023-03-01
|
||||
|
||||
This is a release candidate for the v1.15.0/v0.38.0 release.
|
||||
That release will include the `v1` release of the OpenTelemetry Go metric API and will provide stability guarantees of that API.
|
||||
See our [versioning policy](VERSIONING.md) for more information about these stability guarantees.
|
||||
|
||||
This release drops the compatibility guarantee of [Go 1.18].
|
||||
|
||||
### Added
|
||||
|
||||
- Support global `MeterProvider` in `go.opentelemetry.io/otel`. (#3818)
|
||||
- Use `Meter` for a `metric.Meter` from the global `metric.MeterProvider`.
|
||||
- Use `GetMeterProivder` for a global `metric.MeterProvider`.
|
||||
- Use `SetMeterProivder` to set the global `metric.MeterProvider`.
|
||||
|
||||
### Changed
|
||||
|
||||
- Dropped compatibility testing for [Go 1.18].
|
||||
The project no longer guarantees support for this version of Go. (#3813)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Handle empty environment variable as it they were not set. (#3764)
|
||||
- Clarify the `httpconv` and `netconv` packages in `go.opentelemetry.io/otel/semconv/*` provide tracing semantic conventions. (#3823)
|
||||
- Fix race conditions in `go.opentelemetry.io/otel/exporters/metric/prometheus` that could cause a panic. (#3899)
|
||||
- Fix sending nil `scopeInfo` to metrics channel in `go.opentelemetry.io/otel/exporters/metric/prometheus` that could cause a panic in `github.com/prometheus/client_golang/prometheus`. (#3899)
|
||||
|
||||
### Deprecated
|
||||
|
||||
- The `go.opentelemetry.io/otel/metric/global` package is deprecated.
|
||||
Use `go.opentelemetry.io/otel` instead. (#3818)
|
||||
|
||||
### Removed
|
||||
|
||||
- The deprecated `go.opentelemetry.io/otel/metric/unit` package is removed. (#3814)
|
||||
|
||||
## [1.14.0/0.37.0/0.0.4] 2023-02-27
|
||||
|
||||
This release is the last to support [Go 1.18].
|
||||
|
@ -121,7 +475,7 @@ The next release will require at least [Go 1.19].
|
|||
- 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)
|
||||
These instruments are use as replacements of the deprecated `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`
|
||||
|
@ -144,7 +498,7 @@ The next release will require at least [Go 1.19].
|
|||
### 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)
|
||||
- Instrument configuration in `go.opentelemetry.io/otel/metric/instrument` is split into specific options and configuration 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`.
|
||||
|
@ -157,7 +511,7 @@ The next release will require at least [Go 1.19].
|
|||
- 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.
|
||||
- Errors from `go.opentelemetry.io/otel/exporters/otlp/otlptrace` exporters are wrapped in errors 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)
|
||||
|
@ -266,7 +620,7 @@ The next release will require at least [Go 1.19].
|
|||
- Asynchronous counters (`Counter` and `UpDownCounter`) from the metric SDK now produce delta sums when configured with delta temporality. (#3398)
|
||||
- Exported `Status` codes in the `go.opentelemetry.io/otel/exporters/zipkin` exporter are now exported as all upper case values. (#3340)
|
||||
- `Aggregation`s from `go.opentelemetry.io/otel/sdk/metric` with no data are not exported. (#3394, #3436)
|
||||
- Reenabled Attribute Filters in the Metric SDK. (#3396)
|
||||
- Re-enabled Attribute Filters in the Metric SDK. (#3396)
|
||||
- Asynchronous callbacks are only called if they are registered with at least one instrument that does not use drop aggragation. (#3408)
|
||||
- Do not report empty partial-success responses in the `go.opentelemetry.io/otel/exporters/otlp` exporters. (#3438, #3432)
|
||||
- Handle partial success responses in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric` exporters. (#3162, #3440)
|
||||
|
@ -847,7 +1201,7 @@ This release includes an API and SDK for the tracing signal that will comply wit
|
|||
- Setting the global `ErrorHandler` with `"go.opentelemetry.io/otel".SetErrorHandler` multiple times is now supported. (#2160, #2140)
|
||||
- The `"go.opentelemetry.io/otel/attribute".Any` function now supports `int32` values. (#2169)
|
||||
- Multiple calls to `"go.opentelemetry.io/otel/sdk/metric/controller/basic".WithResource()` are handled correctly, and when no resources are provided `"go.opentelemetry.io/otel/sdk/resource".Default()` is used. (#2120)
|
||||
- The `WithoutTimestamps` option for the `go.opentelemetry.io/otel/exporters/stdout/stdouttrace` exporter causes the exporter to correctly ommit timestamps. (#2195)
|
||||
- The `WithoutTimestamps` option for the `go.opentelemetry.io/otel/exporters/stdout/stdouttrace` exporter causes the exporter to correctly omit timestamps. (#2195)
|
||||
- Fixed typos in resources.go. (#2201)
|
||||
|
||||
## [1.0.0-RC2] - 2021-07-26
|
||||
|
@ -1293,7 +1647,7 @@ with major version 0.
|
|||
- `NewGRPCDriver` function returns a `ProtocolDriver` that maintains a single gRPC connection to the collector. (#1369)
|
||||
- Added documentation about the project's versioning policy. (#1388)
|
||||
- Added `NewSplitDriver` for OTLP exporter that allows sending traces and metrics to different endpoints. (#1418)
|
||||
- Added codeql worfklow to GitHub Actions (#1428)
|
||||
- Added codeql workflow to GitHub Actions (#1428)
|
||||
- Added Gosec workflow to GitHub Actions (#1429)
|
||||
- Add new HTTP driver for OTLP exporter in `exporters/otlp/otlphttp`. Currently it only supports the binary protobuf payloads. (#1420)
|
||||
- Add an OpenCensus exporter bridge. (#1444)
|
||||
|
@ -2136,7 +2490,7 @@ There is still a possibility of breaking changes.
|
|||
|
||||
### Fixed
|
||||
|
||||
- Use stateful batcher on Prometheus exporter fixing regresion introduced in #395. (#428)
|
||||
- Use stateful batcher on Prometheus exporter fixing regression introduced in #395. (#428)
|
||||
|
||||
## [0.2.1] - 2020-01-08
|
||||
|
||||
|
@ -2302,7 +2656,17 @@ 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.14.0...HEAD
|
||||
[Unreleased]: https://github.com/open-telemetry/opentelemetry-go/compare/v1.19.0...HEAD
|
||||
[1.19.0/0.42.0/0.0.7]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.19.0
|
||||
[1.19.0-rc.1/0.42.0-rc.1]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.19.0-rc.1
|
||||
[1.18.0/0.41.0/0.0.6]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.18.0
|
||||
[1.17.0/0.40.0/0.0.5]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.17.0
|
||||
[1.16.0/0.39.0]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.16.0
|
||||
[1.16.0-rc.1/0.39.0-rc.1]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.16.0-rc.1
|
||||
[1.15.1/0.38.1]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.15.1
|
||||
[1.15.0/0.38.0]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.15.0
|
||||
[1.15.0-rc.2/0.38.0-rc.2]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.15.0-rc.2
|
||||
[1.15.0-rc.1/0.38.0-rc.1]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.15.0-rc.1
|
||||
[1.14.0/0.37.0/0.0.4]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.14.0
|
||||
[1.13.0/0.36.0]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.13.0
|
||||
[1.12.0/0.35.0]: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.12.0
|
||||
|
@ -2367,3 +2731,7 @@ It contains api and sdk for trace and meter.
|
|||
[Go 1.20]: https://go.dev/doc/go1.20
|
||||
[Go 1.19]: https://go.dev/doc/go1.19
|
||||
[Go 1.18]: https://go.dev/doc/go1.18
|
||||
[Go 1.19]: https://go.dev/doc/go1.19
|
||||
|
||||
[metric API]:https://pkg.go.dev/go.opentelemetry.io/otel/metric
|
||||
[metric SDK]:https://pkg.go.dev/go.opentelemetry.io/otel/sdk/metric
|
||||
|
|
4
vendor/go.opentelemetry.io/otel/CODEOWNERS
generated
vendored
4
vendor/go.opentelemetry.io/otel/CODEOWNERS
generated
vendored
|
@ -12,6 +12,6 @@
|
|||
# https://help.github.com/en/articles/about-code-owners
|
||||
#
|
||||
|
||||
* @jmacd @MrAlias @Aneurysm9 @evantorrie @XSAM @dashpole @MadVikingGod @pellared @hanyuancheung @dmathieu
|
||||
* @MrAlias @Aneurysm9 @evantorrie @XSAM @dashpole @MadVikingGod @pellared @hanyuancheung @dmathieu
|
||||
|
||||
CODEOWNERS @MrAlias @Aneurysm9 @MadVikingGod
|
||||
CODEOWNERS @MrAlias @MadVikingGod @pellared
|
192
vendor/go.opentelemetry.io/otel/CONTRIBUTING.md
generated
vendored
192
vendor/go.opentelemetry.io/otel/CONTRIBUTING.md
generated
vendored
|
@ -6,7 +6,7 @@ OpenTelemetry
|
|||
repo for information on this and other language SIGs.
|
||||
|
||||
See the [public meeting
|
||||
notes](https://docs.google.com/document/d/1A63zSWX0x2CyCK_LoNhmQC4rqhLpYXJzXbEPDUQ2n6w/edit#heading=h.9tngw7jdwd6b)
|
||||
notes](https://docs.google.com/document/d/1E5e7Ld0NuU1iVvf-42tOBpu2VBBLYnh73GJuITGJTTU/edit)
|
||||
for a summary description of past meetings. To request edit access,
|
||||
join the meeting or get in touch on
|
||||
[Slack](https://cloud-native.slack.com/archives/C01NPAXACKT).
|
||||
|
@ -28,6 +28,11 @@ precommit` - the `precommit` target is the default).
|
|||
The `precommit` target also fixes the formatting of the code and
|
||||
checks the status of the go module files.
|
||||
|
||||
Additionally, there is a `codespell` target that checks for common
|
||||
typos in the code. It is not run by default, but you can run it
|
||||
manually with `make codespell`. It will set up a virtual environment
|
||||
in `venv` and install `codespell` there.
|
||||
|
||||
If after running `make precommit` the output of `git status` contains
|
||||
`nothing to commit, working tree clean` then it means that everything
|
||||
is up-to-date and properly formatted.
|
||||
|
@ -94,38 +99,66 @@ request ID to the entry you added to `CHANGELOG.md`.
|
|||
|
||||
### How to Get PRs Merged
|
||||
|
||||
A PR is considered to be **ready to merge** when:
|
||||
A PR is considered **ready to merge** when:
|
||||
|
||||
* It has received two approvals from Collaborators/Maintainers (at
|
||||
different companies). This is not enforced through technical means
|
||||
and a PR may be **ready to merge** with a single approval if the change
|
||||
and its approach have been discussed and consensus reached.
|
||||
* Feedback has been addressed.
|
||||
* Any substantive changes to your PR will require that you clear any prior
|
||||
Approval reviews, this includes changes resulting from other feedback. Unless
|
||||
the approver explicitly stated that their approval will persist across
|
||||
changes it should be assumed that the PR needs their review again. Other
|
||||
project members (e.g. approvers, maintainers) can help with this if there are
|
||||
any questions or if you forget to clear reviews.
|
||||
* It has been open for review for at least one working day. This gives
|
||||
people reasonable time to review.
|
||||
* Trivial changes (typo, cosmetic, doc, etc.) do not have to wait for
|
||||
one day and may be merged with a single Maintainer's approval.
|
||||
* `CHANGELOG.md` has been updated to reflect what has been
|
||||
added, changed, removed, or fixed.
|
||||
* `README.md` has been updated if necessary.
|
||||
* Urgent fix can take exception as long as it has been actively
|
||||
communicated.
|
||||
* It has received two qualified approvals[^1].
|
||||
|
||||
Any Maintainer can merge the PR once it is **ready to merge**.
|
||||
This is not enforced through automation, but needs to be validated by the
|
||||
maintainer merging.
|
||||
* The qualified approvals need to be from [Approver]s/[Maintainer]s
|
||||
affiliated with different companies. Two qualified approvals from
|
||||
[Approver]s or [Maintainer]s affiliated with the same company counts as a
|
||||
single qualified approval.
|
||||
* PRs introducing changes that have already been discussed and consensus
|
||||
reached only need one qualified approval. The discussion and resolution
|
||||
needs to be linked to the PR.
|
||||
* Trivial changes[^2] only need one qualified approval.
|
||||
|
||||
* All feedback has been addressed.
|
||||
* All PR comments and suggestions are resolved.
|
||||
* All GitHub Pull Request reviews with a status of "Request changes" have
|
||||
been addressed. Another review by the objecting reviewer with a different
|
||||
status can be submitted to clear the original review, or the review can be
|
||||
dismissed by a [Maintainer] when the issues from the original review have
|
||||
been addressed.
|
||||
* Any comments or reviews that cannot be resolved between the PR author and
|
||||
reviewers can be submitted to the community [Approver]s and [Maintainer]s
|
||||
during the weekly SIG meeting. If consensus is reached among the
|
||||
[Approver]s and [Maintainer]s during the SIG meeting the objections to the
|
||||
PR may be dismissed or resolved or the PR closed by a [Maintainer].
|
||||
* Any substantive changes to the PR require existing Approval reviews be
|
||||
cleared unless the approver explicitly states that their approval persists
|
||||
across changes. This includes changes resulting from other feedback.
|
||||
[Approver]s and [Maintainer]s can help in clearing reviews and they should
|
||||
be consulted if there are any questions.
|
||||
|
||||
* The PR branch is up to date with the base branch it is merging into.
|
||||
* To ensure this does not block the PR, it should be configured to allow
|
||||
maintainers to update it.
|
||||
|
||||
* It has been open for review for at least one working day. This gives people
|
||||
reasonable time to review.
|
||||
* Trivial changes[^2] do not have to wait for one day and may be merged with
|
||||
a single [Maintainer]'s approval.
|
||||
|
||||
* All required GitHub workflows have succeeded.
|
||||
* Urgent fix can take exception as long as it has been actively communicated
|
||||
among [Maintainer]s.
|
||||
|
||||
Any [Maintainer] can merge the PR once the above criteria have been met.
|
||||
|
||||
[^1]: A qualified approval is a GitHub Pull Request review with "Approve"
|
||||
status from an OpenTelemetry Go [Approver] or [Maintainer].
|
||||
[^2]: Trivial changes include: typo corrections, cosmetic non-substantive
|
||||
changes, documentation corrections or updates, dependency updates, etc.
|
||||
|
||||
## Design Choices
|
||||
|
||||
As with other OpenTelemetry clients, opentelemetry-go follows the
|
||||
[opentelemetry-specification](https://github.com/open-telemetry/opentelemetry-specification).
|
||||
[OpenTelemetry Specification](https://opentelemetry.io/docs/specs/otel).
|
||||
|
||||
It's especially valuable to read through the [library
|
||||
guidelines](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/library-guidelines.md).
|
||||
guidelines](https://opentelemetry.io/docs/specs/otel/library-guidelines).
|
||||
|
||||
### Focus on Capabilities, Not Structure Compliance
|
||||
|
||||
|
@ -146,23 +179,23 @@ For a deeper discussion, see
|
|||
|
||||
## Documentation
|
||||
|
||||
Each non-example Go Module should have its own `README.md` containing:
|
||||
Each (non-internal, non-test) package must be documented using
|
||||
[Go Doc Comments](https://go.dev/doc/comment),
|
||||
preferably in a `doc.go` file.
|
||||
|
||||
- A pkg.go.dev badge which can be generated [here](https://pkg.go.dev/badge/).
|
||||
- Brief description.
|
||||
- Installation instructions (and requirements if applicable).
|
||||
- Hyperlink to an example. Depending on the component the example can be:
|
||||
- An `example_test.go` like [here](exporters/stdout/stdouttrace/example_test.go).
|
||||
- A sample Go application with its own `README.md`, like [here](example/zipkin).
|
||||
- Additional documentation sections such us:
|
||||
- Configuration,
|
||||
- Contributing,
|
||||
- References.
|
||||
Prefer using [Examples](https://pkg.go.dev/testing#hdr-Examples)
|
||||
instead of putting code snippets in Go doc comments.
|
||||
In some cases, you can even create [Testable Examples](https://go.dev/blog/examples).
|
||||
|
||||
[Here](exporters/jaeger/README.md) is an example of a concise `README.md`.
|
||||
You can install and run a "local Go Doc site" in the following way:
|
||||
|
||||
Moreover, it should be possible to navigate to any `README.md` from the
|
||||
root `README.md`.
|
||||
```sh
|
||||
go install golang.org/x/pkgsite/cmd/pkgsite@latest
|
||||
pkgsite
|
||||
```
|
||||
|
||||
[`go.opentelemetry.io/otel/metric`](https://pkg.go.dev/go.opentelemetry.io/otel/metric)
|
||||
is an example of a very well-documented package.
|
||||
|
||||
## Style Guide
|
||||
|
||||
|
@ -216,7 +249,7 @@ Meaning a `config` from one package should not be directly used by another. The
|
|||
one exception is the API packages. The configs from the base API, eg.
|
||||
`go.opentelemetry.io/otel/trace.TracerConfig` and
|
||||
`go.opentelemetry.io/otel/metric.InstrumentConfig`, are intended to be consumed
|
||||
by the SDK therefor it is expected that these are exported.
|
||||
by the SDK therefore it is expected that these are exported.
|
||||
|
||||
When a config is exported we want to maintain forward and backward
|
||||
compatibility, to achieve this no fields should be exported but should
|
||||
|
@ -234,12 +267,12 @@ func newConfig(options ...Option) config {
|
|||
for _, option := range options {
|
||||
config = option.apply(config)
|
||||
}
|
||||
// Preform any validation here.
|
||||
// Perform any validation here.
|
||||
return config
|
||||
}
|
||||
```
|
||||
|
||||
If validation of the `config` options is also preformed this can return an
|
||||
If validation of the `config` options is also performed this can return an
|
||||
error as well that is expected to be handled by the instantiation function
|
||||
or propagated to the user.
|
||||
|
||||
|
@ -438,12 +471,37 @@ their parameters appropriately named.
|
|||
#### Interface Stability
|
||||
|
||||
All exported stable interfaces that include the following warning in their
|
||||
doumentation are allowed to be extended with additional methods.
|
||||
documentation are allowed to be extended with additional methods.
|
||||
|
||||
> Warning: methods may be added to this interface in minor releases.
|
||||
|
||||
These interfaces are defined by the OpenTelemetry specification and will be
|
||||
updated as the specification evolves.
|
||||
|
||||
Otherwise, stable interfaces MUST NOT be modified.
|
||||
|
||||
#### How to Change Specification Interfaces
|
||||
|
||||
When an API change must be made, we will update the SDK with the new method one
|
||||
release before the API change. This will allow the SDK one version before the
|
||||
API change to work seamlessly with the new API.
|
||||
|
||||
If an incompatible version of the SDK is used with the new API the application
|
||||
will fail to compile.
|
||||
|
||||
#### How Not to Change Specification Interfaces
|
||||
|
||||
We have explored using a v2 of the API to change interfaces and found that there
|
||||
was no way to introduce a v2 and have it work seamlessly with the v1 of the API.
|
||||
Problems happened with libraries that upgraded to v2 when an application did not,
|
||||
and would not produce any telemetry.
|
||||
|
||||
More detail of the approaches considered and their limitations can be found in
|
||||
the [Use a V2 API to evolve interfaces](https://github.com/open-telemetry/opentelemetry-go/issues/3920)
|
||||
issue.
|
||||
|
||||
#### How to Change Other Interfaces
|
||||
|
||||
If new functionality is needed for an interface that cannot be changed it MUST
|
||||
be added by including an additional interface. That added interface can be a
|
||||
simple interface for the specific functionality that you want to add or it can
|
||||
|
@ -498,29 +556,65 @@ functionality should be added, each one will need their own super-set
|
|||
interfaces and will duplicate the pattern. For this reason, the simple targeted
|
||||
interface that defines the specific functionality should be preferred.
|
||||
|
||||
### Testing
|
||||
|
||||
The tests should never leak goroutines.
|
||||
|
||||
Use the term `ConcurrentSafe` in the test name when it aims to verify the
|
||||
absence of race conditions.
|
||||
|
||||
### Internal packages
|
||||
|
||||
The use of internal packages should be scoped to a single module. A sub-module
|
||||
should never import from a parent internal package. This creates a coupling
|
||||
between the two modules where a user can upgrade the parent without the child
|
||||
and if the internal package API has changed it will fail to upgrade[^3].
|
||||
|
||||
There are two known exceptions to this rule:
|
||||
|
||||
- `go.opentelemetry.io/otel/internal/global`
|
||||
- This package manages global state for all of opentelemetry-go. It needs to
|
||||
be a single package in order to ensure the uniqueness of the global state.
|
||||
- `go.opentelemetry.io/otel/internal/baggage`
|
||||
- This package provides values in a `context.Context` that need to be
|
||||
recognized by `go.opentelemetry.io/otel/baggage` and
|
||||
`go.opentelemetry.io/otel/bridge/opentracing` but remain private.
|
||||
|
||||
If you have duplicate code in multiple modules, make that code into a Go
|
||||
template stored in `go.opentelemetry.io/otel/internal/shared` and use [gotmpl]
|
||||
to render the templates in the desired locations. See [#4404] for an example of
|
||||
this.
|
||||
|
||||
[^3]: https://github.com/open-telemetry/opentelemetry-go/issues/3548
|
||||
|
||||
## Approvers and Maintainers
|
||||
|
||||
Approvers:
|
||||
### Approvers
|
||||
|
||||
- [Evan Torrie](https://github.com/evantorrie), Verizon Media
|
||||
- [Josh MacDonald](https://github.com/jmacd), LightStep
|
||||
- [Sam Xie](https://github.com/XSAM), Cisco/AppDynamics
|
||||
- [David Ashpole](https://github.com/dashpole), Google
|
||||
- [Robert Pająk](https://github.com/pellared), Splunk
|
||||
- [Chester Cheung](https://github.com/hanyuancheung), Tencent
|
||||
- [Damien Mathieu](https://github.com/dmathieu), Elastic
|
||||
- [Anthony Mirabella](https://github.com/Aneurysm9), AWS
|
||||
|
||||
Maintainers:
|
||||
### Maintainers
|
||||
|
||||
- [Aaron Clawson](https://github.com/MadVikingGod), LightStep
|
||||
- [Anthony Mirabella](https://github.com/Aneurysm9), AWS
|
||||
- [Robert Pająk](https://github.com/pellared), Splunk
|
||||
- [Tyler Yahn](https://github.com/MrAlias), Splunk
|
||||
|
||||
Emeritus:
|
||||
### Emeritus
|
||||
|
||||
- [Gustavo Silva Paiva](https://github.com/paivagustavo), LightStep
|
||||
- [Josh MacDonald](https://github.com/jmacd), LightStep
|
||||
|
||||
### Become an Approver or a Maintainer
|
||||
|
||||
See the [community membership document in OpenTelemetry community
|
||||
repo](https://github.com/open-telemetry/community/blob/main/community-membership.md).
|
||||
|
||||
[Approver]: #approvers
|
||||
[Maintainer]: #maintainers
|
||||
[gotmpl]: https://pkg.go.dev/go.opentelemetry.io/build-tools/gotmpl
|
||||
[#4404]: https://github.com/open-telemetry/opentelemetry-go/pull/4404
|
||||
|
|
114
vendor/go.opentelemetry.io/otel/Makefile
generated
vendored
114
vendor/go.opentelemetry.io/otel/Makefile
generated
vendored
|
@ -25,8 +25,8 @@ TIMEOUT = 60
|
|||
.DEFAULT_GOAL := precommit
|
||||
|
||||
.PHONY: precommit ci
|
||||
precommit: dependabot-generate license-check vanity-import-fix misspell go-mod-tidy golangci-lint-fix test-default
|
||||
ci: dependabot-check license-check lint vanity-import-check build test-default check-clean-work-tree test-coverage
|
||||
precommit: generate dependabot-generate license-check misspell go-mod-tidy golangci-lint-fix test-default
|
||||
ci: generate dependabot-check license-check lint vanity-import-check build test-default check-clean-work-tree test-coverage
|
||||
|
||||
# Tools
|
||||
|
||||
|
@ -71,21 +71,75 @@ $(TOOLS)/porto: PACKAGE=github.com/jcchavezs/porto/cmd/porto
|
|||
GOJQ = $(TOOLS)/gojq
|
||||
$(TOOLS)/gojq: PACKAGE=github.com/itchyny/gojq/cmd/gojq
|
||||
|
||||
GOTMPL = $(TOOLS)/gotmpl
|
||||
$(GOTMPL): PACKAGE=go.opentelemetry.io/build-tools/gotmpl
|
||||
|
||||
GORELEASE = $(TOOLS)/gorelease
|
||||
$(GORELEASE): PACKAGE=golang.org/x/exp/cmd/gorelease
|
||||
|
||||
.PHONY: tools
|
||||
tools: $(CROSSLINK) $(DBOTCONF) $(GOLANGCI_LINT) $(MISSPELL) $(GOCOVMERGE) $(STRINGER) $(PORTO) $(GOJQ) $(SEMCONVGEN) $(MULTIMOD) $(SEMCONVKIT)
|
||||
tools: $(CROSSLINK) $(DBOTCONF) $(GOLANGCI_LINT) $(MISSPELL) $(GOCOVMERGE) $(STRINGER) $(PORTO) $(GOJQ) $(SEMCONVGEN) $(MULTIMOD) $(SEMCONVKIT) $(GOTMPL) $(GORELEASE)
|
||||
|
||||
# Virtualized python tools via docker
|
||||
|
||||
# The directory where the virtual environment is created.
|
||||
VENVDIR := venv
|
||||
|
||||
# The directory where the python tools are installed.
|
||||
PYTOOLS := $(VENVDIR)/bin
|
||||
|
||||
# The pip executable in the virtual environment.
|
||||
PIP := $(PYTOOLS)/pip
|
||||
|
||||
# The directory in the docker image where the current directory is mounted.
|
||||
WORKDIR := /workdir
|
||||
|
||||
# The python image to use for the virtual environment.
|
||||
PYTHONIMAGE := python:3.11.3-slim-bullseye
|
||||
|
||||
# Run the python image with the current directory mounted.
|
||||
DOCKERPY := docker run --rm -v "$(CURDIR):$(WORKDIR)" -w $(WORKDIR) $(PYTHONIMAGE)
|
||||
|
||||
# Create a virtual environment for Python tools.
|
||||
$(PYTOOLS):
|
||||
# The `--upgrade` flag is needed to ensure that the virtual environment is
|
||||
# created with the latest pip version.
|
||||
@$(DOCKERPY) bash -c "python3 -m venv $(VENVDIR) && $(PIP) install --upgrade pip"
|
||||
|
||||
# Install python packages into the virtual environment.
|
||||
$(PYTOOLS)/%: | $(PYTOOLS)
|
||||
@$(DOCKERPY) $(PIP) install -r requirements.txt
|
||||
|
||||
CODESPELL = $(PYTOOLS)/codespell
|
||||
$(CODESPELL): PACKAGE=codespell
|
||||
|
||||
# Generate
|
||||
|
||||
.PHONY: generate
|
||||
generate: go-generate vanity-import-fix
|
||||
|
||||
.PHONY: go-generate
|
||||
go-generate: $(OTEL_GO_MOD_DIRS:%=go-generate/%)
|
||||
go-generate/%: DIR=$*
|
||||
go-generate/%: | $(STRINGER) $(GOTMPL)
|
||||
@echo "$(GO) generate $(DIR)/..." \
|
||||
&& cd $(DIR) \
|
||||
&& PATH="$(TOOLS):$${PATH}" $(GO) generate ./...
|
||||
|
||||
.PHONY: vanity-import-fix
|
||||
vanity-import-fix: | $(PORTO)
|
||||
@$(PORTO) --include-internal -w .
|
||||
|
||||
# Generate go.work file for local development.
|
||||
.PHONY: go-work
|
||||
go-work: | $(CROSSLINK)
|
||||
$(CROSSLINK) work --root=$(shell pwd)
|
||||
|
||||
# Build
|
||||
|
||||
.PHONY: generate build
|
||||
.PHONY: build
|
||||
|
||||
generate: $(OTEL_GO_MOD_DIRS:%=generate/%)
|
||||
generate/%: DIR=$*
|
||||
generate/%: | $(STRINGER) $(PORTO)
|
||||
@echo "$(GO) generate $(DIR)/..." \
|
||||
&& cd $(DIR) \
|
||||
&& PATH="$(TOOLS):$${PATH}" $(GO) generate ./... && $(PORTO) -w .
|
||||
|
||||
build: generate $(OTEL_GO_MOD_DIRS:%=build/%) $(OTEL_GO_MOD_DIRS:%=build-tests/%)
|
||||
build: $(OTEL_GO_MOD_DIRS:%=build/%) $(OTEL_GO_MOD_DIRS:%=build-tests/%)
|
||||
build/%: DIR=$*
|
||||
build/%:
|
||||
@echo "$(GO) build $(DIR)/..." \
|
||||
|
@ -156,7 +210,7 @@ go-mod-tidy/%: DIR=$*
|
|||
go-mod-tidy/%: | crosslink
|
||||
@echo "$(GO) mod tidy in $(DIR)" \
|
||||
&& cd $(DIR) \
|
||||
&& $(GO) mod tidy -compat=1.18
|
||||
&& $(GO) mod tidy -compat=1.20
|
||||
|
||||
.PHONY: lint-modules
|
||||
lint-modules: go-mod-tidy
|
||||
|
@ -166,20 +220,20 @@ lint: misspell lint-modules golangci-lint
|
|||
|
||||
.PHONY: vanity-import-check
|
||||
vanity-import-check: | $(PORTO)
|
||||
@$(PORTO) --include-internal -l . || echo "(run: make vanity-import-fix)"
|
||||
|
||||
.PHONY: vanity-import-fix
|
||||
vanity-import-fix: | $(PORTO)
|
||||
@$(PORTO) --include-internal -w .
|
||||
@$(PORTO) --include-internal -l . || ( echo "(run: make vanity-import-fix)"; exit 1 )
|
||||
|
||||
.PHONY: misspell
|
||||
misspell: | $(MISSPELL)
|
||||
@$(MISSPELL) -w $(ALL_DOCS)
|
||||
|
||||
.PHONY: codespell
|
||||
codespell: | $(CODESPELL)
|
||||
@$(DOCKERPY) $(CODESPELL)
|
||||
|
||||
.PHONY: license-check
|
||||
license-check:
|
||||
@licRes=$$(for f in $$(find . -type f \( -iname '*.go' -o -iname '*.sh' \) ! -path '**/third_party/*' ! -path './.git/*' ) ; do \
|
||||
awk '/Copyright The OpenTelemetry Authors|generated|GENERATED/ && NR<=3 { found=1; next } END { if (!found) print FILENAME }' $$f; \
|
||||
awk '/Copyright The OpenTelemetry Authors|generated|GENERATED/ && NR<=4 { found=1; next } END { if (!found) print FILENAME }' $$f; \
|
||||
done); \
|
||||
if [ -n "$${licRes}" ]; then \
|
||||
echo "license header checking failed:"; echo "$${licRes}"; \
|
||||
|
@ -189,7 +243,7 @@ license-check:
|
|||
DEPENDABOT_CONFIG = .github/dependabot.yml
|
||||
.PHONY: dependabot-check
|
||||
dependabot-check: | $(DBOTCONF)
|
||||
@$(DBOTCONF) verify $(DEPENDABOT_CONFIG) || echo "(run: make dependabot-generate)"
|
||||
@$(DBOTCONF) verify $(DEPENDABOT_CONFIG) || ( echo "(run: make dependabot-generate)"; exit 1 )
|
||||
|
||||
.PHONY: dependabot-generate
|
||||
dependabot-generate: | $(DBOTCONF)
|
||||
|
@ -208,13 +262,23 @@ 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/." --only=span -p conventionType=trace -f trace.go -t "$(SEMCONVPKG)/template.j2" -s "$(TAG)"
|
||||
$(SEMCONVGEN) -i "$(OTEL_SPEC_REPO)/semantic_conventions/." --only=event -p conventionType=event -f event.go -t "$(SEMCONVPKG)/template.j2" -s "$(TAG)"
|
||||
$(SEMCONVGEN) -i "$(OTEL_SPEC_REPO)/semantic_conventions/." --only=resource -p conventionType=resource -f resource.go -t "$(SEMCONVPKG)/template.j2" -s "$(TAG)"
|
||||
[ "$(TAG)" ] || ( echo "TAG unset: missing opentelemetry semantic-conventions tag"; exit 1 )
|
||||
[ "$(OTEL_SEMCONV_REPO)" ] || ( echo "OTEL_SEMCONV_REPO unset: missing path to opentelemetry semantic-conventions repo"; exit 1 )
|
||||
$(SEMCONVGEN) -i "$(OTEL_SEMCONV_REPO)/model/." --only=span -p conventionType=trace -f trace.go -t "$(SEMCONVPKG)/template.j2" -s "$(TAG)"
|
||||
$(SEMCONVGEN) -i "$(OTEL_SEMCONV_REPO)/model/." --only=attribute_group -p conventionType=trace -f attribute_group.go -t "$(SEMCONVPKG)/template.j2" -s "$(TAG)"
|
||||
$(SEMCONVGEN) -i "$(OTEL_SEMCONV_REPO)/model/." --only=event -p conventionType=event -f event.go -t "$(SEMCONVPKG)/template.j2" -s "$(TAG)"
|
||||
$(SEMCONVGEN) -i "$(OTEL_SEMCONV_REPO)/model/." --only=resource -p conventionType=resource -f resource.go -t "$(SEMCONVPKG)/template.j2" -s "$(TAG)"
|
||||
$(SEMCONVKIT) -output "$(SEMCONVPKG)/$(TAG)" -tag "$(TAG)"
|
||||
|
||||
.PHONY: gorelease
|
||||
gorelease: $(OTEL_GO_MOD_DIRS:%=gorelease/%)
|
||||
gorelease/%: DIR=$*
|
||||
gorelease/%:| $(GORELEASE)
|
||||
@echo "gorelease in $(DIR):" \
|
||||
&& cd $(DIR) \
|
||||
&& $(GORELEASE) \
|
||||
|| echo ""
|
||||
|
||||
.PHONY: prerelease
|
||||
prerelease: | $(MULTIMOD)
|
||||
@[ "${MODSET}" ] || ( echo ">> env var MODSET is not set"; exit 1 )
|
||||
|
|
47
vendor/go.opentelemetry.io/otel/README.md
generated
vendored
47
vendor/go.opentelemetry.io/otel/README.md
generated
vendored
|
@ -11,22 +11,25 @@ It provides a set of APIs to directly measure performance and behavior of your s
|
|||
|
||||
## Project Status
|
||||
|
||||
| Signal | Status | Project |
|
||||
| ------- | ---------- | ------- |
|
||||
| Traces | Stable | N/A |
|
||||
| Metrics | Alpha | N/A |
|
||||
| Logs | Frozen [1] | N/A |
|
||||
| Signal | Status | Project |
|
||||
|---------|------------|-----------------------|
|
||||
| Traces | Stable | N/A |
|
||||
| Metrics | Mixed [1] | [Go: Metric SDK (GA)] |
|
||||
| Logs | Frozen [2] | N/A |
|
||||
|
||||
- [1]: The Logs signal development is halted for this project while we develop both Traces and Metrics.
|
||||
[Go: Metric SDK (GA)]: https://github.com/orgs/open-telemetry/projects/34
|
||||
|
||||
- [1]: [Metrics API](https://pkg.go.dev/go.opentelemetry.io/otel/metric) is Stable. [Metrics SDK](https://pkg.go.dev/go.opentelemetry.io/otel/sdk/metric) is Beta.
|
||||
- [2]: The Logs signal development is halted for this project while we stabilize the Metrics SDK.
|
||||
No Logs Pull Requests are currently being accepted.
|
||||
|
||||
Progress and status specific to this repository is tracked in our local
|
||||
Progress and status specific to this repository is tracked in our
|
||||
[project boards](https://github.com/open-telemetry/opentelemetry-go/projects)
|
||||
and
|
||||
[milestones](https://github.com/open-telemetry/opentelemetry-go/milestones).
|
||||
|
||||
Project versioning information and stability guarantees can be found in the
|
||||
[versioning documentation](./VERSIONING.md).
|
||||
[versioning documentation](VERSIONING.md).
|
||||
|
||||
### Compatibility
|
||||
|
||||
|
@ -49,22 +52,17 @@ stop ensuring compatibility with these versions in the following manner:
|
|||
Currently, this project supports the following environments.
|
||||
|
||||
| OS | Go Version | Architecture |
|
||||
| ------- | ---------- | ------------ |
|
||||
|---------|------------|--------------|
|
||||
| Ubuntu | 1.21 | amd64 |
|
||||
| Ubuntu | 1.20 | amd64 |
|
||||
| Ubuntu | 1.19 | amd64 |
|
||||
| Ubuntu | 1.18 | amd64 |
|
||||
| Ubuntu | 1.21 | 386 |
|
||||
| Ubuntu | 1.20 | 386 |
|
||||
| Ubuntu | 1.19 | 386 |
|
||||
| Ubuntu | 1.18 | 386 |
|
||||
| MacOS | 1.21 | amd64 |
|
||||
| MacOS | 1.20 | amd64 |
|
||||
| MacOS | 1.19 | amd64 |
|
||||
| MacOS | 1.18 | amd64 |
|
||||
| Windows | 1.21 | amd64 |
|
||||
| Windows | 1.20 | amd64 |
|
||||
| Windows | 1.19 | amd64 |
|
||||
| Windows | 1.18 | amd64 |
|
||||
| Windows | 1.21 | 386 |
|
||||
| Windows | 1.20 | 386 |
|
||||
| Windows | 1.19 | 386 |
|
||||
| Windows | 1.18 | 386 |
|
||||
|
||||
While this project should work for other systems, no compatibility guarantees
|
||||
are made for those systems currently.
|
||||
|
@ -102,12 +100,11 @@ export pipeline to send that telemetry to an observability platform.
|
|||
All officially supported exporters for the OpenTelemetry project are contained in the [exporters directory](./exporters).
|
||||
|
||||
| Exporter | Metrics | Traces |
|
||||
| :-----------------------------------: | :-----: | :----: |
|
||||
| [Jaeger](./exporters/jaeger/) | | ✓ |
|
||||
| [OTLP](./exporters/otlp/) | ✓ | ✓ |
|
||||
| [Prometheus](./exporters/prometheus/) | ✓ | |
|
||||
| [stdout](./exporters/stdout/) | ✓ | ✓ |
|
||||
| [Zipkin](./exporters/zipkin/) | | ✓ |
|
||||
|---------------------------------------|:-------:|:------:|
|
||||
| [OTLP](./exporters/otlp/) | ✓ | ✓ |
|
||||
| [Prometheus](./exporters/prometheus/) | ✓ | |
|
||||
| [stdout](./exporters/stdout/) | ✓ | ✓ |
|
||||
| [Zipkin](./exporters/zipkin/) | | ✓ |
|
||||
|
||||
## Contributing
|
||||
|
||||
|
|
32
vendor/go.opentelemetry.io/otel/RELEASING.md
generated
vendored
32
vendor/go.opentelemetry.io/otel/RELEASING.md
generated
vendored
|
@ -2,28 +2,30 @@
|
|||
|
||||
## Semantic Convention Generation
|
||||
|
||||
New versions of the [OpenTelemetry specification] mean new versions of the `semconv` package need to be generated.
|
||||
New versions of the [OpenTelemetry Semantic Conventions] mean new versions of the `semconv` package need to be generated.
|
||||
The `semconv-generate` make target is used for this.
|
||||
|
||||
1. Checkout a local copy of the [OpenTelemetry specification] to the desired release tag.
|
||||
1. Checkout a local copy of the [OpenTelemetry Semantic Conventions] to the desired release tag.
|
||||
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.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" -b "$TAG"
|
||||
export TAG="v1.21.0" # Change to the release version you are generating.
|
||||
export OTEL_SEMCONV_REPO="/absolute/path/to/opentelemetry/semantic-conventions"
|
||||
docker pull otel/semconvgen:latest
|
||||
make semconv-generate # Uses the exported TAG and OTEL_SPEC_REPO.
|
||||
make semconv-generate # Uses the exported TAG and OTEL_SEMCONV_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)).
|
||||
## Breaking changes validation
|
||||
|
||||
You can run `make gorelease` that runs [gorelease](https://pkg.go.dev/golang.org/x/exp/cmd/gorelease) to ensure that there are no unwanted changes done in the public API.
|
||||
|
||||
You can check/report problems with `gorelease` [here](https://golang.org/issues/26420).
|
||||
|
||||
## Pre-Release
|
||||
|
||||
|
@ -121,7 +123,17 @@ Once verified be sure to [make a release for the `contrib` repository](https://g
|
|||
|
||||
### Website Documentation
|
||||
|
||||
Update [the documentation](./website_docs) for [the OpenTelemetry website](https://opentelemetry.io/docs/go/).
|
||||
Update the [Go instrumentation documentation] in the OpenTelemetry website under [content/en/docs/instrumentation/go].
|
||||
Importantly, bump any package versions referenced to be the latest one you just released and ensure all code examples still compile and are accurate.
|
||||
|
||||
[OpenTelemetry specification]: https://github.com/open-telemetry/opentelemetry-specification
|
||||
[OpenTelemetry Semantic Conventions]: https://github.com/open-telemetry/semantic-conventions
|
||||
[Go instrumentation documentation]: https://opentelemetry.io/docs/instrumentation/go/
|
||||
[content/en/docs/instrumentation/go]: https://github.com/open-telemetry/opentelemetry.io/tree/main/content/en/docs/instrumentation/go
|
||||
|
||||
### Demo Repository
|
||||
|
||||
Bump the dependencies in the following Go services:
|
||||
|
||||
- [`accountingservice`](https://github.com/open-telemetry/opentelemetry-demo/tree/main/src/accountingservice)
|
||||
- [`checkoutservice`](https://github.com/open-telemetry/opentelemetry-demo/tree/main/src/checkoutservice)
|
||||
- [`productcatalogservice`](https://github.com/open-telemetry/opentelemetry-demo/tree/main/src/productcatalogservice)
|
||||
|
|
60
vendor/go.opentelemetry.io/otel/attribute/filter.go
generated
vendored
Normal file
60
vendor/go.opentelemetry.io/otel/attribute/filter.go
generated
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
// 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 attribute // import "go.opentelemetry.io/otel/attribute"
|
||||
|
||||
// Filter supports removing certain attributes from attribute sets. When
|
||||
// the filter returns true, the attribute will be kept in the filtered
|
||||
// attribute set. When the filter returns false, the attribute is excluded
|
||||
// from the filtered attribute set, and the attribute instead appears in
|
||||
// the removed list of excluded attributes.
|
||||
type Filter func(KeyValue) bool
|
||||
|
||||
// NewAllowKeysFilter returns a Filter that only allows attributes with one of
|
||||
// the provided keys.
|
||||
//
|
||||
// If keys is empty a deny-all filter is returned.
|
||||
func NewAllowKeysFilter(keys ...Key) Filter {
|
||||
if len(keys) <= 0 {
|
||||
return func(kv KeyValue) bool { return false }
|
||||
}
|
||||
|
||||
allowed := make(map[Key]struct{})
|
||||
for _, k := range keys {
|
||||
allowed[k] = struct{}{}
|
||||
}
|
||||
return func(kv KeyValue) bool {
|
||||
_, ok := allowed[kv.Key]
|
||||
return ok
|
||||
}
|
||||
}
|
||||
|
||||
// NewDenyKeysFilter returns a Filter that only allows attributes
|
||||
// that do not have one of the provided keys.
|
||||
//
|
||||
// If keys is empty an allow-all filter is returned.
|
||||
func NewDenyKeysFilter(keys ...Key) Filter {
|
||||
if len(keys) <= 0 {
|
||||
return func(kv KeyValue) bool { return true }
|
||||
}
|
||||
|
||||
forbid := make(map[Key]struct{})
|
||||
for _, k := range keys {
|
||||
forbid[k] = struct{}{}
|
||||
}
|
||||
return func(kv KeyValue) bool {
|
||||
_, ok := forbid[kv.Key]
|
||||
return !ok
|
||||
}
|
||||
}
|
27
vendor/go.opentelemetry.io/otel/attribute/set.go
generated
vendored
27
vendor/go.opentelemetry.io/otel/attribute/set.go
generated
vendored
|
@ -18,6 +18,7 @@ import (
|
|||
"encoding/json"
|
||||
"reflect"
|
||||
"sort"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type (
|
||||
|
@ -38,13 +39,6 @@ type (
|
|||
iface interface{}
|
||||
}
|
||||
|
||||
// Filter supports removing certain attributes from attribute sets. When
|
||||
// the filter returns true, the attribute will be kept in the filtered
|
||||
// attribute set. When the filter returns false, the attribute is excluded
|
||||
// from the filtered attribute set, and the attribute instead appears in
|
||||
// the removed list of excluded attributes.
|
||||
Filter func(KeyValue) bool
|
||||
|
||||
// Sortable implements sort.Interface, used for sorting KeyValue. This is
|
||||
// an exported type to support a memory optimization. A pointer to one of
|
||||
// these is needed for the call to sort.Stable(), which the caller may
|
||||
|
@ -62,6 +56,12 @@ var (
|
|||
iface: [0]KeyValue{},
|
||||
},
|
||||
}
|
||||
|
||||
// sortables is a pool of Sortables used to create Sets with a user does
|
||||
// not provide one.
|
||||
sortables = sync.Pool{
|
||||
New: func() interface{} { return new(Sortable) },
|
||||
}
|
||||
)
|
||||
|
||||
// EmptySet returns a reference to a Set with no elements.
|
||||
|
@ -91,7 +91,7 @@ func (l *Set) Len() int {
|
|||
|
||||
// Get returns the KeyValue at ordered position idx in this set.
|
||||
func (l *Set) Get(idx int) (KeyValue, bool) {
|
||||
if l == nil {
|
||||
if l == nil || !l.equivalent.Valid() {
|
||||
return KeyValue{}, false
|
||||
}
|
||||
value := l.equivalent.reflectValue()
|
||||
|
@ -107,7 +107,7 @@ func (l *Set) Get(idx int) (KeyValue, bool) {
|
|||
|
||||
// Value returns the value of a specified key in this set.
|
||||
func (l *Set) Value(k Key) (Value, bool) {
|
||||
if l == nil {
|
||||
if l == nil || !l.equivalent.Valid() {
|
||||
return Value{}, false
|
||||
}
|
||||
rValue := l.equivalent.reflectValue()
|
||||
|
@ -191,7 +191,9 @@ func NewSet(kvs ...KeyValue) Set {
|
|||
if len(kvs) == 0 {
|
||||
return empty()
|
||||
}
|
||||
s, _ := NewSetWithSortableFiltered(kvs, new(Sortable), nil)
|
||||
srt := sortables.Get().(*Sortable)
|
||||
s, _ := NewSetWithSortableFiltered(kvs, srt, nil)
|
||||
sortables.Put(srt)
|
||||
return s
|
||||
}
|
||||
|
||||
|
@ -218,7 +220,10 @@ func NewSetWithFiltered(kvs []KeyValue, filter Filter) (Set, []KeyValue) {
|
|||
if len(kvs) == 0 {
|
||||
return empty(), nil
|
||||
}
|
||||
return NewSetWithSortableFiltered(kvs, new(Sortable), filter)
|
||||
srt := sortables.Get().(*Sortable)
|
||||
s, filtered := NewSetWithSortableFiltered(kvs, srt, filter)
|
||||
sortables.Put(srt)
|
||||
return s, filtered
|
||||
}
|
||||
|
||||
// NewSetWithSortableFiltered returns a new Set.
|
||||
|
|
68
vendor/go.opentelemetry.io/otel/baggage/baggage.go
generated
vendored
68
vendor/go.opentelemetry.io/otel/baggage/baggage.go
generated
vendored
|
@ -61,11 +61,6 @@ type Property struct {
|
|||
// hasValue indicates if a zero-value value means the property does not
|
||||
// have a value or if it was the zero-value.
|
||||
hasValue bool
|
||||
|
||||
// hasData indicates whether the created property contains data or not.
|
||||
// Properties that do not contain data are invalid with no other check
|
||||
// required.
|
||||
hasData bool
|
||||
}
|
||||
|
||||
// NewKeyProperty returns a new Property for key.
|
||||
|
@ -76,7 +71,7 @@ func NewKeyProperty(key string) (Property, error) {
|
|||
return newInvalidProperty(), fmt.Errorf("%w: %q", errInvalidKey, key)
|
||||
}
|
||||
|
||||
p := Property{key: key, hasData: true}
|
||||
p := Property{key: key}
|
||||
return p, nil
|
||||
}
|
||||
|
||||
|
@ -95,7 +90,6 @@ func NewKeyValueProperty(key, value string) (Property, error) {
|
|||
key: key,
|
||||
value: value,
|
||||
hasValue: true,
|
||||
hasData: true,
|
||||
}
|
||||
return p, nil
|
||||
}
|
||||
|
@ -117,7 +111,7 @@ func parseProperty(property string) (Property, error) {
|
|||
return newInvalidProperty(), fmt.Errorf("%w: %q", errInvalidProperty, property)
|
||||
}
|
||||
|
||||
p := Property{hasData: true}
|
||||
var p Property
|
||||
if match[1] != "" {
|
||||
p.key = match[1]
|
||||
} else {
|
||||
|
@ -136,10 +130,6 @@ func (p Property) validate() error {
|
|||
return fmt.Errorf("invalid property: %w", err)
|
||||
}
|
||||
|
||||
if !p.hasData {
|
||||
return errFunc(fmt.Errorf("%w: %q", errInvalidProperty, p))
|
||||
}
|
||||
|
||||
if !keyRe.MatchString(p.key) {
|
||||
return errFunc(fmt.Errorf("%w: %q", errInvalidKey, p.key))
|
||||
}
|
||||
|
@ -289,45 +279,37 @@ func parseMember(member string) (Member, error) {
|
|||
props properties
|
||||
)
|
||||
|
||||
parts := strings.SplitN(member, propertyDelimiter, 2)
|
||||
switch len(parts) {
|
||||
case 2:
|
||||
keyValue, properties, found := strings.Cut(member, propertyDelimiter)
|
||||
if found {
|
||||
// Parse the member properties.
|
||||
for _, pStr := range strings.Split(parts[1], propertyDelimiter) {
|
||||
for _, pStr := range strings.Split(properties, propertyDelimiter) {
|
||||
p, err := parseProperty(pStr)
|
||||
if err != nil {
|
||||
return newInvalidMember(), err
|
||||
}
|
||||
props = append(props, p)
|
||||
}
|
||||
fallthrough
|
||||
case 1:
|
||||
// Parse the member key/value pair.
|
||||
}
|
||||
// Parse the member key/value pair.
|
||||
|
||||
// Take into account a value can contain equal signs (=).
|
||||
kv := strings.SplitN(parts[0], keyValueDelimiter, 2)
|
||||
if len(kv) != 2 {
|
||||
return newInvalidMember(), fmt.Errorf("%w: %q", errInvalidMember, member)
|
||||
}
|
||||
// "Leading and trailing whitespaces are allowed but MUST be trimmed
|
||||
// when converting the header into a data structure."
|
||||
key = strings.TrimSpace(kv[0])
|
||||
var err error
|
||||
value, err = url.QueryUnescape(strings.TrimSpace(kv[1]))
|
||||
if err != nil {
|
||||
return newInvalidMember(), fmt.Errorf("%w: %q", err, value)
|
||||
}
|
||||
if !keyRe.MatchString(key) {
|
||||
return newInvalidMember(), fmt.Errorf("%w: %q", errInvalidKey, key)
|
||||
}
|
||||
if !valueRe.MatchString(value) {
|
||||
return newInvalidMember(), fmt.Errorf("%w: %q", errInvalidValue, value)
|
||||
}
|
||||
default:
|
||||
// This should never happen unless a developer has changed the string
|
||||
// splitting somehow. Panic instead of failing silently and allowing
|
||||
// the bug to slip past the CI checks.
|
||||
panic("failed to parse baggage member")
|
||||
// Take into account a value can contain equal signs (=).
|
||||
k, v, found := strings.Cut(keyValue, keyValueDelimiter)
|
||||
if !found {
|
||||
return newInvalidMember(), fmt.Errorf("%w: %q", errInvalidMember, member)
|
||||
}
|
||||
// "Leading and trailing whitespaces are allowed but MUST be trimmed
|
||||
// when converting the header into a data structure."
|
||||
key = strings.TrimSpace(k)
|
||||
var err error
|
||||
value, err = url.QueryUnescape(strings.TrimSpace(v))
|
||||
if err != nil {
|
||||
return newInvalidMember(), fmt.Errorf("%w: %q", err, value)
|
||||
}
|
||||
if !keyRe.MatchString(key) {
|
||||
return newInvalidMember(), fmt.Errorf("%w: %q", errInvalidKey, key)
|
||||
}
|
||||
if !valueRe.MatchString(value) {
|
||||
return newInvalidMember(), fmt.Errorf("%w: %q", errInvalidValue, value)
|
||||
}
|
||||
|
||||
return Member{key: key, value: value, properties: props, hasData: true}, nil
|
||||
|
|
2
vendor/go.opentelemetry.io/otel/codes/doc.go
generated
vendored
2
vendor/go.opentelemetry.io/otel/codes/doc.go
generated
vendored
|
@ -16,6 +16,6 @@
|
|||
Package codes defines the canonical error codes used by OpenTelemetry.
|
||||
|
||||
It conforms to [the OpenTelemetry
|
||||
specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#statuscanonicalcode).
|
||||
specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.20.0/specification/trace/api.md#set-status).
|
||||
*/
|
||||
package codes // import "go.opentelemetry.io/otel/codes"
|
||||
|
|
201
vendor/go.opentelemetry.io/otel/exporters/otlp/internal/retry/LICENSE
generated
vendored
201
vendor/go.opentelemetry.io/otel/exporters/otlp/internal/retry/LICENSE
generated
vendored
|
@ -1,201 +0,0 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
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.
|
61
vendor/go.opentelemetry.io/otel/exporters/otlp/internal/wrappederror.go
generated
vendored
61
vendor/go.opentelemetry.io/otel/exporters/otlp/internal/wrappederror.go
generated
vendored
|
@ -1,61 +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/exporters/otlp/internal"
|
||||
|
||||
// ErrorKind is used to identify the kind of export error
|
||||
// being wrapped.
|
||||
type ErrorKind int
|
||||
|
||||
const (
|
||||
// TracesExport indicates the error comes from the OTLP trace exporter.
|
||||
TracesExport ErrorKind = iota
|
||||
)
|
||||
|
||||
// prefix returns a prefix for the Error() string.
|
||||
func (k ErrorKind) prefix() string {
|
||||
switch k {
|
||||
case TracesExport:
|
||||
return "traces export: "
|
||||
default:
|
||||
return "unknown: "
|
||||
}
|
||||
}
|
||||
|
||||
// wrappedExportError wraps an OTLP exporter error with the kind of
|
||||
// signal that produced it.
|
||||
type wrappedExportError struct {
|
||||
wrap error
|
||||
kind ErrorKind
|
||||
}
|
||||
|
||||
// WrapTracesError wraps an error from the OTLP exporter for traces.
|
||||
func WrapTracesError(err error) error {
|
||||
return wrappedExportError{
|
||||
wrap: err,
|
||||
kind: TracesExport,
|
||||
}
|
||||
}
|
||||
|
||||
var _ error = wrappedExportError{}
|
||||
|
||||
// Error attaches a prefix corresponding to the kind of exporter.
|
||||
func (t wrappedExportError) Error() string {
|
||||
return t.kind.prefix() + t.wrap.Error()
|
||||
}
|
||||
|
||||
// Unwrap returns the wrapped error.
|
||||
func (t wrappedExportError) Unwrap() error {
|
||||
return t.wrap
|
||||
}
|
4
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/README.md
generated
vendored
4
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/README.md
generated
vendored
|
@ -2,7 +2,7 @@
|
|||
|
||||
[](https://pkg.go.dev/go.opentelemetry.io/otel/exporters/otlp/otlptrace)
|
||||
|
||||
[OpenTelemetry Protocol Exporter](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.5.0/specification/protocol/exporter.md) implementation.
|
||||
[OpenTelemetry Protocol Exporter](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.20.0/specification/protocol/exporter.md) implementation.
|
||||
|
||||
## Installation
|
||||
|
||||
|
@ -36,7 +36,7 @@ The `otlptracehttp` package implements a client for the span exporter that sends
|
|||
The following environment variables can be used (instead of options objects) to
|
||||
override the default configuration. For more information about how each of
|
||||
these environment variables is interpreted, see [the OpenTelemetry
|
||||
specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.8.0/specification/protocol/exporter.md).
|
||||
specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.20.0/specification/protocol/exporter.md).
|
||||
|
||||
| Environment variable | Option | Default value |
|
||||
| ------------------------------------------------------------------------ |------------------------------ | -------------------------------------------------------- |
|
||||
|
|
4
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/exporter.go
generated
vendored
4
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/exporter.go
generated
vendored
|
@ -17,9 +17,9 @@ package otlptrace // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace"
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/internal"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform"
|
||||
tracesdk "go.opentelemetry.io/otel/sdk/trace"
|
||||
)
|
||||
|
@ -48,7 +48,7 @@ func (e *Exporter) ExportSpans(ctx context.Context, ss []tracesdk.ReadOnlySpan)
|
|||
|
||||
err := e.client.UploadTraces(ctx, protoSpans)
|
||||
if err != nil {
|
||||
return internal.WrapTracesError(err)
|
||||
return fmt.Errorf("traces export: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
12
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/client.go
generated
vendored
12
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/client.go
generated
vendored
|
@ -27,10 +27,10 @@ import (
|
|||
"google.golang.org/grpc/status"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/internal"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/internal/retry"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlpconfig"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/retry"
|
||||
coltracepb "go.opentelemetry.io/proto/otlp/collector/trace/v1"
|
||||
tracepb "go.opentelemetry.io/proto/otlp/trace/v1"
|
||||
)
|
||||
|
@ -130,13 +130,16 @@ var errAlreadyStopped = errors.New("the client is already stopped")
|
|||
// If the client has already stopped, an error will be returned describing
|
||||
// this.
|
||||
func (c *client) Stop(ctx context.Context) error {
|
||||
// Make sure to return context error if the context is done when calling this method.
|
||||
err := ctx.Err()
|
||||
|
||||
// Acquire the c.tscMu lock within the ctx lifetime.
|
||||
acquired := make(chan struct{})
|
||||
go func() {
|
||||
c.tscMu.Lock()
|
||||
close(acquired)
|
||||
}()
|
||||
var err error
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
// The Stop timeout is reached. Kill any remaining exports to force
|
||||
|
@ -256,7 +259,6 @@ func (c *client) exportContext(parent context.Context) (context.Context, context
|
|||
// retryable returns if err identifies a request that can be retried and a
|
||||
// duration to wait for if an explicit throttle time is included in err.
|
||||
func retryable(err error) (bool, time.Duration) {
|
||||
//func retryable(err error) (bool, time.Duration) {
|
||||
s := status.Convert(err)
|
||||
switch s.Code() {
|
||||
case codes.Canceled,
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// Code created by gotmpl. DO NOT MODIFY.
|
||||
// source: internal/shared/otlp/envconfig/envconfig.go.tmpl
|
||||
|
||||
// Copyright The OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -12,7 +15,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package envconfig // import "go.opentelemetry.io/otel/exporters/otlp/internal/envconfig"
|
||||
package envconfig // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/envconfig"
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
|
@ -166,20 +169,20 @@ func stringToHeader(value string) map[string]string {
|
|||
headers := make(map[string]string)
|
||||
|
||||
for _, header := range headersPairs {
|
||||
nameValue := strings.SplitN(header, "=", 2)
|
||||
if len(nameValue) < 2 {
|
||||
global.Error(errors.New("missing '="), "parse headers", "input", nameValue)
|
||||
n, v, found := strings.Cut(header, "=")
|
||||
if !found {
|
||||
global.Error(errors.New("missing '="), "parse headers", "input", header)
|
||||
continue
|
||||
}
|
||||
name, err := url.QueryUnescape(nameValue[0])
|
||||
name, err := url.QueryUnescape(n)
|
||||
if err != nil {
|
||||
global.Error(err, "escape header key", "key", nameValue[0])
|
||||
global.Error(err, "escape header key", "key", n)
|
||||
continue
|
||||
}
|
||||
trimmedName := strings.TrimSpace(name)
|
||||
value, err := url.QueryUnescape(nameValue[1])
|
||||
value, err := url.QueryUnescape(v)
|
||||
if err != nil {
|
||||
global.Error(err, "escape header value", "value", nameValue[1])
|
||||
global.Error(err, "escape header value", "value", v)
|
||||
continue
|
||||
}
|
||||
trimmedValue := strings.TrimSpace(value)
|
35
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/gen.go
generated
vendored
Normal file
35
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/gen.go
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
// 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/exporters/otlp/otlptrace/otlptracegrpc/internal"
|
||||
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/partialsuccess.go.tmpl "--data={}" --out=partialsuccess.go
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/partialsuccess_test.go.tmpl "--data={}" --out=partialsuccess_test.go
|
||||
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/retry/retry.go.tmpl "--data={}" --out=retry/retry.go
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/retry/retry_test.go.tmpl "--data={}" --out=retry/retry_test.go
|
||||
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/envconfig/envconfig.go.tmpl "--data={}" --out=envconfig/envconfig.go
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/envconfig/envconfig_test.go.tmpl "--data={}" --out=envconfig/envconfig_test.go
|
||||
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/otlptrace/otlpconfig/envconfig.go.tmpl "--data={\"envconfigImportPath\": \"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/envconfig\"}" --out=otlpconfig/envconfig.go
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/otlptrace/otlpconfig/options.go.tmpl "--data={\"retryImportPath\": \"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/retry\"}" --out=otlpconfig/options.go
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/otlptrace/otlpconfig/options_test.go.tmpl "--data={\"envconfigImportPath\": \"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/envconfig\"}" --out=otlpconfig/options_test.go
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/otlptrace/otlpconfig/optiontypes.go.tmpl "--data={}" --out=otlpconfig/optiontypes.go
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/otlptrace/otlpconfig/tls.go.tmpl "--data={}" --out=otlpconfig/tls.go
|
||||
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/otlptrace/otlptracetest/client.go.tmpl "--data={}" --out=otlptracetest/client.go
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/otlptrace/otlptracetest/collector.go.tmpl "--data={}" --out=otlptracetest/collector.go
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/otlptrace/otlptracetest/data.go.tmpl "--data={}" --out=otlptracetest/data.go
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/otlptrace/otlptracetest/otlptest.go.tmpl "--data={}" --out=otlptracetest/otlptest.go
|
|
@ -1,3 +1,6 @@
|
|||
// Code created by gotmpl. DO NOT MODIFY.
|
||||
// source: internal/shared/otlp/otlptrace/otlpconfig/envconfig.go.tmpl
|
||||
|
||||
// Copyright The OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -12,7 +15,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package otlpconfig // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlpconfig"
|
||||
package otlpconfig // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig"
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
|
@ -23,7 +26,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/internal/envconfig"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/envconfig"
|
||||
)
|
||||
|
||||
// DefaultEnvOptionsReader is the default environments reader.
|
|
@ -1,3 +1,6 @@
|
|||
// Code created by gotmpl. DO NOT MODIFY.
|
||||
// source: internal/shared/otlp/otlptrace/otlpconfig/options.go.tmpl
|
||||
|
||||
// Copyright The OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -12,11 +15,13 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package otlpconfig // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlpconfig"
|
||||
package otlpconfig // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig"
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
@ -25,8 +30,8 @@ import (
|
|||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/encoding/gzip"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/internal"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/internal/retry"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/retry"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -82,13 +87,28 @@ func NewHTTPConfig(opts ...HTTPOption) Config {
|
|||
for _, opt := range opts {
|
||||
cfg = opt.ApplyHTTPOption(cfg)
|
||||
}
|
||||
cfg.Traces.URLPath = internal.CleanPath(cfg.Traces.URLPath, DefaultTracesPath)
|
||||
cfg.Traces.URLPath = cleanPath(cfg.Traces.URLPath, DefaultTracesPath)
|
||||
return cfg
|
||||
}
|
||||
|
||||
// cleanPath returns a path with all spaces trimmed and all redundancies
|
||||
// removed. If urlPath is empty or cleaning it results in an empty string,
|
||||
// defaultPath is returned instead.
|
||||
func cleanPath(urlPath string, defaultPath string) string {
|
||||
tmp := path.Clean(strings.TrimSpace(urlPath))
|
||||
if tmp == "." {
|
||||
return defaultPath
|
||||
}
|
||||
if !path.IsAbs(tmp) {
|
||||
tmp = fmt.Sprintf("/%s", tmp)
|
||||
}
|
||||
return tmp
|
||||
}
|
||||
|
||||
// NewGRPCConfig returns a new Config with all settings applied from opts and
|
||||
// any unset setting using the default gRPC config values.
|
||||
func NewGRPCConfig(opts ...GRPCOption) Config {
|
||||
userAgent := "OTel OTLP Exporter Go/" + otlptrace.Version()
|
||||
cfg := Config{
|
||||
Traces: SignalConfig{
|
||||
Endpoint: fmt.Sprintf("%s:%d", DefaultCollectorHost, DefaultCollectorGRPCPort),
|
||||
|
@ -97,7 +117,7 @@ func NewGRPCConfig(opts ...GRPCOption) Config {
|
|||
Timeout: DefaultTimeout,
|
||||
},
|
||||
RetryConfig: retry.DefaultConfig,
|
||||
DialOptions: []grpc.DialOption{grpc.WithUserAgent(internal.GetUserAgentHeader())},
|
||||
DialOptions: []grpc.DialOption{grpc.WithUserAgent(userAgent)},
|
||||
}
|
||||
cfg = ApplyGRPCEnvConfigs(cfg)
|
||||
for _, opt := range opts {
|
|
@ -1,3 +1,6 @@
|
|||
// Code created by gotmpl. DO NOT MODIFY.
|
||||
// source: internal/shared/otlp/otlptrace/otlpconfig/optiontypes.go.tmpl
|
||||
|
||||
// Copyright The OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -12,7 +15,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package otlpconfig // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlpconfig"
|
||||
package otlpconfig // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig"
|
||||
|
||||
const (
|
||||
// DefaultCollectorGRPCPort is the default gRPC port of the collector.
|
|
@ -1,3 +1,6 @@
|
|||
// Code created by gotmpl. DO NOT MODIFY.
|
||||
// source: internal/shared/otlp/otlptrace/otlpconfig/tls.go.tmpl
|
||||
|
||||
// Copyright The OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -12,7 +15,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package otlpconfig // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlpconfig"
|
||||
package otlpconfig // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig"
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
|
@ -1,3 +1,6 @@
|
|||
// Code created by gotmpl. DO NOT MODIFY.
|
||||
// source: internal/shared/otlp/partialsuccess.go
|
||||
|
||||
// Copyright The OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -12,7 +15,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package internal // import "go.opentelemetry.io/otel/exporters/otlp/internal"
|
||||
package internal // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal"
|
||||
|
||||
import "fmt"
|
||||
|
|
@ -1,3 +1,6 @@
|
|||
// Code created by gotmpl. DO NOT MODIFY.
|
||||
// source: internal/shared/otlp/retry/retry.go.tmpl
|
||||
|
||||
// Copyright The OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -15,7 +18,7 @@
|
|||
// Package retry provides request retry functionality that can perform
|
||||
// configurable exponential backoff for transient errors and honor any
|
||||
// explicit throttle responses received.
|
||||
package retry // import "go.opentelemetry.io/otel/exporters/otlp/internal/retry"
|
||||
package retry // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/retry"
|
||||
|
||||
import (
|
||||
"context"
|
4
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/options.go
generated
vendored
4
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/options.go
generated
vendored
|
@ -22,8 +22,8 @@ import (
|
|||
"google.golang.org/grpc/credentials"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/internal/retry"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlpconfig"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/retry"
|
||||
)
|
||||
|
||||
// Option applies an option to the gRPC driver.
|
||||
|
|
15
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/client.go
generated
vendored
15
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/client.go
generated
vendored
|
@ -30,10 +30,10 @@ import (
|
|||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/internal"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/internal/retry"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlpconfig"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/otlpconfig"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/retry"
|
||||
coltracepb "go.opentelemetry.io/proto/otlp/collector/trace/v1"
|
||||
tracepb "go.opentelemetry.io/proto/otlp/trace/v1"
|
||||
)
|
||||
|
@ -164,8 +164,8 @@ func (d *client) UploadTraces(ctx context.Context, protoSpans []*tracepb.Resourc
|
|||
}()
|
||||
}
|
||||
|
||||
switch resp.StatusCode {
|
||||
case http.StatusOK:
|
||||
switch sc := resp.StatusCode; {
|
||||
case sc >= 200 && sc <= 299:
|
||||
// Success, do not retry.
|
||||
// Read the partial success message, if any.
|
||||
var respData bytes.Buffer
|
||||
|
@ -190,7 +190,7 @@ func (d *client) UploadTraces(ctx context.Context, protoSpans []*tracepb.Resourc
|
|||
}
|
||||
return nil
|
||||
|
||||
case http.StatusTooManyRequests, http.StatusServiceUnavailable:
|
||||
case sc == http.StatusTooManyRequests, sc == http.StatusServiceUnavailable:
|
||||
// Retry-able failures. Drain the body to reuse the connection.
|
||||
if _, err := io.Copy(io.Discard, resp.Body); err != nil {
|
||||
otel.Handle(err)
|
||||
|
@ -209,7 +209,8 @@ func (d *client) newRequest(body []byte) (request, error) {
|
|||
return request{Request: r}, err
|
||||
}
|
||||
|
||||
r.Header.Set("User-Agent", internal.GetUserAgentHeader())
|
||||
userAgent := "OTel OTLP Exporter Go/" + otlptrace.Version()
|
||||
r.Header.Set("User-Agent", userAgent)
|
||||
|
||||
for k, v := range d.cfg.Headers {
|
||||
r.Header.Set(k, v)
|
||||
|
|
202
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/envconfig/envconfig.go
generated
vendored
Normal file
202
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/envconfig/envconfig.go
generated
vendored
Normal file
|
@ -0,0 +1,202 @@
|
|||
// Code created by gotmpl. DO NOT MODIFY.
|
||||
// source: internal/shared/otlp/envconfig/envconfig.go.tmpl
|
||||
|
||||
// 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 envconfig // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/envconfig"
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/internal/global"
|
||||
)
|
||||
|
||||
// ConfigFn is the generic function used to set a config.
|
||||
type ConfigFn func(*EnvOptionsReader)
|
||||
|
||||
// EnvOptionsReader reads the required environment variables.
|
||||
type EnvOptionsReader struct {
|
||||
GetEnv func(string) string
|
||||
ReadFile func(string) ([]byte, error)
|
||||
Namespace string
|
||||
}
|
||||
|
||||
// Apply runs every ConfigFn.
|
||||
func (e *EnvOptionsReader) Apply(opts ...ConfigFn) {
|
||||
for _, o := range opts {
|
||||
o(e)
|
||||
}
|
||||
}
|
||||
|
||||
// GetEnvValue gets an OTLP environment variable value of the specified key
|
||||
// using the GetEnv function.
|
||||
// This function prepends the OTLP specified namespace to all key lookups.
|
||||
func (e *EnvOptionsReader) GetEnvValue(key string) (string, bool) {
|
||||
v := strings.TrimSpace(e.GetEnv(keyWithNamespace(e.Namespace, key)))
|
||||
return v, v != ""
|
||||
}
|
||||
|
||||
// WithString retrieves the specified config and passes it to ConfigFn as a string.
|
||||
func WithString(n string, fn func(string)) func(e *EnvOptionsReader) {
|
||||
return func(e *EnvOptionsReader) {
|
||||
if v, ok := e.GetEnvValue(n); ok {
|
||||
fn(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WithBool returns a ConfigFn that reads the environment variable n and if it exists passes its parsed bool value to fn.
|
||||
func WithBool(n string, fn func(bool)) ConfigFn {
|
||||
return func(e *EnvOptionsReader) {
|
||||
if v, ok := e.GetEnvValue(n); ok {
|
||||
b := strings.ToLower(v) == "true"
|
||||
fn(b)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WithDuration retrieves the specified config and passes it to ConfigFn as a duration.
|
||||
func WithDuration(n string, fn func(time.Duration)) func(e *EnvOptionsReader) {
|
||||
return func(e *EnvOptionsReader) {
|
||||
if v, ok := e.GetEnvValue(n); ok {
|
||||
d, err := strconv.Atoi(v)
|
||||
if err != nil {
|
||||
global.Error(err, "parse duration", "input", v)
|
||||
return
|
||||
}
|
||||
fn(time.Duration(d) * time.Millisecond)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WithHeaders retrieves the specified config and passes it to ConfigFn as a map of HTTP headers.
|
||||
func WithHeaders(n string, fn func(map[string]string)) func(e *EnvOptionsReader) {
|
||||
return func(e *EnvOptionsReader) {
|
||||
if v, ok := e.GetEnvValue(n); ok {
|
||||
fn(stringToHeader(v))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WithURL retrieves the specified config and passes it to ConfigFn as a net/url.URL.
|
||||
func WithURL(n string, fn func(*url.URL)) func(e *EnvOptionsReader) {
|
||||
return func(e *EnvOptionsReader) {
|
||||
if v, ok := e.GetEnvValue(n); ok {
|
||||
u, err := url.Parse(v)
|
||||
if err != nil {
|
||||
global.Error(err, "parse url", "input", v)
|
||||
return
|
||||
}
|
||||
fn(u)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WithCertPool returns a ConfigFn that reads the environment variable n as a filepath to a TLS certificate pool. If it exists, it is parsed as a crypto/x509.CertPool and it is passed to fn.
|
||||
func WithCertPool(n string, fn func(*x509.CertPool)) ConfigFn {
|
||||
return func(e *EnvOptionsReader) {
|
||||
if v, ok := e.GetEnvValue(n); ok {
|
||||
b, err := e.ReadFile(v)
|
||||
if err != nil {
|
||||
global.Error(err, "read tls ca cert file", "file", v)
|
||||
return
|
||||
}
|
||||
c, err := createCertPool(b)
|
||||
if err != nil {
|
||||
global.Error(err, "create tls cert pool")
|
||||
return
|
||||
}
|
||||
fn(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WithClientCert returns a ConfigFn that reads the environment variable nc and nk as filepaths to a client certificate and key pair. If they exists, they are parsed as a crypto/tls.Certificate and it is passed to fn.
|
||||
func WithClientCert(nc, nk string, fn func(tls.Certificate)) ConfigFn {
|
||||
return func(e *EnvOptionsReader) {
|
||||
vc, okc := e.GetEnvValue(nc)
|
||||
vk, okk := e.GetEnvValue(nk)
|
||||
if !okc || !okk {
|
||||
return
|
||||
}
|
||||
cert, err := e.ReadFile(vc)
|
||||
if err != nil {
|
||||
global.Error(err, "read tls client cert", "file", vc)
|
||||
return
|
||||
}
|
||||
key, err := e.ReadFile(vk)
|
||||
if err != nil {
|
||||
global.Error(err, "read tls client key", "file", vk)
|
||||
return
|
||||
}
|
||||
crt, err := tls.X509KeyPair(cert, key)
|
||||
if err != nil {
|
||||
global.Error(err, "create tls client key pair")
|
||||
return
|
||||
}
|
||||
fn(crt)
|
||||
}
|
||||
}
|
||||
|
||||
func keyWithNamespace(ns, key string) string {
|
||||
if ns == "" {
|
||||
return key
|
||||
}
|
||||
return fmt.Sprintf("%s_%s", ns, key)
|
||||
}
|
||||
|
||||
func stringToHeader(value string) map[string]string {
|
||||
headersPairs := strings.Split(value, ",")
|
||||
headers := make(map[string]string)
|
||||
|
||||
for _, header := range headersPairs {
|
||||
n, v, found := strings.Cut(header, "=")
|
||||
if !found {
|
||||
global.Error(errors.New("missing '="), "parse headers", "input", header)
|
||||
continue
|
||||
}
|
||||
name, err := url.QueryUnescape(n)
|
||||
if err != nil {
|
||||
global.Error(err, "escape header key", "key", n)
|
||||
continue
|
||||
}
|
||||
trimmedName := strings.TrimSpace(name)
|
||||
value, err := url.QueryUnescape(v)
|
||||
if err != nil {
|
||||
global.Error(err, "escape header value", "value", v)
|
||||
continue
|
||||
}
|
||||
trimmedValue := strings.TrimSpace(value)
|
||||
|
||||
headers[trimmedName] = trimmedValue
|
||||
}
|
||||
|
||||
return headers
|
||||
}
|
||||
|
||||
func createCertPool(certBytes []byte) (*x509.CertPool, error) {
|
||||
cp := x509.NewCertPool()
|
||||
if ok := cp.AppendCertsFromPEM(certBytes); !ok {
|
||||
return nil, errors.New("failed to append certificate to the cert pool")
|
||||
}
|
||||
return cp, nil
|
||||
}
|
35
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/gen.go
generated
vendored
Normal file
35
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/gen.go
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
// 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/exporters/otlp/otlptrace/otlptracehttp/internal"
|
||||
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/partialsuccess.go.tmpl "--data={}" --out=partialsuccess.go
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/partialsuccess_test.go.tmpl "--data={}" --out=partialsuccess_test.go
|
||||
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/retry/retry.go.tmpl "--data={}" --out=retry/retry.go
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/retry/retry_test.go.tmpl "--data={}" --out=retry/retry_test.go
|
||||
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/envconfig/envconfig.go.tmpl "--data={}" --out=envconfig/envconfig.go
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/envconfig/envconfig_test.go.tmpl "--data={}" --out=envconfig/envconfig_test.go
|
||||
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/otlptrace/otlpconfig/envconfig.go.tmpl "--data={\"envconfigImportPath\": \"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/envconfig\"}" --out=otlpconfig/envconfig.go
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/otlptrace/otlpconfig/options.go.tmpl "--data={\"retryImportPath\": \"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/retry\"}" --out=otlpconfig/options.go
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/otlptrace/otlpconfig/options_test.go.tmpl "--data={\"envconfigImportPath\": \"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/envconfig\"}" --out=otlpconfig/options_test.go
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/otlptrace/otlpconfig/optiontypes.go.tmpl "--data={}" --out=otlpconfig/optiontypes.go
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/otlptrace/otlpconfig/tls.go.tmpl "--data={}" --out=otlpconfig/tls.go
|
||||
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/otlptrace/otlptracetest/client.go.tmpl "--data={}" --out=otlptracetest/client.go
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/otlptrace/otlptracetest/collector.go.tmpl "--data={}" --out=otlptracetest/collector.go
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/otlptrace/otlptracetest/data.go.tmpl "--data={}" --out=otlptracetest/data.go
|
||||
//go:generate gotmpl --body=../../../../../internal/shared/otlp/otlptrace/otlptracetest/otlptest.go.tmpl "--data={}" --out=otlptracetest/otlptest.go
|
153
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/otlpconfig/envconfig.go
generated
vendored
Normal file
153
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/otlpconfig/envconfig.go
generated
vendored
Normal file
|
@ -0,0 +1,153 @@
|
|||
// Code created by gotmpl. DO NOT MODIFY.
|
||||
// source: internal/shared/otlp/otlptrace/otlpconfig/envconfig.go.tmpl
|
||||
|
||||
// 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 otlpconfig // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/otlpconfig"
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/envconfig"
|
||||
)
|
||||
|
||||
// DefaultEnvOptionsReader is the default environments reader.
|
||||
var DefaultEnvOptionsReader = envconfig.EnvOptionsReader{
|
||||
GetEnv: os.Getenv,
|
||||
ReadFile: os.ReadFile,
|
||||
Namespace: "OTEL_EXPORTER_OTLP",
|
||||
}
|
||||
|
||||
// ApplyGRPCEnvConfigs applies the env configurations for gRPC.
|
||||
func ApplyGRPCEnvConfigs(cfg Config) Config {
|
||||
opts := getOptionsFromEnv()
|
||||
for _, opt := range opts {
|
||||
cfg = opt.ApplyGRPCOption(cfg)
|
||||
}
|
||||
return cfg
|
||||
}
|
||||
|
||||
// ApplyHTTPEnvConfigs applies the env configurations for HTTP.
|
||||
func ApplyHTTPEnvConfigs(cfg Config) Config {
|
||||
opts := getOptionsFromEnv()
|
||||
for _, opt := range opts {
|
||||
cfg = opt.ApplyHTTPOption(cfg)
|
||||
}
|
||||
return cfg
|
||||
}
|
||||
|
||||
func getOptionsFromEnv() []GenericOption {
|
||||
opts := []GenericOption{}
|
||||
|
||||
tlsConf := &tls.Config{}
|
||||
DefaultEnvOptionsReader.Apply(
|
||||
envconfig.WithURL("ENDPOINT", func(u *url.URL) {
|
||||
opts = append(opts, withEndpointScheme(u))
|
||||
opts = append(opts, newSplitOption(func(cfg Config) Config {
|
||||
cfg.Traces.Endpoint = u.Host
|
||||
// For OTLP/HTTP endpoint URLs without a per-signal
|
||||
// configuration, the passed endpoint is used as a base URL
|
||||
// and the signals are sent to these paths relative to that.
|
||||
cfg.Traces.URLPath = path.Join(u.Path, DefaultTracesPath)
|
||||
return cfg
|
||||
}, withEndpointForGRPC(u)))
|
||||
}),
|
||||
envconfig.WithURL("TRACES_ENDPOINT", func(u *url.URL) {
|
||||
opts = append(opts, withEndpointScheme(u))
|
||||
opts = append(opts, newSplitOption(func(cfg Config) Config {
|
||||
cfg.Traces.Endpoint = u.Host
|
||||
// For endpoint URLs for OTLP/HTTP per-signal variables, the
|
||||
// URL MUST be used as-is without any modification. The only
|
||||
// exception is that if an URL contains no path part, the root
|
||||
// path / MUST be used.
|
||||
path := u.Path
|
||||
if path == "" {
|
||||
path = "/"
|
||||
}
|
||||
cfg.Traces.URLPath = path
|
||||
return cfg
|
||||
}, withEndpointForGRPC(u)))
|
||||
}),
|
||||
envconfig.WithCertPool("CERTIFICATE", func(p *x509.CertPool) { tlsConf.RootCAs = p }),
|
||||
envconfig.WithCertPool("TRACES_CERTIFICATE", func(p *x509.CertPool) { tlsConf.RootCAs = p }),
|
||||
envconfig.WithClientCert("CLIENT_CERTIFICATE", "CLIENT_KEY", func(c tls.Certificate) { tlsConf.Certificates = []tls.Certificate{c} }),
|
||||
envconfig.WithClientCert("TRACES_CLIENT_CERTIFICATE", "TRACES_CLIENT_KEY", func(c tls.Certificate) { tlsConf.Certificates = []tls.Certificate{c} }),
|
||||
withTLSConfig(tlsConf, func(c *tls.Config) { opts = append(opts, WithTLSClientConfig(c)) }),
|
||||
envconfig.WithBool("INSECURE", func(b bool) { opts = append(opts, withInsecure(b)) }),
|
||||
envconfig.WithBool("TRACES_INSECURE", func(b bool) { opts = append(opts, withInsecure(b)) }),
|
||||
envconfig.WithHeaders("HEADERS", func(h map[string]string) { opts = append(opts, WithHeaders(h)) }),
|
||||
envconfig.WithHeaders("TRACES_HEADERS", func(h map[string]string) { opts = append(opts, WithHeaders(h)) }),
|
||||
WithEnvCompression("COMPRESSION", func(c Compression) { opts = append(opts, WithCompression(c)) }),
|
||||
WithEnvCompression("TRACES_COMPRESSION", func(c Compression) { opts = append(opts, WithCompression(c)) }),
|
||||
envconfig.WithDuration("TIMEOUT", func(d time.Duration) { opts = append(opts, WithTimeout(d)) }),
|
||||
envconfig.WithDuration("TRACES_TIMEOUT", func(d time.Duration) { opts = append(opts, WithTimeout(d)) }),
|
||||
)
|
||||
|
||||
return opts
|
||||
}
|
||||
|
||||
func withEndpointScheme(u *url.URL) GenericOption {
|
||||
switch strings.ToLower(u.Scheme) {
|
||||
case "http", "unix":
|
||||
return WithInsecure()
|
||||
default:
|
||||
return WithSecure()
|
||||
}
|
||||
}
|
||||
|
||||
func withEndpointForGRPC(u *url.URL) func(cfg Config) Config {
|
||||
return func(cfg Config) Config {
|
||||
// For OTLP/gRPC endpoints, this is the target to which the
|
||||
// exporter is going to send telemetry.
|
||||
cfg.Traces.Endpoint = path.Join(u.Host, u.Path)
|
||||
return cfg
|
||||
}
|
||||
}
|
||||
|
||||
// WithEnvCompression retrieves the specified config and passes it to ConfigFn as a Compression.
|
||||
func WithEnvCompression(n string, fn func(Compression)) func(e *envconfig.EnvOptionsReader) {
|
||||
return func(e *envconfig.EnvOptionsReader) {
|
||||
if v, ok := e.GetEnvValue(n); ok {
|
||||
cp := NoCompression
|
||||
if v == "gzip" {
|
||||
cp = GzipCompression
|
||||
}
|
||||
|
||||
fn(cp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// revive:disable-next-line:flag-parameter
|
||||
func withInsecure(b bool) GenericOption {
|
||||
if b {
|
||||
return WithInsecure()
|
||||
}
|
||||
return WithSecure()
|
||||
}
|
||||
|
||||
func withTLSConfig(c *tls.Config, fn func(*tls.Config)) func(e *envconfig.EnvOptionsReader) {
|
||||
return func(e *envconfig.EnvOptionsReader) {
|
||||
if c.RootCAs != nil || len(c.Certificates) > 0 {
|
||||
fn(c)
|
||||
}
|
||||
}
|
||||
}
|
328
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/otlpconfig/options.go
generated
vendored
Normal file
328
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/otlpconfig/options.go
generated
vendored
Normal file
|
@ -0,0 +1,328 @@
|
|||
// Code created by gotmpl. DO NOT MODIFY.
|
||||
// source: internal/shared/otlp/otlptrace/otlpconfig/options.go.tmpl
|
||||
|
||||
// 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 otlpconfig // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/otlpconfig"
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/backoff"
|
||||
"google.golang.org/grpc/credentials"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/encoding/gzip"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/retry"
|
||||
)
|
||||
|
||||
const (
|
||||
// DefaultTracesPath is a default URL path for endpoint that
|
||||
// receives spans.
|
||||
DefaultTracesPath string = "/v1/traces"
|
||||
// DefaultTimeout is a default max waiting time for the backend to process
|
||||
// each span batch.
|
||||
DefaultTimeout time.Duration = 10 * time.Second
|
||||
)
|
||||
|
||||
type (
|
||||
SignalConfig struct {
|
||||
Endpoint string
|
||||
Insecure bool
|
||||
TLSCfg *tls.Config
|
||||
Headers map[string]string
|
||||
Compression Compression
|
||||
Timeout time.Duration
|
||||
URLPath string
|
||||
|
||||
// gRPC configurations
|
||||
GRPCCredentials credentials.TransportCredentials
|
||||
}
|
||||
|
||||
Config struct {
|
||||
// Signal specific configurations
|
||||
Traces SignalConfig
|
||||
|
||||
RetryConfig retry.Config
|
||||
|
||||
// gRPC configurations
|
||||
ReconnectionPeriod time.Duration
|
||||
ServiceConfig string
|
||||
DialOptions []grpc.DialOption
|
||||
GRPCConn *grpc.ClientConn
|
||||
}
|
||||
)
|
||||
|
||||
// NewHTTPConfig returns a new Config with all settings applied from opts and
|
||||
// any unset setting using the default HTTP config values.
|
||||
func NewHTTPConfig(opts ...HTTPOption) Config {
|
||||
cfg := Config{
|
||||
Traces: SignalConfig{
|
||||
Endpoint: fmt.Sprintf("%s:%d", DefaultCollectorHost, DefaultCollectorHTTPPort),
|
||||
URLPath: DefaultTracesPath,
|
||||
Compression: NoCompression,
|
||||
Timeout: DefaultTimeout,
|
||||
},
|
||||
RetryConfig: retry.DefaultConfig,
|
||||
}
|
||||
cfg = ApplyHTTPEnvConfigs(cfg)
|
||||
for _, opt := range opts {
|
||||
cfg = opt.ApplyHTTPOption(cfg)
|
||||
}
|
||||
cfg.Traces.URLPath = cleanPath(cfg.Traces.URLPath, DefaultTracesPath)
|
||||
return cfg
|
||||
}
|
||||
|
||||
// cleanPath returns a path with all spaces trimmed and all redundancies
|
||||
// removed. If urlPath is empty or cleaning it results in an empty string,
|
||||
// defaultPath is returned instead.
|
||||
func cleanPath(urlPath string, defaultPath string) string {
|
||||
tmp := path.Clean(strings.TrimSpace(urlPath))
|
||||
if tmp == "." {
|
||||
return defaultPath
|
||||
}
|
||||
if !path.IsAbs(tmp) {
|
||||
tmp = fmt.Sprintf("/%s", tmp)
|
||||
}
|
||||
return tmp
|
||||
}
|
||||
|
||||
// NewGRPCConfig returns a new Config with all settings applied from opts and
|
||||
// any unset setting using the default gRPC config values.
|
||||
func NewGRPCConfig(opts ...GRPCOption) Config {
|
||||
userAgent := "OTel OTLP Exporter Go/" + otlptrace.Version()
|
||||
cfg := Config{
|
||||
Traces: SignalConfig{
|
||||
Endpoint: fmt.Sprintf("%s:%d", DefaultCollectorHost, DefaultCollectorGRPCPort),
|
||||
URLPath: DefaultTracesPath,
|
||||
Compression: NoCompression,
|
||||
Timeout: DefaultTimeout,
|
||||
},
|
||||
RetryConfig: retry.DefaultConfig,
|
||||
DialOptions: []grpc.DialOption{grpc.WithUserAgent(userAgent)},
|
||||
}
|
||||
cfg = ApplyGRPCEnvConfigs(cfg)
|
||||
for _, opt := range opts {
|
||||
cfg = opt.ApplyGRPCOption(cfg)
|
||||
}
|
||||
|
||||
if cfg.ServiceConfig != "" {
|
||||
cfg.DialOptions = append(cfg.DialOptions, grpc.WithDefaultServiceConfig(cfg.ServiceConfig))
|
||||
}
|
||||
// Priroritize GRPCCredentials over Insecure (passing both is an error).
|
||||
if cfg.Traces.GRPCCredentials != nil {
|
||||
cfg.DialOptions = append(cfg.DialOptions, grpc.WithTransportCredentials(cfg.Traces.GRPCCredentials))
|
||||
} else if cfg.Traces.Insecure {
|
||||
cfg.DialOptions = append(cfg.DialOptions, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
} else {
|
||||
// Default to using the host's root CA.
|
||||
creds := credentials.NewTLS(nil)
|
||||
cfg.Traces.GRPCCredentials = creds
|
||||
cfg.DialOptions = append(cfg.DialOptions, grpc.WithTransportCredentials(creds))
|
||||
}
|
||||
if cfg.Traces.Compression == GzipCompression {
|
||||
cfg.DialOptions = append(cfg.DialOptions, grpc.WithDefaultCallOptions(grpc.UseCompressor(gzip.Name)))
|
||||
}
|
||||
if len(cfg.DialOptions) != 0 {
|
||||
cfg.DialOptions = append(cfg.DialOptions, cfg.DialOptions...)
|
||||
}
|
||||
if cfg.ReconnectionPeriod != 0 {
|
||||
p := grpc.ConnectParams{
|
||||
Backoff: backoff.DefaultConfig,
|
||||
MinConnectTimeout: cfg.ReconnectionPeriod,
|
||||
}
|
||||
cfg.DialOptions = append(cfg.DialOptions, grpc.WithConnectParams(p))
|
||||
}
|
||||
|
||||
return cfg
|
||||
}
|
||||
|
||||
type (
|
||||
// GenericOption applies an option to the HTTP or gRPC driver.
|
||||
GenericOption interface {
|
||||
ApplyHTTPOption(Config) Config
|
||||
ApplyGRPCOption(Config) Config
|
||||
|
||||
// A private method to prevent users implementing the
|
||||
// interface and so future additions to it will not
|
||||
// violate compatibility.
|
||||
private()
|
||||
}
|
||||
|
||||
// HTTPOption applies an option to the HTTP driver.
|
||||
HTTPOption interface {
|
||||
ApplyHTTPOption(Config) Config
|
||||
|
||||
// A private method to prevent users implementing the
|
||||
// interface and so future additions to it will not
|
||||
// violate compatibility.
|
||||
private()
|
||||
}
|
||||
|
||||
// GRPCOption applies an option to the gRPC driver.
|
||||
GRPCOption interface {
|
||||
ApplyGRPCOption(Config) Config
|
||||
|
||||
// A private method to prevent users implementing the
|
||||
// interface and so future additions to it will not
|
||||
// violate compatibility.
|
||||
private()
|
||||
}
|
||||
)
|
||||
|
||||
// genericOption is an option that applies the same logic
|
||||
// for both gRPC and HTTP.
|
||||
type genericOption struct {
|
||||
fn func(Config) Config
|
||||
}
|
||||
|
||||
func (g *genericOption) ApplyGRPCOption(cfg Config) Config {
|
||||
return g.fn(cfg)
|
||||
}
|
||||
|
||||
func (g *genericOption) ApplyHTTPOption(cfg Config) Config {
|
||||
return g.fn(cfg)
|
||||
}
|
||||
|
||||
func (genericOption) private() {}
|
||||
|
||||
func newGenericOption(fn func(cfg Config) Config) GenericOption {
|
||||
return &genericOption{fn: fn}
|
||||
}
|
||||
|
||||
// splitOption is an option that applies different logics
|
||||
// for gRPC and HTTP.
|
||||
type splitOption struct {
|
||||
httpFn func(Config) Config
|
||||
grpcFn func(Config) Config
|
||||
}
|
||||
|
||||
func (g *splitOption) ApplyGRPCOption(cfg Config) Config {
|
||||
return g.grpcFn(cfg)
|
||||
}
|
||||
|
||||
func (g *splitOption) ApplyHTTPOption(cfg Config) Config {
|
||||
return g.httpFn(cfg)
|
||||
}
|
||||
|
||||
func (splitOption) private() {}
|
||||
|
||||
func newSplitOption(httpFn func(cfg Config) Config, grpcFn func(cfg Config) Config) GenericOption {
|
||||
return &splitOption{httpFn: httpFn, grpcFn: grpcFn}
|
||||
}
|
||||
|
||||
// httpOption is an option that is only applied to the HTTP driver.
|
||||
type httpOption struct {
|
||||
fn func(Config) Config
|
||||
}
|
||||
|
||||
func (h *httpOption) ApplyHTTPOption(cfg Config) Config {
|
||||
return h.fn(cfg)
|
||||
}
|
||||
|
||||
func (httpOption) private() {}
|
||||
|
||||
func NewHTTPOption(fn func(cfg Config) Config) HTTPOption {
|
||||
return &httpOption{fn: fn}
|
||||
}
|
||||
|
||||
// grpcOption is an option that is only applied to the gRPC driver.
|
||||
type grpcOption struct {
|
||||
fn func(Config) Config
|
||||
}
|
||||
|
||||
func (h *grpcOption) ApplyGRPCOption(cfg Config) Config {
|
||||
return h.fn(cfg)
|
||||
}
|
||||
|
||||
func (grpcOption) private() {}
|
||||
|
||||
func NewGRPCOption(fn func(cfg Config) Config) GRPCOption {
|
||||
return &grpcOption{fn: fn}
|
||||
}
|
||||
|
||||
// Generic Options
|
||||
|
||||
func WithEndpoint(endpoint string) GenericOption {
|
||||
return newGenericOption(func(cfg Config) Config {
|
||||
cfg.Traces.Endpoint = endpoint
|
||||
return cfg
|
||||
})
|
||||
}
|
||||
|
||||
func WithCompression(compression Compression) GenericOption {
|
||||
return newGenericOption(func(cfg Config) Config {
|
||||
cfg.Traces.Compression = compression
|
||||
return cfg
|
||||
})
|
||||
}
|
||||
|
||||
func WithURLPath(urlPath string) GenericOption {
|
||||
return newGenericOption(func(cfg Config) Config {
|
||||
cfg.Traces.URLPath = urlPath
|
||||
return cfg
|
||||
})
|
||||
}
|
||||
|
||||
func WithRetry(rc retry.Config) GenericOption {
|
||||
return newGenericOption(func(cfg Config) Config {
|
||||
cfg.RetryConfig = rc
|
||||
return cfg
|
||||
})
|
||||
}
|
||||
|
||||
func WithTLSClientConfig(tlsCfg *tls.Config) GenericOption {
|
||||
return newSplitOption(func(cfg Config) Config {
|
||||
cfg.Traces.TLSCfg = tlsCfg.Clone()
|
||||
return cfg
|
||||
}, func(cfg Config) Config {
|
||||
cfg.Traces.GRPCCredentials = credentials.NewTLS(tlsCfg)
|
||||
return cfg
|
||||
})
|
||||
}
|
||||
|
||||
func WithInsecure() GenericOption {
|
||||
return newGenericOption(func(cfg Config) Config {
|
||||
cfg.Traces.Insecure = true
|
||||
return cfg
|
||||
})
|
||||
}
|
||||
|
||||
func WithSecure() GenericOption {
|
||||
return newGenericOption(func(cfg Config) Config {
|
||||
cfg.Traces.Insecure = false
|
||||
return cfg
|
||||
})
|
||||
}
|
||||
|
||||
func WithHeaders(headers map[string]string) GenericOption {
|
||||
return newGenericOption(func(cfg Config) Config {
|
||||
cfg.Traces.Headers = headers
|
||||
return cfg
|
||||
})
|
||||
}
|
||||
|
||||
func WithTimeout(duration time.Duration) GenericOption {
|
||||
return newGenericOption(func(cfg Config) Config {
|
||||
cfg.Traces.Timeout = duration
|
||||
return cfg
|
||||
})
|
||||
}
|
51
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/otlpconfig/optiontypes.go
generated
vendored
Normal file
51
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/otlpconfig/optiontypes.go
generated
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
// Code created by gotmpl. DO NOT MODIFY.
|
||||
// source: internal/shared/otlp/otlptrace/otlpconfig/optiontypes.go.tmpl
|
||||
|
||||
// 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 otlpconfig // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/otlpconfig"
|
||||
|
||||
const (
|
||||
// DefaultCollectorGRPCPort is the default gRPC port of the collector.
|
||||
DefaultCollectorGRPCPort uint16 = 4317
|
||||
// DefaultCollectorHTTPPort is the default HTTP port of the collector.
|
||||
DefaultCollectorHTTPPort uint16 = 4318
|
||||
// DefaultCollectorHost is the host address the Exporter will attempt
|
||||
// connect to if no collector address is provided.
|
||||
DefaultCollectorHost string = "localhost"
|
||||
)
|
||||
|
||||
// Compression describes the compression used for payloads sent to the
|
||||
// collector.
|
||||
type Compression int
|
||||
|
||||
const (
|
||||
// NoCompression tells the driver to send payloads without
|
||||
// compression.
|
||||
NoCompression Compression = iota
|
||||
// GzipCompression tells the driver to send payloads after
|
||||
// compressing them with gzip.
|
||||
GzipCompression
|
||||
)
|
||||
|
||||
// Marshaler describes the kind of message format sent to the collector.
|
||||
type Marshaler int
|
||||
|
||||
const (
|
||||
// MarshalProto tells the driver to send using the protobuf binary format.
|
||||
MarshalProto Marshaler = iota
|
||||
// MarshalJSON tells the driver to send using json format.
|
||||
MarshalJSON
|
||||
)
|
37
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/otlpconfig/tls.go
generated
vendored
Normal file
37
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/otlpconfig/tls.go
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Code created by gotmpl. DO NOT MODIFY.
|
||||
// source: internal/shared/otlp/otlptrace/otlpconfig/tls.go.tmpl
|
||||
|
||||
// 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 otlpconfig // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/otlpconfig"
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"errors"
|
||||
)
|
||||
|
||||
// CreateTLSConfig creates a tls.Config from a raw certificate bytes
|
||||
// to verify a server certificate.
|
||||
func CreateTLSConfig(certBytes []byte) (*tls.Config, error) {
|
||||
cp := x509.NewCertPool()
|
||||
if ok := cp.AppendCertsFromPEM(certBytes); !ok {
|
||||
return nil, errors.New("failed to append certificate to the cert pool")
|
||||
}
|
||||
|
||||
return &tls.Config{
|
||||
RootCAs: cp,
|
||||
}, nil
|
||||
}
|
67
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/partialsuccess.go
generated
vendored
Normal file
67
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/partialsuccess.go
generated
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
// Code created by gotmpl. DO NOT MODIFY.
|
||||
// source: internal/shared/otlp/partialsuccess.go
|
||||
|
||||
// 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/exporters/otlp/otlptrace/otlptracehttp/internal"
|
||||
|
||||
import "fmt"
|
||||
|
||||
// PartialSuccess represents the underlying error for all handling
|
||||
// OTLP partial success messages. Use `errors.Is(err,
|
||||
// PartialSuccess{})` to test whether an error passed to the OTel
|
||||
// error handler belongs to this category.
|
||||
type PartialSuccess struct {
|
||||
ErrorMessage string
|
||||
RejectedItems int64
|
||||
RejectedKind string
|
||||
}
|
||||
|
||||
var _ error = PartialSuccess{}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (ps PartialSuccess) Error() string {
|
||||
msg := ps.ErrorMessage
|
||||
if msg == "" {
|
||||
msg = "empty message"
|
||||
}
|
||||
return fmt.Sprintf("OTLP partial success: %s (%d %s rejected)", msg, ps.RejectedItems, ps.RejectedKind)
|
||||
}
|
||||
|
||||
// Is supports the errors.Is() interface.
|
||||
func (ps PartialSuccess) Is(err error) bool {
|
||||
_, ok := err.(PartialSuccess)
|
||||
return ok
|
||||
}
|
||||
|
||||
// TracePartialSuccessError returns an error describing a partial success
|
||||
// response for the trace signal.
|
||||
func TracePartialSuccessError(itemsRejected int64, errorMessage string) error {
|
||||
return PartialSuccess{
|
||||
ErrorMessage: errorMessage,
|
||||
RejectedItems: itemsRejected,
|
||||
RejectedKind: "spans",
|
||||
}
|
||||
}
|
||||
|
||||
// MetricPartialSuccessError returns an error describing a partial success
|
||||
// response for the metric signal.
|
||||
func MetricPartialSuccessError(itemsRejected int64, errorMessage string) error {
|
||||
return PartialSuccess{
|
||||
ErrorMessage: errorMessage,
|
||||
RejectedItems: itemsRejected,
|
||||
RejectedKind: "metric data points",
|
||||
}
|
||||
}
|
156
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/retry/retry.go
generated
vendored
Normal file
156
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/retry/retry.go
generated
vendored
Normal file
|
@ -0,0 +1,156 @@
|
|||
// Code created by gotmpl. DO NOT MODIFY.
|
||||
// source: internal/shared/otlp/retry/retry.go.tmpl
|
||||
|
||||
// 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 retry provides request retry functionality that can perform
|
||||
// configurable exponential backoff for transient errors and honor any
|
||||
// explicit throttle responses received.
|
||||
package retry // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/retry"
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/cenkalti/backoff/v4"
|
||||
)
|
||||
|
||||
// DefaultConfig are the recommended defaults to use.
|
||||
var DefaultConfig = Config{
|
||||
Enabled: true,
|
||||
InitialInterval: 5 * time.Second,
|
||||
MaxInterval: 30 * time.Second,
|
||||
MaxElapsedTime: time.Minute,
|
||||
}
|
||||
|
||||
// Config defines configuration for retrying batches in case of export failure
|
||||
// using an exponential backoff.
|
||||
type Config struct {
|
||||
// Enabled indicates whether to not retry sending batches in case of
|
||||
// export failure.
|
||||
Enabled bool
|
||||
// InitialInterval the time to wait after the first failure before
|
||||
// retrying.
|
||||
InitialInterval time.Duration
|
||||
// MaxInterval is the upper bound on backoff interval. Once this value is
|
||||
// reached the delay between consecutive retries will always be
|
||||
// `MaxInterval`.
|
||||
MaxInterval time.Duration
|
||||
// MaxElapsedTime is the maximum amount of time (including retries) spent
|
||||
// trying to send a request/batch. Once this value is reached, the data
|
||||
// is discarded.
|
||||
MaxElapsedTime time.Duration
|
||||
}
|
||||
|
||||
// RequestFunc wraps a request with retry logic.
|
||||
type RequestFunc func(context.Context, func(context.Context) error) error
|
||||
|
||||
// EvaluateFunc returns if an error is retry-able and if an explicit throttle
|
||||
// duration should be honored that was included in the error.
|
||||
//
|
||||
// The function must return true if the error argument is retry-able,
|
||||
// otherwise it must return false for the first return parameter.
|
||||
//
|
||||
// The function must return a non-zero time.Duration if the error contains
|
||||
// explicit throttle duration that should be honored, otherwise it must return
|
||||
// a zero valued time.Duration.
|
||||
type EvaluateFunc func(error) (bool, time.Duration)
|
||||
|
||||
// RequestFunc returns a RequestFunc using the evaluate function to determine
|
||||
// if requests can be retried and based on the exponential backoff
|
||||
// configuration of c.
|
||||
func (c Config) RequestFunc(evaluate EvaluateFunc) RequestFunc {
|
||||
if !c.Enabled {
|
||||
return func(ctx context.Context, fn func(context.Context) error) error {
|
||||
return fn(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
return func(ctx context.Context, fn func(context.Context) error) error {
|
||||
// Do not use NewExponentialBackOff since it calls Reset and the code here
|
||||
// must call Reset after changing the InitialInterval (this saves an
|
||||
// unnecessary call to Now).
|
||||
b := &backoff.ExponentialBackOff{
|
||||
InitialInterval: c.InitialInterval,
|
||||
RandomizationFactor: backoff.DefaultRandomizationFactor,
|
||||
Multiplier: backoff.DefaultMultiplier,
|
||||
MaxInterval: c.MaxInterval,
|
||||
MaxElapsedTime: c.MaxElapsedTime,
|
||||
Stop: backoff.Stop,
|
||||
Clock: backoff.SystemClock,
|
||||
}
|
||||
b.Reset()
|
||||
|
||||
for {
|
||||
err := fn(ctx)
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
retryable, throttle := evaluate(err)
|
||||
if !retryable {
|
||||
return err
|
||||
}
|
||||
|
||||
bOff := b.NextBackOff()
|
||||
if bOff == backoff.Stop {
|
||||
return fmt.Errorf("max retry time elapsed: %w", err)
|
||||
}
|
||||
|
||||
// Wait for the greater of the backoff or throttle delay.
|
||||
var delay time.Duration
|
||||
if bOff > throttle {
|
||||
delay = bOff
|
||||
} else {
|
||||
elapsed := b.GetElapsedTime()
|
||||
if b.MaxElapsedTime != 0 && elapsed+throttle > b.MaxElapsedTime {
|
||||
return fmt.Errorf("max retry time would elapse: %w", err)
|
||||
}
|
||||
delay = throttle
|
||||
}
|
||||
|
||||
if ctxErr := waitFunc(ctx, delay); ctxErr != nil {
|
||||
return fmt.Errorf("%w: %s", ctxErr, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Allow override for testing.
|
||||
var waitFunc = wait
|
||||
|
||||
// wait takes the caller's context, and the amount of time to wait. It will
|
||||
// return nil if the timer fires before or at the same time as the context's
|
||||
// deadline. This indicates that the call can be retried.
|
||||
func wait(ctx context.Context, delay time.Duration) error {
|
||||
timer := time.NewTimer(delay)
|
||||
defer timer.Stop()
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
// Handle the case where the timer and context deadline end
|
||||
// simultaneously by prioritizing the timer expiration nil value
|
||||
// response.
|
||||
select {
|
||||
case <-timer.C:
|
||||
default:
|
||||
return ctx.Err()
|
||||
}
|
||||
case <-timer.C:
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
4
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/options.go
generated
vendored
4
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/options.go
generated
vendored
|
@ -18,8 +18,8 @@ import (
|
|||
"crypto/tls"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel/exporters/otlp/internal/retry"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/otlpconfig"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/otlpconfig"
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/internal/retry"
|
||||
)
|
||||
|
||||
// Compression describes the compression used for payloads sent to the
|
||||
|
|
20
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/version.go
generated
vendored
Normal file
20
vendor/go.opentelemetry.io/otel/exporters/otlp/otlptrace/version.go
generated
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
// 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 otlptrace // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace"
|
||||
|
||||
// Version is the current release version of the OpenTelemetry OTLP trace exporter in use.
|
||||
func Version() string {
|
||||
return "1.19.0"
|
||||
}
|
64
vendor/go.opentelemetry.io/otel/handler.go
generated
vendored
64
vendor/go.opentelemetry.io/otel/handler.go
generated
vendored
|
@ -15,58 +15,16 @@
|
|||
package otel // import "go.opentelemetry.io/otel"
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"sync/atomic"
|
||||
"unsafe"
|
||||
"go.opentelemetry.io/otel/internal/global"
|
||||
)
|
||||
|
||||
var (
|
||||
// globalErrorHandler provides an ErrorHandler that can be used
|
||||
// throughout an OpenTelemetry instrumented project. When a user
|
||||
// specified ErrorHandler is registered (`SetErrorHandler`) all calls to
|
||||
// `Handle` and will be delegated to the registered ErrorHandler.
|
||||
globalErrorHandler = defaultErrorHandler()
|
||||
|
||||
// Compile-time check that delegator implements ErrorHandler.
|
||||
_ ErrorHandler = (*delegator)(nil)
|
||||
// Compile-time check that errLogger implements ErrorHandler.
|
||||
_ ErrorHandler = (*errLogger)(nil)
|
||||
// Compile-time check global.ErrDelegator implements ErrorHandler.
|
||||
_ ErrorHandler = (*global.ErrDelegator)(nil)
|
||||
// Compile-time check global.ErrLogger implements ErrorHandler.
|
||||
_ ErrorHandler = (*global.ErrLogger)(nil)
|
||||
)
|
||||
|
||||
type delegator struct {
|
||||
delegate unsafe.Pointer
|
||||
}
|
||||
|
||||
func (d *delegator) Handle(err error) {
|
||||
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) {
|
||||
atomic.StorePointer(&d.delegate, unsafe.Pointer(&eh))
|
||||
}
|
||||
|
||||
func defaultErrorHandler() *delegator {
|
||||
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.
|
||||
type errLogger struct {
|
||||
l *log.Logger
|
||||
}
|
||||
|
||||
// Handle logs err if no delegate is set, otherwise it is delegated.
|
||||
func (h *errLogger) Handle(err error) {
|
||||
h.l.Print(err)
|
||||
}
|
||||
|
||||
// GetErrorHandler returns the global ErrorHandler instance.
|
||||
//
|
||||
// The default ErrorHandler instance returned will log all errors to STDERR
|
||||
|
@ -76,9 +34,7 @@ func (h *errLogger) Handle(err error) {
|
|||
//
|
||||
// Subsequent calls to SetErrorHandler after the first will not forward errors
|
||||
// to the new ErrorHandler for prior returned instances.
|
||||
func GetErrorHandler() ErrorHandler {
|
||||
return globalErrorHandler
|
||||
}
|
||||
func GetErrorHandler() ErrorHandler { return global.GetErrorHandler() }
|
||||
|
||||
// SetErrorHandler sets the global ErrorHandler to h.
|
||||
//
|
||||
|
@ -86,11 +42,7 @@ func GetErrorHandler() ErrorHandler {
|
|||
// GetErrorHandler will send errors to h instead of the default logging
|
||||
// ErrorHandler. Subsequent calls will set the global ErrorHandler, but not
|
||||
// delegate errors to h.
|
||||
func SetErrorHandler(h ErrorHandler) {
|
||||
globalErrorHandler.setDelegate(h)
|
||||
}
|
||||
func SetErrorHandler(h ErrorHandler) { global.SetErrorHandler(h) }
|
||||
|
||||
// Handle is a convenience function for ErrorHandler().Handle(err).
|
||||
func Handle(err error) {
|
||||
GetErrorHandler().Handle(err)
|
||||
}
|
||||
func Handle(err error) { global.Handle(err) }
|
||||
|
|
29
vendor/go.opentelemetry.io/otel/internal/gen.go
generated
vendored
Normal file
29
vendor/go.opentelemetry.io/otel/internal/gen.go
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
// 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/internal"
|
||||
|
||||
//go:generate gotmpl --body=./shared/matchers/expectation.go.tmpl "--data={}" --out=matchers/expectation.go
|
||||
//go:generate gotmpl --body=./shared/matchers/expecter.go.tmpl "--data={}" --out=matchers/expecter.go
|
||||
//go:generate gotmpl --body=./shared/matchers/temporal_matcher.go.tmpl "--data={}" --out=matchers/temporal_matcher.go
|
||||
|
||||
//go:generate gotmpl --body=./shared/internaltest/alignment.go.tmpl "--data={}" --out=internaltest/alignment.go
|
||||
//go:generate gotmpl --body=./shared/internaltest/env.go.tmpl "--data={}" --out=internaltest/env.go
|
||||
//go:generate gotmpl --body=./shared/internaltest/env_test.go.tmpl "--data={}" --out=internaltest/env_test.go
|
||||
//go:generate gotmpl --body=./shared/internaltest/errors.go.tmpl "--data={}" --out=internaltest/errors.go
|
||||
//go:generate gotmpl --body=./shared/internaltest/harness.go.tmpl "--data={\"matchersImportPath\": \"go.opentelemetry.io/otel/internal/matchers\"}" --out=internaltest/harness.go
|
||||
//go:generate gotmpl --body=./shared/internaltest/text_map_carrier.go.tmpl "--data={}" --out=internaltest/text_map_carrier.go
|
||||
//go:generate gotmpl --body=./shared/internaltest/text_map_carrier_test.go.tmpl "--data={}" --out=internaltest/text_map_carrier_test.go
|
||||
//go:generate gotmpl --body=./shared/internaltest/text_map_propagator.go.tmpl "--data={}" --out=internaltest/text_map_propagator.go
|
||||
//go:generate gotmpl --body=./shared/internaltest/text_map_propagator_test.go.tmpl "--data={}" --out=internaltest/text_map_propagator_test.go
|
102
vendor/go.opentelemetry.io/otel/internal/global/handler.go
generated
vendored
Normal file
102
vendor/go.opentelemetry.io/otel/internal/global/handler.go
generated
vendored
Normal file
|
@ -0,0 +1,102 @@
|
|||
// 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 global // import "go.opentelemetry.io/otel/internal/global"
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
var (
|
||||
// GlobalErrorHandler provides an ErrorHandler that can be used
|
||||
// throughout an OpenTelemetry instrumented project. When a user
|
||||
// specified ErrorHandler is registered (`SetErrorHandler`) all calls to
|
||||
// `Handle` and will be delegated to the registered ErrorHandler.
|
||||
GlobalErrorHandler = defaultErrorHandler()
|
||||
|
||||
// Compile-time check that delegator implements ErrorHandler.
|
||||
_ ErrorHandler = (*ErrDelegator)(nil)
|
||||
// Compile-time check that errLogger implements ErrorHandler.
|
||||
_ ErrorHandler = (*ErrLogger)(nil)
|
||||
)
|
||||
|
||||
// ErrorHandler handles irremediable events.
|
||||
type ErrorHandler interface {
|
||||
// Handle handles any error deemed irremediable by an OpenTelemetry
|
||||
// component.
|
||||
Handle(error)
|
||||
}
|
||||
|
||||
type ErrDelegator struct {
|
||||
delegate atomic.Pointer[ErrorHandler]
|
||||
}
|
||||
|
||||
func (d *ErrDelegator) Handle(err error) {
|
||||
d.getDelegate().Handle(err)
|
||||
}
|
||||
|
||||
func (d *ErrDelegator) getDelegate() ErrorHandler {
|
||||
return *d.delegate.Load()
|
||||
}
|
||||
|
||||
// setDelegate sets the ErrorHandler delegate.
|
||||
func (d *ErrDelegator) setDelegate(eh ErrorHandler) {
|
||||
d.delegate.Store(&eh)
|
||||
}
|
||||
|
||||
func defaultErrorHandler() *ErrDelegator {
|
||||
d := &ErrDelegator{}
|
||||
d.setDelegate(&ErrLogger{l: log.New(os.Stderr, "", log.LstdFlags)})
|
||||
return d
|
||||
}
|
||||
|
||||
// ErrLogger logs errors if no delegate is set, otherwise they are delegated.
|
||||
type ErrLogger struct {
|
||||
l *log.Logger
|
||||
}
|
||||
|
||||
// Handle logs err if no delegate is set, otherwise it is delegated.
|
||||
func (h *ErrLogger) Handle(err error) {
|
||||
h.l.Print(err)
|
||||
}
|
||||
|
||||
// GetErrorHandler returns the global ErrorHandler instance.
|
||||
//
|
||||
// The default ErrorHandler instance returned will log all errors to STDERR
|
||||
// until an override ErrorHandler is set with SetErrorHandler. All
|
||||
// ErrorHandler returned prior to this will automatically forward errors to
|
||||
// the set instance instead of logging.
|
||||
//
|
||||
// Subsequent calls to SetErrorHandler after the first will not forward errors
|
||||
// to the new ErrorHandler for prior returned instances.
|
||||
func GetErrorHandler() ErrorHandler {
|
||||
return GlobalErrorHandler
|
||||
}
|
||||
|
||||
// SetErrorHandler sets the global ErrorHandler to h.
|
||||
//
|
||||
// The first time this is called all ErrorHandler previously returned from
|
||||
// GetErrorHandler will send errors to h instead of the default logging
|
||||
// ErrorHandler. Subsequent calls will set the global ErrorHandler, but not
|
||||
// delegate errors to h.
|
||||
func SetErrorHandler(h ErrorHandler) {
|
||||
GlobalErrorHandler.setDelegate(h)
|
||||
}
|
||||
|
||||
// Handle is a convenience function for ErrorHandler().Handle(err).
|
||||
func Handle(err error) {
|
||||
GetErrorHandler().Handle(err)
|
||||
}
|
359
vendor/go.opentelemetry.io/otel/internal/global/instruments.go
generated
vendored
Normal file
359
vendor/go.opentelemetry.io/otel/internal/global/instruments.go
generated
vendored
Normal file
|
@ -0,0 +1,359 @@
|
|||
// 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 global // import "go.opentelemetry.io/otel/internal/global"
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync/atomic"
|
||||
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/embedded"
|
||||
)
|
||||
|
||||
// unwrapper unwraps to return the underlying instrument implementation.
|
||||
type unwrapper interface {
|
||||
Unwrap() metric.Observable
|
||||
}
|
||||
|
||||
type afCounter struct {
|
||||
embedded.Float64ObservableCounter
|
||||
metric.Float64Observable
|
||||
|
||||
name string
|
||||
opts []metric.Float64ObservableCounterOption
|
||||
|
||||
delegate atomic.Value //metric.Float64ObservableCounter
|
||||
}
|
||||
|
||||
var _ unwrapper = (*afCounter)(nil)
|
||||
var _ metric.Float64ObservableCounter = (*afCounter)(nil)
|
||||
|
||||
func (i *afCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Float64ObservableCounter(i.name, i.opts...)
|
||||
if err != nil {
|
||||
GetErrorHandler().Handle(err)
|
||||
return
|
||||
}
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *afCounter) Unwrap() metric.Observable {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
return ctr.(metric.Float64ObservableCounter)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type afUpDownCounter struct {
|
||||
embedded.Float64ObservableUpDownCounter
|
||||
metric.Float64Observable
|
||||
|
||||
name string
|
||||
opts []metric.Float64ObservableUpDownCounterOption
|
||||
|
||||
delegate atomic.Value //metric.Float64ObservableUpDownCounter
|
||||
}
|
||||
|
||||
var _ unwrapper = (*afUpDownCounter)(nil)
|
||||
var _ metric.Float64ObservableUpDownCounter = (*afUpDownCounter)(nil)
|
||||
|
||||
func (i *afUpDownCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Float64ObservableUpDownCounter(i.name, i.opts...)
|
||||
if err != nil {
|
||||
GetErrorHandler().Handle(err)
|
||||
return
|
||||
}
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *afUpDownCounter) Unwrap() metric.Observable {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
return ctr.(metric.Float64ObservableUpDownCounter)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type afGauge struct {
|
||||
embedded.Float64ObservableGauge
|
||||
metric.Float64Observable
|
||||
|
||||
name string
|
||||
opts []metric.Float64ObservableGaugeOption
|
||||
|
||||
delegate atomic.Value //metric.Float64ObservableGauge
|
||||
}
|
||||
|
||||
var _ unwrapper = (*afGauge)(nil)
|
||||
var _ metric.Float64ObservableGauge = (*afGauge)(nil)
|
||||
|
||||
func (i *afGauge) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Float64ObservableGauge(i.name, i.opts...)
|
||||
if err != nil {
|
||||
GetErrorHandler().Handle(err)
|
||||
return
|
||||
}
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *afGauge) Unwrap() metric.Observable {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
return ctr.(metric.Float64ObservableGauge)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type aiCounter struct {
|
||||
embedded.Int64ObservableCounter
|
||||
metric.Int64Observable
|
||||
|
||||
name string
|
||||
opts []metric.Int64ObservableCounterOption
|
||||
|
||||
delegate atomic.Value //metric.Int64ObservableCounter
|
||||
}
|
||||
|
||||
var _ unwrapper = (*aiCounter)(nil)
|
||||
var _ metric.Int64ObservableCounter = (*aiCounter)(nil)
|
||||
|
||||
func (i *aiCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Int64ObservableCounter(i.name, i.opts...)
|
||||
if err != nil {
|
||||
GetErrorHandler().Handle(err)
|
||||
return
|
||||
}
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *aiCounter) Unwrap() metric.Observable {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
return ctr.(metric.Int64ObservableCounter)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type aiUpDownCounter struct {
|
||||
embedded.Int64ObservableUpDownCounter
|
||||
metric.Int64Observable
|
||||
|
||||
name string
|
||||
opts []metric.Int64ObservableUpDownCounterOption
|
||||
|
||||
delegate atomic.Value //metric.Int64ObservableUpDownCounter
|
||||
}
|
||||
|
||||
var _ unwrapper = (*aiUpDownCounter)(nil)
|
||||
var _ metric.Int64ObservableUpDownCounter = (*aiUpDownCounter)(nil)
|
||||
|
||||
func (i *aiUpDownCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Int64ObservableUpDownCounter(i.name, i.opts...)
|
||||
if err != nil {
|
||||
GetErrorHandler().Handle(err)
|
||||
return
|
||||
}
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *aiUpDownCounter) Unwrap() metric.Observable {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
return ctr.(metric.Int64ObservableUpDownCounter)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type aiGauge struct {
|
||||
embedded.Int64ObservableGauge
|
||||
metric.Int64Observable
|
||||
|
||||
name string
|
||||
opts []metric.Int64ObservableGaugeOption
|
||||
|
||||
delegate atomic.Value //metric.Int64ObservableGauge
|
||||
}
|
||||
|
||||
var _ unwrapper = (*aiGauge)(nil)
|
||||
var _ metric.Int64ObservableGauge = (*aiGauge)(nil)
|
||||
|
||||
func (i *aiGauge) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Int64ObservableGauge(i.name, i.opts...)
|
||||
if err != nil {
|
||||
GetErrorHandler().Handle(err)
|
||||
return
|
||||
}
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *aiGauge) Unwrap() metric.Observable {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
return ctr.(metric.Int64ObservableGauge)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Sync Instruments.
|
||||
type sfCounter struct {
|
||||
embedded.Float64Counter
|
||||
|
||||
name string
|
||||
opts []metric.Float64CounterOption
|
||||
|
||||
delegate atomic.Value //metric.Float64Counter
|
||||
}
|
||||
|
||||
var _ metric.Float64Counter = (*sfCounter)(nil)
|
||||
|
||||
func (i *sfCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Float64Counter(i.name, i.opts...)
|
||||
if err != nil {
|
||||
GetErrorHandler().Handle(err)
|
||||
return
|
||||
}
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *sfCounter) Add(ctx context.Context, incr float64, opts ...metric.AddOption) {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
ctr.(metric.Float64Counter).Add(ctx, incr, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
type sfUpDownCounter struct {
|
||||
embedded.Float64UpDownCounter
|
||||
|
||||
name string
|
||||
opts []metric.Float64UpDownCounterOption
|
||||
|
||||
delegate atomic.Value //metric.Float64UpDownCounter
|
||||
}
|
||||
|
||||
var _ metric.Float64UpDownCounter = (*sfUpDownCounter)(nil)
|
||||
|
||||
func (i *sfUpDownCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Float64UpDownCounter(i.name, i.opts...)
|
||||
if err != nil {
|
||||
GetErrorHandler().Handle(err)
|
||||
return
|
||||
}
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *sfUpDownCounter) Add(ctx context.Context, incr float64, opts ...metric.AddOption) {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
ctr.(metric.Float64UpDownCounter).Add(ctx, incr, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
type sfHistogram struct {
|
||||
embedded.Float64Histogram
|
||||
|
||||
name string
|
||||
opts []metric.Float64HistogramOption
|
||||
|
||||
delegate atomic.Value //metric.Float64Histogram
|
||||
}
|
||||
|
||||
var _ metric.Float64Histogram = (*sfHistogram)(nil)
|
||||
|
||||
func (i *sfHistogram) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Float64Histogram(i.name, i.opts...)
|
||||
if err != nil {
|
||||
GetErrorHandler().Handle(err)
|
||||
return
|
||||
}
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *sfHistogram) Record(ctx context.Context, x float64, opts ...metric.RecordOption) {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
ctr.(metric.Float64Histogram).Record(ctx, x, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
type siCounter struct {
|
||||
embedded.Int64Counter
|
||||
|
||||
name string
|
||||
opts []metric.Int64CounterOption
|
||||
|
||||
delegate atomic.Value //metric.Int64Counter
|
||||
}
|
||||
|
||||
var _ metric.Int64Counter = (*siCounter)(nil)
|
||||
|
||||
func (i *siCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Int64Counter(i.name, i.opts...)
|
||||
if err != nil {
|
||||
GetErrorHandler().Handle(err)
|
||||
return
|
||||
}
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *siCounter) Add(ctx context.Context, x int64, opts ...metric.AddOption) {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
ctr.(metric.Int64Counter).Add(ctx, x, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
type siUpDownCounter struct {
|
||||
embedded.Int64UpDownCounter
|
||||
|
||||
name string
|
||||
opts []metric.Int64UpDownCounterOption
|
||||
|
||||
delegate atomic.Value //metric.Int64UpDownCounter
|
||||
}
|
||||
|
||||
var _ metric.Int64UpDownCounter = (*siUpDownCounter)(nil)
|
||||
|
||||
func (i *siUpDownCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Int64UpDownCounter(i.name, i.opts...)
|
||||
if err != nil {
|
||||
GetErrorHandler().Handle(err)
|
||||
return
|
||||
}
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *siUpDownCounter) Add(ctx context.Context, x int64, opts ...metric.AddOption) {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
ctr.(metric.Int64UpDownCounter).Add(ctx, x, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
type siHistogram struct {
|
||||
embedded.Int64Histogram
|
||||
|
||||
name string
|
||||
opts []metric.Int64HistogramOption
|
||||
|
||||
delegate atomic.Value //metric.Int64Histogram
|
||||
}
|
||||
|
||||
var _ metric.Int64Histogram = (*siHistogram)(nil)
|
||||
|
||||
func (i *siHistogram) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Int64Histogram(i.name, i.opts...)
|
||||
if err != nil {
|
||||
GetErrorHandler().Handle(err)
|
||||
return
|
||||
}
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *siHistogram) Record(ctx context.Context, x int64, opts ...metric.RecordOption) {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
ctr.(metric.Int64Histogram).Record(ctx, x, opts...)
|
||||
}
|
||||
}
|
26
vendor/go.opentelemetry.io/otel/internal/global/internal_logging.go
generated
vendored
26
vendor/go.opentelemetry.io/otel/internal/global/internal_logging.go
generated
vendored
|
@ -18,17 +18,16 @@ import (
|
|||
"log"
|
||||
"os"
|
||||
"sync/atomic"
|
||||
"unsafe"
|
||||
|
||||
"github.com/go-logr/logr"
|
||||
"github.com/go-logr/stdr"
|
||||
)
|
||||
|
||||
// globalLogger is the logging interface used within the otel api and sdk provide deatails of the internals.
|
||||
// globalLogger is the logging interface used within the otel api and sdk provide details of the internals.
|
||||
//
|
||||
// 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 unsafe.Pointer
|
||||
var globalLogger atomic.Pointer[logr.Logger]
|
||||
|
||||
func init() {
|
||||
SetLogger(stdr.New(log.New(os.Stderr, "", log.LstdFlags|log.Lshortfile)))
|
||||
|
@ -36,20 +35,21 @@ func init() {
|
|||
|
||||
// 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`.
|
||||
// To see Warn messages use a logger with `l.V(1).Enabled() == true`
|
||||
// To see Info messages use a logger with `l.V(4).Enabled() == true`
|
||||
// To see Debug messages use a logger with `l.V(8).Enabled() == true`.
|
||||
func SetLogger(l logr.Logger) {
|
||||
atomic.StorePointer(&globalLogger, unsafe.Pointer(&l))
|
||||
globalLogger.Store(&l)
|
||||
}
|
||||
|
||||
func getLogger() logr.Logger {
|
||||
return *(*logr.Logger)(atomic.LoadPointer(&globalLogger))
|
||||
return *globalLogger.Load()
|
||||
}
|
||||
|
||||
// Info prints messages about the general state of the API or SDK.
|
||||
// This should usually be less then 5 messages a minute.
|
||||
// This should usually be less than 5 messages a minute.
|
||||
func Info(msg string, keysAndValues ...interface{}) {
|
||||
getLogger().V(1).Info(msg, keysAndValues...)
|
||||
getLogger().V(4).Info(msg, keysAndValues...)
|
||||
}
|
||||
|
||||
// Error prints messages about exceptional states of the API or SDK.
|
||||
|
@ -59,5 +59,11 @@ func Error(err error, msg string, keysAndValues ...interface{}) {
|
|||
|
||||
// Debug prints messages about all internal changes in the API or SDK.
|
||||
func Debug(msg string, keysAndValues ...interface{}) {
|
||||
getLogger().V(5).Info(msg, keysAndValues...)
|
||||
getLogger().V(8).Info(msg, keysAndValues...)
|
||||
}
|
||||
|
||||
// Warn prints messages about warnings in the API or SDK.
|
||||
// Not an error but is likely more important than an informational event.
|
||||
func Warn(msg string, keysAndValues ...interface{}) {
|
||||
getLogger().V(1).Info(msg, keysAndValues...)
|
||||
}
|
||||
|
|
|
@ -12,16 +12,15 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package global // import "go.opentelemetry.io/otel/metric/internal/global"
|
||||
package global // import "go.opentelemetry.io/otel/internal/global"
|
||||
|
||||
import (
|
||||
"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/embedded"
|
||||
)
|
||||
|
||||
// meterProvider is a placeholder for a configured SDK MeterProvider.
|
||||
|
@ -29,17 +28,14 @@ import (
|
|||
// All MeterProvider functionality is forwarded to a delegate once
|
||||
// configured.
|
||||
type meterProvider struct {
|
||||
embedded.MeterProvider
|
||||
|
||||
mtx sync.Mutex
|
||||
meters map[il]*meter
|
||||
|
||||
delegate metric.MeterProvider
|
||||
}
|
||||
|
||||
type il struct {
|
||||
name string
|
||||
version string
|
||||
}
|
||||
|
||||
// setDelegate configures p to delegate all MeterProvider functionality to
|
||||
// provider.
|
||||
//
|
||||
|
@ -100,6 +96,8 @@ func (p *meterProvider) Meter(name string, opts ...metric.MeterOption) metric.Me
|
|||
// All Meter functionality is forwarded to a delegate once configured.
|
||||
// Otherwise, all functionality is forwarded to a NoopMeter.
|
||||
type meter struct {
|
||||
embedded.Meter
|
||||
|
||||
name string
|
||||
opts []metric.MeterOption
|
||||
|
||||
|
@ -142,7 +140,7 @@ func (m *meter) setDelegate(provider metric.MeterProvider) {
|
|||
m.registry.Init()
|
||||
}
|
||||
|
||||
func (m *meter) Int64Counter(name string, options ...instrument.Int64Option) (instrument.Int64Counter, error) {
|
||||
func (m *meter) Int64Counter(name string, options ...metric.Int64CounterOption) (metric.Int64Counter, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Int64Counter(name, options...)
|
||||
}
|
||||
|
@ -153,7 +151,7 @@ func (m *meter) Int64Counter(name string, options ...instrument.Int64Option) (in
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Int64UpDownCounter(name string, options ...instrument.Int64Option) (instrument.Int64UpDownCounter, error) {
|
||||
func (m *meter) Int64UpDownCounter(name string, options ...metric.Int64UpDownCounterOption) (metric.Int64UpDownCounter, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Int64UpDownCounter(name, options...)
|
||||
}
|
||||
|
@ -164,7 +162,7 @@ func (m *meter) Int64UpDownCounter(name string, options ...instrument.Int64Optio
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Int64Histogram(name string, options ...instrument.Int64Option) (instrument.Int64Histogram, error) {
|
||||
func (m *meter) Int64Histogram(name string, options ...metric.Int64HistogramOption) (metric.Int64Histogram, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Int64Histogram(name, options...)
|
||||
}
|
||||
|
@ -175,7 +173,7 @@ func (m *meter) Int64Histogram(name string, options ...instrument.Int64Option) (
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Int64ObservableCounter(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableCounter, error) {
|
||||
func (m *meter) Int64ObservableCounter(name string, options ...metric.Int64ObservableCounterOption) (metric.Int64ObservableCounter, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Int64ObservableCounter(name, options...)
|
||||
}
|
||||
|
@ -186,7 +184,7 @@ func (m *meter) Int64ObservableCounter(name string, options ...instrument.Int64O
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Int64ObservableUpDownCounter(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableUpDownCounter, error) {
|
||||
func (m *meter) Int64ObservableUpDownCounter(name string, options ...metric.Int64ObservableUpDownCounterOption) (metric.Int64ObservableUpDownCounter, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Int64ObservableUpDownCounter(name, options...)
|
||||
}
|
||||
|
@ -197,7 +195,7 @@ func (m *meter) Int64ObservableUpDownCounter(name string, options ...instrument.
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Int64ObservableGauge(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableGauge, error) {
|
||||
func (m *meter) Int64ObservableGauge(name string, options ...metric.Int64ObservableGaugeOption) (metric.Int64ObservableGauge, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Int64ObservableGauge(name, options...)
|
||||
}
|
||||
|
@ -208,7 +206,7 @@ func (m *meter) Int64ObservableGauge(name string, options ...instrument.Int64Obs
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Float64Counter(name string, options ...instrument.Float64Option) (instrument.Float64Counter, error) {
|
||||
func (m *meter) Float64Counter(name string, options ...metric.Float64CounterOption) (metric.Float64Counter, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Float64Counter(name, options...)
|
||||
}
|
||||
|
@ -219,7 +217,7 @@ func (m *meter) Float64Counter(name string, options ...instrument.Float64Option)
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Float64UpDownCounter(name string, options ...instrument.Float64Option) (instrument.Float64UpDownCounter, error) {
|
||||
func (m *meter) Float64UpDownCounter(name string, options ...metric.Float64UpDownCounterOption) (metric.Float64UpDownCounter, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Float64UpDownCounter(name, options...)
|
||||
}
|
||||
|
@ -230,7 +228,7 @@ func (m *meter) Float64UpDownCounter(name string, options ...instrument.Float64O
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Float64Histogram(name string, options ...instrument.Float64Option) (instrument.Float64Histogram, error) {
|
||||
func (m *meter) Float64Histogram(name string, options ...metric.Float64HistogramOption) (metric.Float64Histogram, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Float64Histogram(name, options...)
|
||||
}
|
||||
|
@ -241,7 +239,7 @@ func (m *meter) Float64Histogram(name string, options ...instrument.Float64Optio
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Float64ObservableCounter(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableCounter, error) {
|
||||
func (m *meter) Float64ObservableCounter(name string, options ...metric.Float64ObservableCounterOption) (metric.Float64ObservableCounter, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Float64ObservableCounter(name, options...)
|
||||
}
|
||||
|
@ -252,7 +250,7 @@ func (m *meter) Float64ObservableCounter(name string, options ...instrument.Floa
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Float64ObservableUpDownCounter(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableUpDownCounter, error) {
|
||||
func (m *meter) Float64ObservableUpDownCounter(name string, options ...metric.Float64ObservableUpDownCounterOption) (metric.Float64ObservableUpDownCounter, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Float64ObservableUpDownCounter(name, options...)
|
||||
}
|
||||
|
@ -263,7 +261,7 @@ func (m *meter) Float64ObservableUpDownCounter(name string, options ...instrumen
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Float64ObservableGauge(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableGauge, error) {
|
||||
func (m *meter) Float64ObservableGauge(name string, options ...metric.Float64ObservableGaugeOption) (metric.Float64ObservableGauge, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Float64ObservableGauge(name, options...)
|
||||
}
|
||||
|
@ -275,7 +273,7 @@ func (m *meter) Float64ObservableGauge(name string, options ...instrument.Float6
|
|||
}
|
||||
|
||||
// RegisterCallback captures the function that will be called during Collect.
|
||||
func (m *meter) RegisterCallback(f metric.Callback, insts ...instrument.Asynchronous) (metric.Registration, error) {
|
||||
func (m *meter) RegisterCallback(f metric.Callback, insts ...metric.Observable) (metric.Registration, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
insts = unwrapInstruments(insts)
|
||||
return del.RegisterCallback(f, insts...)
|
||||
|
@ -296,11 +294,11 @@ func (m *meter) RegisterCallback(f metric.Callback, insts ...instrument.Asynchro
|
|||
}
|
||||
|
||||
type wrapped interface {
|
||||
unwrap() instrument.Asynchronous
|
||||
unwrap() metric.Observable
|
||||
}
|
||||
|
||||
func unwrapInstruments(instruments []instrument.Asynchronous) []instrument.Asynchronous {
|
||||
out := make([]instrument.Asynchronous, 0, len(instruments))
|
||||
func unwrapInstruments(instruments []metric.Observable) []metric.Observable {
|
||||
out := make([]metric.Observable, 0, len(instruments))
|
||||
|
||||
for _, inst := range instruments {
|
||||
if in, ok := inst.(wrapped); ok {
|
||||
|
@ -314,7 +312,9 @@ func unwrapInstruments(instruments []instrument.Asynchronous) []instrument.Async
|
|||
}
|
||||
|
||||
type registration struct {
|
||||
instruments []instrument.Asynchronous
|
||||
embedded.Registration
|
||||
|
||||
instruments []metric.Observable
|
||||
function metric.Callback
|
||||
|
||||
unreg func() error
|
||||
|
@ -334,7 +334,7 @@ func (c *registration) setDelegate(m metric.Meter) {
|
|||
|
||||
reg, err := m.RegisterCallback(c.function, insts...)
|
||||
if err != nil {
|
||||
otel.Handle(err)
|
||||
GetErrorHandler().Handle(err)
|
||||
}
|
||||
|
||||
c.unreg = reg.Unregister
|
45
vendor/go.opentelemetry.io/otel/internal/global/state.go
generated
vendored
45
vendor/go.opentelemetry.io/otel/internal/global/state.go
generated
vendored
|
@ -19,6 +19,7 @@ import (
|
|||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/propagation"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
@ -31,14 +32,20 @@ type (
|
|||
propagatorsHolder struct {
|
||||
tm propagation.TextMapPropagator
|
||||
}
|
||||
|
||||
meterProviderHolder struct {
|
||||
mp metric.MeterProvider
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
globalTracer = defaultTracerValue()
|
||||
globalPropagators = defaultPropagatorsValue()
|
||||
globalTracer = defaultTracerValue()
|
||||
globalPropagators = defaultPropagatorsValue()
|
||||
globalMeterProvider = defaultMeterProvider()
|
||||
|
||||
delegateTraceOnce sync.Once
|
||||
delegateTextMapPropagatorOnce sync.Once
|
||||
delegateMeterOnce sync.Once
|
||||
)
|
||||
|
||||
// TracerProvider is the internal implementation for global.TracerProvider.
|
||||
|
@ -102,6 +109,34 @@ func SetTextMapPropagator(p propagation.TextMapPropagator) {
|
|||
globalPropagators.Store(propagatorsHolder{tm: p})
|
||||
}
|
||||
|
||||
// MeterProvider is the internal implementation for global.MeterProvider.
|
||||
func MeterProvider() metric.MeterProvider {
|
||||
return globalMeterProvider.Load().(meterProviderHolder).mp
|
||||
}
|
||||
|
||||
// SetMeterProvider is the internal implementation for global.SetMeterProvider.
|
||||
func SetMeterProvider(mp metric.MeterProvider) {
|
||||
current := MeterProvider()
|
||||
if _, cOk := current.(*meterProvider); cOk {
|
||||
if _, mpOk := mp.(*meterProvider); mpOk && current == mp {
|
||||
// Do not assign the default delegating MeterProvider to delegate
|
||||
// to itself.
|
||||
Error(
|
||||
errors.New("no delegate configured in meter provider"),
|
||||
"Setting meter provider to it's current value. No delegate will be configured",
|
||||
)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
delegateMeterOnce.Do(func() {
|
||||
if def, ok := current.(*meterProvider); ok {
|
||||
def.setDelegate(mp)
|
||||
}
|
||||
})
|
||||
globalMeterProvider.Store(meterProviderHolder{mp: mp})
|
||||
}
|
||||
|
||||
func defaultTracerValue() *atomic.Value {
|
||||
v := &atomic.Value{}
|
||||
v.Store(tracerProviderHolder{tp: &tracerProvider{}})
|
||||
|
@ -113,3 +148,9 @@ func defaultPropagatorsValue() *atomic.Value {
|
|||
v.Store(propagatorsHolder{tm: newTextMapPropagator()})
|
||||
return v
|
||||
}
|
||||
|
||||
func defaultMeterProvider() *atomic.Value {
|
||||
v := &atomic.Value{}
|
||||
v.Store(meterProviderHolder{mp: &meterProvider{}})
|
||||
return v
|
||||
}
|
||||
|
|
53
vendor/go.opentelemetry.io/otel/metric.go
generated
vendored
Normal file
53
vendor/go.opentelemetry.io/otel/metric.go
generated
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
// 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 otel // import "go.opentelemetry.io/otel"
|
||||
|
||||
import (
|
||||
"go.opentelemetry.io/otel/internal/global"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
)
|
||||
|
||||
// Meter returns a Meter from the global MeterProvider. The name must be the
|
||||
// name of the library providing instrumentation. This name may be the same as
|
||||
// the instrumented code only if that code provides built-in instrumentation.
|
||||
// If the name is empty, then a implementation defined default name will be
|
||||
// used instead.
|
||||
//
|
||||
// If this is called before a global MeterProvider is registered the returned
|
||||
// Meter will be a No-op implementation of a Meter. When a global MeterProvider
|
||||
// is registered for the first time, the returned Meter, and all the
|
||||
// instruments it has created or will create, are recreated automatically from
|
||||
// the new MeterProvider.
|
||||
//
|
||||
// This is short for GetMeterProvider().Meter(name).
|
||||
func Meter(name string, opts ...metric.MeterOption) metric.Meter {
|
||||
return GetMeterProvider().Meter(name, opts...)
|
||||
}
|
||||
|
||||
// GetMeterProvider returns the registered global meter provider.
|
||||
//
|
||||
// If no global GetMeterProvider has been registered, a No-op GetMeterProvider
|
||||
// implementation is returned. When a global GetMeterProvider is registered for
|
||||
// the first time, the returned GetMeterProvider, and all the Meters it has
|
||||
// created or will create, are recreated automatically from the new
|
||||
// GetMeterProvider.
|
||||
func GetMeterProvider() metric.MeterProvider {
|
||||
return global.MeterProvider()
|
||||
}
|
||||
|
||||
// SetMeterProvider registers mp as the global MeterProvider.
|
||||
func SetMeterProvider(mp metric.MeterProvider) {
|
||||
global.SetMeterProvider(mp)
|
||||
}
|
271
vendor/go.opentelemetry.io/otel/metric/asyncfloat64.go
generated
vendored
Normal file
271
vendor/go.opentelemetry.io/otel/metric/asyncfloat64.go
generated
vendored
Normal file
|
@ -0,0 +1,271 @@
|
|||
// 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 metric // import "go.opentelemetry.io/otel/metric"
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/metric/embedded"
|
||||
)
|
||||
|
||||
// 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 {
|
||||
Observable
|
||||
|
||||
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. See
|
||||
// package documentation on API implementation for information on how to set
|
||||
// default behavior for
|
||||
// unimplemented methods.
|
||||
type Float64ObservableCounter interface {
|
||||
// Users of the interface can ignore this. This embedded type is only used
|
||||
// by implementations of this interface. See the "API Implementations"
|
||||
// section of the package documentation for more information.
|
||||
embedded.Float64ObservableCounter
|
||||
|
||||
Float64Observable
|
||||
}
|
||||
|
||||
// Float64ObservableCounterConfig contains options for asynchronous counter
|
||||
// instruments that record int64 values.
|
||||
type Float64ObservableCounterConfig struct {
|
||||
description string
|
||||
unit string
|
||||
callbacks []Float64Callback
|
||||
}
|
||||
|
||||
// NewFloat64ObservableCounterConfig returns a new
|
||||
// [Float64ObservableCounterConfig] with all opts applied.
|
||||
func NewFloat64ObservableCounterConfig(opts ...Float64ObservableCounterOption) Float64ObservableCounterConfig {
|
||||
var config Float64ObservableCounterConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyFloat64ObservableCounter(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the configured description.
|
||||
func (c Float64ObservableCounterConfig) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the configured unit.
|
||||
func (c Float64ObservableCounterConfig) Unit() string {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Callbacks returns the configured callbacks.
|
||||
func (c Float64ObservableCounterConfig) Callbacks() []Float64Callback {
|
||||
return c.callbacks
|
||||
}
|
||||
|
||||
// Float64ObservableCounterOption applies options to a
|
||||
// [Float64ObservableCounterConfig]. See [Float64ObservableOption] and
|
||||
// [InstrumentOption] for other options that can be used as a
|
||||
// Float64ObservableCounterOption.
|
||||
type Float64ObservableCounterOption interface {
|
||||
applyFloat64ObservableCounter(Float64ObservableCounterConfig) Float64ObservableCounterConfig
|
||||
}
|
||||
|
||||
// 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. See
|
||||
// package documentation on API implementation for information on how to set
|
||||
// default behavior for unimplemented methods.
|
||||
type Float64ObservableUpDownCounter interface {
|
||||
// Users of the interface can ignore this. This embedded type is only used
|
||||
// by implementations of this interface. See the "API Implementations"
|
||||
// section of the package documentation for more information.
|
||||
embedded.Float64ObservableUpDownCounter
|
||||
|
||||
Float64Observable
|
||||
}
|
||||
|
||||
// Float64ObservableUpDownCounterConfig contains options for asynchronous
|
||||
// counter instruments that record int64 values.
|
||||
type Float64ObservableUpDownCounterConfig struct {
|
||||
description string
|
||||
unit string
|
||||
callbacks []Float64Callback
|
||||
}
|
||||
|
||||
// NewFloat64ObservableUpDownCounterConfig returns a new
|
||||
// [Float64ObservableUpDownCounterConfig] with all opts applied.
|
||||
func NewFloat64ObservableUpDownCounterConfig(opts ...Float64ObservableUpDownCounterOption) Float64ObservableUpDownCounterConfig {
|
||||
var config Float64ObservableUpDownCounterConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyFloat64ObservableUpDownCounter(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the configured description.
|
||||
func (c Float64ObservableUpDownCounterConfig) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the configured unit.
|
||||
func (c Float64ObservableUpDownCounterConfig) Unit() string {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Callbacks returns the configured callbacks.
|
||||
func (c Float64ObservableUpDownCounterConfig) Callbacks() []Float64Callback {
|
||||
return c.callbacks
|
||||
}
|
||||
|
||||
// Float64ObservableUpDownCounterOption applies options to a
|
||||
// [Float64ObservableUpDownCounterConfig]. See [Float64ObservableOption] and
|
||||
// [InstrumentOption] for other options that can be used as a
|
||||
// Float64ObservableUpDownCounterOption.
|
||||
type Float64ObservableUpDownCounterOption interface {
|
||||
applyFloat64ObservableUpDownCounter(Float64ObservableUpDownCounterConfig) Float64ObservableUpDownCounterConfig
|
||||
}
|
||||
|
||||
// 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. See
|
||||
// package documentation on API implementation for information on how to set
|
||||
// default behavior for unimplemented methods.
|
||||
type Float64ObservableGauge interface {
|
||||
// Users of the interface can ignore this. This embedded type is only used
|
||||
// by implementations of this interface. See the "API Implementations"
|
||||
// section of the package documentation for more information.
|
||||
embedded.Float64ObservableGauge
|
||||
|
||||
Float64Observable
|
||||
}
|
||||
|
||||
// Float64ObservableGaugeConfig contains options for asynchronous counter
|
||||
// instruments that record int64 values.
|
||||
type Float64ObservableGaugeConfig struct {
|
||||
description string
|
||||
unit string
|
||||
callbacks []Float64Callback
|
||||
}
|
||||
|
||||
// NewFloat64ObservableGaugeConfig returns a new [Float64ObservableGaugeConfig]
|
||||
// with all opts applied.
|
||||
func NewFloat64ObservableGaugeConfig(opts ...Float64ObservableGaugeOption) Float64ObservableGaugeConfig {
|
||||
var config Float64ObservableGaugeConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyFloat64ObservableGauge(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the configured description.
|
||||
func (c Float64ObservableGaugeConfig) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the configured unit.
|
||||
func (c Float64ObservableGaugeConfig) Unit() string {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Callbacks returns the configured callbacks.
|
||||
func (c Float64ObservableGaugeConfig) Callbacks() []Float64Callback {
|
||||
return c.callbacks
|
||||
}
|
||||
|
||||
// Float64ObservableGaugeOption applies options to a
|
||||
// [Float64ObservableGaugeConfig]. See [Float64ObservableOption] and
|
||||
// [InstrumentOption] for other options that can be used as a
|
||||
// Float64ObservableGaugeOption.
|
||||
type Float64ObservableGaugeOption interface {
|
||||
applyFloat64ObservableGauge(Float64ObservableGaugeConfig) Float64ObservableGaugeConfig
|
||||
}
|
||||
|
||||
// Float64Observer is a recorder of float64 measurements.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// package documentation on API implementation for information on how to set
|
||||
// default behavior for unimplemented methods.
|
||||
type Float64Observer interface {
|
||||
// Users of the interface can ignore this. This embedded type is only used
|
||||
// by implementations of this interface. See the "API Implementations"
|
||||
// section of the package documentation for more information.
|
||||
embedded.Float64Observer
|
||||
|
||||
// Observe records the float64 value.
|
||||
//
|
||||
// Use the WithAttributeSet (or, if performance is not a concern,
|
||||
// the WithAttributes) option to include measurement attributes.
|
||||
Observe(value float64, options ...ObserveOption)
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
// Float64ObservableOption applies options to float64 Observer instruments.
|
||||
type Float64ObservableOption interface {
|
||||
Float64ObservableCounterOption
|
||||
Float64ObservableUpDownCounterOption
|
||||
Float64ObservableGaugeOption
|
||||
}
|
||||
|
||||
type float64CallbackOpt struct {
|
||||
cback Float64Callback
|
||||
}
|
||||
|
||||
func (o float64CallbackOpt) applyFloat64ObservableCounter(cfg Float64ObservableCounterConfig) Float64ObservableCounterConfig {
|
||||
cfg.callbacks = append(cfg.callbacks, o.cback)
|
||||
return cfg
|
||||
}
|
||||
|
||||
func (o float64CallbackOpt) applyFloat64ObservableUpDownCounter(cfg Float64ObservableUpDownCounterConfig) Float64ObservableUpDownCounterConfig {
|
||||
cfg.callbacks = append(cfg.callbacks, o.cback)
|
||||
return cfg
|
||||
}
|
||||
|
||||
func (o float64CallbackOpt) applyFloat64ObservableGauge(cfg Float64ObservableGaugeConfig) Float64ObservableGaugeConfig {
|
||||
cfg.callbacks = append(cfg.callbacks, o.cback)
|
||||
return cfg
|
||||
}
|
||||
|
||||
// WithFloat64Callback adds callback to be called for an instrument.
|
||||
func WithFloat64Callback(callback Float64Callback) Float64ObservableOption {
|
||||
return float64CallbackOpt{callback}
|
||||
}
|
269
vendor/go.opentelemetry.io/otel/metric/asyncint64.go
generated
vendored
Normal file
269
vendor/go.opentelemetry.io/otel/metric/asyncint64.go
generated
vendored
Normal file
|
@ -0,0 +1,269 @@
|
|||
// 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 metric // import "go.opentelemetry.io/otel/metric"
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/metric/embedded"
|
||||
)
|
||||
|
||||
// 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 {
|
||||
Observable
|
||||
|
||||
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. See
|
||||
// package documentation on API implementation for information on how to set
|
||||
// default behavior for unimplemented methods.
|
||||
type Int64ObservableCounter interface {
|
||||
// Users of the interface can ignore this. This embedded type is only used
|
||||
// by implementations of this interface. See the "API Implementations"
|
||||
// section of the package documentation for more information.
|
||||
embedded.Int64ObservableCounter
|
||||
|
||||
Int64Observable
|
||||
}
|
||||
|
||||
// Int64ObservableCounterConfig contains options for asynchronous counter
|
||||
// instruments that record int64 values.
|
||||
type Int64ObservableCounterConfig struct {
|
||||
description string
|
||||
unit string
|
||||
callbacks []Int64Callback
|
||||
}
|
||||
|
||||
// NewInt64ObservableCounterConfig returns a new [Int64ObservableCounterConfig]
|
||||
// with all opts applied.
|
||||
func NewInt64ObservableCounterConfig(opts ...Int64ObservableCounterOption) Int64ObservableCounterConfig {
|
||||
var config Int64ObservableCounterConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyInt64ObservableCounter(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the configured description.
|
||||
func (c Int64ObservableCounterConfig) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the configured unit.
|
||||
func (c Int64ObservableCounterConfig) Unit() string {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Callbacks returns the configured callbacks.
|
||||
func (c Int64ObservableCounterConfig) Callbacks() []Int64Callback {
|
||||
return c.callbacks
|
||||
}
|
||||
|
||||
// Int64ObservableCounterOption applies options to a
|
||||
// [Int64ObservableCounterConfig]. See [Int64ObservableOption] and
|
||||
// [InstrumentOption] for other options that can be used as an
|
||||
// Int64ObservableCounterOption.
|
||||
type Int64ObservableCounterOption interface {
|
||||
applyInt64ObservableCounter(Int64ObservableCounterConfig) Int64ObservableCounterConfig
|
||||
}
|
||||
|
||||
// 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. See
|
||||
// package documentation on API implementation for information on how to set
|
||||
// default behavior for unimplemented methods.
|
||||
type Int64ObservableUpDownCounter interface {
|
||||
// Users of the interface can ignore this. This embedded type is only used
|
||||
// by implementations of this interface. See the "API Implementations"
|
||||
// section of the package documentation for more information.
|
||||
embedded.Int64ObservableUpDownCounter
|
||||
|
||||
Int64Observable
|
||||
}
|
||||
|
||||
// Int64ObservableUpDownCounterConfig contains options for asynchronous counter
|
||||
// instruments that record int64 values.
|
||||
type Int64ObservableUpDownCounterConfig struct {
|
||||
description string
|
||||
unit string
|
||||
callbacks []Int64Callback
|
||||
}
|
||||
|
||||
// NewInt64ObservableUpDownCounterConfig returns a new
|
||||
// [Int64ObservableUpDownCounterConfig] with all opts applied.
|
||||
func NewInt64ObservableUpDownCounterConfig(opts ...Int64ObservableUpDownCounterOption) Int64ObservableUpDownCounterConfig {
|
||||
var config Int64ObservableUpDownCounterConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyInt64ObservableUpDownCounter(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the configured description.
|
||||
func (c Int64ObservableUpDownCounterConfig) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the configured unit.
|
||||
func (c Int64ObservableUpDownCounterConfig) Unit() string {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Callbacks returns the configured callbacks.
|
||||
func (c Int64ObservableUpDownCounterConfig) Callbacks() []Int64Callback {
|
||||
return c.callbacks
|
||||
}
|
||||
|
||||
// Int64ObservableUpDownCounterOption applies options to a
|
||||
// [Int64ObservableUpDownCounterConfig]. See [Int64ObservableOption] and
|
||||
// [InstrumentOption] for other options that can be used as an
|
||||
// Int64ObservableUpDownCounterOption.
|
||||
type Int64ObservableUpDownCounterOption interface {
|
||||
applyInt64ObservableUpDownCounter(Int64ObservableUpDownCounterConfig) Int64ObservableUpDownCounterConfig
|
||||
}
|
||||
|
||||
// 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. See
|
||||
// package documentation on API implementation for information on how to set
|
||||
// default behavior for unimplemented methods.
|
||||
type Int64ObservableGauge interface {
|
||||
// Users of the interface can ignore this. This embedded type is only used
|
||||
// by implementations of this interface. See the "API Implementations"
|
||||
// section of the package documentation for more information.
|
||||
embedded.Int64ObservableGauge
|
||||
|
||||
Int64Observable
|
||||
}
|
||||
|
||||
// Int64ObservableGaugeConfig contains options for asynchronous counter
|
||||
// instruments that record int64 values.
|
||||
type Int64ObservableGaugeConfig struct {
|
||||
description string
|
||||
unit string
|
||||
callbacks []Int64Callback
|
||||
}
|
||||
|
||||
// NewInt64ObservableGaugeConfig returns a new [Int64ObservableGaugeConfig]
|
||||
// with all opts applied.
|
||||
func NewInt64ObservableGaugeConfig(opts ...Int64ObservableGaugeOption) Int64ObservableGaugeConfig {
|
||||
var config Int64ObservableGaugeConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyInt64ObservableGauge(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the configured description.
|
||||
func (c Int64ObservableGaugeConfig) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the configured unit.
|
||||
func (c Int64ObservableGaugeConfig) Unit() string {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Callbacks returns the configured callbacks.
|
||||
func (c Int64ObservableGaugeConfig) Callbacks() []Int64Callback {
|
||||
return c.callbacks
|
||||
}
|
||||
|
||||
// Int64ObservableGaugeOption applies options to a
|
||||
// [Int64ObservableGaugeConfig]. See [Int64ObservableOption] and
|
||||
// [InstrumentOption] for other options that can be used as an
|
||||
// Int64ObservableGaugeOption.
|
||||
type Int64ObservableGaugeOption interface {
|
||||
applyInt64ObservableGauge(Int64ObservableGaugeConfig) Int64ObservableGaugeConfig
|
||||
}
|
||||
|
||||
// Int64Observer is a recorder of int64 measurements.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// package documentation on API implementation for information on how to set
|
||||
// default behavior for unimplemented methods.
|
||||
type Int64Observer interface {
|
||||
// Users of the interface can ignore this. This embedded type is only used
|
||||
// by implementations of this interface. See the "API Implementations"
|
||||
// section of the package documentation for more information.
|
||||
embedded.Int64Observer
|
||||
|
||||
// Observe records the int64 value.
|
||||
//
|
||||
// Use the WithAttributeSet (or, if performance is not a concern,
|
||||
// the WithAttributes) option to include measurement attributes.
|
||||
Observe(value int64, options ...ObserveOption)
|
||||
}
|
||||
|
||||
// Int64Callback is a function registered with a Meter that makes observations
|
||||
// for an 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
|
||||
// Int64Callbacks. 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
|
||||
|
||||
// Int64ObservableOption applies options to int64 Observer instruments.
|
||||
type Int64ObservableOption interface {
|
||||
Int64ObservableCounterOption
|
||||
Int64ObservableUpDownCounterOption
|
||||
Int64ObservableGaugeOption
|
||||
}
|
||||
|
||||
type int64CallbackOpt struct {
|
||||
cback Int64Callback
|
||||
}
|
||||
|
||||
func (o int64CallbackOpt) applyInt64ObservableCounter(cfg Int64ObservableCounterConfig) Int64ObservableCounterConfig {
|
||||
cfg.callbacks = append(cfg.callbacks, o.cback)
|
||||
return cfg
|
||||
}
|
||||
|
||||
func (o int64CallbackOpt) applyInt64ObservableUpDownCounter(cfg Int64ObservableUpDownCounterConfig) Int64ObservableUpDownCounterConfig {
|
||||
cfg.callbacks = append(cfg.callbacks, o.cback)
|
||||
return cfg
|
||||
}
|
||||
|
||||
func (o int64CallbackOpt) applyInt64ObservableGauge(cfg Int64ObservableGaugeConfig) Int64ObservableGaugeConfig {
|
||||
cfg.callbacks = append(cfg.callbacks, o.cback)
|
||||
return cfg
|
||||
}
|
||||
|
||||
// WithInt64Callback adds callback to be called for an instrument.
|
||||
func WithInt64Callback(callback Int64Callback) Int64ObservableOption {
|
||||
return int64CallbackOpt{callback}
|
||||
}
|
157
vendor/go.opentelemetry.io/otel/metric/doc.go
generated
vendored
157
vendor/go.opentelemetry.io/otel/metric/doc.go
generated
vendored
|
@ -13,11 +13,158 @@
|
|||
// limitations under the License.
|
||||
|
||||
/*
|
||||
Package metric provides an implementation of the metrics part of the
|
||||
OpenTelemetry API.
|
||||
Package metric provides the OpenTelemetry API used to measure metrics about
|
||||
source code operation.
|
||||
|
||||
This package is currently in a pre-GA phase. Backwards incompatible changes
|
||||
may be introduced in subsequent minor version releases as we work to track the
|
||||
evolving OpenTelemetry specification and user feedback.
|
||||
This API is separate from its implementation so the instrumentation built from
|
||||
it is reusable. See [go.opentelemetry.io/otel/sdk/metric] for the official
|
||||
OpenTelemetry implementation of this API.
|
||||
|
||||
All measurements made with this package are made via instruments. These
|
||||
instruments are created by a [Meter] which itself is created by a
|
||||
[MeterProvider]. Applications need to accept a [MeterProvider] implementation
|
||||
as a starting point when instrumenting. This can be done directly, or by using
|
||||
the OpenTelemetry global MeterProvider via [GetMeterProvider]. Using an
|
||||
appropriately named [Meter] from the accepted [MeterProvider], instrumentation
|
||||
can then be built from the [Meter]'s instruments.
|
||||
|
||||
# Instruments
|
||||
|
||||
Each instrument is designed to make measurements of a particular type. Broadly,
|
||||
all instruments fall into two overlapping logical categories: asynchronous or
|
||||
synchronous, and int64 or float64.
|
||||
|
||||
All synchronous instruments ([Int64Counter], [Int64UpDownCounter],
|
||||
[Int64Histogram], [Float64Counter], [Float64UpDownCounter], and
|
||||
[Float64Histogram]) are used to measure the operation and performance of source
|
||||
code during the source code execution. These instruments only make measurements
|
||||
when the source code they instrument is run.
|
||||
|
||||
All asynchronous instruments ([Int64ObservableCounter],
|
||||
[Int64ObservableUpDownCounter], [Int64ObservableGauge],
|
||||
[Float64ObservableCounter], [Float64ObservableUpDownCounter], and
|
||||
[Float64ObservableGauge]) are used to measure metrics outside of the execution
|
||||
of source code. They are said to make "observations" via a callback function
|
||||
called once every measurement collection cycle.
|
||||
|
||||
Each instrument is also grouped by the value type it measures. Either int64 or
|
||||
float64. The value being measured will dictate which instrument in these
|
||||
categories to use.
|
||||
|
||||
Outside of these two broad categories, instruments are described by the
|
||||
function they are designed to serve. All Counters ([Int64Counter],
|
||||
[Float64Counter], [Int64ObservableCounter], and [Float64ObservableCounter]) are
|
||||
designed to measure values that never decrease in value, but instead only
|
||||
incrementally increase in value. UpDownCounters ([Int64UpDownCounter],
|
||||
[Float64UpDownCounter], [Int64ObservableUpDownCounter], and
|
||||
[Float64ObservableUpDownCounter]) on the other hand, are designed to measure
|
||||
values that can increase and decrease. When more information needs to be
|
||||
conveyed about all the synchronous measurements made during a collection cycle,
|
||||
a Histogram ([Int64Histogram] and [Float64Histogram]) should be used. Finally,
|
||||
when just the most recent measurement needs to be conveyed about an
|
||||
asynchronous measurement, a Gauge ([Int64ObservableGauge] and
|
||||
[Float64ObservableGauge]) should be used.
|
||||
|
||||
See the [OpenTelemetry documentation] for more information about instruments
|
||||
and their intended use.
|
||||
|
||||
# Measurements
|
||||
|
||||
Measurements are made by recording values and information about the values with
|
||||
an instrument. How these measurements are recorded depends on the instrument.
|
||||
|
||||
Measurements for synchronous instruments ([Int64Counter], [Int64UpDownCounter],
|
||||
[Int64Histogram], [Float64Counter], [Float64UpDownCounter], and
|
||||
[Float64Histogram]) are recorded using the instrument methods directly. All
|
||||
counter instruments have an Add method that is used to measure an increment
|
||||
value, and all histogram instruments have a Record method to measure a data
|
||||
point.
|
||||
|
||||
Asynchronous instruments ([Int64ObservableCounter],
|
||||
[Int64ObservableUpDownCounter], [Int64ObservableGauge],
|
||||
[Float64ObservableCounter], [Float64ObservableUpDownCounter], and
|
||||
[Float64ObservableGauge]) record measurements within a callback function. The
|
||||
callback is registered with the Meter which ensures the callback is called once
|
||||
per collection cycle. A callback can be registered two ways: during the
|
||||
instrument's creation using an option, or later using the RegisterCallback
|
||||
method of the [Meter] that created the instrument.
|
||||
|
||||
If the following criteria are met, an option ([WithInt64Callback] or
|
||||
[WithFloat64Callback]) can be used during the asynchronous instrument's
|
||||
creation to register a callback ([Int64Callback] or [Float64Callback],
|
||||
respectively):
|
||||
|
||||
- The measurement process is known when the instrument is created
|
||||
- Only that instrument will make a measurement within the callback
|
||||
- The callback never needs to be unregistered
|
||||
|
||||
If the criteria are not met, use the RegisterCallback method of the [Meter] that
|
||||
created the instrument to register a [Callback].
|
||||
|
||||
# API Implementations
|
||||
|
||||
This package does not conform to the standard Go versioning policy, all of its
|
||||
interfaces may have methods added to them without a package major version bump.
|
||||
This non-standard API evolution could surprise an uninformed implementation
|
||||
author. They could unknowingly build their implementation in a way that would
|
||||
result in a runtime panic for their users that update to the new API.
|
||||
|
||||
The API is designed to help inform an instrumentation author about this
|
||||
non-standard API evolution. It requires them to choose a default behavior for
|
||||
unimplemented interface methods. There are three behavior choices they can
|
||||
make:
|
||||
|
||||
- Compilation failure
|
||||
- Panic
|
||||
- Default to another implementation
|
||||
|
||||
All interfaces in this API embed a corresponding interface from
|
||||
[go.opentelemetry.io/otel/metric/embedded]. If an author wants the default
|
||||
behavior of their implementations to be a compilation failure, signaling to
|
||||
their users they need to update to the latest version of that implementation,
|
||||
they need to embed the corresponding interface from
|
||||
[go.opentelemetry.io/otel/metric/embedded] in their implementation. For
|
||||
example,
|
||||
|
||||
import "go.opentelemetry.io/otel/metric/embedded"
|
||||
|
||||
type MeterProvider struct {
|
||||
embedded.MeterProvider
|
||||
// ...
|
||||
}
|
||||
|
||||
If an author wants the default behavior of their implementations to a panic,
|
||||
they need to embed the API interface directly.
|
||||
|
||||
import "go.opentelemetry.io/otel/metric"
|
||||
|
||||
type MeterProvider struct {
|
||||
metric.MeterProvider
|
||||
// ...
|
||||
}
|
||||
|
||||
This is not a recommended behavior as it could lead to publishing packages that
|
||||
contain runtime panics when users update other package that use newer versions
|
||||
of [go.opentelemetry.io/otel/metric].
|
||||
|
||||
Finally, an author can embed another implementation in theirs. The embedded
|
||||
implementation will be used for methods not defined by the author. For example,
|
||||
an author who want to default to silently dropping the call can use
|
||||
[go.opentelemetry.io/otel/metric/noop]:
|
||||
|
||||
import "go.opentelemetry.io/otel/metric/noop"
|
||||
|
||||
type MeterProvider struct {
|
||||
noop.MeterProvider
|
||||
// ...
|
||||
}
|
||||
|
||||
It is strongly recommended that authors only embed
|
||||
[go.opentelemetry.io/otel/metric/noop] if they choose this default behavior.
|
||||
That implementation is the only one OpenTelemetry authors can guarantee will
|
||||
fully implement all the API interfaces when a user updates their API.
|
||||
|
||||
[OpenTelemetry documentation]: https://opentelemetry.io/docs/concepts/signals/metrics/
|
||||
[GetMeterProvider]: https://pkg.go.dev/go.opentelemetry.io/otel#GetMeterProvider
|
||||
*/
|
||||
package metric // import "go.opentelemetry.io/otel/metric"
|
||||
|
|
234
vendor/go.opentelemetry.io/otel/metric/embedded/embedded.go
generated
vendored
Normal file
234
vendor/go.opentelemetry.io/otel/metric/embedded/embedded.go
generated
vendored
Normal file
|
@ -0,0 +1,234 @@
|
|||
// 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 embedded provides interfaces embedded within the [OpenTelemetry
|
||||
// metric API].
|
||||
//
|
||||
// Implementers of the [OpenTelemetry metric API] can embed the relevant type
|
||||
// from this package into their implementation directly. Doing so will result
|
||||
// in a compilation error for users when the [OpenTelemetry metric API] is
|
||||
// extended (which is something that can happen without a major version bump of
|
||||
// the API package).
|
||||
//
|
||||
// [OpenTelemetry metric API]: https://pkg.go.dev/go.opentelemetry.io/otel/metric
|
||||
package embedded // import "go.opentelemetry.io/otel/metric/embedded"
|
||||
|
||||
// MeterProvider is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.MeterProvider].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.MeterProvider] if you want users to
|
||||
// experience a compilation error, signaling they need to update to your latest
|
||||
// implementation, when the [go.opentelemetry.io/otel/metric.MeterProvider]
|
||||
// interface is extended (which is something that can happen without a major
|
||||
// version bump of the API package).
|
||||
type MeterProvider interface{ meterProvider() }
|
||||
|
||||
// Meter is embedded in [go.opentelemetry.io/otel/metric.Meter].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Meter] if you want users to experience a
|
||||
// compilation error, signaling they need to update to your latest
|
||||
// implementation, when the [go.opentelemetry.io/otel/metric.Meter] interface
|
||||
// is extended (which is something that can happen without a major version bump
|
||||
// of the API package).
|
||||
type Meter interface{ meter() }
|
||||
|
||||
// Float64Observer is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Float64Observer].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Float64Observer] if you want
|
||||
// users to experience a compilation error, signaling they need to update to
|
||||
// your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Float64Observer] interface is
|
||||
// extended (which is something that can happen without a major version bump of
|
||||
// the API package).
|
||||
type Float64Observer interface{ float64Observer() }
|
||||
|
||||
// Int64Observer is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Int64Observer].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Int64Observer] if you want users
|
||||
// to experience a compilation error, signaling they need to update to your
|
||||
// latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Int64Observer] interface is
|
||||
// extended (which is something that can happen without a major version bump of
|
||||
// the API package).
|
||||
type Int64Observer interface{ int64Observer() }
|
||||
|
||||
// Observer is embedded in [go.opentelemetry.io/otel/metric.Observer].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Observer] if you want users to experience a
|
||||
// compilation error, signaling they need to update to your latest
|
||||
// implementation, when the [go.opentelemetry.io/otel/metric.Observer]
|
||||
// interface is extended (which is something that can happen without a major
|
||||
// version bump of the API package).
|
||||
type Observer interface{ observer() }
|
||||
|
||||
// Registration is embedded in [go.opentelemetry.io/otel/metric.Registration].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Registration] if you want users to
|
||||
// experience a compilation error, signaling they need to update to your latest
|
||||
// implementation, when the [go.opentelemetry.io/otel/metric.Registration]
|
||||
// interface is extended (which is something that can happen without a major
|
||||
// version bump of the API package).
|
||||
type Registration interface{ registration() }
|
||||
|
||||
// Float64Counter is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Float64Counter].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Float64Counter] if you want
|
||||
// users to experience a compilation error, signaling they need to update to
|
||||
// your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Float64Counter] interface is
|
||||
// extended (which is something that can happen without a major version bump of
|
||||
// the API package).
|
||||
type Float64Counter interface{ float64Counter() }
|
||||
|
||||
// Float64Histogram is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Float64Histogram].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Float64Histogram] if you want
|
||||
// users to experience a compilation error, signaling they need to update to
|
||||
// your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Float64Histogram] interface is
|
||||
// extended (which is something that can happen without a major version bump of
|
||||
// the API package).
|
||||
type Float64Histogram interface{ float64Histogram() }
|
||||
|
||||
// Float64ObservableCounter is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableCounter].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableCounter] if you
|
||||
// want users to experience a compilation error, signaling they need to update
|
||||
// to your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableCounter]
|
||||
// interface is extended (which is something that can happen without a major
|
||||
// version bump of the API package).
|
||||
type Float64ObservableCounter interface{ float64ObservableCounter() }
|
||||
|
||||
// Float64ObservableGauge is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableGauge].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableGauge] if you
|
||||
// want users to experience a compilation error, signaling they need to update
|
||||
// to your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableGauge]
|
||||
// interface is extended (which is something that can happen without a major
|
||||
// version bump of the API package).
|
||||
type Float64ObservableGauge interface{ float64ObservableGauge() }
|
||||
|
||||
// Float64ObservableUpDownCounter is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableUpDownCounter].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableUpDownCounter]
|
||||
// if you want users to experience a compilation error, signaling they need to
|
||||
// update to your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableUpDownCounter]
|
||||
// interface is extended (which is something that can happen without a major
|
||||
// version bump of the API package).
|
||||
type Float64ObservableUpDownCounter interface{ float64ObservableUpDownCounter() }
|
||||
|
||||
// Float64UpDownCounter is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Float64UpDownCounter].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Float64UpDownCounter] if you
|
||||
// want users to experience a compilation error, signaling they need to update
|
||||
// to your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Float64UpDownCounter] interface
|
||||
// is extended (which is something that can happen without a major version bump
|
||||
// of the API package).
|
||||
type Float64UpDownCounter interface{ float64UpDownCounter() }
|
||||
|
||||
// Int64Counter is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Int64Counter].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Int64Counter] if you want users
|
||||
// to experience a compilation error, signaling they need to update to your
|
||||
// latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Int64Counter] interface is
|
||||
// extended (which is something that can happen without a major version bump of
|
||||
// the API package).
|
||||
type Int64Counter interface{ int64Counter() }
|
||||
|
||||
// Int64Histogram is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Int64Histogram].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Int64Histogram] if you want
|
||||
// users to experience a compilation error, signaling they need to update to
|
||||
// your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Int64Histogram] interface is
|
||||
// extended (which is something that can happen without a major version bump of
|
||||
// the API package).
|
||||
type Int64Histogram interface{ int64Histogram() }
|
||||
|
||||
// Int64ObservableCounter is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableCounter].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableCounter] if you
|
||||
// want users to experience a compilation error, signaling they need to update
|
||||
// to your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableCounter]
|
||||
// interface is extended (which is something that can happen without a major
|
||||
// version bump of the API package).
|
||||
type Int64ObservableCounter interface{ int64ObservableCounter() }
|
||||
|
||||
// Int64ObservableGauge is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableGauge].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableGauge] if you
|
||||
// want users to experience a compilation error, signaling they need to update
|
||||
// to your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableGauge] interface
|
||||
// is extended (which is something that can happen without a major version bump
|
||||
// of the API package).
|
||||
type Int64ObservableGauge interface{ int64ObservableGauge() }
|
||||
|
||||
// Int64ObservableUpDownCounter is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableUpDownCounter].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableUpDownCounter] if
|
||||
// you want users to experience a compilation error, signaling they need to
|
||||
// update to your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableUpDownCounter]
|
||||
// interface is extended (which is something that can happen without a major
|
||||
// version bump of the API package).
|
||||
type Int64ObservableUpDownCounter interface{ int64ObservableUpDownCounter() }
|
||||
|
||||
// Int64UpDownCounter is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Int64UpDownCounter].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Int64UpDownCounter] if you want
|
||||
// users to experience a compilation error, signaling they need to update to
|
||||
// your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Int64UpDownCounter] interface is
|
||||
// extended (which is something that can happen without a major version bump of
|
||||
// the API package).
|
||||
type Int64UpDownCounter interface{ int64UpDownCounter() }
|
42
vendor/go.opentelemetry.io/otel/metric/global/global.go
generated
vendored
42
vendor/go.opentelemetry.io/otel/metric/global/global.go
generated
vendored
|
@ -1,42 +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 global // import "go.opentelemetry.io/otel/metric/global"
|
||||
|
||||
import (
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/internal/global"
|
||||
)
|
||||
|
||||
// Meter returns a Meter from the global MeterProvider. The
|
||||
// instrumentationName must be the name of the library providing
|
||||
// instrumentation. This name may be the same as the instrumented code only if
|
||||
// that code provides built-in instrumentation. If the instrumentationName is
|
||||
// empty, then a implementation defined default name will be used instead.
|
||||
//
|
||||
// This is short for MeterProvider().Meter(name).
|
||||
func Meter(instrumentationName string, opts ...metric.MeterOption) metric.Meter {
|
||||
return MeterProvider().Meter(instrumentationName, opts...)
|
||||
}
|
||||
|
||||
// MeterProvider returns the registered global meter provider.
|
||||
// If none is registered then a No-op MeterProvider is returned.
|
||||
func MeterProvider() metric.MeterProvider {
|
||||
return global.MeterProvider()
|
||||
}
|
||||
|
||||
// SetMeterProvider registers `mp` as the global meter provider.
|
||||
func SetMeterProvider(mp metric.MeterProvider) {
|
||||
global.SetMeterProvider(mp)
|
||||
}
|
334
vendor/go.opentelemetry.io/otel/metric/instrument.go
generated
vendored
Normal file
334
vendor/go.opentelemetry.io/otel/metric/instrument.go
generated
vendored
Normal file
|
@ -0,0 +1,334 @@
|
|||
// 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 metric // import "go.opentelemetry.io/otel/metric"
|
||||
|
||||
import "go.opentelemetry.io/otel/attribute"
|
||||
|
||||
// Observable is used as a grouping mechanism for all instruments that are
|
||||
// updated within a Callback.
|
||||
type Observable interface {
|
||||
observable()
|
||||
}
|
||||
|
||||
// InstrumentOption applies options to all instruments.
|
||||
type InstrumentOption interface {
|
||||
Int64CounterOption
|
||||
Int64UpDownCounterOption
|
||||
Int64HistogramOption
|
||||
Int64ObservableCounterOption
|
||||
Int64ObservableUpDownCounterOption
|
||||
Int64ObservableGaugeOption
|
||||
|
||||
Float64CounterOption
|
||||
Float64UpDownCounterOption
|
||||
Float64HistogramOption
|
||||
Float64ObservableCounterOption
|
||||
Float64ObservableUpDownCounterOption
|
||||
Float64ObservableGaugeOption
|
||||
}
|
||||
|
||||
type descOpt string
|
||||
|
||||
func (o descOpt) applyFloat64Counter(c Float64CounterConfig) Float64CounterConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyFloat64UpDownCounter(c Float64UpDownCounterConfig) Float64UpDownCounterConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyFloat64Histogram(c Float64HistogramConfig) Float64HistogramConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyFloat64ObservableCounter(c Float64ObservableCounterConfig) Float64ObservableCounterConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyFloat64ObservableUpDownCounter(c Float64ObservableUpDownCounterConfig) Float64ObservableUpDownCounterConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyFloat64ObservableGauge(c Float64ObservableGaugeConfig) Float64ObservableGaugeConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyInt64Counter(c Int64CounterConfig) Int64CounterConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyInt64UpDownCounter(c Int64UpDownCounterConfig) Int64UpDownCounterConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyInt64Histogram(c Int64HistogramConfig) Int64HistogramConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyInt64ObservableCounter(c Int64ObservableCounterConfig) Int64ObservableCounterConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyInt64ObservableUpDownCounter(c Int64ObservableUpDownCounterConfig) Int64ObservableUpDownCounterConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyInt64ObservableGauge(c Int64ObservableGaugeConfig) Int64ObservableGaugeConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
// WithDescription sets the instrument description.
|
||||
func WithDescription(desc string) InstrumentOption { return descOpt(desc) }
|
||||
|
||||
type unitOpt string
|
||||
|
||||
func (o unitOpt) applyFloat64Counter(c Float64CounterConfig) Float64CounterConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyFloat64UpDownCounter(c Float64UpDownCounterConfig) Float64UpDownCounterConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyFloat64Histogram(c Float64HistogramConfig) Float64HistogramConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyFloat64ObservableCounter(c Float64ObservableCounterConfig) Float64ObservableCounterConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyFloat64ObservableUpDownCounter(c Float64ObservableUpDownCounterConfig) Float64ObservableUpDownCounterConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyFloat64ObservableGauge(c Float64ObservableGaugeConfig) Float64ObservableGaugeConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyInt64Counter(c Int64CounterConfig) Int64CounterConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyInt64UpDownCounter(c Int64UpDownCounterConfig) Int64UpDownCounterConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyInt64Histogram(c Int64HistogramConfig) Int64HistogramConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyInt64ObservableCounter(c Int64ObservableCounterConfig) Int64ObservableCounterConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyInt64ObservableUpDownCounter(c Int64ObservableUpDownCounterConfig) Int64ObservableUpDownCounterConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyInt64ObservableGauge(c Int64ObservableGaugeConfig) Int64ObservableGaugeConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
// WithUnit sets the instrument unit.
|
||||
//
|
||||
// The unit u should be defined using the appropriate [UCUM](https://ucum.org) case-sensitive code.
|
||||
func WithUnit(u string) InstrumentOption { return unitOpt(u) }
|
||||
|
||||
// AddOption applies options to an addition measurement. See
|
||||
// [MeasurementOption] for other options that can be used as an AddOption.
|
||||
type AddOption interface {
|
||||
applyAdd(AddConfig) AddConfig
|
||||
}
|
||||
|
||||
// AddConfig contains options for an addition measurement.
|
||||
type AddConfig struct {
|
||||
attrs attribute.Set
|
||||
}
|
||||
|
||||
// NewAddConfig returns a new [AddConfig] with all opts applied.
|
||||
func NewAddConfig(opts []AddOption) AddConfig {
|
||||
config := AddConfig{attrs: *attribute.EmptySet()}
|
||||
for _, o := range opts {
|
||||
config = o.applyAdd(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Attributes returns the configured attribute set.
|
||||
func (c AddConfig) Attributes() attribute.Set {
|
||||
return c.attrs
|
||||
}
|
||||
|
||||
// RecordOption applies options to an addition measurement. See
|
||||
// [MeasurementOption] for other options that can be used as a RecordOption.
|
||||
type RecordOption interface {
|
||||
applyRecord(RecordConfig) RecordConfig
|
||||
}
|
||||
|
||||
// RecordConfig contains options for a recorded measurement.
|
||||
type RecordConfig struct {
|
||||
attrs attribute.Set
|
||||
}
|
||||
|
||||
// NewRecordConfig returns a new [RecordConfig] with all opts applied.
|
||||
func NewRecordConfig(opts []RecordOption) RecordConfig {
|
||||
config := RecordConfig{attrs: *attribute.EmptySet()}
|
||||
for _, o := range opts {
|
||||
config = o.applyRecord(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Attributes returns the configured attribute set.
|
||||
func (c RecordConfig) Attributes() attribute.Set {
|
||||
return c.attrs
|
||||
}
|
||||
|
||||
// ObserveOption applies options to an addition measurement. See
|
||||
// [MeasurementOption] for other options that can be used as a ObserveOption.
|
||||
type ObserveOption interface {
|
||||
applyObserve(ObserveConfig) ObserveConfig
|
||||
}
|
||||
|
||||
// ObserveConfig contains options for an observed measurement.
|
||||
type ObserveConfig struct {
|
||||
attrs attribute.Set
|
||||
}
|
||||
|
||||
// NewObserveConfig returns a new [ObserveConfig] with all opts applied.
|
||||
func NewObserveConfig(opts []ObserveOption) ObserveConfig {
|
||||
config := ObserveConfig{attrs: *attribute.EmptySet()}
|
||||
for _, o := range opts {
|
||||
config = o.applyObserve(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Attributes returns the configured attribute set.
|
||||
func (c ObserveConfig) Attributes() attribute.Set {
|
||||
return c.attrs
|
||||
}
|
||||
|
||||
// MeasurementOption applies options to all instrument measurement.
|
||||
type MeasurementOption interface {
|
||||
AddOption
|
||||
RecordOption
|
||||
ObserveOption
|
||||
}
|
||||
|
||||
type attrOpt struct {
|
||||
set attribute.Set
|
||||
}
|
||||
|
||||
// mergeSets returns the union of keys between a and b. Any duplicate keys will
|
||||
// use the value associated with b.
|
||||
func mergeSets(a, b attribute.Set) attribute.Set {
|
||||
// NewMergeIterator uses the first value for any duplicates.
|
||||
iter := attribute.NewMergeIterator(&b, &a)
|
||||
merged := make([]attribute.KeyValue, 0, a.Len()+b.Len())
|
||||
for iter.Next() {
|
||||
merged = append(merged, iter.Attribute())
|
||||
}
|
||||
return attribute.NewSet(merged...)
|
||||
}
|
||||
|
||||
func (o attrOpt) applyAdd(c AddConfig) AddConfig {
|
||||
switch {
|
||||
case o.set.Len() == 0:
|
||||
case c.attrs.Len() == 0:
|
||||
c.attrs = o.set
|
||||
default:
|
||||
c.attrs = mergeSets(c.attrs, o.set)
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
func (o attrOpt) applyRecord(c RecordConfig) RecordConfig {
|
||||
switch {
|
||||
case o.set.Len() == 0:
|
||||
case c.attrs.Len() == 0:
|
||||
c.attrs = o.set
|
||||
default:
|
||||
c.attrs = mergeSets(c.attrs, o.set)
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
func (o attrOpt) applyObserve(c ObserveConfig) ObserveConfig {
|
||||
switch {
|
||||
case o.set.Len() == 0:
|
||||
case c.attrs.Len() == 0:
|
||||
c.attrs = o.set
|
||||
default:
|
||||
c.attrs = mergeSets(c.attrs, o.set)
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
// WithAttributeSet sets the attribute Set associated with a measurement is
|
||||
// made with.
|
||||
//
|
||||
// If multiple WithAttributeSet or WithAttributes options are passed the
|
||||
// attributes will be merged together in the order they are passed. Attributes
|
||||
// with duplicate keys will use the last value passed.
|
||||
func WithAttributeSet(attributes attribute.Set) MeasurementOption {
|
||||
return attrOpt{set: attributes}
|
||||
}
|
||||
|
||||
// WithAttributes converts attributes into an attribute Set and sets the Set to
|
||||
// be associated with a measurement. This is shorthand for:
|
||||
//
|
||||
// cp := make([]attribute.KeyValue, len(attributes))
|
||||
// copy(cp, attributes)
|
||||
// WithAttributes(attribute.NewSet(cp...))
|
||||
//
|
||||
// [attribute.NewSet] may modify the passed attributes so this will make a copy
|
||||
// of attributes before creating a set in order to ensure this function is
|
||||
// concurrent safe. This makes this option function less optimized in
|
||||
// comparison to [WithAttributeSet]. Therefore, [WithAttributeSet] should be
|
||||
// preferred for performance sensitive code.
|
||||
//
|
||||
// See [WithAttributeSet] for information about how multiple WithAttributes are
|
||||
// merged.
|
||||
func WithAttributes(attributes ...attribute.KeyValue) MeasurementOption {
|
||||
cp := make([]attribute.KeyValue, len(attributes))
|
||||
copy(cp, attributes)
|
||||
return attrOpt{set: attribute.NewSet(cp...)}
|
||||
}
|
130
vendor/go.opentelemetry.io/otel/metric/instrument/asyncfloat64.go
generated
vendored
130
vendor/go.opentelemetry.io/otel/metric/instrument/asyncfloat64.go
generated
vendored
|
@ -1,130 +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 (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
)
|
||||
|
||||
// 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 string
|
||||
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() string {
|
||||
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
|
||||
})
|
||||
}
|
130
vendor/go.opentelemetry.io/otel/metric/instrument/asyncint64.go
generated
vendored
130
vendor/go.opentelemetry.io/otel/metric/instrument/asyncint64.go
generated
vendored
|
@ -1,130 +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 (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
)
|
||||
|
||||
// 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 string
|
||||
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() string {
|
||||
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
|
||||
})
|
||||
}
|
88
vendor/go.opentelemetry.io/otel/metric/instrument/instrument.go
generated
vendored
88
vendor/go.opentelemetry.io/otel/metric/instrument/instrument.go
generated
vendored
|
@ -1,88 +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"
|
||||
|
||||
// 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.
|
||||
//
|
||||
// This interface is used as a grouping mechanism.
|
||||
type Asynchronous interface {
|
||||
asynchronous()
|
||||
}
|
||||
|
||||
// Synchronous instruments are updated in line with application code.
|
||||
//
|
||||
// This interface is used as a grouping mechanism.
|
||||
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 string
|
||||
|
||||
func (o unitOpt) applyFloat64(c Float64Config) Float64Config {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyInt64(c Int64Config) Int64Config {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyFloat64Observer(c Float64ObserverConfig) Float64ObserverConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyInt64Observer(c Int64ObserverConfig) Int64ObserverConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
// WithUnit sets the instrument unit.
|
||||
func WithUnit(u string) Option { return unitOpt(u) }
|
85
vendor/go.opentelemetry.io/otel/metric/instrument/syncfloat64.go
generated
vendored
85
vendor/go.opentelemetry.io/otel/metric/instrument/syncfloat64.go
generated
vendored
|
@ -1,85 +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 (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
)
|
||||
|
||||
// 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 string
|
||||
}
|
||||
|
||||
// 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() string {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Float64Option applies options to synchronous float64 instruments.
|
||||
type Float64Option interface {
|
||||
applyFloat64(Float64Config) Float64Config
|
||||
}
|
85
vendor/go.opentelemetry.io/otel/metric/instrument/syncint64.go
generated
vendored
85
vendor/go.opentelemetry.io/otel/metric/instrument/syncint64.go
generated
vendored
|
@ -1,85 +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 (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
)
|
||||
|
||||
// Int64Counter is an instrument that records increasing int64 values.
|
||||
//
|
||||
// Warning: methods may be added to this interface in minor releases.
|
||||
type Int64Counter interface {
|
||||
// Add records a change to the counter.
|
||||
Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue)
|
||||
|
||||
Synchronous
|
||||
}
|
||||
|
||||
// Int64UpDownCounter is an instrument that records increasing or decreasing
|
||||
// int64 values.
|
||||
//
|
||||
// Warning: methods may be added to this interface in minor releases.
|
||||
type Int64UpDownCounter interface {
|
||||
// Add records a change to the counter.
|
||||
Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue)
|
||||
|
||||
Synchronous
|
||||
}
|
||||
|
||||
// Int64Histogram is an instrument that records a distribution of int64
|
||||
// values.
|
||||
//
|
||||
// Warning: methods may be added to this interface in minor releases.
|
||||
type Int64Histogram interface {
|
||||
// Record adds an additional value to the distribution.
|
||||
Record(ctx context.Context, incr int64, attrs ...attribute.KeyValue)
|
||||
|
||||
Synchronous
|
||||
}
|
||||
|
||||
// Int64Config contains options for Synchronous instruments that record int64
|
||||
// values.
|
||||
type Int64Config struct {
|
||||
description string
|
||||
unit string
|
||||
}
|
||||
|
||||
// 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() string {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Int64Option applies options to synchronous int64 instruments.
|
||||
type Int64Option interface {
|
||||
applyInt64(Int64Config) Int64Config
|
||||
}
|
355
vendor/go.opentelemetry.io/otel/metric/internal/global/instruments.go
generated
vendored
355
vendor/go.opentelemetry.io/otel/metric/internal/global/instruments.go
generated
vendored
|
@ -1,355 +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 global // import "go.opentelemetry.io/otel/metric/internal/global"
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync/atomic"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/instrument"
|
||||
)
|
||||
|
||||
// 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.Float64ObservableCounter(i.name, i.opts...)
|
||||
if err != nil {
|
||||
otel.Handle(err)
|
||||
return
|
||||
}
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *afCounter) Unwrap() instrument.Asynchronous {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
return ctr.(instrument.Float64ObservableCounter)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type afUpDownCounter struct {
|
||||
instrument.Float64Observable
|
||||
|
||||
name string
|
||||
opts []instrument.Float64ObserverOption
|
||||
|
||||
delegate atomic.Value //instrument.Float64ObservableUpDownCounter
|
||||
}
|
||||
|
||||
var _ unwrapper = (*afUpDownCounter)(nil)
|
||||
var _ instrument.Float64ObservableUpDownCounter = (*afUpDownCounter)(nil)
|
||||
|
||||
func (i *afUpDownCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Float64ObservableUpDownCounter(i.name, i.opts...)
|
||||
if err != nil {
|
||||
otel.Handle(err)
|
||||
return
|
||||
}
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *afUpDownCounter) Unwrap() instrument.Asynchronous {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
return ctr.(instrument.Float64ObservableUpDownCounter)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type afGauge struct {
|
||||
instrument.Float64Observable
|
||||
|
||||
name string
|
||||
opts []instrument.Float64ObserverOption
|
||||
|
||||
delegate atomic.Value //instrument.Float64ObservableGauge
|
||||
}
|
||||
|
||||
var _ unwrapper = (*afGauge)(nil)
|
||||
var _ instrument.Float64ObservableGauge = (*afGauge)(nil)
|
||||
|
||||
func (i *afGauge) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Float64ObservableGauge(i.name, i.opts...)
|
||||
if err != nil {
|
||||
otel.Handle(err)
|
||||
return
|
||||
}
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *afGauge) Unwrap() instrument.Asynchronous {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
return ctr.(instrument.Float64ObservableGauge)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type aiCounter struct {
|
||||
instrument.Int64Observable
|
||||
|
||||
name string
|
||||
opts []instrument.Int64ObserverOption
|
||||
|
||||
delegate atomic.Value //instrument.Int64ObservableCounter
|
||||
}
|
||||
|
||||
var _ unwrapper = (*aiCounter)(nil)
|
||||
var _ instrument.Int64ObservableCounter = (*aiCounter)(nil)
|
||||
|
||||
func (i *aiCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Int64ObservableCounter(i.name, i.opts...)
|
||||
if err != nil {
|
||||
otel.Handle(err)
|
||||
return
|
||||
}
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *aiCounter) Unwrap() instrument.Asynchronous {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
return ctr.(instrument.Int64ObservableCounter)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type aiUpDownCounter struct {
|
||||
instrument.Int64Observable
|
||||
|
||||
name string
|
||||
opts []instrument.Int64ObserverOption
|
||||
|
||||
delegate atomic.Value //instrument.Int64ObservableUpDownCounter
|
||||
}
|
||||
|
||||
var _ unwrapper = (*aiUpDownCounter)(nil)
|
||||
var _ instrument.Int64ObservableUpDownCounter = (*aiUpDownCounter)(nil)
|
||||
|
||||
func (i *aiUpDownCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Int64ObservableUpDownCounter(i.name, i.opts...)
|
||||
if err != nil {
|
||||
otel.Handle(err)
|
||||
return
|
||||
}
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *aiUpDownCounter) Unwrap() instrument.Asynchronous {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
return ctr.(instrument.Int64ObservableUpDownCounter)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type aiGauge struct {
|
||||
instrument.Int64Observable
|
||||
|
||||
name string
|
||||
opts []instrument.Int64ObserverOption
|
||||
|
||||
delegate atomic.Value //instrument.Int64ObservableGauge
|
||||
}
|
||||
|
||||
var _ unwrapper = (*aiGauge)(nil)
|
||||
var _ instrument.Int64ObservableGauge = (*aiGauge)(nil)
|
||||
|
||||
func (i *aiGauge) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Int64ObservableGauge(i.name, i.opts...)
|
||||
if err != nil {
|
||||
otel.Handle(err)
|
||||
return
|
||||
}
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *aiGauge) Unwrap() instrument.Asynchronous {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
return ctr.(instrument.Int64ObservableGauge)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Sync Instruments.
|
||||
type sfCounter struct {
|
||||
name string
|
||||
opts []instrument.Float64Option
|
||||
|
||||
delegate atomic.Value //instrument.Float64Counter
|
||||
|
||||
instrument.Synchronous
|
||||
}
|
||||
|
||||
var _ instrument.Float64Counter = (*sfCounter)(nil)
|
||||
|
||||
func (i *sfCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Float64Counter(i.name, i.opts...)
|
||||
if err != nil {
|
||||
otel.Handle(err)
|
||||
return
|
||||
}
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *sfCounter) Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue) {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
ctr.(instrument.Float64Counter).Add(ctx, incr, attrs...)
|
||||
}
|
||||
}
|
||||
|
||||
type sfUpDownCounter struct {
|
||||
name string
|
||||
opts []instrument.Float64Option
|
||||
|
||||
delegate atomic.Value //instrument.Float64UpDownCounter
|
||||
|
||||
instrument.Synchronous
|
||||
}
|
||||
|
||||
var _ instrument.Float64UpDownCounter = (*sfUpDownCounter)(nil)
|
||||
|
||||
func (i *sfUpDownCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Float64UpDownCounter(i.name, i.opts...)
|
||||
if err != nil {
|
||||
otel.Handle(err)
|
||||
return
|
||||
}
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *sfUpDownCounter) Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue) {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
ctr.(instrument.Float64UpDownCounter).Add(ctx, incr, attrs...)
|
||||
}
|
||||
}
|
||||
|
||||
type sfHistogram struct {
|
||||
name string
|
||||
opts []instrument.Float64Option
|
||||
|
||||
delegate atomic.Value //instrument.Float64Histogram
|
||||
|
||||
instrument.Synchronous
|
||||
}
|
||||
|
||||
var _ instrument.Float64Histogram = (*sfHistogram)(nil)
|
||||
|
||||
func (i *sfHistogram) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Float64Histogram(i.name, i.opts...)
|
||||
if err != nil {
|
||||
otel.Handle(err)
|
||||
return
|
||||
}
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *sfHistogram) Record(ctx context.Context, x float64, attrs ...attribute.KeyValue) {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
ctr.(instrument.Float64Histogram).Record(ctx, x, attrs...)
|
||||
}
|
||||
}
|
||||
|
||||
type siCounter struct {
|
||||
name string
|
||||
opts []instrument.Int64Option
|
||||
|
||||
delegate atomic.Value //instrument.Int64Counter
|
||||
|
||||
instrument.Synchronous
|
||||
}
|
||||
|
||||
var _ instrument.Int64Counter = (*siCounter)(nil)
|
||||
|
||||
func (i *siCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Int64Counter(i.name, i.opts...)
|
||||
if err != nil {
|
||||
otel.Handle(err)
|
||||
return
|
||||
}
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *siCounter) Add(ctx context.Context, x int64, attrs ...attribute.KeyValue) {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
ctr.(instrument.Int64Counter).Add(ctx, x, attrs...)
|
||||
}
|
||||
}
|
||||
|
||||
type siUpDownCounter struct {
|
||||
name string
|
||||
opts []instrument.Int64Option
|
||||
|
||||
delegate atomic.Value //instrument.Int64UpDownCounter
|
||||
|
||||
instrument.Synchronous
|
||||
}
|
||||
|
||||
var _ instrument.Int64UpDownCounter = (*siUpDownCounter)(nil)
|
||||
|
||||
func (i *siUpDownCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Int64UpDownCounter(i.name, i.opts...)
|
||||
if err != nil {
|
||||
otel.Handle(err)
|
||||
return
|
||||
}
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *siUpDownCounter) Add(ctx context.Context, x int64, attrs ...attribute.KeyValue) {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
ctr.(instrument.Int64UpDownCounter).Add(ctx, x, attrs...)
|
||||
}
|
||||
}
|
||||
|
||||
type siHistogram struct {
|
||||
name string
|
||||
opts []instrument.Int64Option
|
||||
|
||||
delegate atomic.Value //instrument.Int64Histogram
|
||||
|
||||
instrument.Synchronous
|
||||
}
|
||||
|
||||
var _ instrument.Int64Histogram = (*siHistogram)(nil)
|
||||
|
||||
func (i *siHistogram) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Int64Histogram(i.name, i.opts...)
|
||||
if err != nil {
|
||||
otel.Handle(err)
|
||||
return
|
||||
}
|
||||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *siHistogram) Record(ctx context.Context, x int64, attrs ...attribute.KeyValue) {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
ctr.(instrument.Int64Histogram).Record(ctx, x, attrs...)
|
||||
}
|
||||
}
|
68
vendor/go.opentelemetry.io/otel/metric/internal/global/state.go
generated
vendored
68
vendor/go.opentelemetry.io/otel/metric/internal/global/state.go
generated
vendored
|
@ -1,68 +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
|
||||
//
|
||||
// htmp://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 global // import "go.opentelemetry.io/otel/metric/internal/global"
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"go.opentelemetry.io/otel/internal/global"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
)
|
||||
|
||||
var (
|
||||
globalMeterProvider = defaultMeterProvider()
|
||||
|
||||
delegateMeterOnce sync.Once
|
||||
)
|
||||
|
||||
type meterProviderHolder struct {
|
||||
mp metric.MeterProvider
|
||||
}
|
||||
|
||||
// MeterProvider is the internal implementation for global.MeterProvider.
|
||||
func MeterProvider() metric.MeterProvider {
|
||||
return globalMeterProvider.Load().(meterProviderHolder).mp
|
||||
}
|
||||
|
||||
// SetMeterProvider is the internal implementation for global.SetMeterProvider.
|
||||
func SetMeterProvider(mp metric.MeterProvider) {
|
||||
current := MeterProvider()
|
||||
if _, cOk := current.(*meterProvider); cOk {
|
||||
if _, mpOk := mp.(*meterProvider); mpOk && current == mp {
|
||||
// Do not assign the default delegating MeterProvider to delegate
|
||||
// to itself.
|
||||
global.Error(
|
||||
errors.New("no delegate configured in meter provider"),
|
||||
"Setting meter provider to it's current value. No delegate will be configured",
|
||||
)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
delegateMeterOnce.Do(func() {
|
||||
if def, ok := current.(*meterProvider); ok {
|
||||
def.setDelegate(mp)
|
||||
}
|
||||
})
|
||||
globalMeterProvider.Store(meterProviderHolder{mp: mp})
|
||||
}
|
||||
|
||||
func defaultMeterProvider() *atomic.Value {
|
||||
v := &atomic.Value{}
|
||||
v.Store(meterProviderHolder{mp: &meterProvider{}})
|
||||
return v
|
||||
}
|
204
vendor/go.opentelemetry.io/otel/metric/meter.go
generated
vendored
204
vendor/go.opentelemetry.io/otel/metric/meter.go
generated
vendored
|
@ -17,80 +17,134 @@ 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/embedded"
|
||||
)
|
||||
|
||||
// MeterProvider provides access to named Meter instances, for instrumenting
|
||||
// an application or library.
|
||||
// an application or package.
|
||||
//
|
||||
// Warning: methods may be added to this interface in minor releases.
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// package documentation on API implementation for information on how to set
|
||||
// default behavior for unimplemented methods.
|
||||
type MeterProvider interface {
|
||||
// Meter creates an instance of a `Meter` interface. The name must be the
|
||||
// name of the library providing instrumentation. This name may be the same
|
||||
// as the instrumented code only if that code provides built-in
|
||||
// instrumentation. If the name is empty, then a implementation defined
|
||||
// default name will be used instead.
|
||||
// Users of the interface can ignore this. This embedded type is only used
|
||||
// by implementations of this interface. See the "API Implementations"
|
||||
// section of the package documentation for more information.
|
||||
embedded.MeterProvider
|
||||
|
||||
// Meter returns a new Meter with the provided name and configuration.
|
||||
//
|
||||
// A Meter should be scoped at most to a single package. The name needs to
|
||||
// be unique so it does not collide with other names used by
|
||||
// an application, nor other applications. To achieve this, the import path
|
||||
// of the instrumentation package is recommended to be used as name.
|
||||
//
|
||||
// If the name is empty, then an implementation defined default name will
|
||||
// be used instead.
|
||||
Meter(name string, opts ...MeterOption) Meter
|
||||
}
|
||||
|
||||
// Meter provides access to instrument instances for recording metrics.
|
||||
//
|
||||
// Warning: methods may be added to this interface in minor releases.
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// package documentation on API implementation for information on how to set
|
||||
// default behavior for unimplemented methods.
|
||||
type Meter interface {
|
||||
// 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)
|
||||
// Users of the interface can ignore this. This embedded type is only used
|
||||
// by implementations of this interface. See the "API Implementations"
|
||||
// section of the package documentation for more information.
|
||||
embedded.Meter
|
||||
|
||||
// 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
|
||||
// Int64Counter returns a new Int64Counter 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 ...Int64CounterOption) (Int64Counter, error)
|
||||
// Int64UpDownCounter returns a new Int64UpDownCounter instrument
|
||||
// identified by name and configured with options. The instrument is used
|
||||
// to synchronously record int64 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
|
||||
Int64UpDownCounter(name string, options ...Int64UpDownCounterOption) (Int64UpDownCounter, error)
|
||||
// Int64Histogram returns a new Int64Histogram 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
|
||||
// synchronously record the distribution of int64 measurements during a
|
||||
// computational operation.
|
||||
Int64Histogram(name string, options ...Int64HistogramOption) (Int64Histogram, error)
|
||||
// Int64ObservableCounter returns a new Int64ObservableCounter identified
|
||||
// by name and configured with options. The instrument is used to
|
||||
// asynchronously record increasing int64 measurements once per a
|
||||
// measurement collection cycle.
|
||||
//
|
||||
// Measurements for the returned instrument are made via a callback. Use
|
||||
// the WithInt64Callback option to register the callback here, or use the
|
||||
// RegisterCallback method of this Meter to register one later. See the
|
||||
// Measurements section of the package documentation for more information.
|
||||
Int64ObservableCounter(name string, options ...Int64ObservableCounterOption) (Int64ObservableCounter, error)
|
||||
// Int64ObservableUpDownCounter returns a new Int64ObservableUpDownCounter
|
||||
// instrument identified by name and configured with options. The
|
||||
// instrument is used to asynchronously record int64 measurements once per
|
||||
// a measurement collection cycle.
|
||||
//
|
||||
// Measurements for the returned instrument are made via a callback. Use
|
||||
// the WithInt64Callback option to register the callback here, or use the
|
||||
// RegisterCallback method of this Meter to register one later. See the
|
||||
// Measurements section of the package documentation for more information.
|
||||
Int64ObservableUpDownCounter(name string, options ...Int64ObservableUpDownCounterOption) (Int64ObservableUpDownCounter, error)
|
||||
// Int64ObservableGauge returns a new Int64ObservableGauge instrument
|
||||
// identified by name and configured with options. The instrument is used
|
||||
// to asynchronously record instantaneous int64 measurements once per a
|
||||
// measurement collection cycle.
|
||||
//
|
||||
// Measurements for the returned instrument are made via a callback. Use
|
||||
// the WithInt64Callback option to register the callback here, or use the
|
||||
// RegisterCallback method of this Meter to register one later. See the
|
||||
// Measurements section of the package documentation for more information.
|
||||
Int64ObservableGauge(name string, options ...Int64ObservableGaugeOption) (Int64ObservableGauge, error)
|
||||
|
||||
// Float64Counter returns a new Float64Counter 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 ...Float64CounterOption) (Float64Counter, error)
|
||||
// Float64UpDownCounter returns a new Float64UpDownCounter 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 ...Float64UpDownCounterOption) (Float64UpDownCounter, error)
|
||||
// Float64Histogram returns a new Float64Histogram 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 ...Float64HistogramOption) (Float64Histogram, error)
|
||||
// Float64ObservableCounter returns a new Float64ObservableCounter
|
||||
// instrument identified by name and configured with options. The
|
||||
// instrument is used to asynchronously record increasing float64
|
||||
// measurements once per a measurement collection cycle.
|
||||
//
|
||||
// Measurements for the returned instrument are made via a callback. Use
|
||||
// the WithFloat64Callback option to register the callback here, or use the
|
||||
// RegisterCallback method of this Meter to register one later. See the
|
||||
// Measurements section of the package documentation for more information.
|
||||
Float64ObservableCounter(name string, options ...Float64ObservableCounterOption) (Float64ObservableCounter, error)
|
||||
// Float64ObservableUpDownCounter returns a new
|
||||
// Float64ObservableUpDownCounter 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)
|
||||
// float64 measurements once per a measurement collection cycle.
|
||||
//
|
||||
// Measurements for the returned instrument are made via a callback. Use
|
||||
// the WithFloat64Callback option to register the callback here, or use the
|
||||
// RegisterCallback method of this Meter to register one later. See the
|
||||
// Measurements section of the package documentation for more information.
|
||||
Float64ObservableUpDownCounter(name string, options ...Float64ObservableUpDownCounterOption) (Float64ObservableUpDownCounter, error)
|
||||
// Float64ObservableGauge returns a new Float64ObservableGauge instrument
|
||||
// identified by name and configured with options. The instrument is used
|
||||
// to asynchronously record instantaneous float64 measurements once per a
|
||||
// measurement collection cycle.
|
||||
//
|
||||
// Measurements for the returned instrument are made via a callback. Use
|
||||
// the WithFloat64Callback option to register the callback here, or use the
|
||||
// RegisterCallback method of this Meter to register one later. See the
|
||||
// Measurements section of the package documentation for more information.
|
||||
Float64ObservableGauge(name string, options ...Float64ObservableGaugeOption) (Float64ObservableGauge, error)
|
||||
|
||||
// RegisterCallback registers f to be called during the collection of a
|
||||
// measurement cycle.
|
||||
|
@ -103,12 +157,14 @@ type Meter interface {
|
|||
//
|
||||
// If no instruments are passed, f should not be registered nor called
|
||||
// during collection.
|
||||
RegisterCallback(f Callback, instruments ...instrument.Asynchronous) (Registration, error)
|
||||
//
|
||||
// The function f needs to be concurrent safe.
|
||||
RegisterCallback(f Callback, instruments ...Observable) (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.
|
||||
// to record measurement 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.
|
||||
|
@ -121,16 +177,34 @@ type Meter interface {
|
|||
type Callback func(context.Context, Observer) error
|
||||
|
||||
// Observer records measurements for multiple instruments in a Callback.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// package documentation on API implementation for information on how to set
|
||||
// default behavior for unimplemented methods.
|
||||
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)
|
||||
// Users of the interface can ignore this. This embedded type is only used
|
||||
// by implementations of this interface. See the "API Implementations"
|
||||
// section of the package documentation for more information.
|
||||
embedded.Observer
|
||||
|
||||
// ObserveFloat64 records the float64 value for obsrv.
|
||||
ObserveFloat64(obsrv Float64Observable, value float64, opts ...ObserveOption)
|
||||
// ObserveInt64 records the int64 value for obsrv.
|
||||
ObserveInt64(obsrv Int64Observable, value int64, opts ...ObserveOption)
|
||||
}
|
||||
|
||||
// Registration is an token representing the unique registration of a callback
|
||||
// for a set of instruments with a Meter.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// package documentation on API implementation for information on how to set
|
||||
// default behavior for unimplemented methods.
|
||||
type Registration interface {
|
||||
// Users of the interface can ignore this. This embedded type is only used
|
||||
// by implementations of this interface. See the "API Implementations"
|
||||
// section of the package documentation for more information.
|
||||
embedded.Registration
|
||||
|
||||
// Unregister removes the callback registration from a Meter.
|
||||
//
|
||||
// This method needs to be idempotent and concurrent safe.
|
||||
|
|
143
vendor/go.opentelemetry.io/otel/metric/noop.go
generated
vendored
143
vendor/go.opentelemetry.io/otel/metric/noop.go
generated
vendored
|
@ -1,143 +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 metric // import "go.opentelemetry.io/otel/metric"
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric/instrument"
|
||||
)
|
||||
|
||||
// NewNoopMeterProvider creates a MeterProvider that does not record any metrics.
|
||||
func NewNoopMeterProvider() MeterProvider {
|
||||
return noopMeterProvider{}
|
||||
}
|
||||
|
||||
type noopMeterProvider struct{}
|
||||
|
||||
func (noopMeterProvider) Meter(string, ...MeterOption) Meter {
|
||||
return noopMeter{}
|
||||
}
|
||||
|
||||
// NewNoopMeter creates a Meter that does not record any metrics.
|
||||
func NewNoopMeter() Meter {
|
||||
return noopMeter{}
|
||||
}
|
||||
|
||||
type noopMeter struct{}
|
||||
|
||||
func (noopMeter) Int64Counter(string, ...instrument.Int64Option) (instrument.Int64Counter, error) {
|
||||
return nonrecordingSyncInt64Instrument{}, nil
|
||||
}
|
||||
|
||||
func (noopMeter) Int64UpDownCounter(string, ...instrument.Int64Option) (instrument.Int64UpDownCounter, error) {
|
||||
return nonrecordingSyncInt64Instrument{}, nil
|
||||
}
|
||||
|
||||
func (noopMeter) Int64Histogram(string, ...instrument.Int64Option) (instrument.Int64Histogram, error) {
|
||||
return nonrecordingSyncInt64Instrument{}, nil
|
||||
}
|
||||
|
||||
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(Callback, ...instrument.Asynchronous) (Registration, error) {
|
||||
return noopReg{}, nil
|
||||
}
|
||||
|
||||
type noopReg struct{}
|
||||
|
||||
func (noopReg) Unregister() error { return nil }
|
||||
|
||||
type nonrecordingAsyncFloat64Instrument struct {
|
||||
instrument.Float64Observable
|
||||
}
|
||||
|
||||
var (
|
||||
_ instrument.Float64ObservableCounter = nonrecordingAsyncFloat64Instrument{}
|
||||
_ instrument.Float64ObservableUpDownCounter = nonrecordingAsyncFloat64Instrument{}
|
||||
_ instrument.Float64ObservableGauge = nonrecordingAsyncFloat64Instrument{}
|
||||
)
|
||||
|
||||
type nonrecordingAsyncInt64Instrument struct {
|
||||
instrument.Int64Observable
|
||||
}
|
||||
|
||||
var (
|
||||
_ instrument.Int64ObservableCounter = nonrecordingAsyncInt64Instrument{}
|
||||
_ instrument.Int64ObservableUpDownCounter = nonrecordingAsyncInt64Instrument{}
|
||||
_ instrument.Int64ObservableGauge = nonrecordingAsyncInt64Instrument{}
|
||||
)
|
||||
|
||||
type nonrecordingSyncFloat64Instrument struct {
|
||||
instrument.Synchronous
|
||||
}
|
||||
|
||||
var (
|
||||
_ instrument.Float64Counter = nonrecordingSyncFloat64Instrument{}
|
||||
_ instrument.Float64UpDownCounter = nonrecordingSyncFloat64Instrument{}
|
||||
_ instrument.Float64Histogram = nonrecordingSyncFloat64Instrument{}
|
||||
)
|
||||
|
||||
func (nonrecordingSyncFloat64Instrument) Add(context.Context, float64, ...attribute.KeyValue) {}
|
||||
func (nonrecordingSyncFloat64Instrument) Record(context.Context, float64, ...attribute.KeyValue) {}
|
||||
|
||||
type nonrecordingSyncInt64Instrument struct {
|
||||
instrument.Synchronous
|
||||
}
|
||||
|
||||
var (
|
||||
_ instrument.Int64Counter = nonrecordingSyncInt64Instrument{}
|
||||
_ instrument.Int64UpDownCounter = nonrecordingSyncInt64Instrument{}
|
||||
_ instrument.Int64Histogram = nonrecordingSyncInt64Instrument{}
|
||||
)
|
||||
|
||||
func (nonrecordingSyncInt64Instrument) Add(context.Context, int64, ...attribute.KeyValue) {}
|
||||
func (nonrecordingSyncInt64Instrument) Record(context.Context, int64, ...attribute.KeyValue) {}
|
179
vendor/go.opentelemetry.io/otel/metric/syncfloat64.go
generated
vendored
Normal file
179
vendor/go.opentelemetry.io/otel/metric/syncfloat64.go
generated
vendored
Normal file
|
@ -0,0 +1,179 @@
|
|||
// 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 metric // import "go.opentelemetry.io/otel/metric"
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/metric/embedded"
|
||||
)
|
||||
|
||||
// Float64Counter is an instrument that records increasing float64 values.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// package documentation on API implementation for information on how to set
|
||||
// default behavior for unimplemented methods.
|
||||
type Float64Counter interface {
|
||||
// Users of the interface can ignore this. This embedded type is only used
|
||||
// by implementations of this interface. See the "API Implementations"
|
||||
// section of the package documentation for more information.
|
||||
embedded.Float64Counter
|
||||
|
||||
// Add records a change to the counter.
|
||||
//
|
||||
// Use the WithAttributeSet (or, if performance is not a concern,
|
||||
// the WithAttributes) option to include measurement attributes.
|
||||
Add(ctx context.Context, incr float64, options ...AddOption)
|
||||
}
|
||||
|
||||
// Float64CounterConfig contains options for synchronous counter instruments that
|
||||
// record int64 values.
|
||||
type Float64CounterConfig struct {
|
||||
description string
|
||||
unit string
|
||||
}
|
||||
|
||||
// NewFloat64CounterConfig returns a new [Float64CounterConfig] with all opts
|
||||
// applied.
|
||||
func NewFloat64CounterConfig(opts ...Float64CounterOption) Float64CounterConfig {
|
||||
var config Float64CounterConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyFloat64Counter(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the configured description.
|
||||
func (c Float64CounterConfig) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the configured unit.
|
||||
func (c Float64CounterConfig) Unit() string {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Float64CounterOption applies options to a [Float64CounterConfig]. See
|
||||
// [InstrumentOption] for other options that can be used as a
|
||||
// Float64CounterOption.
|
||||
type Float64CounterOption interface {
|
||||
applyFloat64Counter(Float64CounterConfig) Float64CounterConfig
|
||||
}
|
||||
|
||||
// Float64UpDownCounter is an instrument that records increasing or decreasing
|
||||
// float64 values.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// package documentation on API implementation for information on how to set
|
||||
// default behavior for unimplemented methods.
|
||||
type Float64UpDownCounter interface {
|
||||
// Users of the interface can ignore this. This embedded type is only used
|
||||
// by implementations of this interface. See the "API Implementations"
|
||||
// section of the package documentation for more information.
|
||||
embedded.Float64UpDownCounter
|
||||
|
||||
// Add records a change to the counter.
|
||||
//
|
||||
// Use the WithAttributeSet (or, if performance is not a concern,
|
||||
// the WithAttributes) option to include measurement attributes.
|
||||
Add(ctx context.Context, incr float64, options ...AddOption)
|
||||
}
|
||||
|
||||
// Float64UpDownCounterConfig contains options for synchronous counter
|
||||
// instruments that record int64 values.
|
||||
type Float64UpDownCounterConfig struct {
|
||||
description string
|
||||
unit string
|
||||
}
|
||||
|
||||
// NewFloat64UpDownCounterConfig returns a new [Float64UpDownCounterConfig]
|
||||
// with all opts applied.
|
||||
func NewFloat64UpDownCounterConfig(opts ...Float64UpDownCounterOption) Float64UpDownCounterConfig {
|
||||
var config Float64UpDownCounterConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyFloat64UpDownCounter(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the configured description.
|
||||
func (c Float64UpDownCounterConfig) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the configured unit.
|
||||
func (c Float64UpDownCounterConfig) Unit() string {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Float64UpDownCounterOption applies options to a
|
||||
// [Float64UpDownCounterConfig]. See [InstrumentOption] for other options that
|
||||
// can be used as a Float64UpDownCounterOption.
|
||||
type Float64UpDownCounterOption interface {
|
||||
applyFloat64UpDownCounter(Float64UpDownCounterConfig) Float64UpDownCounterConfig
|
||||
}
|
||||
|
||||
// Float64Histogram is an instrument that records a distribution of float64
|
||||
// values.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// package documentation on API implementation for information on how to set
|
||||
// default behavior for unimplemented methods.
|
||||
type Float64Histogram interface {
|
||||
// Users of the interface can ignore this. This embedded type is only used
|
||||
// by implementations of this interface. See the "API Implementations"
|
||||
// section of the package documentation for more information.
|
||||
embedded.Float64Histogram
|
||||
|
||||
// Record adds an additional value to the distribution.
|
||||
//
|
||||
// Use the WithAttributeSet (or, if performance is not a concern,
|
||||
// the WithAttributes) option to include measurement attributes.
|
||||
Record(ctx context.Context, incr float64, options ...RecordOption)
|
||||
}
|
||||
|
||||
// Float64HistogramConfig contains options for synchronous counter instruments
|
||||
// that record int64 values.
|
||||
type Float64HistogramConfig struct {
|
||||
description string
|
||||
unit string
|
||||
}
|
||||
|
||||
// NewFloat64HistogramConfig returns a new [Float64HistogramConfig] with all
|
||||
// opts applied.
|
||||
func NewFloat64HistogramConfig(opts ...Float64HistogramOption) Float64HistogramConfig {
|
||||
var config Float64HistogramConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyFloat64Histogram(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the configured description.
|
||||
func (c Float64HistogramConfig) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the configured unit.
|
||||
func (c Float64HistogramConfig) Unit() string {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Float64HistogramOption applies options to a [Float64HistogramConfig]. See
|
||||
// [InstrumentOption] for other options that can be used as a
|
||||
// Float64HistogramOption.
|
||||
type Float64HistogramOption interface {
|
||||
applyFloat64Histogram(Float64HistogramConfig) Float64HistogramConfig
|
||||
}
|
179
vendor/go.opentelemetry.io/otel/metric/syncint64.go
generated
vendored
Normal file
179
vendor/go.opentelemetry.io/otel/metric/syncint64.go
generated
vendored
Normal file
|
@ -0,0 +1,179 @@
|
|||
// 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 metric // import "go.opentelemetry.io/otel/metric"
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/metric/embedded"
|
||||
)
|
||||
|
||||
// Int64Counter is an instrument that records increasing int64 values.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// package documentation on API implementation for information on how to set
|
||||
// default behavior for unimplemented methods.
|
||||
type Int64Counter interface {
|
||||
// Users of the interface can ignore this. This embedded type is only used
|
||||
// by implementations of this interface. See the "API Implementations"
|
||||
// section of the package documentation for more information.
|
||||
embedded.Int64Counter
|
||||
|
||||
// Add records a change to the counter.
|
||||
//
|
||||
// Use the WithAttributeSet (or, if performance is not a concern,
|
||||
// the WithAttributes) option to include measurement attributes.
|
||||
Add(ctx context.Context, incr int64, options ...AddOption)
|
||||
}
|
||||
|
||||
// Int64CounterConfig contains options for synchronous counter instruments that
|
||||
// record int64 values.
|
||||
type Int64CounterConfig struct {
|
||||
description string
|
||||
unit string
|
||||
}
|
||||
|
||||
// NewInt64CounterConfig returns a new [Int64CounterConfig] with all opts
|
||||
// applied.
|
||||
func NewInt64CounterConfig(opts ...Int64CounterOption) Int64CounterConfig {
|
||||
var config Int64CounterConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyInt64Counter(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the configured description.
|
||||
func (c Int64CounterConfig) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the configured unit.
|
||||
func (c Int64CounterConfig) Unit() string {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Int64CounterOption applies options to a [Int64CounterConfig]. See
|
||||
// [InstrumentOption] for other options that can be used as an
|
||||
// Int64CounterOption.
|
||||
type Int64CounterOption interface {
|
||||
applyInt64Counter(Int64CounterConfig) Int64CounterConfig
|
||||
}
|
||||
|
||||
// Int64UpDownCounter is an instrument that records increasing or decreasing
|
||||
// int64 values.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// package documentation on API implementation for information on how to set
|
||||
// default behavior for unimplemented methods.
|
||||
type Int64UpDownCounter interface {
|
||||
// Users of the interface can ignore this. This embedded type is only used
|
||||
// by implementations of this interface. See the "API Implementations"
|
||||
// section of the package documentation for more information.
|
||||
embedded.Int64UpDownCounter
|
||||
|
||||
// Add records a change to the counter.
|
||||
//
|
||||
// Use the WithAttributeSet (or, if performance is not a concern,
|
||||
// the WithAttributes) option to include measurement attributes.
|
||||
Add(ctx context.Context, incr int64, options ...AddOption)
|
||||
}
|
||||
|
||||
// Int64UpDownCounterConfig contains options for synchronous counter
|
||||
// instruments that record int64 values.
|
||||
type Int64UpDownCounterConfig struct {
|
||||
description string
|
||||
unit string
|
||||
}
|
||||
|
||||
// NewInt64UpDownCounterConfig returns a new [Int64UpDownCounterConfig] with
|
||||
// all opts applied.
|
||||
func NewInt64UpDownCounterConfig(opts ...Int64UpDownCounterOption) Int64UpDownCounterConfig {
|
||||
var config Int64UpDownCounterConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyInt64UpDownCounter(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the configured description.
|
||||
func (c Int64UpDownCounterConfig) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the configured unit.
|
||||
func (c Int64UpDownCounterConfig) Unit() string {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Int64UpDownCounterOption applies options to a [Int64UpDownCounterConfig].
|
||||
// See [InstrumentOption] for other options that can be used as an
|
||||
// Int64UpDownCounterOption.
|
||||
type Int64UpDownCounterOption interface {
|
||||
applyInt64UpDownCounter(Int64UpDownCounterConfig) Int64UpDownCounterConfig
|
||||
}
|
||||
|
||||
// Int64Histogram is an instrument that records a distribution of int64
|
||||
// values.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// package documentation on API implementation for information on how to set
|
||||
// default behavior for unimplemented methods.
|
||||
type Int64Histogram interface {
|
||||
// Users of the interface can ignore this. This embedded type is only used
|
||||
// by implementations of this interface. See the "API Implementations"
|
||||
// section of the package documentation for more information.
|
||||
embedded.Int64Histogram
|
||||
|
||||
// Record adds an additional value to the distribution.
|
||||
//
|
||||
// Use the WithAttributeSet (or, if performance is not a concern,
|
||||
// the WithAttributes) option to include measurement attributes.
|
||||
Record(ctx context.Context, incr int64, options ...RecordOption)
|
||||
}
|
||||
|
||||
// Int64HistogramConfig contains options for synchronous counter instruments
|
||||
// that record int64 values.
|
||||
type Int64HistogramConfig struct {
|
||||
description string
|
||||
unit string
|
||||
}
|
||||
|
||||
// NewInt64HistogramConfig returns a new [Int64HistogramConfig] with all opts
|
||||
// applied.
|
||||
func NewInt64HistogramConfig(opts ...Int64HistogramOption) Int64HistogramConfig {
|
||||
var config Int64HistogramConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyInt64Histogram(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the configured description.
|
||||
func (c Int64HistogramConfig) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the configured unit.
|
||||
func (c Int64HistogramConfig) Unit() string {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Int64HistogramOption applies options to a [Int64HistogramConfig]. See
|
||||
// [InstrumentOption] for other options that can be used as an
|
||||
// Int64HistogramOption.
|
||||
type Int64HistogramOption interface {
|
||||
applyInt64Histogram(Int64HistogramConfig) Int64HistogramConfig
|
||||
}
|
1
vendor/go.opentelemetry.io/otel/requirements.txt
generated
vendored
Normal file
1
vendor/go.opentelemetry.io/otel/requirements.txt
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
codespell==2.2.5
|
10
vendor/go.opentelemetry.io/otel/sdk/internal/env/env.go
generated
vendored
10
vendor/go.opentelemetry.io/otel/sdk/internal/env/env.go
generated
vendored
|
@ -70,8 +70,8 @@ const (
|
|||
// returned.
|
||||
func firstInt(defaultValue int, keys ...string) int {
|
||||
for _, key := range keys {
|
||||
value, ok := os.LookupEnv(key)
|
||||
if !ok {
|
||||
value := os.Getenv(key)
|
||||
if value == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -88,10 +88,10 @@ func firstInt(defaultValue int, keys ...string) int {
|
|||
}
|
||||
|
||||
// IntEnvOr returns the int value of the environment variable with name key if
|
||||
// it exists and the value is an int. Otherwise, defaultValue is returned.
|
||||
// it exists, it is not empty, and the value is an int. Otherwise, defaultValue is returned.
|
||||
func IntEnvOr(key string, defaultValue int) int {
|
||||
value, ok := os.LookupEnv(key)
|
||||
if !ok {
|
||||
value := os.Getenv(key)
|
||||
if value == "" {
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
|
|
29
vendor/go.opentelemetry.io/otel/sdk/internal/gen.go
generated
vendored
Normal file
29
vendor/go.opentelemetry.io/otel/sdk/internal/gen.go
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
// 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/sdk/internal"
|
||||
|
||||
//go:generate gotmpl --body=../../internal/shared/matchers/expectation.go.tmpl "--data={}" --out=matchers/expectation.go
|
||||
//go:generate gotmpl --body=../../internal/shared/matchers/expecter.go.tmpl "--data={}" --out=matchers/expecter.go
|
||||
//go:generate gotmpl --body=../../internal/shared/matchers/temporal_matcher.go.tmpl "--data={}" --out=matchers/temporal_matcher.go
|
||||
|
||||
//go:generate gotmpl --body=../../internal/shared/internaltest/alignment.go.tmpl "--data={}" --out=internaltest/alignment.go
|
||||
//go:generate gotmpl --body=../../internal/shared/internaltest/env.go.tmpl "--data={}" --out=internaltest/env.go
|
||||
//go:generate gotmpl --body=../../internal/shared/internaltest/env_test.go.tmpl "--data={}" --out=internaltest/env_test.go
|
||||
//go:generate gotmpl --body=../../internal/shared/internaltest/errors.go.tmpl "--data={}" --out=internaltest/errors.go
|
||||
//go:generate gotmpl --body=../../internal/shared/internaltest/harness.go.tmpl "--data={\"matchersImportPath\": \"go.opentelemetry.io/otel/sdk/internal/matchers\"}" --out=internaltest/harness.go
|
||||
//go:generate gotmpl --body=../../internal/shared/internaltest/text_map_carrier.go.tmpl "--data={}" --out=internaltest/text_map_carrier.go
|
||||
//go:generate gotmpl --body=../../internal/shared/internaltest/text_map_carrier_test.go.tmpl "--data={}" --out=internaltest/text_map_carrier_test.go
|
||||
//go:generate gotmpl --body=../../internal/shared/internaltest/text_map_propagator.go.tmpl "--data={}" --out=internaltest/text_map_propagator.go
|
||||
//go:generate gotmpl --body=../../internal/shared/internaltest/text_map_propagator_test.go.tmpl "--data={}" --out=internaltest/text_map_propagator_test.go
|
11
vendor/go.opentelemetry.io/otel/sdk/internal/internal.go
generated
vendored
11
vendor/go.opentelemetry.io/otel/sdk/internal/internal.go
generated
vendored
|
@ -14,16 +14,7 @@
|
|||
|
||||
package internal // import "go.opentelemetry.io/otel/sdk/internal"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
)
|
||||
|
||||
// UserAgent is the user agent to be added to the outgoing
|
||||
// requests from the exporters.
|
||||
var UserAgent = fmt.Sprintf("opentelemetry-go/%s", otel.Version())
|
||||
import "time"
|
||||
|
||||
// MonotonicEndTime returns the end time at present
|
||||
// but offset from start, monotonically.
|
||||
|
|
58
vendor/go.opentelemetry.io/otel/sdk/resource/auto.go
generated
vendored
58
vendor/go.opentelemetry.io/otel/sdk/resource/auto.go
generated
vendored
|
@ -18,6 +18,7 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -45,28 +46,65 @@ type Detector interface {
|
|||
// Detect calls all input detectors sequentially and merges each result with the previous one.
|
||||
// It returns the merged error too.
|
||||
func Detect(ctx context.Context, detectors ...Detector) (*Resource, error) {
|
||||
var autoDetectedRes *Resource
|
||||
var errInfo []string
|
||||
r := new(Resource)
|
||||
return r, detect(ctx, r, detectors)
|
||||
}
|
||||
|
||||
// detect runs all detectors using ctx and merges the result into res. This
|
||||
// assumes res is allocated and not nil, it will panic otherwise.
|
||||
func detect(ctx context.Context, res *Resource, detectors []Detector) error {
|
||||
var (
|
||||
r *Resource
|
||||
errs detectErrs
|
||||
err error
|
||||
)
|
||||
|
||||
for _, detector := range detectors {
|
||||
if detector == nil {
|
||||
continue
|
||||
}
|
||||
res, err := detector.Detect(ctx)
|
||||
r, err = detector.Detect(ctx)
|
||||
if err != nil {
|
||||
errInfo = append(errInfo, err.Error())
|
||||
errs = append(errs, err)
|
||||
if !errors.Is(err, ErrPartialResource) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
autoDetectedRes, err = Merge(autoDetectedRes, res)
|
||||
r, err = Merge(res, r)
|
||||
if err != nil {
|
||||
errInfo = append(errInfo, err.Error())
|
||||
errs = append(errs, err)
|
||||
}
|
||||
*res = *r
|
||||
}
|
||||
|
||||
var aggregatedError error
|
||||
if len(errInfo) > 0 {
|
||||
aggregatedError = fmt.Errorf("detecting resources: %s", errInfo)
|
||||
if len(errs) == 0 {
|
||||
return nil
|
||||
}
|
||||
return autoDetectedRes, aggregatedError
|
||||
return errs
|
||||
}
|
||||
|
||||
type detectErrs []error
|
||||
|
||||
func (e detectErrs) Error() string {
|
||||
errStr := make([]string, len(e))
|
||||
for i, err := range e {
|
||||
errStr[i] = fmt.Sprintf("* %s", err)
|
||||
}
|
||||
|
||||
format := "%d errors occurred detecting resource:\n\t%s"
|
||||
return fmt.Sprintf(format, len(e), strings.Join(errStr, "\n\t"))
|
||||
}
|
||||
|
||||
func (e detectErrs) Unwrap() error {
|
||||
switch len(e) {
|
||||
case 0:
|
||||
return nil
|
||||
case 1:
|
||||
return e[0]
|
||||
}
|
||||
return e[1:]
|
||||
}
|
||||
|
||||
func (e detectErrs) Is(target error) bool {
|
||||
return len(e) != 0 && errors.Is(e[0], target)
|
||||
}
|
||||
|
|
6
vendor/go.opentelemetry.io/otel/sdk/resource/builtin.go
generated
vendored
6
vendor/go.opentelemetry.io/otel/sdk/resource/builtin.go
generated
vendored
|
@ -20,9 +20,9 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
|
||||
"go.opentelemetry.io/otel/sdk"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.21.0"
|
||||
)
|
||||
|
||||
type (
|
||||
|
@ -62,7 +62,7 @@ func (telemetrySDK) Detect(context.Context) (*Resource, error) {
|
|||
semconv.SchemaURL,
|
||||
semconv.TelemetrySDKName("opentelemetry"),
|
||||
semconv.TelemetrySDKLanguageGo,
|
||||
semconv.TelemetrySDKVersion(otel.Version()),
|
||||
semconv.TelemetrySDKVersion(sdk.Version()),
|
||||
), nil
|
||||
}
|
||||
|
||||
|
|
5
vendor/go.opentelemetry.io/otel/sdk/resource/config.go
generated
vendored
5
vendor/go.opentelemetry.io/otel/sdk/resource/config.go
generated
vendored
|
@ -71,6 +71,11 @@ func WithHost() Option {
|
|||
return WithDetectors(host{})
|
||||
}
|
||||
|
||||
// WithHostID adds host ID information to the configured resource.
|
||||
func WithHostID() Option {
|
||||
return WithDetectors(hostIDDetector{})
|
||||
}
|
||||
|
||||
// WithTelemetrySDK adds TelemetrySDK version info to the configured resource.
|
||||
func WithTelemetrySDK() Option {
|
||||
return WithDetectors(telemetrySDK{})
|
||||
|
|
2
vendor/go.opentelemetry.io/otel/sdk/resource/container.go
generated
vendored
2
vendor/go.opentelemetry.io/otel/sdk/resource/container.go
generated
vendored
|
@ -22,7 +22,7 @@ import (
|
|||
"os"
|
||||
"regexp"
|
||||
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.21.0"
|
||||
)
|
||||
|
||||
type containerIDProvider func() (string, error)
|
||||
|
|
3
vendor/go.opentelemetry.io/otel/sdk/resource/doc.go
generated
vendored
3
vendor/go.opentelemetry.io/otel/sdk/resource/doc.go
generated
vendored
|
@ -25,4 +25,7 @@
|
|||
// OTEL_RESOURCE_ATTRIBUTES the FromEnv Detector can be used. It will interpret
|
||||
// the value as a list of comma delimited key/value pairs
|
||||
// (e.g. `<key1>=<value1>,<key2>=<value2>,...`).
|
||||
//
|
||||
// While this package provides a stable API,
|
||||
// the attributes added by resource detectors may change.
|
||||
package resource // import "go.opentelemetry.io/otel/sdk/resource"
|
||||
|
|
16
vendor/go.opentelemetry.io/otel/sdk/resource/env.go
generated
vendored
16
vendor/go.opentelemetry.io/otel/sdk/resource/env.go
generated
vendored
|
@ -23,7 +23,7 @@ import (
|
|||
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.21.0"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -82,23 +82,23 @@ func constructOTResources(s string) (*Resource, error) {
|
|||
return Empty(), nil
|
||||
}
|
||||
pairs := strings.Split(s, ",")
|
||||
attrs := []attribute.KeyValue{}
|
||||
var attrs []attribute.KeyValue
|
||||
var invalid []string
|
||||
for _, p := range pairs {
|
||||
field := strings.SplitN(p, "=", 2)
|
||||
if len(field) != 2 {
|
||||
k, v, found := strings.Cut(p, "=")
|
||||
if !found {
|
||||
invalid = append(invalid, p)
|
||||
continue
|
||||
}
|
||||
k := strings.TrimSpace(field[0])
|
||||
v, err := url.QueryUnescape(strings.TrimSpace(field[1]))
|
||||
key := strings.TrimSpace(k)
|
||||
val, err := url.QueryUnescape(strings.TrimSpace(v))
|
||||
if err != nil {
|
||||
// Retain original value if decoding fails, otherwise it will be
|
||||
// an empty string.
|
||||
v = field[1]
|
||||
val = v
|
||||
otel.Handle(err)
|
||||
}
|
||||
attrs = append(attrs, attribute.String(k, v))
|
||||
attrs = append(attrs, attribute.String(key, val))
|
||||
}
|
||||
var err error
|
||||
if len(invalid) > 0 {
|
||||
|
|
120
vendor/go.opentelemetry.io/otel/sdk/resource/host_id.go
generated
vendored
Normal file
120
vendor/go.opentelemetry.io/otel/sdk/resource/host_id.go
generated
vendored
Normal file
|
@ -0,0 +1,120 @@
|
|||
// 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 resource // import "go.opentelemetry.io/otel/sdk/resource"
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.21.0"
|
||||
)
|
||||
|
||||
type hostIDProvider func() (string, error)
|
||||
|
||||
var defaultHostIDProvider hostIDProvider = platformHostIDReader.read
|
||||
|
||||
var hostID = defaultHostIDProvider
|
||||
|
||||
type hostIDReader interface {
|
||||
read() (string, error)
|
||||
}
|
||||
|
||||
type fileReader func(string) (string, error)
|
||||
|
||||
type commandExecutor func(string, ...string) (string, error)
|
||||
|
||||
// hostIDReaderBSD implements hostIDReader.
|
||||
type hostIDReaderBSD struct {
|
||||
execCommand commandExecutor
|
||||
readFile fileReader
|
||||
}
|
||||
|
||||
// read attempts to read the machine-id from /etc/hostid. If not found it will
|
||||
// execute `kenv -q smbios.system.uuid`. If neither location yields an id an
|
||||
// error will be returned.
|
||||
func (r *hostIDReaderBSD) read() (string, error) {
|
||||
if result, err := r.readFile("/etc/hostid"); err == nil {
|
||||
return strings.TrimSpace(result), nil
|
||||
}
|
||||
|
||||
if result, err := r.execCommand("kenv", "-q", "smbios.system.uuid"); err == nil {
|
||||
return strings.TrimSpace(result), nil
|
||||
}
|
||||
|
||||
return "", errors.New("host id not found in: /etc/hostid or kenv")
|
||||
}
|
||||
|
||||
// hostIDReaderDarwin implements hostIDReader.
|
||||
type hostIDReaderDarwin struct {
|
||||
execCommand commandExecutor
|
||||
}
|
||||
|
||||
// read executes `ioreg -rd1 -c "IOPlatformExpertDevice"` and parses host id
|
||||
// from the IOPlatformUUID line. If the command fails or the uuid cannot be
|
||||
// parsed an error will be returned.
|
||||
func (r *hostIDReaderDarwin) read() (string, error) {
|
||||
result, err := r.execCommand("ioreg", "-rd1", "-c", "IOPlatformExpertDevice")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
lines := strings.Split(result, "\n")
|
||||
for _, line := range lines {
|
||||
if strings.Contains(line, "IOPlatformUUID") {
|
||||
parts := strings.Split(line, " = ")
|
||||
if len(parts) == 2 {
|
||||
return strings.Trim(parts[1], "\""), nil
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return "", errors.New("could not parse IOPlatformUUID")
|
||||
}
|
||||
|
||||
type hostIDReaderLinux struct {
|
||||
readFile fileReader
|
||||
}
|
||||
|
||||
// read attempts to read the machine-id from /etc/machine-id followed by
|
||||
// /var/lib/dbus/machine-id. If neither location yields an ID an error will
|
||||
// be returned.
|
||||
func (r *hostIDReaderLinux) read() (string, error) {
|
||||
if result, err := r.readFile("/etc/machine-id"); err == nil {
|
||||
return strings.TrimSpace(result), nil
|
||||
}
|
||||
|
||||
if result, err := r.readFile("/var/lib/dbus/machine-id"); err == nil {
|
||||
return strings.TrimSpace(result), nil
|
||||
}
|
||||
|
||||
return "", errors.New("host id not found in: /etc/machine-id or /var/lib/dbus/machine-id")
|
||||
}
|
||||
|
||||
type hostIDDetector struct{}
|
||||
|
||||
// Detect returns a *Resource containing the platform specific host id.
|
||||
func (hostIDDetector) Detect(ctx context.Context) (*Resource, error) {
|
||||
hostID, err := hostID()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return NewWithAttributes(
|
||||
semconv.SchemaURL,
|
||||
semconv.HostID(hostID),
|
||||
), nil
|
||||
}
|
|
@ -12,13 +12,12 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package internal contains common functionality for all OTLP exporters.
|
||||
package internal // import "go.opentelemetry.io/otel/exporters/otlp/internal"
|
||||
//go:build dragonfly || freebsd || netbsd || openbsd || solaris
|
||||
// +build dragonfly freebsd netbsd openbsd solaris
|
||||
|
||||
import "go.opentelemetry.io/otel"
|
||||
package resource // import "go.opentelemetry.io/otel/sdk/resource"
|
||||
|
||||
// GetUserAgentHeader return an OTLP header value form "OTel OTLP Exporter Go/{{ .Version }}"
|
||||
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#user-agent
|
||||
func GetUserAgentHeader() string {
|
||||
return "OTel OTLP Exporter Go/" + otel.Version()
|
||||
var platformHostIDReader hostIDReader = &hostIDReaderBSD{
|
||||
execCommand: execCommand,
|
||||
readFile: readFile,
|
||||
}
|
19
vendor/go.opentelemetry.io/otel/sdk/resource/host_id_darwin.go
generated
vendored
Normal file
19
vendor/go.opentelemetry.io/otel/sdk/resource/host_id_darwin.go
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
// 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 resource // import "go.opentelemetry.io/otel/sdk/resource"
|
||||
|
||||
var platformHostIDReader hostIDReader = &hostIDReaderDarwin{
|
||||
execCommand: execCommand,
|
||||
}
|
|
@ -12,23 +12,18 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package internal contains common functionality for all OTLP exporters.
|
||||
package internal // import "go.opentelemetry.io/otel/exporters/otlp/internal"
|
||||
//go:build darwin || dragonfly || freebsd || netbsd || openbsd || solaris
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"strings"
|
||||
)
|
||||
package resource // import "go.opentelemetry.io/otel/sdk/resource"
|
||||
|
||||
// CleanPath returns a path with all spaces trimmed and all redundancies removed. If urlPath is empty or cleaning it results in an empty string, defaultPath is returned instead.
|
||||
func CleanPath(urlPath string, defaultPath string) string {
|
||||
tmp := path.Clean(strings.TrimSpace(urlPath))
|
||||
if tmp == "." {
|
||||
return defaultPath
|
||||
import "os/exec"
|
||||
|
||||
func execCommand(name string, arg ...string) (string, error) {
|
||||
cmd := exec.Command(name, arg...)
|
||||
b, err := cmd.Output()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if !path.IsAbs(tmp) {
|
||||
tmp = fmt.Sprintf("/%s", tmp)
|
||||
}
|
||||
return tmp
|
||||
|
||||
return string(b), nil
|
||||
}
|
22
vendor/go.opentelemetry.io/otel/sdk/resource/host_id_linux.go
generated
vendored
Normal file
22
vendor/go.opentelemetry.io/otel/sdk/resource/host_id_linux.go
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
// 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.
|
||||
|
||||
//go:build linux
|
||||
// +build linux
|
||||
|
||||
package resource // import "go.opentelemetry.io/otel/sdk/resource"
|
||||
|
||||
var platformHostIDReader hostIDReader = &hostIDReaderLinux{
|
||||
readFile: readFile,
|
||||
}
|
28
vendor/go.opentelemetry.io/otel/sdk/resource/host_id_readfile.go
generated
vendored
Normal file
28
vendor/go.opentelemetry.io/otel/sdk/resource/host_id_readfile.go
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
// 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.
|
||||
|
||||
//go:build linux || dragonfly || freebsd || netbsd || openbsd || solaris
|
||||
|
||||
package resource // import "go.opentelemetry.io/otel/sdk/resource"
|
||||
|
||||
import "os"
|
||||
|
||||
func readFile(filename string) (string, error) {
|
||||
b, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(b), nil
|
||||
}
|
36
vendor/go.opentelemetry.io/otel/sdk/resource/host_id_unsupported.go
generated
vendored
Normal file
36
vendor/go.opentelemetry.io/otel/sdk/resource/host_id_unsupported.go
generated
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
// 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.
|
||||
|
||||
// +build !darwin
|
||||
// +build !dragonfly
|
||||
// +build !freebsd
|
||||
// +build !linux
|
||||
// +build !netbsd
|
||||
// +build !openbsd
|
||||
// +build !solaris
|
||||
// +build !windows
|
||||
|
||||
package resource // import "go.opentelemetry.io/otel/sdk/resource"
|
||||
|
||||
// hostIDReaderUnsupported is a placeholder implementation for operating systems
|
||||
// for which this project currently doesn't support host.id
|
||||
// attribute detection. See build tags declaration early on this file
|
||||
// for a list of unsupported OSes.
|
||||
type hostIDReaderUnsupported struct{}
|
||||
|
||||
func (*hostIDReaderUnsupported) read() (string, error) {
|
||||
return "<unknown>", nil
|
||||
}
|
||||
|
||||
var platformHostIDReader hostIDReader = &hostIDReaderUnsupported{}
|
48
vendor/go.opentelemetry.io/otel/sdk/resource/host_id_windows.go
generated
vendored
Normal file
48
vendor/go.opentelemetry.io/otel/sdk/resource/host_id_windows.go
generated
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
// 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.
|
||||
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package resource // import "go.opentelemetry.io/otel/sdk/resource"
|
||||
|
||||
import (
|
||||
"golang.org/x/sys/windows/registry"
|
||||
)
|
||||
|
||||
// implements hostIDReader
|
||||
type hostIDReaderWindows struct{}
|
||||
|
||||
// read reads MachineGuid from the windows registry key:
|
||||
// SOFTWARE\Microsoft\Cryptography
|
||||
func (*hostIDReaderWindows) read() (string, error) {
|
||||
k, err := registry.OpenKey(
|
||||
registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Cryptography`,
|
||||
registry.QUERY_VALUE|registry.WOW64_64KEY,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer k.Close()
|
||||
|
||||
guid, _, err := k.GetStringValue("MachineGuid")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return guid, nil
|
||||
}
|
||||
|
||||
var platformHostIDReader hostIDReader = &hostIDReaderWindows{}
|
4
vendor/go.opentelemetry.io/otel/sdk/resource/os.go
generated
vendored
4
vendor/go.opentelemetry.io/otel/sdk/resource/os.go
generated
vendored
|
@ -19,7 +19,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.21.0"
|
||||
)
|
||||
|
||||
type osDescriptionProvider func() (string, error)
|
||||
|
@ -75,6 +75,7 @@ func mapRuntimeOSToSemconvOSType(osType string) attribute.KeyValue {
|
|||
// the elements in this map are the intersection between
|
||||
// available GOOS values and defined semconv OS types
|
||||
osTypeAttributeMap := map[string]attribute.KeyValue{
|
||||
"aix": semconv.OSTypeAIX,
|
||||
"darwin": semconv.OSTypeDarwin,
|
||||
"dragonfly": semconv.OSTypeDragonflyBSD,
|
||||
"freebsd": semconv.OSTypeFreeBSD,
|
||||
|
@ -83,6 +84,7 @@ func mapRuntimeOSToSemconvOSType(osType string) attribute.KeyValue {
|
|||
"openbsd": semconv.OSTypeOpenBSD,
|
||||
"solaris": semconv.OSTypeSolaris,
|
||||
"windows": semconv.OSTypeWindows,
|
||||
"zos": semconv.OSTypeZOS,
|
||||
}
|
||||
|
||||
var osTypeAttribute attribute.KeyValue
|
||||
|
|
8
vendor/go.opentelemetry.io/otel/sdk/resource/os_release_unix.go
generated
vendored
8
vendor/go.opentelemetry.io/otel/sdk/resource/os_release_unix.go
generated
vendored
|
@ -85,14 +85,14 @@ func skip(line string) bool {
|
|||
// parse attempts to split the provided line on the first '=' character, and then
|
||||
// sanitize each side of the split before returning them as a key-value pair.
|
||||
func parse(line string) (string, string, bool) {
|
||||
parts := strings.SplitN(line, "=", 2)
|
||||
k, v, found := strings.Cut(line, "=")
|
||||
|
||||
if len(parts) != 2 || len(parts[0]) == 0 {
|
||||
if !found || len(k) == 0 {
|
||||
return "", "", false
|
||||
}
|
||||
|
||||
key := strings.TrimSpace(parts[0])
|
||||
value := unescape(unquote(strings.TrimSpace(parts[1])))
|
||||
key := strings.TrimSpace(k)
|
||||
value := unescape(unquote(strings.TrimSpace(v)))
|
||||
|
||||
return key, value, true
|
||||
}
|
||||
|
|
2
vendor/go.opentelemetry.io/otel/sdk/resource/process.go
generated
vendored
2
vendor/go.opentelemetry.io/otel/sdk/resource/process.go
generated
vendored
|
@ -22,7 +22,7 @@ import (
|
|||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.21.0"
|
||||
)
|
||||
|
||||
type pidProvider func() int
|
||||
|
|
27
vendor/go.opentelemetry.io/otel/sdk/resource/resource.go
generated
vendored
27
vendor/go.opentelemetry.io/otel/sdk/resource/resource.go
generated
vendored
|
@ -17,7 +17,6 @@ package resource // import "go.opentelemetry.io/otel/sdk/resource"
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
|
@ -37,7 +36,6 @@ type Resource struct {
|
|||
}
|
||||
|
||||
var (
|
||||
emptyResource Resource
|
||||
defaultResource *Resource
|
||||
defaultResourceOnce sync.Once
|
||||
)
|
||||
|
@ -51,17 +49,8 @@ func New(ctx context.Context, opts ...Option) (*Resource, error) {
|
|||
cfg = opt.apply(cfg)
|
||||
}
|
||||
|
||||
resource, err := Detect(ctx, cfg.detectors...)
|
||||
|
||||
var err2 error
|
||||
resource, err2 = Merge(resource, &Resource{schemaURL: cfg.schemaURL})
|
||||
if err == nil {
|
||||
err = err2
|
||||
} else if err2 != nil {
|
||||
err = fmt.Errorf("detecting resources: %s", []string{err.Error(), err2.Error()})
|
||||
}
|
||||
|
||||
return resource, err
|
||||
r := &Resource{schemaURL: cfg.schemaURL}
|
||||
return r, detect(ctx, r, cfg.detectors)
|
||||
}
|
||||
|
||||
// NewWithAttributes creates a resource from attrs and associates the resource with a
|
||||
|
@ -80,18 +69,18 @@ func NewWithAttributes(schemaURL string, attrs ...attribute.KeyValue) *Resource
|
|||
// of the attrs is known use NewWithAttributes instead.
|
||||
func NewSchemaless(attrs ...attribute.KeyValue) *Resource {
|
||||
if len(attrs) == 0 {
|
||||
return &emptyResource
|
||||
return &Resource{}
|
||||
}
|
||||
|
||||
// Ensure attributes comply with the specification:
|
||||
// https://github.com/open-telemetry/opentelemetry-specification/blob/v1.0.1/specification/common/common.md#attributes
|
||||
// https://github.com/open-telemetry/opentelemetry-specification/blob/v1.20.0/specification/common/README.md#attribute
|
||||
s, _ := attribute.NewSetWithFiltered(attrs, func(kv attribute.KeyValue) bool {
|
||||
return kv.Valid()
|
||||
})
|
||||
|
||||
// If attrs only contains invalid entries do not allocate a new resource.
|
||||
if s.Len() == 0 {
|
||||
return &emptyResource
|
||||
return &Resource{}
|
||||
}
|
||||
|
||||
return &Resource{attrs: s} //nolint
|
||||
|
@ -164,7 +153,7 @@ func (r *Resource) Equal(eq *Resource) bool {
|
|||
// if resource b's value is empty.
|
||||
//
|
||||
// The SchemaURL of the resources will be merged according to the spec rules:
|
||||
// https://github.com/open-telemetry/opentelemetry-specification/blob/bad49c714a62da5493f2d1d9bafd7ebe8c8ce7eb/specification/resource/sdk.md#merge
|
||||
// https://github.com/open-telemetry/opentelemetry-specification/blob/v1.20.0/specification/resource/sdk.md#merge
|
||||
// If the resources have different non-empty schemaURL an empty resource and an error
|
||||
// will be returned.
|
||||
func Merge(a, b *Resource) (*Resource, error) {
|
||||
|
@ -205,7 +194,7 @@ func Merge(a, b *Resource) (*Resource, error) {
|
|||
// Empty returns an instance of Resource with no attributes. It is
|
||||
// equivalent to a `nil` Resource.
|
||||
func Empty() *Resource {
|
||||
return &emptyResource
|
||||
return &Resource{}
|
||||
}
|
||||
|
||||
// Default returns an instance of Resource with a default
|
||||
|
@ -224,7 +213,7 @@ func Default() *Resource {
|
|||
}
|
||||
// If Detect did not return a valid resource, fall back to emptyResource.
|
||||
if defaultResource == nil {
|
||||
defaultResource = &emptyResource
|
||||
defaultResource = &Resource{}
|
||||
}
|
||||
})
|
||||
return defaultResource
|
||||
|
|
70
vendor/go.opentelemetry.io/otel/sdk/trace/batch_span_processor.go
generated
vendored
70
vendor/go.opentelemetry.io/otel/sdk/trace/batch_span_processor.go
generated
vendored
|
@ -16,7 +16,6 @@ package trace // import "go.opentelemetry.io/otel/sdk/trace"
|
|||
|
||||
import (
|
||||
"context"
|
||||
"runtime"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
@ -84,6 +83,7 @@ type batchSpanProcessor struct {
|
|||
stopWait sync.WaitGroup
|
||||
stopOnce sync.Once
|
||||
stopCh chan struct{}
|
||||
stopped atomic.Bool
|
||||
}
|
||||
|
||||
var _ SpanProcessor = (*batchSpanProcessor)(nil)
|
||||
|
@ -91,7 +91,7 @@ var _ SpanProcessor = (*batchSpanProcessor)(nil)
|
|||
// NewBatchSpanProcessor creates a new SpanProcessor that will send completed
|
||||
// span batches to the exporter with the supplied options.
|
||||
//
|
||||
// If the exporter is nil, the span processor will preform no action.
|
||||
// If the exporter is nil, the span processor will perform no action.
|
||||
func NewBatchSpanProcessor(exporter SpanExporter, options ...BatchSpanProcessorOption) SpanProcessor {
|
||||
maxQueueSize := env.BatchSpanProcessorMaxQueueSize(DefaultMaxQueueSize)
|
||||
maxExportBatchSize := env.BatchSpanProcessorMaxExportBatchSize(DefaultMaxExportBatchSize)
|
||||
|
@ -137,6 +137,11 @@ func (bsp *batchSpanProcessor) OnStart(parent context.Context, s ReadWriteSpan)
|
|||
|
||||
// OnEnd method enqueues a ReadOnlySpan for later processing.
|
||||
func (bsp *batchSpanProcessor) OnEnd(s ReadOnlySpan) {
|
||||
// Do not enqueue spans after Shutdown.
|
||||
if bsp.stopped.Load() {
|
||||
return
|
||||
}
|
||||
|
||||
// Do not enqueue spans if we are just going to drop them.
|
||||
if bsp.e == nil {
|
||||
return
|
||||
|
@ -149,6 +154,7 @@ func (bsp *batchSpanProcessor) OnEnd(s ReadOnlySpan) {
|
|||
func (bsp *batchSpanProcessor) Shutdown(ctx context.Context) error {
|
||||
var err error
|
||||
bsp.stopOnce.Do(func() {
|
||||
bsp.stopped.Store(true)
|
||||
wait := make(chan struct{})
|
||||
go func() {
|
||||
close(bsp.stopCh)
|
||||
|
@ -181,11 +187,24 @@ func (f forceFlushSpan) SpanContext() trace.SpanContext {
|
|||
|
||||
// ForceFlush exports all ended spans that have not yet been exported.
|
||||
func (bsp *batchSpanProcessor) ForceFlush(ctx context.Context) error {
|
||||
// Interrupt if context is already canceled.
|
||||
if err := ctx.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Do nothing after Shutdown.
|
||||
if bsp.stopped.Load() {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
if bsp.e != nil {
|
||||
flushCh := make(chan struct{})
|
||||
if bsp.enqueueBlockOnQueueFull(ctx, forceFlushSpan{flushed: flushCh}) {
|
||||
select {
|
||||
case <-bsp.stopCh:
|
||||
// The batchSpanProcessor is Shutdown.
|
||||
return nil
|
||||
case <-flushCh:
|
||||
// Processed any items in queue prior to ForceFlush being called
|
||||
case <-ctx.Done():
|
||||
|
@ -326,11 +345,9 @@ func (bsp *batchSpanProcessor) drainQueue() {
|
|||
for {
|
||||
select {
|
||||
case sd := <-bsp.queue:
|
||||
if sd == nil {
|
||||
if err := bsp.exportSpans(ctx); err != nil {
|
||||
otel.Handle(err)
|
||||
}
|
||||
return
|
||||
if _, ok := sd.(forceFlushSpan); ok {
|
||||
// Ignore flush requests as they are not valid spans.
|
||||
continue
|
||||
}
|
||||
|
||||
bsp.batchMutex.Lock()
|
||||
|
@ -344,7 +361,11 @@ func (bsp *batchSpanProcessor) drainQueue() {
|
|||
}
|
||||
}
|
||||
default:
|
||||
close(bsp.queue)
|
||||
// There are no more enqueued spans. Make final export.
|
||||
if err := bsp.exportSpans(ctx); err != nil {
|
||||
otel.Handle(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -358,34 +379,11 @@ func (bsp *batchSpanProcessor) enqueue(sd ReadOnlySpan) {
|
|||
}
|
||||
}
|
||||
|
||||
func recoverSendOnClosedChan() {
|
||||
x := recover()
|
||||
switch err := x.(type) {
|
||||
case nil:
|
||||
return
|
||||
case runtime.Error:
|
||||
if err.Error() == "send on closed channel" {
|
||||
return
|
||||
}
|
||||
}
|
||||
panic(x)
|
||||
}
|
||||
|
||||
func (bsp *batchSpanProcessor) enqueueBlockOnQueueFull(ctx context.Context, sd ReadOnlySpan) bool {
|
||||
if !sd.SpanContext().IsSampled() {
|
||||
return false
|
||||
}
|
||||
|
||||
// This ensures the bsp.queue<- below does not panic as the
|
||||
// processor shuts down.
|
||||
defer recoverSendOnClosedChan()
|
||||
|
||||
select {
|
||||
case <-bsp.stopCh:
|
||||
return false
|
||||
default:
|
||||
}
|
||||
|
||||
select {
|
||||
case bsp.queue <- sd:
|
||||
return true
|
||||
|
@ -399,16 +397,6 @@ func (bsp *batchSpanProcessor) enqueueDrop(ctx context.Context, sd ReadOnlySpan)
|
|||
return false
|
||||
}
|
||||
|
||||
// This ensures the bsp.queue<- below does not panic as the
|
||||
// processor shuts down.
|
||||
defer recoverSendOnClosedChan()
|
||||
|
||||
select {
|
||||
case <-bsp.stopCh:
|
||||
return false
|
||||
default:
|
||||
}
|
||||
|
||||
select {
|
||||
case bsp.queue <- sd:
|
||||
return true
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue