From 91123b3c2c6cb1782013b75b0643cef9753d7e28 Mon Sep 17 00:00:00 2001 From: Joel Hendrix Date: Tue, 16 Jun 2020 16:54:54 -0700 Subject: [PATCH] Add SDK and module info to telemetry (#426) --- src/generator/client.ts | 22 +++++++++++++++++- src/generator/helpers.ts | 6 +---- src/transform/namer.ts | 4 ++++ .../generated/additionalpropsgroup/client.go | 23 ++++++++++++++++++- test/autorest/generated/arraygroup/client.go | 23 ++++++++++++++++++- .../generated/azurereportgroup/client.go | 23 ++++++++++++++++++- .../generated/azurespecialsgroup/client.go | 23 ++++++++++++++++++- .../autorest/generated/booleangroup/client.go | 23 ++++++++++++++++++- test/autorest/generated/bytegroup/client.go | 23 ++++++++++++++++++- .../autorest/generated/complexgroup/client.go | 23 ++++++++++++++++++- .../generated/complexmodelgroup/client.go | 23 ++++++++++++++++++- .../generated/custombaseurlgroup/client.go | 23 ++++++++++++++++++- .../generated/datetimegroup/client.go | 23 ++++++++++++++++++- .../generated/datetimerfc1123group/client.go | 23 ++++++++++++++++++- .../generated/dictionarygroup/client.go | 23 ++++++++++++++++++- test/autorest/generated/errorsgroup/client.go | 23 ++++++++++++++++++- test/autorest/generated/filegroup/client.go | 23 ++++++++++++++++++- test/autorest/generated/headergroup/client.go | 23 ++++++++++++++++++- .../httpinfrastructuregroup/client.go | 23 ++++++++++++++++++- .../autorest/generated/integergroup/client.go | 23 ++++++++++++++++++- test/autorest/generated/lrogroup/client.go | 23 ++++++++++++++++++- test/autorest/generated/migroup/client.go | 23 ++++++++++++++++++- .../morecustombaseurigroup/client.go | 23 ++++++++++++++++++- test/autorest/generated/numbergroup/client.go | 23 ++++++++++++++++++- .../generated/optionalgroup/client.go | 23 ++++++++++++++++++- test/autorest/generated/paginggroup/client.go | 23 ++++++++++++++++++- .../generated/paramgroupinggroup/client.go | 23 ++++++++++++++++++- test/autorest/generated/reportgroup/client.go | 23 ++++++++++++++++++- test/autorest/generated/stringgroup/client.go | 23 ++++++++++++++++++- test/autorest/generated/urlgroup/client.go | 23 ++++++++++++++++++- .../generated/urlmultigroup/client.go | 23 ++++++++++++++++++- .../generated/validationgroup/client.go | 23 ++++++++++++++++++- test/autorest/generated/xmlgroup/client.go | 23 ++++++++++++++++++- test/storage/2019-07-07/azblob/client.go | 22 +++++++++++++++++- 34 files changed, 707 insertions(+), 37 deletions(-) diff --git a/src/generator/client.ts b/src/generator/client.ts index cd827d8e4..e54ad3556 100644 --- a/src/generator/client.ts +++ b/src/generator/client.ts @@ -16,6 +16,7 @@ export async function generateClient(session: Session): Promise): Promise): Promise): Promise): Promise): Promise { const headerText = comment(await session.getValue('header-text', 'MISSING LICENSE HEADER'), '// '); - // default namespce to the output folder - const outputFolder = await session.getValue('output-folder'); - // default namespace to equal the output directory name as they have to match. - const namespace = outputFolder.substr(outputFolder.lastIndexOf('/') + 1); let text = `${headerText}\n\n`; - text += `package ${namespace}\n\n`; + text += `package ${session.model.language.go!.packageName}\n\n`; return text; } diff --git a/src/transform/namer.ts b/src/transform/namer.ts index 083086d6b..ac82df87a 100644 --- a/src/transform/namer.ts +++ b/src/transform/namer.ts @@ -51,6 +51,10 @@ export async function namer(session: Session) { // copy all the .language.default data into .language.go cloneLanguageInfo(model); + // default namespce to the output folder + const outputFolder = await session.getValue('output-folder'); + model.language.go!.packageName = outputFolder.substr(outputFolder.lastIndexOf('/') + 1); + // pascal-case and capitzalize acronym names of objects and their fields for (const obj of values(model.schemas.objects)) { const details = obj.language.go; diff --git a/test/autorest/generated/additionalpropsgroup/client.go b/test/autorest/generated/additionalpropsgroup/client.go index 47161aaed..a6c4598de 100644 --- a/test/autorest/generated/additionalpropsgroup/client.go +++ b/test/autorest/generated/additionalpropsgroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-additionalpropsgroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Test Infrastructure for AutoRest type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/arraygroup/client.go b/test/autorest/generated/arraygroup/client.go index dfe62f94b..75dc4d986 100644 --- a/test/autorest/generated/arraygroup/client.go +++ b/test/autorest/generated/arraygroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-arraygroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Test Infrastructure for AutoRest Swagger BAT type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/azurereportgroup/client.go b/test/autorest/generated/azurereportgroup/client.go index 86b167553..a4488761b 100644 --- a/test/autorest/generated/azurereportgroup/client.go +++ b/test/autorest/generated/azurereportgroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-azurereportgroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Test Infrastructure for AutoRest type Client struct { u *url.URL @@ -44,7 +65,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/azurespecialsgroup/client.go b/test/autorest/generated/azurespecialsgroup/client.go index 343cfd01f..7d78e191c 100644 --- a/test/autorest/generated/azurespecialsgroup/client.go +++ b/test/autorest/generated/azurespecialsgroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-azurespecialsgroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Test Infrastructure for AutoRest type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/booleangroup/client.go b/test/autorest/generated/booleangroup/client.go index 04fb38c46..8279a9caf 100644 --- a/test/autorest/generated/booleangroup/client.go +++ b/test/autorest/generated/booleangroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-booleangroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Test Infrastructure for AutoRest type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/bytegroup/client.go b/test/autorest/generated/bytegroup/client.go index ed8074419..6a235c927 100644 --- a/test/autorest/generated/bytegroup/client.go +++ b/test/autorest/generated/bytegroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-bytegroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Test Infrastructure for AutoRest Swagger BAT type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/complexgroup/client.go b/test/autorest/generated/complexgroup/client.go index c63353e45..3baa592fb 100644 --- a/test/autorest/generated/complexgroup/client.go +++ b/test/autorest/generated/complexgroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-complexgroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Test Infrastructure for AutoRest type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/complexmodelgroup/client.go b/test/autorest/generated/complexmodelgroup/client.go index 002725d1e..d1362e8f6 100644 --- a/test/autorest/generated/complexmodelgroup/client.go +++ b/test/autorest/generated/complexmodelgroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-complexmodelgroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Some cool documentation. type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/custombaseurlgroup/client.go b/test/autorest/generated/custombaseurlgroup/client.go index 5292ea6a2..8badf2f34 100644 --- a/test/autorest/generated/custombaseurlgroup/client.go +++ b/test/autorest/generated/custombaseurlgroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-custombaseurlgroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Test Infrastructure for AutoRest type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/datetimegroup/client.go b/test/autorest/generated/datetimegroup/client.go index f0f8e7241..7cfc9ba4d 100644 --- a/test/autorest/generated/datetimegroup/client.go +++ b/test/autorest/generated/datetimegroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-datetimegroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Test Infrastructure for AutoRest type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/datetimerfc1123group/client.go b/test/autorest/generated/datetimerfc1123group/client.go index 8d842db60..96bfe7edb 100644 --- a/test/autorest/generated/datetimerfc1123group/client.go +++ b/test/autorest/generated/datetimerfc1123group/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-datetimerfc1123group/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Test Infrastructure for AutoRest type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/dictionarygroup/client.go b/test/autorest/generated/dictionarygroup/client.go index 0f60dfc63..15bdd9fac 100644 --- a/test/autorest/generated/dictionarygroup/client.go +++ b/test/autorest/generated/dictionarygroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-dictionarygroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Test Infrastructure for AutoRest Swagger BAT type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/errorsgroup/client.go b/test/autorest/generated/errorsgroup/client.go index 8433ff19c..1f58d9a09 100644 --- a/test/autorest/generated/errorsgroup/client.go +++ b/test/autorest/generated/errorsgroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-errorsgroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - XMS Error Response Extensions type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/filegroup/client.go b/test/autorest/generated/filegroup/client.go index eca3f78dd..a058aaa29 100644 --- a/test/autorest/generated/filegroup/client.go +++ b/test/autorest/generated/filegroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-filegroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Test Infrastructure for AutoRest Swagger BAT type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/headergroup/client.go b/test/autorest/generated/headergroup/client.go index 012eabcf2..4d25a0ede 100644 --- a/test/autorest/generated/headergroup/client.go +++ b/test/autorest/generated/headergroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-headergroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Test Infrastructure for AutoRest type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/httpinfrastructuregroup/client.go b/test/autorest/generated/httpinfrastructuregroup/client.go index 57d9d1d30..505ec4b8c 100644 --- a/test/autorest/generated/httpinfrastructuregroup/client.go +++ b/test/autorest/generated/httpinfrastructuregroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-httpinfrastructuregroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Test Infrastructure for AutoRest type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/integergroup/client.go b/test/autorest/generated/integergroup/client.go index 9caa8dcd5..f96f1a7bd 100644 --- a/test/autorest/generated/integergroup/client.go +++ b/test/autorest/generated/integergroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-integergroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Test Infrastructure for AutoRest type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/lrogroup/client.go b/test/autorest/generated/lrogroup/client.go index 8c9fa2948..407cab261 100644 --- a/test/autorest/generated/lrogroup/client.go +++ b/test/autorest/generated/lrogroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-lrogroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Long-running Operation for AutoRest type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/migroup/client.go b/test/autorest/generated/migroup/client.go index c88dcbbf0..e5b676706 100644 --- a/test/autorest/generated/migroup/client.go +++ b/test/autorest/generated/migroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-migroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Service client for multiinheritance client testing type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/morecustombaseurigroup/client.go b/test/autorest/generated/morecustombaseurigroup/client.go index 97f43f3fe..2251fa521 100644 --- a/test/autorest/generated/morecustombaseurigroup/client.go +++ b/test/autorest/generated/morecustombaseurigroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-morecustombaseurigroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Test Infrastructure for AutoRest type Client struct { u *url.URL @@ -44,7 +65,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/numbergroup/client.go b/test/autorest/generated/numbergroup/client.go index 95e65f21e..91f908326 100644 --- a/test/autorest/generated/numbergroup/client.go +++ b/test/autorest/generated/numbergroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-numbergroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Test Infrastructure for AutoRest type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/optionalgroup/client.go b/test/autorest/generated/optionalgroup/client.go index 6ca82fe63..3f5be6eb2 100644 --- a/test/autorest/generated/optionalgroup/client.go +++ b/test/autorest/generated/optionalgroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-optionalgroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Test Infrastructure for AutoRest type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/paginggroup/client.go b/test/autorest/generated/paginggroup/client.go index ce4816bee..e99401898 100644 --- a/test/autorest/generated/paginggroup/client.go +++ b/test/autorest/generated/paginggroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-paginggroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Long-running Operation for AutoRest type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/paramgroupinggroup/client.go b/test/autorest/generated/paramgroupinggroup/client.go index 23dcb00a5..514a8a768 100644 --- a/test/autorest/generated/paramgroupinggroup/client.go +++ b/test/autorest/generated/paramgroupinggroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-paramgroupinggroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Test Infrastructure for AutoRest type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/reportgroup/client.go b/test/autorest/generated/reportgroup/client.go index 06bb5d42d..2ed3235ed 100644 --- a/test/autorest/generated/reportgroup/client.go +++ b/test/autorest/generated/reportgroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-reportgroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Test Infrastructure for AutoRest type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/stringgroup/client.go b/test/autorest/generated/stringgroup/client.go index 9713f47c3..db15ed99a 100644 --- a/test/autorest/generated/stringgroup/client.go +++ b/test/autorest/generated/stringgroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-stringgroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Test Infrastructure for AutoRest Swagger BAT type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/urlgroup/client.go b/test/autorest/generated/urlgroup/client.go index d999a29c5..f8b327b3f 100644 --- a/test/autorest/generated/urlgroup/client.go +++ b/test/autorest/generated/urlgroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-urlgroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Test Infrastructure for AutoRest type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/urlmultigroup/client.go b/test/autorest/generated/urlmultigroup/client.go index 49bf683c7..edc903a08 100644 --- a/test/autorest/generated/urlmultigroup/client.go +++ b/test/autorest/generated/urlmultigroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-urlmultigroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Test Infrastructure for AutoRest type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/validationgroup/client.go b/test/autorest/generated/validationgroup/client.go index 0c1e736f2..d8d279a6e 100644 --- a/test/autorest/generated/validationgroup/client.go +++ b/test/autorest/generated/validationgroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-validationgroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Test Infrastructure for AutoRest. No server backend exists for these tests. type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/autorest/generated/xmlgroup/client.go b/test/autorest/generated/xmlgroup/client.go index b2a0dfe4a..50fe0b0e5 100644 --- a/test/autorest/generated/xmlgroup/client.go +++ b/test/autorest/generated/xmlgroup/client.go @@ -9,8 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) +const telemetryInfo = "azsdk-go-xmlgroup/" + // ClientOptions contains configuration settings for the default client's pipeline. type ClientOptions struct { // HTTPClient sets the transport for making HTTP requests. @@ -21,6 +24,9 @@ type ClientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // DefaultClientOptions creates a ClientOptions type initialized with default values. @@ -31,6 +37,21 @@ func DefaultClientOptions() ClientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + // Client - Test Infrastructure for AutoRest Swagger BAT type Client struct { u *url.URL @@ -52,7 +73,7 @@ func NewClient(endpoint string, options *ClientOptions) (*Client, error) { options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), azcore.NewRequestLogPolicy(options.LogOptions)) diff --git a/test/storage/2019-07-07/azblob/client.go b/test/storage/2019-07-07/azblob/client.go index 2fad161cb..7e3cb9590 100644 --- a/test/storage/2019-07-07/azblob/client.go +++ b/test/storage/2019-07-07/azblob/client.go @@ -9,9 +9,11 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/url" + "strings" ) const scope = "https://storage.azure.com/.default" +const telemetryInfo = "azsdk-go-azblob/" // ClientOptions contains configuration settings for the default client's pipeline. type clientOptions struct { @@ -23,6 +25,9 @@ type clientOptions struct { Retry azcore.RetryOptions // Telemetry configures the built-in telemetry policy behavior. Telemetry azcore.TelemetryOptions + // ApplicationID is an application-specific identification string used in telemetry. + // It has a maximum length of 24 characters and must not contain any spaces. + ApplicationID string } // defaultClientOptions creates a clientOptions type initialized with default values. @@ -33,6 +38,21 @@ func defaultClientOptions() clientOptions { } } +func (c *ClientOptions) telemetryOptions() azcore.TelemetryOptions { + t := telemetryInfo + if c.ApplicationID != "" { + a := strings.ReplaceAll(c.ApplicationID, " ", "/") + if len(a) > 24 { + a = a[:24] + } + t = fmt.Sprintf("%s %s", a, telemetryInfo) + } + if c.Telemetry.Value == "" { + return azcore.TelemetryOptions{Value: t} + } + return azcore.TelemetryOptions{Value: fmt.Sprintf("%s %s", c.Telemetry.Value, t)} +} + type client struct { u *url.URL p azcore.Pipeline @@ -45,7 +65,7 @@ func newClient(endpoint string, cred azcore.Credential, options *clientOptions) options = &o } p := azcore.NewPipeline(options.HTTPClient, - azcore.NewTelemetryPolicy(options.Telemetry), + azcore.NewTelemetryPolicy(options.telemetryOptions()), azcore.NewUniqueRequestIDPolicy(), azcore.NewRetryPolicy(&options.Retry), cred.AuthenticationPolicy(azcore.AuthenticationPolicyOptions{Options: azcore.TokenRequestOptions{Scopes: []string{scope}}}),