DataDog / datadog-api-client-go

Golang client for the Datadog API
https://pkg.go.dev/github.com/DataDog/datadog-api-client-go/v2
Apache License 2.0
133 stars 54 forks source link

Support for custom (enterprise) domains in `site` configuration variable #2456

Open inhearst opened 6 months ago

inhearst commented 6 months ago

Is your feature request related to a problem? Please describe. I use Datadog under an enterprise domain (like xxx.datadoghq.com) but it does not seem like I can set the URL in the configuration to this. I am able to use the Ruby API with this URL and it works correctly. Same as #1913 but it was closed for some reason.

Describe the solution you'd like Ability to set the site and similar variables to our custom domain.

Describe alternatives you've considered I can use another language, however a package I want to use (DD query parser) is only available in golang.

Additional context Error info:

% go run main.go
Error when calling `MetricsApi.ListMetricAssets`: the variable site in the server URL has invalid value xxx.datadoghq.com. Must be [datadoghq.com us3.datadoghq.com us5.datadoghq.com ap1.datadoghq.com datadoghq.eu ddog-gov.com]
Full HTTP response: <nil>
Response from `MetricsApi.ListMetricAssets`:
{}
therve commented 6 months ago

Hi,

Note that you should be able to use regular domain names for your organization, you don't have to use the custom. If you do, you need to set the ContextServerIndex context variable:

    ctx := datadog.NewDefaultContext(context.Background())
    ctx = context.WithValue(ctx, datadog.ContextServerIndex, 1)
    ctx = context.WithValue(ctx, datadog.ContextServerVariables,
        map[string]string{"name": "abc.datadoghq.com"},
    )

Let me know if that works for you.

github-actions[bot] commented 5 months ago

Thanks for your contribution!

This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.

If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of this project.

  2. Comment that the issue is still reproducible and include updated details requested in the issue template.