Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a dogshell option to change Datadog site to call API #691

Merged
merged 4 commits into from
Oct 19, 2021

Conversation

aquiladayc
Copy link
Contributor

What does this PR do?

Issue to fix
#652

Description of the Change

Adding --site option to change the site to call the API

Verification Process

Tested with my sandbox account in EU and US3 site.

@aquiladayc aquiladayc requested a review from a team as a code owner October 8, 2021 00:49
@aquiladayc
Copy link
Contributor Author

@DataDog/integrations-tools-and-libraries can anyone review please?

@therve therve added the changelog/Added Added features results into a minor version bump label Oct 11, 2021
Copy link
Contributor

@therve therve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the lint errors as well.

"--site",
help="Datadog site to send data, us (datadoghq.com), eu (datadoghq.eu) or us3 (us3.datadoghq.com), default: us",
dest="site",
default=os.environ.get("DD_SITE", os.environ.get("DATADOG_HOST")),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Site and host have different semantic, I don't think we should use the same env var for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I will change it to api_host

help="Datadog site to send data, us (datadoghq.com), eu (datadoghq.eu) or us3 (us3.datadoghq.com), default: us",
dest="site",
default=os.environ.get("DD_SITE", os.environ.get("DATADOG_HOST")),
choices=["datadoghq.com", "us", "datadoghq.eu", "eu", "us3.datadoghq.com", "us3"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure we want support us and eu ? That could be confusing with other datacenters.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we can be aligned with https://github.com/DataDog/datadogpy/blob/master/datadog/dogshell/wrap.py#L289
What do you think? Should we remove us, eu, us3?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK fair enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks I will leave it.

elif site in ("datadoghq.eu", "eu"):
self["api_host"] = "https://datadoghq.eu"
elif site in ("us3.datadoghq.com", "us3"):
self["api_host"] = "https://us3.datadoghq.com"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably raise an error if the value doesn't match.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error is thrown by choices=["datadoghq.com", "us", "datadoghq.eu", "eu", "us3.datadoghq.com", "us3"]
Error message will be like
__init__.py: error: argument --api_host: invalid choice: 'us4' (choose from 'datadoghq.com', 'us', 'datadoghq.eu', 'eu', 'us3.datadoghq.com', 'us3')

Is it cool?

@aquiladayc
Copy link
Contributor Author

aquiladayc commented Oct 12, 2021

@therve Updated, can you review please?

@therve
Copy link
Contributor

therve commented Oct 19, 2021

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@therve
Copy link
Contributor

therve commented Oct 19, 2021

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@therve
Copy link
Contributor

therve commented Oct 19, 2021

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@therve therve changed the title Add an option to change Datadog site to call API Add a dogshell option to change Datadog site to call API Oct 19, 2021
@therve therve merged commit 0b0ffe0 into master Oct 19, 2021
@therve therve deleted the akira-site-selection branch October 19, 2021 15:28
@janorn
Copy link

janorn commented Jan 27, 2022

I know this has already been merged but just a tiny comment. The new option --api_host uses an under score where both other api options just uses a hyphen.
--api-key
--application-key

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/Added Added features results into a minor version bump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants