delphix-integrations / terraform-provider-delphix

Repository for Delphix Terraform Provider built on DCT APIs.
https://integrations.delphix.com
11 stars 9 forks source link

HUBS-1562 | Telemetry Support #56

Closed Uddipaan-Hazarika closed 1 year ago

Uddipaan-Hazarika commented 1 year ago

Context:

We want telemetry headers to be added. More details: https://delphix.atlassian.net/browse/HUBS-1562

Problem:

Doing this we can gather api usage reports

Solution:

Added telemetry headers.

Testing

x-dct-client-name: { "api_count": 52, "client_name": "Terraform" } user_agent: { "api_count": 38, "user_agent": "Terraform/1.3.9 (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-delphix/1.0.0" }

nick-mathison commented 1 year ago

Can we split this up?

"user_agent": "Terraform/1.3.9 (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-delphix/1.0.0"

I can see myself searching on which provider versions are installed and I suspect it'd be a lot harder if it's combined with other fields.

If not, can we put the provider version up front so it's easier to scan?

Uddipaan-Hazarika commented 1 year ago

Can we split this up?

"user_agent": "Terraform/1.3.9 (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-delphix/1.0.0"

I can see myself searching on which provider versions are installed and I suspect it'd be a lot harder if it's combined with other fields.

If not, can we put the provider version up front so it's easier to scan?

So we dont have much control over this string as this is generated in the sdk code. Ref:

func (p *Provider) UserAgent(name, version string) string {
    ua := fmt.Sprintf("Terraform/%s (+https://www.terraform.io) Terraform-Plugin-SDK/%s", p.TerraformVersion, meta.SDKVersionString())
    if name != "" {
        ua += " " + name
        if version != "" {
            ua += "/" + version
        }
    }

    if add := os.Getenv(uaEnvVar); add != "" {
        add = strings.TrimSpace(add)
        if len(add) > 0 {
            ua += " " + add
            log.Printf("[DEBUG] Using modified User-Agent: %s", ua)
        }
    }

    return ua
}

But if this is not something we would want, I think we can override the useragent.

nick-mathison commented 1 year ago

We already send the user_agent, so not worth changing now.