Skip to content

Rename apiHostsite and DataDogReporterDatadogReporter#100

Merged
Mr0grog merged 5 commits intomainfrom
realign-some-names
Feb 21, 2023
Merged

Rename apiHostsite and DataDogReporterDatadogReporter#100
Mr0grog merged 5 commits intomainfrom
realign-some-names

Conversation

@Mr0grog
Copy link
Copy Markdown
Collaborator

@Mr0grog Mr0grog commented Sep 26, 2022

In some other spots, I’ve noted that it might be good to rename apiHost to site so that it matches the Datadog documentation and official libraries, which all call this concept the site. This does so by adding a new site option and deprecating apiHost (so it still works, but prints a warning message) and having it set site under the hood.

While I was at it, I followed the lead of #59 and #98 and renamed DataDogReporter to DatadogReporter (no capital "D" in the middle). I didn’t do a deprecation here since there hasn’t yet been a release where it’s publicly visible. But we could do a deprecation instead if we want.

This also builds on some of the tooling in #99, so if we want to land this, it needs to be done a little more carefully so everything merges correctly. (Edit: updated to merge cleanly.)

@ErikBoesen what do you think of these changes? I think the first one is a good change that makes things easier to understand for new users, although neither one is really necessary.

More broadly, I’ve been holding off on implementing the breaking changes (#83 and part of #84 both involve subtle breakage) in case you want to cut a non-breaking 0.10.2 release first. The deprecation stuff here probably isn’t useful if you aren’t interested in that.

@Mr0grog Mr0grog requested a review from ErikBoesen September 26, 2022 21:26
@Mr0grog Mr0grog marked this pull request as draft September 26, 2022 21:26
Base automatically changed from 52-errors-are-important to main September 26, 2022 22:02
@Mr0grog
Copy link
Copy Markdown
Collaborator Author

Mr0grog commented Sep 27, 2022

I’ve been holding off on implementing the breaking changes (#83 and part of #84 both involve subtle breakage) in case you want to cut a non-breaking 0.10.2 release first.

I’m going to see about doing #85 tomorrow, but will probably make that the last change for now until I hear more feedback on this question of breaking changes and release plans.

This renames the `apiHost` option for `init()` and `BufferedMetricsLogger` to `site` in order to better align with Datadog docs and official packages. The old name is kept for now, but logs a deprecation warning to the console (regardless of the user's DEBUG setting) the first time it is used. It also adds tooling for logging similar deprecation messages and centralizes debug logging so we don't have to worry about typos when people define the debug logger in a module.
As a followup to #98, rename `DataDogReporter` to `DatadogReporter` (no capital "D" in the middle). I didn't add a deprecation warning here because we haven't yet had a release that exposes this class publicly, so nobody could have been using it before.
@Mr0grog Mr0grog force-pushed the realign-some-names branch from 657f3da to cad565d Compare February 9, 2023 21:37
@Mr0grog
Copy link
Copy Markdown
Collaborator Author

Mr0grog commented Feb 9, 2023

Rebased this to resolve merge conflicts. We wound up shipping a release that publicly exposes DataDogReporter in the mean time, so this needs to either not rename it, or deprecate it instead of removing the old name.

I think the straightforward way to deprecate is with a subclass:

class DataDogReporter extends DatadogReporter {
    constructor(apiKey, appKey, site) {
        logDeprecation(
            'DataDogReporter has been renamed to DatadogReporter ' +
            '(lower-case D in "dog"); the old name will be removed in a ' +
            'future release.'
        );
        super(apiKey, appKey, site);
    }
}

On the other hand, I’m not sure this really minor change is worthwhile in the way that apiHostsite is, where we are making the name line up with all kinds of documentation from Datadog.

@Mr0grog
Copy link
Copy Markdown
Collaborator Author

Mr0grog commented Feb 14, 2023

@ErikBoesen did you have any thoughts on this? In particular, whether to rename DataDogReporter?

If not, I’m going to figure out how much I want to merge this and see about pushing out a v0.11.0 release later in the week (so the built-in type annotations are available, hopefully solving things like #109).

@ErikBoesen
Copy link
Copy Markdown
Collaborator

ErikBoesen commented Feb 14, 2023

Frankly I trust your judgment on this, considering I don't actually use this package myself anymore. I would lean towards the renaming to adhere to Datadog's branding standards.

@Mr0grog
Copy link
Copy Markdown
Collaborator Author

Mr0grog commented Feb 14, 2023

👍 That's helpful feedback!

@Mr0grog Mr0grog marked this pull request as ready for review February 14, 2023 21:06
@Mr0grog Mr0grog merged commit 735b632 into main Feb 21, 2023
@Mr0grog Mr0grog deleted the realign-some-names branch February 21, 2023 21:16
Mr0grog added a commit that referenced this pull request Nov 18, 2024
Back in #100, I renamed the `apiHost` option to `site` (in order to match up with Datadog's own docs and terminology), but forgot to rename the corresponding environment variable. This deprecates `DATADOG_API_HOST` in favor of `DATADOG_SITE` (as should have been done before). We'll remove support for the old env var when we remove `apiHost`.
Mr0grog added a commit that referenced this pull request Nov 20, 2024
Back in #100, I renamed the `apiHost` option to `site` (in order to match up with Datadog's own docs and terminology), but forgot to rename the corresponding environment variable. This deprecates `DATADOG_API_HOST` in favor of `DATADOG_SITE` (as should have been done before). We'll remove support for the old env var when we remove `apiHost`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants