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

Move to DogStatsD. #10238

Merged
merged 9 commits into from
Feb 11, 2022
Merged

Move to DogStatsD. #10238

merged 9 commits into from
Feb 11, 2022

Conversation

davinchia
Copy link
Contributor

@davinchia davinchia commented Feb 10, 2022

What

We want to move to DogStatsD to make it easier to do more complex metrics collection. The official DD library also does not double count metrics so using this is cheaper overall.

Unfortunately unlike Prometheus, there is no good way to test that metrics are being reported in an automated test so I've omitted that for now. I've tested this manually in the dev env to make sure metrics are being emitted.

How

  • Rename the old metrics singleton to make it clear it's Prometheus related. Also add a deprecated annotation.
  • Add a DogStatsD metric singleton class.

I will remove the old Prometheus class in a follow up PR.

Recommended reading order

  1. DogStatsdMetricSingleton.java
  2. rest of the class are renames.

🚨 User Impact 🚨

Are there any breaking changes? What is the end result perceived by the user? If yes, please merge this PR with the 🚨🚨 emoji so changelog authors can further highlight this if needed.

Pre-merge Checklist

Expand the relevant checklist and delete the others.

New Connector

Community member or Airbyter

  • Community member? Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • docs/SUMMARY.md
    • docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
    • docs/integrations/README.md
    • airbyte-integrations/builds.md
  • PR name follows PR naming conventions

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • Credentials added to Github CI. Instructions.
  • /test connector=connectors/<name> command is passing.
  • New Connector version released on Dockerhub by running the /publish command described here
  • After the connector is published, connector added to connector index as described here
  • Seed specs have been re-generated by building the platform and committing the changes to the seed spec files, as described here

Updating a connector

Community member or Airbyter

  • Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • Changelog updated in docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
  • PR name follows PR naming conventions

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • Credentials added to Github CI. Instructions.
  • /test connector=connectors/<name> command is passing.
  • New Connector version released on Dockerhub by running the /publish command described here
  • After the new connector version is published, connector version bumped in the seed directory as described here
  • Seed specs have been re-generated by building the platform and committing the changes to the seed spec files, as described here

Connector Generator

  • Issue acceptance criteria met
  • PR name follows PR naming conventions
  • If adding a new generator, add it to the list of scaffold modules being tested
  • The generator test modules (all connectors with -scaffold in their name) have been updated with the latest scaffold by running ./gradlew :airbyte-integrations:connector-templates:generator:testScaffoldTemplates then checking in your changes
  • Documentation which references the generator is updated as needed.

@github-actions github-actions bot added area/platform issues related to the platform area/scheduler labels Feb 10, 2022
@davinchia davinchia temporarily deployed to more-secrets February 10, 2022 10:49 Inactive
@davinchia davinchia temporarily deployed to more-secrets February 10, 2022 11:31 Inactive
@davinchia davinchia temporarily deployed to more-secrets February 10, 2022 11:41 Inactive
@davinchia davinchia temporarily deployed to more-secrets February 10, 2022 14:40 Inactive
@davinchia davinchia temporarily deployed to more-secrets February 10, 2022 14:42 Inactive
@davinchia davinchia temporarily deployed to more-secrets February 10, 2022 14:56 Inactive
@davinchia davinchia marked this pull request as ready for review February 10, 2022 15:02
return instance;
}

public synchronized static void initialize(final String appName, final Map<String, String> mdc, final boolean publish) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the MDC important here? Shouldn't the initialization be run from some thread that has the MDC configured?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point - I think it's left over from when I was testing. You should be right that we don't need this anymore. Will remove.


public static synchronized DogstatsdMetricSingleton getInstance() {
if (instance == null) {
throw new RuntimeException("You must initialize configuration with the initializeMonitoringServiceDaemon() method before getting an instance.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this say .. with the initialize() method?

Also, what is the downside of combining getInstance() and initialize() into the same method? The behavior would be that if instance == null, it initializes and returns. If instance != null, it just returns. That approach feels like it would be a bit more ergonomic, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah yes good catch on the error message.

this is a small thing - the main downside would be the initialise method has more parameters than the getInstance method. we'd have to combine those parameters if we combined the methods. because of this I prefer to keep these separate for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

@davinchia I'm curious how you are thinking about consumers of this class. If I want to use the DogstatsdMetricSingleton, how do I know if it has been initialized or not? Is it expected that a consumer would call getInstance wrapped with a try-catch to catch a RuntimeException in the case that it was already initialized, and call initialize in that case? That doesn't feel very ergonomic to me, but let me know if I'm thinking about this wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question - I'm trying to follow the general singleton pattern where initialize is called in the main method, and getInstance is called everywhere else. Although it's possible to catch, most folks don't really catch the RTE since it's usually understood the singleton is initialised when the JVM first starts up.

I agree with you having to do getInstance is somewhat annoying, but this is a fairly common pattern and I don't really think it's worth trying to get rid of.

I can't see how to not have a simply method signature if we combine initialize and getInstance and I didn't want to spend more time playing with this.

Happy to discuss more/review any ideas/approaches you come up with!

Copy link
Contributor

@lmossman lmossman left a comment

Choose a reason for hiding this comment

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

Left a couple of fairly small comments but looks good to me overall

@davinchia davinchia temporarily deployed to more-secrets February 11, 2022 15:49 Inactive
@davinchia davinchia merged commit 4b73bb0 into master Feb 11, 2022
@davinchia davinchia deleted the davinchia/use-dogstats-d branch February 11, 2022 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/platform issues related to the platform area/scheduler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants