diff --git a/sdk/messaging/azeventhubs/consumer_client_test.go b/sdk/messaging/azeventhubs/consumer_client_test.go index 9c66e170f7ba..6bb9ed225674 100644 --- a/sdk/messaging/azeventhubs/consumer_client_test.go +++ b/sdk/messaging/azeventhubs/consumer_client_test.go @@ -21,8 +21,8 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs" "github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs/internal/test" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/eventhub/armeventhub" + "github.com/coder/websocket" "github.com/stretchr/testify/require" - "nhooyr.io/websocket" ) func TestConsumerClient_UsingWebSockets(t *testing.T) { diff --git a/sdk/messaging/azeventhubs/example_websockets_and_proxies_test.go b/sdk/messaging/azeventhubs/example_websockets_and_proxies_test.go index 1d54aecbffdf..059abc9dc795 100644 --- a/sdk/messaging/azeventhubs/example_websockets_and_proxies_test.go +++ b/sdk/messaging/azeventhubs/example_websockets_and_proxies_test.go @@ -12,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs" - "nhooyr.io/websocket" + "github.com/coder/websocket" ) func ExampleNewClient_usingWebsocketsAndProxies() { diff --git a/sdk/messaging/azeventhubs/go.mod b/sdk/messaging/azeventhubs/go.mod index 0ef51bc19265..61f4bed146e9 100644 --- a/sdk/messaging/azeventhubs/go.mod +++ b/sdk/messaging/azeventhubs/go.mod @@ -1,8 +1,6 @@ module github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs -go 1.22.0 - -toolchain go1.23.1 +go 1.18 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0 @@ -11,18 +9,17 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/eventhub/armeventhub v1.3.0 github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.5.0 github.com/Azure/go-amqp v1.3.0 + github.com/coder/websocket v1.8.12 github.com/golang/mock v1.6.0 github.com/joho/godotenv v1.5.1 github.com/stretchr/testify v1.10.0 - nhooyr.io/websocket v1.8.17 ) require ( - code.cloudfoundry.org/clock v1.25.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.3.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gofrs/uuid v4.4.0+incompatible // indirect github.com/golang-jwt/jwt/v5 v5.2.1 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect @@ -33,6 +30,3 @@ require ( golang.org/x/text v0.21.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) - -// used in stress tests -require github.com/microsoft/ApplicationInsights-Go v0.4.4 diff --git a/sdk/messaging/azeventhubs/go.sum b/sdk/messaging/azeventhubs/go.sum index c1eca75ce99f..7f2410ac8f1a 100644 --- a/sdk/messaging/azeventhubs/go.sum +++ b/sdk/messaging/azeventhubs/go.sum @@ -1,97 +1,65 @@ -code.cloudfoundry.org/clock v0.0.0-20180518195852-02e53af36e6c/go.mod h1:QD9Lzhd/ux6eNQVUDVRJX/RKTigpewimNYBi7ivZKY8= -code.cloudfoundry.org/clock v1.25.0 h1:ZLojbz5oXOcCO+RwTQnGVAdft6pMi7wcqDMuwA7Ec+g= -code.cloudfoundry.org/clock v1.25.0/go.mod h1:Z2W2iZzagFVW6CYkuHcJIS1Kx2eEhzqKYNb1AQo6YWw= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0 h1:JZg6HRh6W6U4OLl6lk7BZ7BLisIzM9dG1R50zUk9C/M= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0/go.mod h1:YL1xnZ6QejvQHWJrX/AvhFl4WW4rqHVoKspWNVwFk0M= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0 h1:B/dfvscEQtew9dVuoxqxrUKKv8Ih2f55PydknDamU+g= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0/go.mod h1:fiPSssYvltE08HJchL04dOy+RD4hgrjph0cwGGMntdI= github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.0 h1:+m0M/LFxN43KvULkDNfdXOgrjtg6UYJPFBJyuEcRCAw= -github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.0/go.mod h1:PwOyop78lveYMRs6oCxjiVyBdyCgIYH6XHIVZO9/SFQ= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/eventhub/armeventhub v1.3.0 h1:4hGvxD72TluuFIXVr8f4XkKZfqAa7Pj61t0jmQ7+kes= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/eventhub/armeventhub v1.3.0/go.mod h1:TSH7DcFItwAufy0Lz+Ft2cyopExCpxbOxI5SkH4dRNo= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0 h1:2qsIIvxVT+uE6yrNldntJKlLRgxGbZ85kgtz5SNBhMw= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0/go.mod h1:AW8VEadnhw9xox+VaVd9sP7NjzOAnaZBLRH6Tq3cJ38= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0 h1:Dd+RhdJn0OTtVGaeDLZpcumkIVCtA/3/Fo42+eoYvVM= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0/go.mod h1:5kakwfW5CjC9KK+Q4wjXAg+ShuIm2mBMua0ZFj2C8PE= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.6.0 h1:PiSrjRPpkQNjrM8H0WwKMnZUdu1RGMtd/LdGKUrOo+c= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.6.0/go.mod h1:oDrbWx4ewMylP7xHivfgixbfGBT6APAwsSoHRKotnIc= github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.5.0 h1:mlmW46Q0B79I+Aj4azKC6xDMFN9a9SyZWESlGWYXbFs= github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.5.0/go.mod h1:PXe2h+LKcWTX9afWdZoHyODqR4fBa5boUM/8uJfZ0Jo= github.com/Azure/go-amqp v1.3.0 h1://1rikYhoIQNXJFXyoO/Rlb4+4EkHYfJceNtLlys2/4= github.com/Azure/go-amqp v1.3.0/go.mod h1:vZAogwdrkbyK3Mla8m/CxSc/aKdnTZ4IbPxl51Y5WZE= github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= -github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1/go.mod h1:tCcJZ0uHAmvjsVYzEFivsRTN00oz5BEsRgQHu5JZ9WE= github.com/AzureAD/microsoft-authentication-library-for-go v1.3.2 h1:kYRSnvJju5gYVyhkij+RTJ/VR6QIUaCfWeaFm2ycsjQ= github.com/AzureAD/microsoft-authentication-library-for-go v1.3.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= -github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/coder/websocket v1.8.12 h1:5bUXkEPPIbewrnkU8LTCLVaxi4N4J8ahufH2vlo4NAo= +github.com/coder/websocket v1.8.12/go.mod h1:LNVeNrXQZfe5qhS9ALED3uA+l5pPqvwXg3CKoDBB2gs= 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/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= -github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA= -github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 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/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6 h1:IsMZxCuZqKuao2vNdfD82fjjgPLfyHLpR41Z88viRWs= -github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6/go.mod h1:3VeWNIJaW+O5xpRQbPp0Ybqu1vJd/pm7s2F473HRrkw= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 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/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/microsoft/ApplicationInsights-Go v0.4.4 h1:G4+H9WNs6ygSCe6sUyxRc2U81TI5Es90b2t/MwX5KqY= -github.com/microsoft/ApplicationInsights-Go v0.4.4/go.mod h1:fKRUseBqkw6bDiXTs3ESTiU/4YTIHsQS4W3fP2ieF4U= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= 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/redis/go-redis/v9 v9.6.1 h1:HHDteefn6ZkTtY5fGUE8tj8uy85AHk6zP7CpzIAM0y4= -github.com/redis/go-redis/v9 v9.6.1/go.mod h1:0C0c6ycQsdpVNQpxb1njEQIqkx5UcsM8FJCQLgE9+RA= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= -github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/tedsuo/ifrit v0.0.0-20180802180643-bea94bb476cc/go.mod h1:eyZnKCc955uh98WQvzOm0dgAeLnf2O0Rz0LPoC5ze+0= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= 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.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 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-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -112,13 +80,6 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/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= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -nhooyr.io/websocket v1.8.17 h1:KEVeLJkUywCKVsnLIDlD/5gtayKp8VoCkksHCGGfT9Y= -nhooyr.io/websocket v1.8.17/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c= diff --git a/sdk/messaging/azeventhubs/internal/eh/stress/shared/telemetry_client_wrapper.go b/sdk/messaging/azeventhubs/internal/eh/stress/shared/telemetry_client_wrapper.go new file mode 100644 index 000000000000..e330a47399fd --- /dev/null +++ b/sdk/messaging/azeventhubs/internal/eh/stress/shared/telemetry_client_wrapper.go @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package shared + +func NewTelemetryClientWrapper[MetricT ~string, EventT ~string]() *TelemetryClientWrapper[MetricT, EventT] { + return &TelemetryClientWrapper[MetricT, EventT]{} +} + +// TelemetryClientWrapper is a wrapper for telemetry client, once we get that phased back in. +type TelemetryClientWrapper[MetricT ~string, EventT ~string] struct { + context TelemetryClientWrapperContext +} + +type TelemetryClientWrapperContext struct { + CommonProperties map[string]string +} + +func (tc *TelemetryClientWrapper[MetricT, EventT]) TrackException(err error) { + // will be replaced with a real telemetry client once we enable OTEL reporting. +} + +func (tc *TelemetryClientWrapper[MetricT, EventT]) TrackEvent(name EventT) { + // will be replaced with a real telemetry client once we enable OTEL reporting. +} + +func (tc *TelemetryClientWrapper[MetricT, EventT]) TrackMetricWithProps(name MetricT, value float64, properties map[string]string) { + // will be replaced with a real telemetry client once we enable OTEL reporting. +} + +func (tc *TelemetryClientWrapper[MetricT, EventT]) TrackEventWithProps(name EventT, properties map[string]string) { + // will be replaced with a real telemetry client once we enable OTEL reporting. +} + +func (tc *TelemetryClientWrapper[MetricT, EventT]) TrackExceptionWithProps(err error, properties map[string]string) { + // will be replaced with a real telemetry client once we enable OTEL reporting. +} + +func (tc *TelemetryClientWrapper[MetricT, EventT]) Flush() { + // tc.TC.Channel().Flush() + // <-tc.TC.Channel().Close() +} + +// Context returns the context that is included for each reported event or metric. +func (tc *TelemetryClientWrapper[MetricT, EventT]) Context() *TelemetryClientWrapperContext { + return &tc.context +} diff --git a/sdk/messaging/azeventhubs/internal/eh/stress/tests/balance_tester.go b/sdk/messaging/azeventhubs/internal/eh/stress/tests/balance_tester.go index dcc757d6b0a3..52a9339de012 100644 --- a/sdk/messaging/azeventhubs/internal/eh/stress/tests/balance_tester.go +++ b/sdk/messaging/azeventhubs/internal/eh/stress/tests/balance_tester.go @@ -139,7 +139,7 @@ func (bt *balanceTester) Run(ctx context.Context) error { log.Writef(EventBalanceTest, "Balance not achieved, resetting balancedCount: %s", ibErr) balancedCount = 0 - bt.TC.TrackEvent("Unbalanced", map[string]string{ + bt.TC.TrackEventWithProps(EventUnbalanced, map[string]string{ "Message": ibErr.Error(), }) continue @@ -159,7 +159,7 @@ func (bt *balanceTester) Run(ctx context.Context) error { balancedCount++ log.Writef(EventBalanceTest, "Balanced, with %d consecutive checks", balancedCount) - bt.TC.TrackEvent("Balanced", map[string]string{ + bt.TC.TrackEventWithProps(EventBalanced, map[string]string{ "Count": fmt.Sprintf("%d", balancedCount), "DurationSeconds": fmt.Sprintf("%d", firstBalance/time.Second), }) diff --git a/sdk/messaging/azeventhubs/internal/eh/stress/tests/batch_stress_tester.go b/sdk/messaging/azeventhubs/internal/eh/stress/tests/batch_stress_tester.go index f16cf1cccd0d..c3054b718f25 100644 --- a/sdk/messaging/azeventhubs/internal/eh/stress/tests/batch_stress_tester.go +++ b/sdk/messaging/azeventhubs/internal/eh/stress/tests/batch_stress_tester.go @@ -190,7 +190,7 @@ func consumeForBatchTester(ctx context.Context, round int64, cc *azeventhubs.Con if err != nil { if errors.Is(err, context.DeadlineExceeded) || errors.Is(err, context.Canceled) { // track these, we can use it as a proxy for "network was slow" or similar. - testData.TC.TrackMetric(MetricDeadlineExceeded, float64(1), nil) + testData.TC.TrackMetricWithProps(MetricDeadlineExceeded, float64(1), nil) numCancels++ if numCancels >= cancelLimit { @@ -213,7 +213,7 @@ func consumeForBatchTester(ctx context.Context, round int64, cc *azeventhubs.Con panic(err) } - testData.TC.TrackMetric(MetricReceived, float64(len(events)), nil) + testData.TC.TrackMetricWithProps(MetricNameReceived, float64(len(events)), nil) total += len(events) if total >= params.numToSend { diff --git a/sdk/messaging/azeventhubs/internal/eh/stress/tests/metric_names.go b/sdk/messaging/azeventhubs/internal/eh/stress/tests/metric_names.go new file mode 100644 index 000000000000..40c61a6e3b0b --- /dev/null +++ b/sdk/messaging/azeventhubs/internal/eh/stress/tests/metric_names.go @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package tests + +type Metric string + +const ( + // standard to all tests + MetricNameSent Metric = "Sent" + MetricNameReceived Metric = "Received" + MetricNameOwnershipLost Metric = "OwnershipLost" + + // go specific + MetricDeadlineExceeded Metric = "DeadlineExceeded" +) + +type Event string + +const ( + EventUnbalanced Event = "Unbalanced" + EventBalanced Event = "Balanced" + EventEnd Event = "end" + EventStart Event = "start" +) diff --git a/sdk/messaging/azeventhubs/internal/eh/stress/tests/processor_stress_tester.go b/sdk/messaging/azeventhubs/internal/eh/stress/tests/processor_stress_tester.go index 78e8f6336771..7d3cd5576b8f 100644 --- a/sdk/messaging/azeventhubs/internal/eh/stress/tests/processor_stress_tester.go +++ b/sdk/messaging/azeventhubs/internal/eh/stress/tests/processor_stress_tester.go @@ -266,7 +266,7 @@ func (inf *processorStressTest) receiveForever(ctx context.Context, partClient * if errors.Is(err, context.DeadlineExceeded) && ctx.Err() == nil { // this is fine - it just means we ran out of time waiting for events. // This'll happen periodically in between tests when there are no messages. - inf.TC.TrackMetric(MetricDeadlineExceeded, 1.0, map[string]string{ + inf.TC.TrackMetricWithProps(MetricDeadlineExceeded, 1.0, map[string]string{ "PartitionID": partClient.PartitionID(), }) continue @@ -275,7 +275,7 @@ func (inf *processorStressTest) receiveForever(ctx context.Context, partClient * if ehErr := (*azeventhubs.Error)(nil); errors.As(err, &ehErr) && ehErr.Code == azeventhubs.ErrorCodeOwnershipLost { // this can happen as partitions are rebalanced between processors - Event Hubs // actually detaches us with this error. - inf.TC.TrackMetric(MetricOwnershipLost, 1.0, map[string]string{ + inf.TC.TrackMetricWithProps(MetricNameOwnershipLost, 1.0, map[string]string{ "PartitionID": partClient.PartitionID(), }) logger("Ownership lost") @@ -296,7 +296,7 @@ func (inf *processorStressTest) receiveForever(ctx context.Context, partClient * panic(err) } - inf.TC.TrackMetric(MetricReceived, float64(len(events)), map[string]string{ + inf.TC.TrackMetricWithProps(MetricNameReceived, float64(len(events)), map[string]string{ "PartitionID": partClient.PartitionID(), }) } diff --git a/sdk/messaging/azeventhubs/internal/eh/stress/tests/shared.go b/sdk/messaging/azeventhubs/internal/eh/stress/tests/shared.go index 6a6789b75016..1aee3a349599 100644 --- a/sdk/messaging/azeventhubs/internal/eh/stress/tests/shared.go +++ b/sdk/messaging/azeventhubs/internal/eh/stress/tests/shared.go @@ -20,10 +20,10 @@ import ( azlog "github.com/Azure/azure-sdk-for-go/sdk/internal/log" "github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs" "github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs/checkpoints" + "github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs/internal/eh/stress/shared" "github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs/internal/test" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container" "github.com/joho/godotenv" - "github.com/microsoft/ApplicationInsights-Go/appinsights" ) const ( @@ -32,21 +32,10 @@ const ( numProperty = "Number" ) -// metric names -const ( - // standard to all tests - MetricSent = "Sent" - MetricReceived = "Received" - MetricOwnershipLost = "OwnershipLost" - - // go specific - MetricDeadlineExceeded = "DeadlineExceeded" -) - type stressTestData struct { name string runID string - TC telemetryClient + TC *shared.TelemetryClientWrapper[Metric, Event] Namespace string HubName string @@ -56,9 +45,7 @@ type stressTestData struct { } func (td *stressTestData) Close() { - td.TC.TrackEvent("end", nil) - td.TC.Channel().Flush() - <-td.TC.Channel().Close() + td.TC.TrackEvent(EventEnd) } type logf func(format string, v ...any) @@ -101,16 +88,11 @@ func newStressTestData(name string, baggage map[string]string) (*stressTestData, return nil, fmt.Errorf("missing environment variables (%s)", strings.Join(missing, ",")) } - tc, err := loadAppInsights() - - if err != nil { - return nil, err - } - - td.TC = telemetryClient{tc} + td.TC = shared.NewTelemetryClientWrapper[Metric, Event]() // NOTE: this isn't run in the live testing pipelines, only within stress testing // so you shouldn't use the test credential. + var err error td.Cred, err = azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -135,7 +117,7 @@ func newStressTestData(name string, baggage map[string]string) (*stressTestData, startBaggage[k] = v } - td.TC.TrackEvent("start", startBaggage) + td.TC.TrackEventWithProps(EventStart, startBaggage) return td, nil } @@ -178,7 +160,7 @@ func sendEventsToPartition(ctx context.Context, args sendEventsToPartitionArgs) return err } - args.testData.TC.TrackMetric(MetricSent, float64(batch.NumEvents()), map[string]string{ + args.testData.TC.TrackMetricWithProps(MetricNameSent, float64(batch.NumEvents()), map[string]string{ "PartitionID": args.partitionID, }) @@ -329,18 +311,6 @@ func initCheckpointStore(ctx context.Context, containerName string, testData *st return updatedCheckpoints, nil } -func loadAppInsights() (appinsights.TelemetryClient, error) { - aiKey := os.Getenv("APPINSIGHTS_INSTRUMENTATIONKEY") - - if aiKey == "" { - return nil, errors.New("missing APPINSIGHTS_INSTRUMENTATIONKEY environment variable") - } - - config := appinsights.NewTelemetryConfiguration(aiKey) - config.MaxBatchInterval = 5 * time.Second - return appinsights.NewTelemetryClientFromConfig(config), nil -} - func addEndProperty(ed *azeventhubs.EventData, expectedCount int64) { ed.Properties[endProperty] = expectedCount } diff --git a/sdk/messaging/azeventhubs/internal/eh/stress/tests/telemetry_client.go b/sdk/messaging/azeventhubs/internal/eh/stress/tests/telemetry_client.go deleted file mode 100644 index 2cf469216b09..000000000000 --- a/sdk/messaging/azeventhubs/internal/eh/stress/tests/telemetry_client.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package tests - -import ( - "github.com/microsoft/ApplicationInsights-Go/appinsights" -) - -// telemetryClient embeds an appinsights TelemtryClient but adds some convenience -// functions to make sending events with baggage/properties one-liners. -type telemetryClient struct { - appinsights.TelemetryClient -} - -func (tc *telemetryClient) TrackMetric(name string, value float64, properties map[string]string) { - mt := appinsights.NewMetricTelemetry(name, value) - - for k, v := range properties { - mt.Properties[k] = v - } - - tc.TelemetryClient.Track(mt) -} - -func (tc *telemetryClient) TrackEvent(name string, properties map[string]string) { - et := appinsights.NewEventTelemetry(name) - - for k, v := range properties { - et.Properties[k] = v - } - - tc.TelemetryClient.Track(et) -} diff --git a/sdk/messaging/azeventhubs/internal/namespace_test.go b/sdk/messaging/azeventhubs/internal/namespace_test.go index 6c97cc935a8b..3d2949895900 100644 --- a/sdk/messaging/azeventhubs/internal/namespace_test.go +++ b/sdk/messaging/azeventhubs/internal/namespace_test.go @@ -368,6 +368,7 @@ func TestNamespaceConnectionRecovery(t *testing.T) { NS *Namespace NewClientCount int FakeClientError error + FakeClient *fakeAMQPClient } init := func() *testData { @@ -376,7 +377,7 @@ func TestNamespaceConnectionRecovery(t *testing.T) { connID: 2, newClientFn: func(ctx context.Context, connID uint64) (amqpwrap.AMQPClient, error) { td.NewClientCount++ - return nil, td.FakeClientError + return td.FakeClient, td.FakeClientError }, } return td @@ -397,6 +398,7 @@ func TestNamespaceConnectionRecovery(t *testing.T) { t.Run("connection matches", func(t *testing.T) { testData := init() + testData.FakeClient = &fakeAMQPClient{} // new client that was "created" for our recovery // this time the connection must be having errors AND it matches our current ID origConnID := testData.NS.connID @@ -408,7 +410,7 @@ func TestNamespaceConnectionRecovery(t *testing.T) { require.Equal(t, origConnID+1, testData.NS.connID, "new client created, connID increments") require.NoError(t, err) require.Equal(t, 1, origClient.closeCalled, "old client is closed") - require.NotSame(t, origClient, testData.NS.client, "new client instance created") + require.NotSame(t, origClient, testData.NS.client) }) t.Run("recover but failed", func(t *testing.T) { diff --git a/sdk/messaging/azservicebus/client_test.go b/sdk/messaging/azservicebus/client_test.go index b5afd398eaf6..ac1acd118f67 100644 --- a/sdk/messaging/azservicebus/client_test.go +++ b/sdk/messaging/azservicebus/client_test.go @@ -19,8 +19,8 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebus/internal" "github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebus/internal/sas" "github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebus/internal/test" + "github.com/coder/websocket" "github.com/stretchr/testify/require" - "nhooyr.io/websocket" ) func TestNewClientWithAzureIdentity(t *testing.T) { diff --git a/sdk/messaging/azservicebus/example_websockets_and_proxies_test.go b/sdk/messaging/azservicebus/example_websockets_and_proxies_test.go index 2a13cf338d59..ee633c1bcbb2 100644 --- a/sdk/messaging/azservicebus/example_websockets_and_proxies_test.go +++ b/sdk/messaging/azservicebus/example_websockets_and_proxies_test.go @@ -8,7 +8,7 @@ import ( "net" "github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebus" - "nhooyr.io/websocket" + "github.com/coder/websocket" ) func ExampleNewClient_usingWebsocketsAndProxies() { diff --git a/sdk/messaging/azservicebus/go.mod b/sdk/messaging/azservicebus/go.mod index 92b97caa7e6f..c32310bb19cb 100644 --- a/sdk/messaging/azservicebus/go.mod +++ b/sdk/messaging/azservicebus/go.mod @@ -14,16 +14,13 @@ require ( require ( // used in tests only github.com/joho/godotenv v1.5.1 - - // used in stress tests - // github.com/microsoft/ApplicationInsights-Go v0.4.4 github.com/stretchr/testify v1.10.0 - - // used in examples only - nhooyr.io/websocket v1.8.17 ) -require github.com/golang/mock v1.6.0 +require ( + github.com/coder/websocket v1.8.12 + github.com/golang/mock v1.6.0 +) require ( github.com/AzureAD/microsoft-authentication-library-for-go v1.3.2 // indirect diff --git a/sdk/messaging/azservicebus/go.sum b/sdk/messaging/azservicebus/go.sum index 37742eaff0eb..d2997c6de5ba 100644 --- a/sdk/messaging/azservicebus/go.sum +++ b/sdk/messaging/azservicebus/go.sum @@ -11,6 +11,8 @@ github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJ github.com/AzureAD/microsoft-authentication-library-for-go v1.3.2 h1:kYRSnvJju5gYVyhkij+RTJ/VR6QIUaCfWeaFm2ycsjQ= github.com/AzureAD/microsoft-authentication-library-for-go v1.3.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/coder/websocket v1.8.12 h1:5bUXkEPPIbewrnkU8LTCLVaxi4N4J8ahufH2vlo4NAo= +github.com/coder/websocket v1.8.12/go.mod h1:LNVeNrXQZfe5qhS9ALED3uA+l5pPqvwXg3CKoDBB2gs= 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/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= @@ -74,5 +76,3 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -nhooyr.io/websocket v1.8.17 h1:KEVeLJkUywCKVsnLIDlD/5gtayKp8VoCkksHCGGfT9Y= -nhooyr.io/websocket v1.8.17/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c= diff --git a/sdk/messaging/azservicebus/internal/stress/shared/metric_names.go b/sdk/messaging/azservicebus/internal/stress/shared/metric_names.go index 540a42409733..fbbfe897fa60 100644 --- a/sdk/messaging/azservicebus/internal/stress/shared/metric_names.go +++ b/sdk/messaging/azservicebus/internal/stress/shared/metric_names.go @@ -52,3 +52,10 @@ const ( const ( MetricStressSuccessfulCancels = "stress.cancels" ) + +type Event string + +const ( + EventEnd Event = "end" + EventStart Event = "start" +) diff --git a/sdk/messaging/azservicebus/internal/stress/shared/stress_context.go b/sdk/messaging/azservicebus/internal/stress/shared/stress_context.go index 99f4ec39c0d6..593d3336c4e5 100644 --- a/sdk/messaging/azservicebus/internal/stress/shared/stress_context.go +++ b/sdk/messaging/azservicebus/internal/stress/shared/stress_context.go @@ -17,66 +17,11 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebus" ) -// TelemetryClientWrapper is a wrapper for telemetry client, once we get that phased back in. -type TelemetryClientWrapper struct { - context TelemetryClientWrapperContext -} - -func newTelemetryClientStub() *TelemetryClientWrapper { - // config := NewTelemetryConfiguration(aiKey) - // config.MaxBatchInterval = 5 * time.Second - // telemetryClient := NewTelemetryClientFromConfig(config) - return &TelemetryClientWrapper{} -} - -type TelemetryClientWrapperContext struct { - CommonProperties map[string]string -} - -func (tc *TelemetryClientWrapper) Track(evt any) {} -func (tc *TelemetryClientWrapper) TrackException(err error) {} -func (tc *TelemetryClientWrapper) TrackEvent(name string) {} - -func (tc *TelemetryClientWrapper) Flush() { - // tc.TC.Channel().Flush() - // <-tc.TC.Channel().Close() -} - -func (tc *TelemetryClientWrapper) Context() *TelemetryClientWrapperContext { - return &tc.context -} - -type BaseTelemetry struct { - Properties map[string]string -} - -type MetricTelemetry struct { - Name string - Value any - BaseTelemetry BaseTelemetry -} - -type ExceptionTelemetry struct { - BaseTelemetry BaseTelemetry -} - -type EventTelemetry struct { - Properties map[string]string -} - -func NewExceptionTelemetry(err error) *ExceptionTelemetry { - return &ExceptionTelemetry{} -} - -func NewEventTelemetry(name string) *EventTelemetry { - return &EventTelemetry{} -} - // StressContext holds onto some common useful state for stress tests, including some simple stats tracking, // a telemetry client and a context that represents the lifetime of the test itself (and will be cancelled if the user // quits out of the stress) type StressContext struct { - TC *TelemetryClientWrapper + TC *TelemetryClientWrapper[Metric, Event] Context context.Context // TestRunID represents the test run and can be used to tie into other container metrics generated within the test cluster. @@ -98,7 +43,7 @@ type StressContext struct { // TrackDuration tracks durations (as a metric), using the initial call to TrackDuration as the start. The duration is // ended when you call the returned function. // TrackDuration respects any included baggage in the context. -func TrackDuration(ctx context.Context, tc *TelemetryClientWrapper, name Metric) func(map[string]string) { +func TrackDuration(ctx context.Context, tc *TelemetryClientWrapper[Metric, Event], name Metric) func(map[string]string) { start := time.Now() return func(attrs map[string]string) { @@ -108,30 +53,20 @@ func TrackDuration(ctx context.Context, tc *TelemetryClientWrapper, name Metric) } // TrackMetric tracks metric and respects any included baggage in the context. -func TrackMetric(ctx context.Context, tc *TelemetryClientWrapper, name Metric, value float64, attrs map[string]string) { - tc.Track(&MetricTelemetry{ - Name: string(name), - Value: value, - BaseTelemetry: BaseTelemetry{ - Properties: UpdateBaggage(ctx, attrs), - }, - }) +func TrackMetric(ctx context.Context, tc *TelemetryClientWrapper[Metric, Event], name Metric, value float64, attrs map[string]string) { + tc.TrackMetricWithProps(name, value, UpdateBaggage(ctx, attrs)) } // TrackError tracks an error (using the AppInsights exceptions table). // TrackError respects any included baggage in the context. // // NOTE: this function does not consider context cancellations/deadlines as errors. -func TrackError(ctx context.Context, tc *TelemetryClientWrapper, err error) { +func TrackError(ctx context.Context, tc *TelemetryClientWrapper[Metric, Event], err error) { // track all errors except for cancellation errors - the caller can take care of those since // they're the only one that knows if it's a true error or just normal behavior. if err != nil && !isCancelError(err) { log.Printf("Error: %#v, %T", err, err) - - ext := NewExceptionTelemetry(err) - ext.BaseTelemetry.Properties = UpdateBaggage(ctx, nil) - - tc.Track(ext) + tc.TrackExceptionWithProps(err, UpdateBaggage(ctx, nil)) } } @@ -167,7 +102,7 @@ func MustCreateStressContext(testName string, options *StressContextOptions) *St log.Fatalf("failed to create DefaultAzureCredential: %s", err) } - telemetryClient := newTelemetryClientStub() + telemetryClient := NewTelemetryClientWrapper[Metric, Event]() testRunID := strings.ToLower(fmt.Sprintf("%X", time.Now().UnixNano())) @@ -238,17 +173,8 @@ func MustCreateStressContext(testName string, options *StressContextOptions) *St } func (sc *StressContext) Start(entityName string, attributes map[string]string) { - startEvent := NewEventTelemetry("Start") - startEvent.Properties = map[string]string{ - "Entity": entityName, - } - - for k, v := range attributes { - startEvent.Properties[k] = v - } - - log.Printf("Start: %#v", startEvent.Properties) - sc.TC.Track(startEvent) + log.Printf("Start: %#v", attributes) + sc.TC.TrackEventWithProps(EventStart, attributes) } func (sc *StressContext) End() { @@ -256,7 +182,7 @@ func (sc *StressContext) End() { sc.cancel() - sc.TC.TrackEvent("End") + sc.TC.TrackEvent(EventEnd) sc.TC.Flush() time.Sleep(5 * time.Second) diff --git a/sdk/messaging/azservicebus/internal/stress/shared/telemetry_client_wrapper.go b/sdk/messaging/azservicebus/internal/stress/shared/telemetry_client_wrapper.go new file mode 100644 index 000000000000..e330a47399fd --- /dev/null +++ b/sdk/messaging/azservicebus/internal/stress/shared/telemetry_client_wrapper.go @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package shared + +func NewTelemetryClientWrapper[MetricT ~string, EventT ~string]() *TelemetryClientWrapper[MetricT, EventT] { + return &TelemetryClientWrapper[MetricT, EventT]{} +} + +// TelemetryClientWrapper is a wrapper for telemetry client, once we get that phased back in. +type TelemetryClientWrapper[MetricT ~string, EventT ~string] struct { + context TelemetryClientWrapperContext +} + +type TelemetryClientWrapperContext struct { + CommonProperties map[string]string +} + +func (tc *TelemetryClientWrapper[MetricT, EventT]) TrackException(err error) { + // will be replaced with a real telemetry client once we enable OTEL reporting. +} + +func (tc *TelemetryClientWrapper[MetricT, EventT]) TrackEvent(name EventT) { + // will be replaced with a real telemetry client once we enable OTEL reporting. +} + +func (tc *TelemetryClientWrapper[MetricT, EventT]) TrackMetricWithProps(name MetricT, value float64, properties map[string]string) { + // will be replaced with a real telemetry client once we enable OTEL reporting. +} + +func (tc *TelemetryClientWrapper[MetricT, EventT]) TrackEventWithProps(name EventT, properties map[string]string) { + // will be replaced with a real telemetry client once we enable OTEL reporting. +} + +func (tc *TelemetryClientWrapper[MetricT, EventT]) TrackExceptionWithProps(err error, properties map[string]string) { + // will be replaced with a real telemetry client once we enable OTEL reporting. +} + +func (tc *TelemetryClientWrapper[MetricT, EventT]) Flush() { + // tc.TC.Channel().Flush() + // <-tc.TC.Channel().Close() +} + +// Context returns the context that is included for each reported event or metric. +func (tc *TelemetryClientWrapper[MetricT, EventT]) Context() *TelemetryClientWrapperContext { + return &tc.context +} diff --git a/sdk/messaging/azservicebus/internal/stress/shared/tracking_receiver.go b/sdk/messaging/azservicebus/internal/stress/shared/tracking_receiver.go index 720a857a29a0..3c61b678a6c5 100644 --- a/sdk/messaging/azservicebus/internal/stress/shared/tracking_receiver.go +++ b/sdk/messaging/azservicebus/internal/stress/shared/tracking_receiver.go @@ -11,7 +11,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebus" ) -func NewTrackingReceiverForQueue(tc *TelemetryClientWrapper, client *azservicebus.Client, queueName string, options *azservicebus.ReceiverOptions) (*TrackingReceiver, error) { +func NewTrackingReceiverForQueue(tc *TelemetryClientWrapper[Metric, Event], client *azservicebus.Client, queueName string, options *azservicebus.ReceiverOptions) (*TrackingReceiver, error) { tmpReceiver, err := client.NewReceiverForQueue(queueName, options) if err != nil { @@ -21,7 +21,7 @@ func NewTrackingReceiverForQueue(tc *TelemetryClientWrapper, client *azservicebu return &TrackingReceiver{r: tmpReceiver, tc: tc}, nil } -func NewTrackingReceiverForSubscription(tc *TelemetryClientWrapper, client *azservicebus.Client, topicName string, subscriptionName string, options *azservicebus.ReceiverOptions) (*TrackingReceiver, error) { +func NewTrackingReceiverForSubscription(tc *TelemetryClientWrapper[Metric, Event], client *azservicebus.Client, topicName string, subscriptionName string, options *azservicebus.ReceiverOptions) (*TrackingReceiver, error) { tmpReceiver, err := client.NewReceiverForSubscription(topicName, subscriptionName, options) if err != nil { @@ -34,7 +34,7 @@ func NewTrackingReceiverForSubscription(tc *TelemetryClientWrapper, client *azse // TrackingReceiver reports metrics and errors automatically for its methods. type TrackingReceiver struct { r *azservicebus.Receiver - tc *TelemetryClientWrapper + tc *TelemetryClientWrapper[Metric, Event] } func (tr *TrackingReceiver) ReceiveMessages(ctx context.Context, maxMessages int, options *azservicebus.ReceiveMessagesOptions) ([]*azservicebus.ReceivedMessage, error) { diff --git a/sdk/messaging/azservicebus/internal/stress/shared/tracking_sender.go b/sdk/messaging/azservicebus/internal/stress/shared/tracking_sender.go index 1fdf171a27fd..aa120e5d3f94 100644 --- a/sdk/messaging/azservicebus/internal/stress/shared/tracking_sender.go +++ b/sdk/messaging/azservicebus/internal/stress/shared/tracking_sender.go @@ -10,7 +10,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/messaging/azservicebus" ) -func NewTrackingSender(tc *TelemetryClientWrapper, client *azservicebus.Client, queueOrTopic string, options *azservicebus.NewSenderOptions) (*TrackingSender, error) { +func NewTrackingSender(tc *TelemetryClientWrapper[Metric, Event], client *azservicebus.Client, queueOrTopic string, options *azservicebus.NewSenderOptions) (*TrackingSender, error) { tmpSender, err := client.NewSender(queueOrTopic, options) if err != nil { @@ -22,7 +22,7 @@ func NewTrackingSender(tc *TelemetryClientWrapper, client *azservicebus.Client, // TrackingSender reports metrics and errors automatically for its methods. type TrackingSender struct { - tc *TelemetryClientWrapper + tc *TelemetryClientWrapper[Metric, Event] s *azservicebus.Sender }