Skip to content
This repository has been archived by the owner on Feb 1, 2018. It is now read-only.

Autogenerate the various JMX json files. #9

Merged
merged 3 commits into from
Jun 4, 2015

Conversation

coreykosak
Copy link
Contributor

The purpose of this PR is to create a framework to autogenerate the JMX JSON files.

There are four flavors of JSON files, and they differ only in small details. The four flavors are {stackdriver, google-cloud-monitoring} x {json-detect-instance,json-specify-instance}

The approach taken in this PR is to create ".tmpl" files in the "templates" directory, and a Python script to generate the four flavors of files from the templates.

This Pull Request has three parts:

  1. The first commit is the Python program (generate-json-files-from-templates.py) and its helper library (differ.py). The reason for the 'differ' library is explained below.
  2. The second commit is all the .tmpl files. The tmpl file has a pretty straightforward syntax. The purpose of generate-json-files-from-templates.py is to move the properties from the .tmpl file to the right place in the output.
  3. The third commit is the result of running the generator on the .tmpl files. Though it looks like there are a lot of changes, these are primarily the result of formatting changes, missing files, and human error. The differences are summarized in the file differences.txt (which exists for the benefit of the reviewer and might not be checked in after this PR is accepted).

Why differ.py
It is labor-intensive for a human to look at the differences between 'old' and 'new' files to decide whether they're valid. To help with this, I wrote 'differ.py' which shows the meaningful (not whitespace-related) differences. Looking at differences.txt, we can readily see that the changes are simply:

  1. Standardization of the text INSTANCE_ID. This is changed to AWS_INSTANCE_ID for the stackdriver items and GCE_INSTANCE_IDfor the google-cloud-monitoring items.
    1. In some cases AWS_INSTANCE_ID appeared in a google-cloud-monitoring subdirectory, so this needed to be changed to GCE_INSTANCE_ID.
  2. Missing files: cassandra-06.json was missing from {stackdriver, google-cloud-monitoring} x json-specify-instance.
  3. Inconsistent specification of CASSANDRA_HOST and CASSANDRA_PORT. Some files used the above, and others used localhost/7199.

@coreykosak
Copy link
Contributor Author

Assigning to @ekilby, also tagging @katzj as a heads-up.

@ekilby
Copy link
Contributor

ekilby commented May 27, 2015

This seems like a good approach within the constraints that we face with jmxtrans. It will certainly cut down on edit labor and copy-paste errors.

I'd add some docstrings to the python scripts but otherwise it seems sound to me and as simple as it could possibly be.

@katzj
Copy link

katzj commented May 27, 2015

Yeah, a few docstrings wouldn't hurt. But LGTM too in terms of the output and general approach

@coreykosak
Copy link
Contributor Author

Hi, I added a bunch of documentation. PTAL

@ekilby
Copy link
Contributor

ekilby commented May 29, 2015

This looks great, thanks for adding those comments.

@katzj
Copy link

katzj commented May 29, 2015

:shipit:

Corey Kosak added 3 commits June 4, 2015 17:10
from template files.

Auto-generating them should reduce the potential for human error in
keeping them in sync.
This is the result of running
./generate-json-files-from-templates.pl *.tmpl > differences.txt
coreykosak added a commit that referenced this pull request Jun 4, 2015
Autogenerate the various JMX json files.
@coreykosak coreykosak merged commit 5ec6b61 into master Jun 4, 2015
@coreykosak coreykosak deleted the kosak-autogen-json-files branch June 4, 2015 21:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants