From ceec1a472454b62f408c39eb8bcbe037be3ab7fa Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Tue, 1 Oct 2024 14:23:43 -0700 Subject: [PATCH 1/8] Update sdk pkg to use telemetry instead of pdata --- internal/test/e2e/autosdk/go.mod | 15 -- internal/test/e2e/autosdk/go.sum | 60 -------- sdk/go.mod | 16 +- sdk/go.sum | 65 +------- sdk/trace.go | 255 ++++++++++++++++++------------- sdk/trace_test.go | 253 +++++++++++++++--------------- 6 files changed, 281 insertions(+), 383 deletions(-) diff --git a/internal/test/e2e/autosdk/go.mod b/internal/test/e2e/autosdk/go.mod index 5a6305762..a0a2f05c4 100644 --- a/internal/test/e2e/autosdk/go.mod +++ b/internal/test/e2e/autosdk/go.mod @@ -8,19 +8,4 @@ require ( go.opentelemetry.io/otel/trace v1.31.0 ) -require ( - github.com/gogo/protobuf v1.3.2 // indirect - github.com/json-iterator/go v1.1.12 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect - go.opentelemetry.io/collector/pdata v1.17.0 // indirect - go.uber.org/multierr v1.11.0 // indirect - golang.org/x/net v0.28.0 // indirect - golang.org/x/sys v0.25.0 // indirect - golang.org/x/text v0.17.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect - google.golang.org/grpc v1.67.1 // indirect - google.golang.org/protobuf v1.34.2 // indirect -) - replace go.opentelemetry.io/auto/sdk => ../../../../sdk/ diff --git a/internal/test/e2e/autosdk/go.sum b/internal/test/e2e/autosdk/go.sum index 141452d88..0484ed766 100644 --- a/internal/test/e2e/autosdk/go.sum +++ b/internal/test/e2e/autosdk/go.sum @@ -1,74 +1,14 @@ -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.opentelemetry.io/collector/pdata v1.17.0 h1:z8cjjT2FThAehWu5fbF48OnZyK5q8xd1UhC4XszDo0w= -go.opentelemetry.io/collector/pdata v1.17.0/go.mod h1:yZaQ9KZAm/qie96LTygRKxOXMq0/54h8OW7330ycuvQ= go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY= go.opentelemetry.io/otel v1.31.0/go.mod h1:O0C14Yl9FgkjqcCZAsE053C13OaddMYr/hz6clDkEJE= go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HYdmJys= go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A= -go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= -go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= -go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= -golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= -golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= -google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= -google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/go.mod b/sdk/go.mod index 8deabb707..460c289b4 100644 --- a/sdk/go.mod +++ b/sdk/go.mod @@ -6,25 +6,15 @@ toolchain go1.22.6 require ( github.com/stretchr/testify v1.9.0 - go.opentelemetry.io/collector/pdata v1.17.0 go.opentelemetry.io/otel v1.31.0 go.opentelemetry.io/otel/trace v1.31.0 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/json-iterator/go v1.1.12 // indirect - github.com/kr/text v0.2.0 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/kr/pretty v0.3.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - go.uber.org/multierr v1.11.0 // indirect - golang.org/x/net v0.28.0 // indirect - golang.org/x/sys v0.24.0 // indirect - golang.org/x/text v0.17.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect - google.golang.org/grpc v1.67.1 // indirect - google.golang.org/protobuf v1.34.2 // indirect + github.com/rogpeppe/go-internal v1.10.0 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/sdk/go.sum b/sdk/go.sum index d8eccd24b..d471db661 100644 --- a/sdk/go.sum +++ b/sdk/go.sum @@ -1,82 +1,27 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.opentelemetry.io/collector/pdata v1.17.0 h1:z8cjjT2FThAehWu5fbF48OnZyK5q8xd1UhC4XszDo0w= -go.opentelemetry.io/collector/pdata v1.17.0/go.mod h1:yZaQ9KZAm/qie96LTygRKxOXMq0/54h8OW7330ycuvQ= go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY= go.opentelemetry.io/otel v1.31.0/go.mod h1:O0C14Yl9FgkjqcCZAsE053C13OaddMYr/hz6clDkEJE= go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HYdmJys= go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A= -go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= -go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= -go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= -golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= -google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= -google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/sdk/trace.go b/sdk/trace.go index d473a0f23..052c02d1c 100644 --- a/sdk/trace.go +++ b/sdk/trace.go @@ -5,18 +5,19 @@ package sdk import ( "context" + "encoding/json" "fmt" "reflect" "runtime" "time" - "go.opentelemetry.io/collector/pdata/pcommon" - "go.opentelemetry.io/collector/pdata/ptrace" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/codes" semconv "go.opentelemetry.io/otel/semconv/v1.26.0" "go.opentelemetry.io/otel/trace" "go.opentelemetry.io/otel/trace/embedded" + + "go.opentelemetry.io/auto/sdk/telemetry" ) // GetTracerProvider returns an auto-instrumentable [trace.TracerProvider]. @@ -85,56 +86,57 @@ func (t *tracer) start( // start is used for testing. var start = func(context.Context, *span, *trace.SpanContext, *bool, *trace.SpanContext) {} -func (t tracer) traces(ctx context.Context, name string, cfg trace.SpanConfig, sc, psc trace.SpanContext) (ptrace.Traces, ptrace.Span) { - // TODO: pool this. It can be returned on end. - traces := ptrace.NewTraces() - traces.ResourceSpans().EnsureCapacity(1) - - rs := traces.ResourceSpans().AppendEmpty() - rs.ScopeSpans().EnsureCapacity(1) - - ss := rs.ScopeSpans().AppendEmpty() - ss.Scope().SetName(t.name) - ss.Scope().SetVersion(t.version) - ss.SetSchemaUrl(t.schemaURL) - ss.Spans().EnsureCapacity(1) - - span := ss.Spans().AppendEmpty() - span.SetTraceID(pcommon.TraceID(sc.TraceID())) - span.SetSpanID(pcommon.SpanID(sc.SpanID())) - span.SetFlags(uint32(sc.TraceFlags())) - span.TraceState().FromRaw(sc.TraceState().String()) - span.SetParentSpanID(pcommon.SpanID(psc.SpanID())) - span.SetName(name) - span.SetKind(spanKind(cfg.SpanKind())) - - var start pcommon.Timestamp +func (t tracer) traces(ctx context.Context, name string, cfg trace.SpanConfig, sc, psc trace.SpanContext) (*telemetry.Traces, *telemetry.Span) { + span := &telemetry.Span{ + TraceID: telemetry.TraceID(sc.TraceID()), + SpanID: telemetry.SpanID(sc.SpanID()), + Flags: uint32(sc.TraceFlags()), + TraceState: sc.TraceState().String(), + ParentSpanID: telemetry.SpanID(psc.SpanID()), + Name: name, + Kind: spanKind(cfg.SpanKind()), + Attrs: convAttrs(cfg.Attributes()), + Links: convLinks(cfg.Links()), + } + if t := cfg.Timestamp(); !t.IsZero() { - start = pcommon.NewTimestampFromTime(cfg.Timestamp()) + span.StartTime = cfg.Timestamp() } else { - start = pcommon.NewTimestampFromTime(time.Now()) + span.StartTime = time.Now() } - span.SetStartTimestamp(start) - addLinks(span.Links(), cfg.Links()...) - setAttributes(span.Attributes(), cfg.Attributes()) - return traces, span + return &telemetry.Traces{ + ResourceSpans: []*telemetry.ResourceSpans{ + { + ScopeSpans: []*telemetry.ScopeSpans{ + { + Scope: &telemetry.Scope{ + Name: t.name, + Version: t.version, + }, + Spans: []*telemetry.Span{span}, + SchemaURL: t.schemaURL, + }, + }, + }, + }, + }, span } -func spanKind(kind trace.SpanKind) ptrace.SpanKind { +func spanKind(kind trace.SpanKind) telemetry.SpanKind { switch kind { case trace.SpanKindInternal: - return ptrace.SpanKindInternal + return telemetry.SpanKindInternal case trace.SpanKindServer: - return ptrace.SpanKindServer + return telemetry.SpanKindServer case trace.SpanKindClient: - return ptrace.SpanKindClient + return telemetry.SpanKindClient case trace.SpanKindProducer: - return ptrace.SpanKindProducer + return telemetry.SpanKindProducer case trace.SpanKindConsumer: - return ptrace.SpanKindConsumer + return telemetry.SpanKindConsumer } - return ptrace.SpanKindUnspecified + return telemetry.SpanKind(0) // undefined. } type span struct { @@ -143,8 +145,8 @@ type span struct { sampled bool spanContext trace.SpanContext - traces ptrace.Traces - span ptrace.Span + traces *telemetry.Traces + span *telemetry.Span } func (s *span) SpanContext() trace.SpanContext { @@ -166,16 +168,19 @@ func (s *span) SetStatus(c codes.Code, msg string) { return } - stat := s.span.Status() - stat.SetMessage(msg) + if s.span.Status == nil { + s.span.Status = new(telemetry.Status) + } + + s.span.Status.Message = msg switch c { case codes.Unset: - stat.SetCode(ptrace.StatusCodeUnset) + s.span.Status.Code = telemetry.StatusCodeUnset case codes.Error: - stat.SetCode(ptrace.StatusCodeError) + s.span.Status.Code = telemetry.StatusCodeError case codes.Ok: - stat.SetCode(ptrace.StatusCodeOk) + s.span.Status.Code = telemetry.StatusCodeOK } } @@ -186,52 +191,85 @@ func (s *span) SetAttributes(attrs ...attribute.KeyValue) { // TODO: handle attribute limits. - setAttributes(s.span.Attributes(), attrs) + m := make(map[string]int) + for i, a := range s.span.Attrs { + m[a.Key] = i + } + + for _, a := range attrs { + val := convAttrValue(a.Value) + if val.Empty() { + continue + } + + if idx, ok := m[string(a.Key)]; ok { + s.span.Attrs[idx] = telemetry.Attr{ + Key: string(a.Key), + Value: val, + } + } else { + s.span.Attrs = append(s.span.Attrs, telemetry.Attr{ + Key: string(a.Key), + Value: val, + }) + m[string(a.Key)] = len(s.span.Attrs) - 1 + } + } } -func setAttributes(dest pcommon.Map, attrs []attribute.KeyValue) { - dest.EnsureCapacity(len(attrs)) +func convAttrs(attrs []attribute.KeyValue) []telemetry.Attr { + out := make([]telemetry.Attr, 0, len(attrs)) for _, attr := range attrs { key := string(attr.Key) - switch attr.Value.Type() { - case attribute.BOOL: - dest.PutBool(key, attr.Value.AsBool()) - case attribute.INT64: - dest.PutInt(key, attr.Value.AsInt64()) - case attribute.FLOAT64: - dest.PutDouble(key, attr.Value.AsFloat64()) - case attribute.STRING: - dest.PutStr(key, attr.Value.AsString()) - case attribute.BOOLSLICE: - val := attr.Value.AsBoolSlice() - s := dest.PutEmptySlice(key) - s.EnsureCapacity(len(val)) - for _, v := range val { - s.AppendEmpty().SetBool(v) - } - case attribute.INT64SLICE: - val := attr.Value.AsInt64Slice() - s := dest.PutEmptySlice(key) - s.EnsureCapacity(len(val)) - for _, v := range val { - s.AppendEmpty().SetInt(v) - } - case attribute.FLOAT64SLICE: - val := attr.Value.AsFloat64Slice() - s := dest.PutEmptySlice(key) - s.EnsureCapacity(len(val)) - for _, v := range val { - s.AppendEmpty().SetDouble(v) - } - case attribute.STRINGSLICE: - val := attr.Value.AsStringSlice() - s := dest.PutEmptySlice(key) - s.EnsureCapacity(len(val)) - for _, v := range val { - s.AppendEmpty().SetStr(v) - } + val := convAttrValue(attr.Value) + if val.Empty() { + continue } + out = append(out, telemetry.Attr{Key: key, Value: val}) } + return out +} + +func convAttrValue(value attribute.Value) telemetry.Value { + switch value.Type() { + case attribute.BOOL: + return telemetry.BoolValue(value.AsBool()) + case attribute.INT64: + return telemetry.Int64Value(value.AsInt64()) + case attribute.FLOAT64: + return telemetry.Float64Value(value.AsFloat64()) + case attribute.STRING: + return telemetry.StringValue(value.AsString()) + case attribute.BOOLSLICE: + slice := value.AsBoolSlice() + out := make([]telemetry.Value, 0, len(slice)) + for _, v := range slice { + out = append(out, telemetry.BoolValue(v)) + } + return telemetry.SliceValue(out...) + case attribute.INT64SLICE: + slice := value.AsInt64Slice() + out := make([]telemetry.Value, 0, len(slice)) + for _, v := range slice { + out = append(out, telemetry.Int64Value(v)) + } + return telemetry.SliceValue(out...) + case attribute.FLOAT64SLICE: + slice := value.AsFloat64Slice() + out := make([]telemetry.Value, 0, len(slice)) + for _, v := range slice { + out = append(out, telemetry.Float64Value(v)) + } + return telemetry.SliceValue(out...) + case attribute.STRINGSLICE: + slice := value.AsStringSlice() + out := make([]telemetry.Value, 0, len(slice)) + for _, v := range slice { + out = append(out, telemetry.StringValue(v)) + } + return telemetry.SliceValue(out...) + } + return telemetry.Value{} } func (s *span) End(opts ...trace.SpanEndOption) { @@ -240,16 +278,13 @@ func (s *span) End(opts ...trace.SpanEndOption) { } cfg := trace.NewSpanEndConfig(opts...) - var end time.Time if t := cfg.Timestamp(); !t.IsZero() { - end = t + s.span.EndTime = cfg.Timestamp() } else { - end = time.Now() + s.span.EndTime = time.Now() } - s.span.SetEndTimestamp(pcommon.NewTimestampFromTime(end)) - var m ptrace.ProtoMarshaler - b, _ := m.MarshalTraces(s.traces) // TODO: do not ignore this error. + b, _ := json.Marshal(s.traces) // TODO: do not ignore this error. s.sampled = false @@ -306,11 +341,11 @@ func (s *span) AddEvent(name string, opts ...trace.EventOption) { func (s *span) addEvent(name string, tStamp time.Time, attrs []attribute.KeyValue) { // TODO: handle event limits. - event := s.span.Events().AppendEmpty() - event.SetName(name) - ts := pcommon.NewTimestampFromTime(tStamp) - event.SetTimestamp(ts) - setAttributes(event.Attributes(), attrs) + s.span.Events = append(s.span.Events, &telemetry.SpanEvent{ + Time: tStamp, + Name: name, + Attrs: convAttrs(attrs), + }) } func (s *span) AddLink(link trace.Link) { @@ -320,18 +355,24 @@ func (s *span) AddLink(link trace.Link) { // TODO: handle link limits. - addLinks(s.span.Links(), link) + s.span.Links = append(s.span.Links, convLink(link)) } -func addLinks(dest ptrace.SpanLinkSlice, links ...trace.Link) { - dest.EnsureCapacity(len(links)) +func convLinks(links []trace.Link) []*telemetry.SpanLink { + out := make([]*telemetry.SpanLink, 0, len(links)) for _, link := range links { - l := dest.AppendEmpty() - l.SetTraceID(pcommon.TraceID(link.SpanContext.TraceID())) - l.SetSpanID(pcommon.SpanID(link.SpanContext.SpanID())) - l.SetFlags(uint32(link.SpanContext.TraceFlags())) - l.TraceState().FromRaw(link.SpanContext.TraceState().String()) - setAttributes(l.Attributes(), link.Attributes) + out = append(out, convLink(link)) + } + return out +} + +func convLink(link trace.Link) *telemetry.SpanLink { + return &telemetry.SpanLink{ + TraceID: telemetry.TraceID(link.SpanContext.TraceID()), + SpanID: telemetry.SpanID(link.SpanContext.SpanID()), + TraceState: link.SpanContext.TraceState().String(), + Attrs: convAttrs(link.Attributes), + Flags: uint32(link.SpanContext.TraceFlags()), } } @@ -339,7 +380,7 @@ func (s *span) SetName(name string) { if s == nil || !s.sampled { return } - s.span.SetName(name) + s.span.Name = name } func (*span) TracerProvider() trace.TracerProvider { return GetTracerProvider() } diff --git a/sdk/trace_test.go b/sdk/trace_test.go index 61569cebf..f2937d08f 100644 --- a/sdk/trace_test.go +++ b/sdk/trace_test.go @@ -5,6 +5,7 @@ package sdk import ( "context" + "encoding/json" "errors" "math" "testing" @@ -12,12 +13,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/pdata/pcommon" - "go.opentelemetry.io/collector/pdata/ptrace" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/codes" semconv "go.opentelemetry.io/otel/semconv/v1.26.0" "go.opentelemetry.io/otel/trace" + + "go.opentelemetry.io/auto/sdk/telemetry" ) var ( @@ -34,38 +35,34 @@ var ( attribute.StringSlice("string slice", []string{"one", "two"}), } - pAttrs = func() pcommon.Map { - m := pcommon.NewMap() - m.PutBool("bool", true) - m.PutInt("int", -1) - m.PutInt("int64", 43) - m.PutDouble("float64", 0.3) - m.PutStr("string", "value") - - s := m.PutEmptySlice("bool slice") - s.AppendEmpty().SetBool(true) - s.AppendEmpty().SetBool(false) - s.AppendEmpty().SetBool(true) - - s = m.PutEmptySlice("int slice") - s.AppendEmpty().SetInt(-1) - s.AppendEmpty().SetInt(-30) - s.AppendEmpty().SetInt(328) - - s = m.PutEmptySlice("int64 slice") - s.AppendEmpty().SetInt(1030) - s.AppendEmpty().SetInt(0) - s.AppendEmpty().SetInt(0) - - s = m.PutEmptySlice("float64 slice") - s.AppendEmpty().SetDouble(1e9) - - s = m.PutEmptySlice("string slice") - s.AppendEmpty().SetStr("one") - s.AppendEmpty().SetStr("two") - - return m - }() + tAttrs = []telemetry.Attr{ + telemetry.Bool("bool", true), + telemetry.Int("int", -1), + telemetry.Int64("int64", 43), + telemetry.Float64("float64", 0.3), + telemetry.String("string", "value"), + telemetry.Slice( + "bool slice", + telemetry.BoolValue(true), + telemetry.BoolValue(false), + telemetry.BoolValue(true), + ), + telemetry.Slice("int slice", + telemetry.IntValue(-1), + telemetry.IntValue(-30), + telemetry.IntValue(328), + ), + telemetry.Slice("int64 slice", + telemetry.Int64Value(1030), + telemetry.Int64Value(0), + telemetry.Int64Value(0), + ), + telemetry.Slice("float64 slice", telemetry.Float64Value(1e9)), + telemetry.Slice("string slice", + telemetry.StringValue("one"), + telemetry.StringValue("two"), + ), + } spanContext0 = trace.NewSpanContext(trace.SpanContextConfig{ TraceID: trace.TraceID{0x1}, @@ -91,22 +88,18 @@ var ( }, } - pLink0 = func() ptrace.SpanLink { - l := ptrace.NewSpanLink() - l.SetTraceID(pcommon.TraceID(spanContext0.TraceID())) - l.SetSpanID(pcommon.SpanID(spanContext0.SpanID())) - l.SetFlags(uint32(spanContext0.TraceFlags())) - l.Attributes().PutInt("n", 0) - return l - }() - pLink1 = func() ptrace.SpanLink { - l := ptrace.NewSpanLink() - l.SetTraceID(pcommon.TraceID(spanContext1.TraceID())) - l.SetSpanID(pcommon.SpanID(spanContext1.SpanID())) - l.SetFlags(uint32(spanContext1.TraceFlags())) - l.Attributes().PutInt("n", 1) - return l - }() + tLink0 = &telemetry.SpanLink{ + TraceID: telemetry.TraceID(spanContext0.TraceID()), + SpanID: telemetry.SpanID(spanContext0.SpanID()), + Flags: uint32(spanContext0.TraceFlags()), + Attrs: []telemetry.Attr{telemetry.Int("n", 0)}, + } + tLink1 = &telemetry.SpanLink{ + TraceID: telemetry.TraceID(spanContext1.TraceID()), + SpanID: telemetry.SpanID(spanContext1.SpanID()), + Flags: uint32(spanContext1.TraceFlags()), + Attrs: []telemetry.Attr{telemetry.Int("n", 1)}, + } ) func TestSpanCreation(t *testing.T) { @@ -124,18 +117,18 @@ func TestSpanCreation(t *testing.T) { trace.WithSchemaURL(semconv.SchemaURL), ) - assertTracer := func(traces ptrace.Traces) func(*testing.T) { + assertTracer := func(traces *telemetry.Traces) func(*testing.T) { return func(t *testing.T) { t.Helper() - rs := traces.ResourceSpans() - require.Equal(t, 1, rs.Len()) - sss := rs.At(0).ScopeSpans() - require.Equal(t, 1, sss.Len()) - ss := sss.At(0) - assert.Equal(t, tracerName, ss.Scope().Name(), "tracer name") - assert.Equal(t, tracerVer, ss.Scope().Version(), "tracer version") - assert.Equal(t, semconv.SchemaURL, ss.SchemaUrl(), "tracer schema URL") + rs := traces.ResourceSpans + require.Len(t, rs, 1) + sss := rs[0].ScopeSpans + require.Len(t, sss, 1) + ss := sss[0] + assert.Equal(t, tracerName, ss.Scope.Name, "tracer name") + assert.Equal(t, tracerVer, ss.Scope.Version, "tracer version") + assert.Equal(t, semconv.SchemaURL, ss.SchemaURL, "tracer schema URL") } } @@ -167,7 +160,7 @@ func TestSpanCreation(t *testing.T) { assertTracer(s.traces) want := spanContext0.SpanID().String() - got := s.span.ParentSpanID().String() + got := s.span.ParentSpanID.String() assert.Equal(t, want, got) }, }, @@ -186,10 +179,10 @@ func TestSpanCreation(t *testing.T) { str := func(i interface{ String() string }) string { return i.String() } - assert.Equal(t, str(spanContext0.TraceID()), str(s.span.TraceID()), "trace ID") - assert.Equal(t, str(spanContext0.SpanID()), str(s.span.SpanID()), "span ID") - assert.Equal(t, uint32(spanContext0.TraceFlags()), s.span.Flags(), "flags") - assert.Equal(t, str(spanContext0.TraceState()), s.span.TraceState().AsRaw(), "tracestate") + assert.Equal(t, str(spanContext0.TraceID()), s.span.TraceID.String(), "trace ID") + assert.Equal(t, str(spanContext0.SpanID()), s.span.SpanID.String(), "span ID") + assert.Equal(t, uint32(spanContext0.TraceFlags()), s.span.Flags, "flags") + assert.Equal(t, str(spanContext0.TraceState()), s.span.TraceState, "tracestate") }, }, { @@ -210,7 +203,7 @@ func TestSpanCreation(t *testing.T) { SpanName: spanName, Eval: func(t *testing.T, _ context.Context, s *span) { assertTracer(s.traces) - assert.Equal(t, spanName, s.span.Name()) + assert.Equal(t, spanName, s.span.Name) }, }, { @@ -220,7 +213,7 @@ func TestSpanCreation(t *testing.T) { }, Eval: func(t *testing.T, _ context.Context, s *span) { assertTracer(s.traces) - assert.Equal(t, ptrace.SpanKindClient, s.span.Kind()) + assert.Equal(t, telemetry.SpanKindClient, s.span.Kind) }, }, { @@ -230,7 +223,7 @@ func TestSpanCreation(t *testing.T) { }, Eval: func(t *testing.T, _ context.Context, s *span) { assertTracer(s.traces) - assert.Equal(t, pcommon.NewTimestampFromTime(ts), s.span.StartTimestamp()) + assert.Equal(t, ts, s.span.StartTime) }, }, { @@ -240,7 +233,7 @@ func TestSpanCreation(t *testing.T) { }, Eval: func(t *testing.T, _ context.Context, s *span) { assertTracer(s.traces) - assert.Equal(t, pAttrs, s.span.Attributes()) + assert.Equal(t, tAttrs, s.span.Attrs) }, }, { @@ -250,10 +243,8 @@ func TestSpanCreation(t *testing.T) { }, Eval: func(t *testing.T, _ context.Context, s *span) { assertTracer(s.traces) - want := ptrace.NewSpanLinkSlice() - pLink0.CopyTo(want.AppendEmpty()) - pLink1.CopyTo(want.AppendEmpty()) - assert.Equal(t, want, s.span.Links()) + want := []*telemetry.SpanLink{tLink0, tLink1} + assert.Equal(t, want, s.span.Links) }, }, } @@ -275,16 +266,16 @@ func TestSpanCreation(t *testing.T) { } func TestSpanKindTransform(t *testing.T) { - tests := map[trace.SpanKind]ptrace.SpanKind{ - trace.SpanKind(-1): ptrace.SpanKindUnspecified, - trace.SpanKindUnspecified: ptrace.SpanKindUnspecified, - trace.SpanKind(math.MaxInt): ptrace.SpanKindUnspecified, - - trace.SpanKindInternal: ptrace.SpanKindInternal, - trace.SpanKindServer: ptrace.SpanKindServer, - trace.SpanKindClient: ptrace.SpanKindClient, - trace.SpanKindProducer: ptrace.SpanKindProducer, - trace.SpanKindConsumer: ptrace.SpanKindConsumer, + tests := map[trace.SpanKind]telemetry.SpanKind{ + trace.SpanKind(-1): telemetry.SpanKind(0), + trace.SpanKindUnspecified: telemetry.SpanKind(0), + trace.SpanKind(math.MaxInt): telemetry.SpanKind(0), + + trace.SpanKindInternal: telemetry.SpanKindInternal, + trace.SpanKindServer: telemetry.SpanKindServer, + trace.SpanKindClient: telemetry.SpanKindClient, + trace.SpanKindProducer: telemetry.SpanKindProducer, + trace.SpanKindConsumer: telemetry.SpanKindConsumer, } for in, want := range tests { @@ -299,17 +290,17 @@ func TestSpanEnd(t *testing.T) { var buf []byte ended = func(b []byte) { buf = b } - timeNow := time.Now() + timeNow := time.Unix(0, time.Now().UnixNano()) // No location. tests := []struct { Name string Options []trace.SpanEndOption - Eval func(*testing.T, pcommon.Timestamp) + Eval func(*testing.T, time.Time) }{ { Name: "Now", - Eval: func(t *testing.T, ts pcommon.Timestamp) { - assert.False(t, ts.AsTime().IsZero(), "zero end time") + Eval: func(t *testing.T, ts time.Time) { + assert.False(t, ts.IsZero(), "zero end time") }, }, { @@ -317,8 +308,8 @@ func TestSpanEnd(t *testing.T) { Options: []trace.SpanEndOption{ trace.WithTimestamp(timeNow), }, - Eval: func(t *testing.T, ts pcommon.Timestamp) { - assert.True(t, ts.AsTime().Equal(timeNow), "end time not set") + Eval: func(t *testing.T, ts time.Time) { + assert.Equal(t, timeNow, ts, "end time not set") }, }, } @@ -331,18 +322,18 @@ func TestSpanEnd(t *testing.T) { assert.False(t, s.sampled, "ended span should not be sampled") require.NotNil(t, buf, "no span data emitted") - var m ptrace.ProtoUnmarshaler - traces, err := m.UnmarshalTraces(buf) + var traces telemetry.Traces + err := json.Unmarshal(buf, &traces) require.NoError(t, err) - rs := traces.ResourceSpans() - require.Equal(t, 1, rs.Len()) - ss := rs.At(0).ScopeSpans() - require.Equal(t, 1, ss.Len()) - spans := ss.At(0).Spans() - require.Equal(t, 1, spans.Len()) + rs := traces.ResourceSpans + require.Len(t, rs, 1) + ss := rs[0].ScopeSpans + require.Len(t, ss, 1) + spans := ss[0].Spans + require.Len(t, spans, 1) - test.Eval(t, spans.At(0).EndTimestamp()) + test.Eval(t, spans[0].EndTime) }) } } @@ -376,10 +367,8 @@ func TestSpanAddLink(t *testing.T) { }.Build() s.AddLink(link1) - want := ptrace.NewSpanLinkSlice() - pLink0.CopyTo(want.AppendEmpty()) - pLink1.CopyTo(want.AppendEmpty()) - assert.Equal(t, want, s.span.Links()) + want := []*telemetry.SpanLink{tLink0, tLink1} + assert.Equal(t, want, s.span.Links) } func TestSpanIsRecording(t *testing.T) { @@ -395,9 +384,9 @@ func TestSpanIsRecording(t *testing.T) { func TestSpanRecordError(t *testing.T) { s := spanBuilder{}.Build() - want := ptrace.NewSpanEventSlice() + var want []*telemetry.SpanEvent s.RecordError(nil) - require.Equal(t, want, s.span.Events(), "nil error recorded") + require.Equal(t, want, s.span.Events, "nil error recorded") ts := time.Now() err := errors.New("test") @@ -406,19 +395,28 @@ func TestSpanRecordError(t *testing.T) { trace.WithTimestamp(ts), trace.WithAttributes(attribute.Bool("testing", true)), ) - e := want.AppendEmpty() - e.SetName(semconv.ExceptionEventName) - e.SetTimestamp(pcommon.NewTimestampFromTime(ts)) - e.Attributes().PutBool("testing", true) - e.Attributes().PutStr(string(semconv.ExceptionTypeKey), "*errors.errorString") - e.Attributes().PutStr(string(semconv.ExceptionMessageKey), err.Error()) - assert.Equal(t, want, s.span.Events(), "nil error recorded") + want = append(want, &telemetry.SpanEvent{ + Name: semconv.ExceptionEventName, + Time: ts, + Attrs: []telemetry.Attr{ + telemetry.Bool("testing", true), + telemetry.String(string(semconv.ExceptionTypeKey), "*errors.errorString"), + telemetry.String(string(semconv.ExceptionMessageKey), err.Error()), + }, + }) + assert.Equal(t, want, s.span.Events, "nil error recorded") s.RecordError(err, trace.WithStackTrace(true)) - require.Equal(t, 2, s.span.Events().Len(), "missing event") - e = s.span.Events().At(1) - _, ok := e.Attributes().Get(string(semconv.ExceptionStacktraceKey)) - assert.True(t, ok, "missing stacktrace attribute") + require.Len(t, s.span.Events, 2, "missing event") + + var hasST bool + for _, attr := range s.span.Events[1].Attrs { + if attr.Key == string(semconv.ExceptionStacktraceKey) { + hasST = true + break + } + } + assert.True(t, hasST, "missing stacktrace attribute") } func TestSpanSpanContext(t *testing.T) { @@ -429,20 +427,19 @@ func TestSpanSpanContext(t *testing.T) { func TestSpanSetStatus(t *testing.T) { s := spanBuilder{}.Build() - want := ptrace.NewStatus() - assert.Equal(t, want, s.span.Status(), "empty status should not be set") + assert.Nil(t, s.span.Status, "empty status should not be set") - msg := "test" - want.SetMessage(msg) + const msg = "test" + want := &telemetry.Status{Message: msg} - for c, p := range map[codes.Code]ptrace.StatusCode{ - codes.Error: ptrace.StatusCodeError, - codes.Ok: ptrace.StatusCodeOk, - codes.Unset: ptrace.StatusCodeUnset, + for c, tCode := range map[codes.Code]telemetry.StatusCode{ + codes.Error: telemetry.StatusCodeError, + codes.Ok: telemetry.StatusCodeOK, + codes.Unset: telemetry.StatusCodeUnset, } { - want.SetCode(p) + want.Code = tCode s.SetStatus(c, msg) - assert.Equalf(t, want, s.span.Status(), "code: %s, msg: %s", c, msg) + assert.Equalf(t, want, s.span.Status, "code: %s, msg: %s", c, msg) } } @@ -452,12 +449,12 @@ func TestSpanSetName(t *testing.T) { s := builder.Build() s.SetName(name) - assert.Equal(t, name, s.span.Name(), "span name not set") + assert.Equal(t, name, s.span.Name, "span name not set") builder.Name = "alt" s = builder.Build() s.SetName(name) - assert.Equal(t, name, s.span.Name(), "SetName did not overwrite") + assert.Equal(t, name, s.span.Name, "SetName did not overwrite") } func TestSpanSetAttributes(t *testing.T) { @@ -465,7 +462,7 @@ func TestSpanSetAttributes(t *testing.T) { s := builder.Build() s.SetAttributes(attrs...) - assert.Equal(t, pAttrs, s.span.Attributes(), "span attributes not set") + assert.Equal(t, tAttrs, s.span.Attrs, "span attributes not set") builder.Options = []trace.SpanStartOption{ trace.WithAttributes(attrs[0].Key.Bool(!attrs[0].Value.AsBool())), @@ -473,7 +470,7 @@ func TestSpanSetAttributes(t *testing.T) { s = builder.Build() s.SetAttributes(attrs...) - assert.Equal(t, pAttrs, s.span.Attributes(), "SpanAttributes did not override") + assert.Equal(t, tAttrs, s.span.Attrs, "SpanAttributes did not override") } func TestSpanTracerProvider(t *testing.T) { From 18fa86bc5107c6d36e55c21db61d31900d305cb9 Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Tue, 1 Oct 2024 14:24:53 -0700 Subject: [PATCH 2/8] Use sdk pkg in auto/sdk probe --- go.mod | 9 +- go.sum | 46 ---- .../bpf/go.opentelemetry.io/auto/sdk/probe.go | 223 +++++++++--------- sdk/telemetry/test/go.mod | 1 + sdk/telemetry/test/go.sum | 1 + 5 files changed, 121 insertions(+), 159 deletions(-) diff --git a/go.mod b/go.mod index a7379bafa..be148446e 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/hashicorp/go-version v1.7.0 github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.9.0 - go.opentelemetry.io/collector/pdata v1.17.0 + go.opentelemetry.io/auto/sdk v0.0.0-00010101000000-000000000000 go.opentelemetry.io/contrib/exporters/autoexport v0.56.0 go.opentelemetry.io/otel v1.31.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.31.0 @@ -40,13 +40,9 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/google/uuid v1.6.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect - github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.17.11 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_golang v1.20.4 // indirect @@ -69,7 +65,6 @@ require ( go.opentelemetry.io/otel/sdk/log v0.7.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.31.0 // indirect go.opentelemetry.io/proto/otlp v1.3.1 // indirect - go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2 // indirect golang.org/x/net v0.30.0 // indirect golang.org/x/text v0.19.0 // indirect @@ -78,3 +73,5 @@ require ( google.golang.org/grpc v1.67.1 // indirect google.golang.org/protobuf v1.35.1 // indirect ) + +replace go.opentelemetry.io/auto/sdk => ./sdk diff --git a/go.sum b/go.sum index 9adf59591..2889d0fee 100644 --- a/go.sum +++ b/go.sum @@ -6,7 +6,6 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cilium/ebpf v0.16.0 h1:+BiEnHL6Z7lXnlGUsXQPPAE7+kenAd4ES8MQ5min0Ok= github.com/cilium/ebpf v0.16.0/go.mod h1:L7u2Blt2jMM/vLAVgjxluxtBKlz3/GWjB0dMOEngfwE= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -16,11 +15,8 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7eI= github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys= @@ -31,10 +27,6 @@ github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtL github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w= github.com/jsimonetti/rtnetlink/v2 v2.0.1 h1:xda7qaHDSVOsADNouv7ukSuicKZO7GgVUCXxpaIEIlM= github.com/jsimonetti/rtnetlink/v2 v2.0.1/go.mod h1:7MoNYNbb3UaDHtF8udiJo/RH6VsTKP1pqKLUTVCvToE= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -47,11 +39,6 @@ github.com/mdlayher/netlink v1.7.2 h1:/UtM3ofJap7Vl4QWCPDGXY8d3GIY2UGSDbK+QWmY8/ github.com/mdlayher/netlink v1.7.2/go.mod h1:xraEF7uJbxLhc5fpHL4cPe221LI2bdttWlU+ZGLfQSw= github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U= github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -68,14 +55,8 @@ github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0leargg github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.opentelemetry.io/collector/pdata v1.17.0 h1:z8cjjT2FThAehWu5fbF48OnZyK5q8xd1UhC4XszDo0w= -go.opentelemetry.io/collector/pdata v1.17.0/go.mod h1:yZaQ9KZAm/qie96LTygRKxOXMq0/54h8OW7330ycuvQ= go.opentelemetry.io/contrib/bridges/prometheus v0.56.0 h1:ax2MzrA26l3LTS2NRnagkbeKDrW4SM8VcAubasnpYqs= go.opentelemetry.io/contrib/bridges/prometheus v0.56.0/go.mod h1:+aiuB6jaKqSb5xaY7sOpGZEMIgjL0sxXfIW1PQmp5d0= go.opentelemetry.io/contrib/exporters/autoexport v0.56.0 h1:2k73WaZ+jHYcK3lLAC3CJ8viT/LqkIcDDUWpbbYbZK0= @@ -120,45 +101,18 @@ go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeX go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= -go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= golang.org/x/arch v0.11.0 h1:KXV8WWKCXm6tRpLirl2szsO5j/oOODwZf4hATmGVNs4= golang.org/x/arch v0.11.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2 h1:Jvc7gsqn21cJHCmAWx0LiimpP18LZmUxkT5Mp7EZ1mI= golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9 h1:T6rh4haD3GVYsgEfWExoCZA2o2FmbNyKpTuAxbEFPTg= google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9/go.mod h1:wp2WsuBYj6j8wUdo3ToZsdxxixbvQNAHqVJrTgi5E5M= google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 h1:QCqS/PdaHTSWGvupk2F/ehwHtGc0/GYkT+3GAcR1CCc= diff --git a/internal/pkg/instrumentation/bpf/go.opentelemetry.io/auto/sdk/probe.go b/internal/pkg/instrumentation/bpf/go.opentelemetry.io/auto/sdk/probe.go index 1e67861d7..1347ea1e8 100644 --- a/internal/pkg/instrumentation/bpf/go.opentelemetry.io/auto/sdk/probe.go +++ b/internal/pkg/instrumentation/bpf/go.opentelemetry.io/auto/sdk/probe.go @@ -6,15 +6,15 @@ package sdk import ( "bytes" "encoding/binary" + "encoding/json" "fmt" "log/slog" "github.com/cilium/ebpf/perf" - "go.opentelemetry.io/collector/pdata/pcommon" - "go.opentelemetry.io/collector/pdata/ptrace" "go.opentelemetry.io/auto/internal/pkg/instrumentation/probe" "go.opentelemetry.io/auto/internal/pkg/structfield" + "go.opentelemetry.io/auto/sdk/telemetry" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/codes" @@ -111,211 +111,220 @@ func (c *converter) decodeEvent(record perf.Record) (event, error) { } func (c *converter) convertEvent(e *event) []*probe.SpanEvent { - var m ptrace.ProtoUnmarshaler - traces, err := m.UnmarshalTraces(e.SpanData[:e.Size]) + var traces telemetry.Traces + err := json.Unmarshal(e.SpanData[:e.Size], &traces) if err != nil { c.logger.Error("failed to unmarshal span data", "error", err) return nil } - ss := traces.ResourceSpans().At(0).ScopeSpans().At(0) // TODO: validate len before lookup. - span := ss.Spans().At(0) // TODO: validate len before lookup. + switch { + case len(traces.ResourceSpans) == 0: + c.logger.Error("empty ResourceSpans") + return nil + case len(traces.ResourceSpans[0].ScopeSpans) == 0: + c.logger.Error("empty ScopeSpans") + return nil + case len(traces.ResourceSpans[0].ScopeSpans[0].Spans) == 0: + c.logger.Error("empty Spans") + return nil + } - raw := span.TraceState().AsRaw() - ts, err := trace.ParseTraceState(raw) + ss := traces.ResourceSpans[0].ScopeSpans[0] + span := ss.Spans[0] + + ts, err := trace.ParseTraceState(span.TraceState) if err != nil { - c.logger.Error("failed to parse tracestate", "error", err, "tracestate", raw) + c.logger.Error("failed to parse tracestate", "error", err, "tracestate", span.TraceState) } var pscPtr *trace.SpanContext - if psid := span.ParentSpanID(); psid != pcommon.NewSpanIDEmpty() { + if psid := span.ParentSpanID; !psid.IsEmpty() { psc := trace.NewSpanContext(trace.SpanContextConfig{ - TraceID: trace.TraceID(span.TraceID()), + TraceID: trace.TraceID(span.TraceID), SpanID: trace.SpanID(psid), - TraceFlags: trace.TraceFlags(span.Flags()), + TraceFlags: trace.TraceFlags(span.Flags), TraceState: ts, }) pscPtr = &psc } sc := trace.NewSpanContext(trace.SpanContextConfig{ - TraceID: trace.TraceID(span.TraceID()), - SpanID: trace.SpanID(span.SpanID()), - TraceFlags: trace.TraceFlags(span.Flags()), + TraceID: trace.TraceID(span.TraceID), + SpanID: trace.SpanID(span.SpanID), + TraceFlags: trace.TraceFlags(span.Flags), TraceState: ts, }) - span.ParentSpanID() return []*probe.SpanEvent{{ - SpanName: span.Name(), - StartTime: span.StartTimestamp().AsTime(), - EndTime: span.EndTimestamp().AsTime(), + SpanName: span.Name, + StartTime: span.StartTime, + EndTime: span.EndTime, SpanContext: &sc, ParentSpanContext: pscPtr, - TracerName: ss.Scope().Name(), - TracerVersion: ss.Scope().Version(), - TracerSchema: ss.SchemaUrl(), - Kind: spanKind(span.Kind()), - Attributes: attributes(span.Attributes()), - Events: events(span.Events()), - Links: c.links(span.Links()), - Status: status(span.Status()), + TracerName: ss.Scope.Name, + TracerVersion: ss.Scope.Version, + TracerSchema: ss.SchemaURL, + Kind: spanKind(span.Kind), + Attributes: attributes(span.Attrs), + Events: events(span.Events), + Links: c.links(span.Links), + Status: status(span.Status), }} } -func spanKind(kind ptrace.SpanKind) trace.SpanKind { +func spanKind(kind telemetry.SpanKind) trace.SpanKind { switch kind { - case ptrace.SpanKindInternal: + case telemetry.SpanKindInternal: return trace.SpanKindInternal - case ptrace.SpanKindServer: + case telemetry.SpanKindServer: return trace.SpanKindServer - case ptrace.SpanKindClient: + case telemetry.SpanKindClient: return trace.SpanKindClient - case ptrace.SpanKindProducer: + case telemetry.SpanKindProducer: return trace.SpanKindProducer - case ptrace.SpanKindConsumer: + case telemetry.SpanKindConsumer: return trace.SpanKindConsumer default: return trace.SpanKindUnspecified } } -func events(e ptrace.SpanEventSlice) map[string][]trace.EventOption { +func events(e []*telemetry.SpanEvent) map[string][]trace.EventOption { out := make(map[string][]trace.EventOption) - for i := 0; i < e.Len(); i++ { + for _, event := range e { var opts []trace.EventOption - event := e.At(i) - - ts := event.Timestamp().AsTime() + ts := event.Time if !ts.IsZero() { opts = append(opts, trace.WithTimestamp(ts)) } - attrs := attributes(event.Attributes()) + attrs := attributes(event.Attrs) if len(attrs) > 0 { opts = append(opts, trace.WithAttributes(attrs...)) } - out[event.Name()] = opts + out[event.Name] = opts } return out } -func (c *converter) links(links ptrace.SpanLinkSlice) []trace.Link { - n := links.Len() - if n == 0 { - return nil - } - - out := make([]trace.Link, n) - for i := range out { - l := links.At(i) - - raw := l.TraceState().AsRaw() - ts, err := trace.ParseTraceState(raw) +func (c *converter) links(links []*telemetry.SpanLink) []trace.Link { + out := make([]trace.Link, len(links)) + for i, l := range links { + ts, err := trace.ParseTraceState(l.TraceState) if err != nil { - c.logger.Error("failed to parse link tracestate", "error", err, "tracestate", raw) + c.logger.Error("failed to parse link tracestate", "error", err, "tracestate", l.TraceState) } out[i] = trace.Link{ SpanContext: trace.NewSpanContext(trace.SpanContextConfig{ - TraceID: trace.TraceID(l.TraceID()), - SpanID: trace.SpanID(l.SpanID()), - TraceFlags: trace.TraceFlags(l.Flags()), + TraceID: trace.TraceID(l.TraceID), + SpanID: trace.SpanID(l.SpanID), + TraceFlags: trace.TraceFlags(l.Flags), TraceState: ts, }), - Attributes: attributes(l.Attributes()), + Attributes: attributes(l.Attrs), } } return out } -func attributes(m pcommon.Map) []attribute.KeyValue { - out := make([]attribute.KeyValue, 0, m.Len()) - m.Range(func(key string, val pcommon.Value) bool { +func attributes(attrs []telemetry.Attr) []attribute.KeyValue { + out := make([]attribute.KeyValue, 0, len(attrs)) + for _, a := range attrs { out = append(out, attribute.KeyValue{ - Key: attribute.Key(key), - Value: attributeValue(val), + Key: attribute.Key(a.Key), + Value: attributeValue(a.Value), }) - return true - }) + } return out } -func attributeValue(val pcommon.Value) (out attribute.Value) { - switch val.Type() { - case pcommon.ValueTypeEmpty: - case pcommon.ValueTypeStr: +func attributeValue(val telemetry.Value) (out attribute.Value) { + switch val.Kind() { + // ValueKindBytes and ValueKindMap not supported as they are invalid input + // types from the OTel Go trace API. + case telemetry.ValueKindEmpty: + case telemetry.ValueKindString: out = attribute.StringValue(val.AsString()) - case pcommon.ValueTypeInt: - out = attribute.Int64Value(val.Int()) - case pcommon.ValueTypeDouble: - out = attribute.Float64Value(val.Double()) - case pcommon.ValueTypeBool: - out = attribute.BoolValue(val.Bool()) - case pcommon.ValueTypeSlice: - s := val.Slice() - if s.Len() == 0 { + case telemetry.ValueKindInt64: + out = attribute.Int64Value(val.AsInt64()) + case telemetry.ValueKindFloat64: + out = attribute.Float64Value(val.AsFloat64()) + case telemetry.ValueKindBool: + out = attribute.BoolValue(val.AsBool()) + case telemetry.ValueKindSlice: + s := val.AsSlice() + if len(s) == 0 { // Undetectable slice type. out = attribute.StringValue("") return out } // Validate homogeneity before allocating. - t := s.At(0).Type() - for i := 1; i < s.Len(); i++ { - if s.At(i).Type() != t { - out = attribute.StringValue("") - return out + var k telemetry.ValueKind + for i, v := range s { + if i == 0 { + k = v.Kind() + } else { + if v.Kind() != k { + out = attribute.StringValue("") + return out + } } } - switch t { - case pcommon.ValueTypeBool: - v := make([]bool, s.Len()) - for i := 0; i < s.Len(); i++ { - v[i] = s.At(i).Bool() + switch k { + case telemetry.ValueKindBool: + v := make([]bool, len(s)) + for i := 0; i < len(s); i++ { + v[i] = s[i].AsBool() } out = attribute.BoolSliceValue(v) - case pcommon.ValueTypeStr: - v := make([]string, s.Len()) - for i := 0; i < s.Len(); i++ { - v[i] = s.At(i).Str() + case telemetry.ValueKindString: + v := make([]string, len(s)) + for i := 0; i < len(s); i++ { + v[i] = s[i].AsString() } out = attribute.StringSliceValue(v) - case pcommon.ValueTypeInt: - v := make([]int64, s.Len()) - for i := 0; i < s.Len(); i++ { - v[i] = s.At(i).Int() + case telemetry.ValueKindInt64: + v := make([]int64, len(s)) + for i := 0; i < len(s); i++ { + v[i] = s[i].AsInt64() } out = attribute.Int64SliceValue(v) - case pcommon.ValueTypeDouble: - v := make([]float64, s.Len()) - for i := 0; i < s.Len(); i++ { - v[i] = s.At(i).Double() + case telemetry.ValueKindFloat64: + v := make([]float64, len(s)) + for i := 0; i < len(s); i++ { + v[i] = s[i].AsFloat64() } out = attribute.Float64SliceValue(v) default: - out = attribute.StringValue(fmt.Sprintf("", t.String())) + out = attribute.StringValue(fmt.Sprintf("", k.String())) } default: - out = attribute.StringValue(fmt.Sprintf("", val.AsRaw())) + out = attribute.StringValue(fmt.Sprintf("", val.String())) } return out } -func status(stat ptrace.Status) probe.Status { +func status(stat *telemetry.Status) probe.Status { + if stat == nil { + return probe.Status{} + } + var c codes.Code - switch stat.Code() { - case ptrace.StatusCodeUnset: + switch stat.Code { + case telemetry.StatusCodeUnset: c = codes.Unset - case ptrace.StatusCodeOk: + case telemetry.StatusCodeOK: c = codes.Ok - case ptrace.StatusCodeError: + case telemetry.StatusCodeError: c = codes.Error } return probe.Status{ Code: c, - Description: stat.Message(), + Description: stat.Message, } } diff --git a/sdk/telemetry/test/go.mod b/sdk/telemetry/test/go.mod index 59fbca8a9..313c555b1 100644 --- a/sdk/telemetry/test/go.mod +++ b/sdk/telemetry/test/go.mod @@ -12,6 +12,7 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/json-iterator/go v1.1.12 // indirect + github.com/kr/text v0.2.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect diff --git a/sdk/telemetry/test/go.sum b/sdk/telemetry/test/go.sum index 258254fdf..49af93dbb 100644 --- a/sdk/telemetry/test/go.sum +++ b/sdk/telemetry/test/go.sum @@ -1,3 +1,4 @@ +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From fa2f223fef6b700f0be0526682d560deafea27c3 Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Tue, 15 Oct 2024 09:17:29 -0700 Subject: [PATCH 3/8] Fix Dockerfile Copy sdk pkg prior to build --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 25a5dc44a..43af4a51f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,10 @@ FROM golang:1.23.2-bullseye as base +RUN apt-get update && apt-get install -y curl clang gcc llvm make libbpf-dev + WORKDIR /app -RUN apt-get update && apt-get install -y curl clang gcc llvm make libbpf-dev +COPY sdk/ /app/sdk/ # pre-copy/cache go.mod for pre-downloading dependencies and only redownloading # them in subsequent builds if they change From 0666146efa7df55fcc59f3fcddf7609373c74ac1 Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Tue, 15 Oct 2024 10:24:54 -0700 Subject: [PATCH 4/8] Update licenses --- LICENSES/github.com/gogo/protobuf/LICENSE | 35 --- LICENSES/github.com/json-iterator/go/LICENSE | 21 -- .../client_golang/prometheus/NOTICE | 5 - .../auto/sdk/telemetry}/LICENSE | 0 .../collector/pdata/LICENSE | 202 ------------------ LICENSES/go.uber.org/multierr/LICENSE.txt | 19 -- LICENSES/golang.org/x/arch/x86/x86asm/LICENSE | 4 +- LICENSES/golang.org/x/net/LICENSE | 4 +- LICENSES/golang.org/x/sys/unix/LICENSE | 4 +- LICENSES/golang.org/x/text/LICENSE | 4 +- .../modern-go/reflect2 => sdk}/LICENSE | 0 11 files changed, 8 insertions(+), 290 deletions(-) delete mode 100644 LICENSES/github.com/gogo/protobuf/LICENSE delete mode 100644 LICENSES/github.com/json-iterator/go/LICENSE rename LICENSES/{github.com/modern-go/concurrent => go.opentelemetry.io/auto/sdk/telemetry}/LICENSE (100%) delete mode 100644 LICENSES/go.opentelemetry.io/collector/pdata/LICENSE delete mode 100644 LICENSES/go.uber.org/multierr/LICENSE.txt rename {LICENSES/github.com/modern-go/reflect2 => sdk}/LICENSE (100%) diff --git a/LICENSES/github.com/gogo/protobuf/LICENSE b/LICENSES/github.com/gogo/protobuf/LICENSE deleted file mode 100644 index f57de90da..000000000 --- a/LICENSES/github.com/gogo/protobuf/LICENSE +++ /dev/null @@ -1,35 +0,0 @@ -Copyright (c) 2013, The GoGo Authors. All rights reserved. - -Protocol Buffers for Go with Gadgets - -Go support for Protocol Buffers - Google's data interchange format - -Copyright 2010 The Go Authors. All rights reserved. -https://github.com/golang/protobuf - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/LICENSES/github.com/json-iterator/go/LICENSE b/LICENSES/github.com/json-iterator/go/LICENSE deleted file mode 100644 index 2cf4f5ab2..000000000 --- a/LICENSES/github.com/json-iterator/go/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2016 json-iterator - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/LICENSES/github.com/prometheus/client_golang/prometheus/NOTICE b/LICENSES/github.com/prometheus/client_golang/prometheus/NOTICE index dd878a30e..b9cc55abb 100644 --- a/LICENSES/github.com/prometheus/client_golang/prometheus/NOTICE +++ b/LICENSES/github.com/prometheus/client_golang/prometheus/NOTICE @@ -16,8 +16,3 @@ Go support for Protocol Buffers - Google's data interchange format http://github.com/golang/protobuf/ Copyright 2010 The Go Authors See source code for license details. - -Support for streaming Protocol Buffer messages for the Go language (golang). -https://github.com/matttproud/golang_protobuf_extensions -Copyright 2013 Matt T. Proud -Licensed under the Apache License, Version 2.0 diff --git a/LICENSES/github.com/modern-go/concurrent/LICENSE b/LICENSES/go.opentelemetry.io/auto/sdk/telemetry/LICENSE similarity index 100% rename from LICENSES/github.com/modern-go/concurrent/LICENSE rename to LICENSES/go.opentelemetry.io/auto/sdk/telemetry/LICENSE diff --git a/LICENSES/go.opentelemetry.io/collector/pdata/LICENSE b/LICENSES/go.opentelemetry.io/collector/pdata/LICENSE deleted file mode 100644 index d64569567..000000000 --- a/LICENSES/go.opentelemetry.io/collector/pdata/LICENSE +++ /dev/null @@ -1,202 +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. diff --git a/LICENSES/go.uber.org/multierr/LICENSE.txt b/LICENSES/go.uber.org/multierr/LICENSE.txt deleted file mode 100644 index 413e30f7c..000000000 --- a/LICENSES/go.uber.org/multierr/LICENSE.txt +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2017-2021 Uber Technologies, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/LICENSES/golang.org/x/arch/x86/x86asm/LICENSE b/LICENSES/golang.org/x/arch/x86/x86asm/LICENSE index d29b37261..686d8a919 100644 --- a/LICENSES/golang.org/x/arch/x86/x86asm/LICENSE +++ b/LICENSES/golang.org/x/arch/x86/x86asm/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2015 The Go Authors. All rights reserved. +Copyright 2015 The Go Authors. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer. copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/LICENSES/golang.org/x/net/LICENSE b/LICENSES/golang.org/x/net/LICENSE index 6a66aea5e..2a7cf70da 100644 --- a/LICENSES/golang.org/x/net/LICENSE +++ b/LICENSES/golang.org/x/net/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009 The Go Authors. All rights reserved. +Copyright 2009 The Go Authors. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer. copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/LICENSES/golang.org/x/sys/unix/LICENSE b/LICENSES/golang.org/x/sys/unix/LICENSE index 6a66aea5e..2a7cf70da 100644 --- a/LICENSES/golang.org/x/sys/unix/LICENSE +++ b/LICENSES/golang.org/x/sys/unix/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009 The Go Authors. All rights reserved. +Copyright 2009 The Go Authors. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer. copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/LICENSES/golang.org/x/text/LICENSE b/LICENSES/golang.org/x/text/LICENSE index 6a66aea5e..2a7cf70da 100644 --- a/LICENSES/golang.org/x/text/LICENSE +++ b/LICENSES/golang.org/x/text/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009 The Go Authors. All rights reserved. +Copyright 2009 The Go Authors. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer. copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/LICENSES/github.com/modern-go/reflect2/LICENSE b/sdk/LICENSE similarity index 100% rename from LICENSES/github.com/modern-go/reflect2/LICENSE rename to sdk/LICENSE From 3de57b64eec214733b535ebab7a715f2161b928b Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Tue, 15 Oct 2024 12:08:48 -0700 Subject: [PATCH 5/8] Update max span size in probe --- .../bpf/go.opentelemetry.io/auto/sdk/bpf/probe.bpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/pkg/instrumentation/bpf/go.opentelemetry.io/auto/sdk/bpf/probe.bpf.c b/internal/pkg/instrumentation/bpf/go.opentelemetry.io/auto/sdk/bpf/probe.bpf.c index 32591e535..2b14d1f35 100644 --- a/internal/pkg/instrumentation/bpf/go.opentelemetry.io/auto/sdk/bpf/probe.bpf.c +++ b/internal/pkg/instrumentation/bpf/go.opentelemetry.io/auto/sdk/bpf/probe.bpf.c @@ -15,7 +15,7 @@ char __license[] SEC("license") = "Dual MIT/GPL"; // the maximum size of a span (based on limits) and set this. Ideally, we could // also look into a tiered allocation strategy so we do not over allocate // space (i.e. small, medium, large data sizes). -#define MAX_SIZE 1024 +#define MAX_SIZE 2048 // Injected const. volatile const u64 span_context_trace_id_pos; From 059a2af1a1cc91e3fbf103654fa8928b6603a61b Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Tue, 15 Oct 2024 12:09:04 -0700 Subject: [PATCH 6/8] Fix SpanLink unmarshal of flags --- sdk/telemetry/span.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/telemetry/span.go b/sdk/telemetry/span.go index 4cb4dca14..b5d9cddf0 100644 --- a/sdk/telemetry/span.go +++ b/sdk/telemetry/span.go @@ -416,6 +416,8 @@ func (sl *SpanLink) UnmarshalJSON(data []byte) error { err = decoder.Decode(&sl.Attrs) case "droppedAttributesCount", "dropped_attributes_count": err = decoder.Decode(&sl.DroppedAttrs) + case "flags": + err = decoder.Decode(&sl.Flags) default: // Skip unknown. } From acc80557e23a94591aebb6129ff6b898a973f7f4 Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Tue, 15 Oct 2024 12:09:26 -0700 Subject: [PATCH 7/8] End span before sleeping --- internal/test/e2e/autosdk/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/test/e2e/autosdk/main.go b/internal/test/e2e/autosdk/main.go index 5ab23643e..c085dbba6 100644 --- a/internal/test/e2e/autosdk/main.go +++ b/internal/test/e2e/autosdk/main.go @@ -91,7 +91,6 @@ func main() { defer stop() ctx, span := tracer.Start(ctx, "main", trace.WithTimestamp(y2k)) - defer span.End(trace.WithTimestamp(y2k.Add(5 * time.Second))) err := app.Run(ctx, "Alice", true, sig(ctx)) if err != nil { @@ -104,6 +103,8 @@ func main() { ) } + span.End(trace.WithTimestamp(y2k.Add(5 * time.Second))) + // give time for auto-instrumentation to report signal time.Sleep(5 * time.Second) } From 174ffd4d06dead5b9b6fea417f68d19829d9b11f Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Sun, 20 Oct 2024 07:41:01 -0700 Subject: [PATCH 8/8] Add String method to TraceID and SpanID --- sdk/telemetry/id.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sdk/telemetry/id.go b/sdk/telemetry/id.go index 438581611..e854d7e84 100644 --- a/sdk/telemetry/id.go +++ b/sdk/telemetry/id.go @@ -17,6 +17,11 @@ const ( // TraceID is a custom data type that is used for all trace IDs. type TraceID [traceIDSize]byte +// String returns the hex string representation form of a TraceID. +func (tid TraceID) String() string { + return hex.EncodeToString(tid[:]) +} + // IsEmpty returns false if id contains at least one non-zero byte. func (tid TraceID) IsEmpty() bool { return tid == [traceIDSize]byte{} @@ -40,6 +45,11 @@ func (tid *TraceID) UnmarshalJSON(data []byte) error { // SpanID is a custom data type that is used for all span IDs. type SpanID [spanIDSize]byte +// String returns the hex string representation form of a SpanID. +func (sid SpanID) String() string { + return hex.EncodeToString(sid[:]) +} + // IsEmpty returns true if the span ID contains at least one non-zero byte. func (sid SpanID) IsEmpty() bool { return sid == [spanIDSize]byte{}