-
Notifications
You must be signed in to change notification settings - Fork 158
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 metrics storage support to auto-generated CLI documentation #539
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,31 +3,48 @@ | |
import json | ||
|
||
if len(sys.argv) < 3: | ||
print("You must supply a Jaeger version as the first argument and the output path as the second") | ||
print("You must supply a Jaeger version as the first argument and " | ||
"the output path as the second") | ||
sys.exit(1) | ||
|
||
jaeger_ver=sys.argv[1] | ||
output_path=sys.argv[2] | ||
jaeger_ver = sys.argv[1] | ||
output_path = sys.argv[2] | ||
|
||
with open("%s/data/cli/%s/config.json" % (output_path, jaeger_ver), 'r') as f: | ||
cfg=json.load(f) | ||
with open(f"{output_path}/data/cli/{jaeger_ver}/config.json", 'r') as f: | ||
cfg = json.load(f) | ||
|
||
def generate(tool, storage='', sampling=''): | ||
print('Generating YAML for {}, storage {} and sampling {}'.format(tool, storage, sampling)) | ||
|
||
volume='%s/data/cli/%s:/data' % (output_path, jaeger_ver) | ||
docker_img='all-in-one' if tool == 'jaeger-all-in-one' else tool | ||
docker_image="jaegertracing/%s:%s" % (docker_img, jaeger_ver) | ||
storageOrSampling=storage or sampling | ||
# generate generates the CLI documentation for a given "tool" (e.g. | ||
# jaeger-collector, jaeger-query, etc.) and feature (e.g. storage=elasticsearch, | ||
# sampling=adaptive, metrics-storage=prometheus). | ||
def generate(tool, **kwargs): | ||
if len(kwargs) > 1: | ||
print(f"Expected at most 1 feature, got {len(kwargs)}.") | ||
sys.exit(1) | ||
|
||
feature_name = "" | ||
|
||
# Get the first feature name (e.g. elasticsearch, adaptive, prometheus, | ||
# etc.) in kwargs if it exists. The feature type (e.g. storage, | ||
# sampling, metrics-storage) is not used, and hence ignored. | ||
for _, feature_name in kwargs.items(): | ||
break | ||
|
||
print(f'Generating YAML for tool: {tool}, feature: {feature_name}') | ||
|
||
cmd=" ".join([ | ||
volume = f'{output_path}/data/cli/{jaeger_ver}:/data' | ||
docker_img = 'all-in-one' if tool == 'jaeger-all-in-one' else tool | ||
docker_image = f"jaegertracing/{docker_img}:{jaeger_ver}" | ||
|
||
cmd = " ".join([ | ||
"docker run", | ||
"--rm", | ||
"--interactive", | ||
"--privileged", | ||
"--volume {}".format(volume), | ||
"-e SPAN_STORAGE_TYPE={}".format(storage), | ||
"-e SAMPLING_CONFIG_TYPE={}".format(sampling), | ||
f"--volume {volume}", | ||
f"-e SPAN_STORAGE_TYPE={kwargs.get('storage', '')}", | ||
f"-e SAMPLING_CONFIG_TYPE={kwargs.get('sampling', '')}", | ||
f"-e METRICS_STORAGE_TYPE={kwargs.get('metrics_storage', '')}", | ||
docker_image, | ||
"docs", | ||
"--format=yaml", | ||
|
@@ -36,24 +53,26 @@ def generate(tool, storage='', sampling=''): | |
print(cmd) | ||
if os.system(cmd) != 0: | ||
sys.exit(1) | ||
if storageOrSampling: | ||
|
||
if feature_name: | ||
os.rename( | ||
'{}/data/cli/{}/{}.yaml'.format(output_path, jaeger_ver, tool), | ||
'{}/data/cli/{}/{}-{}.yaml'.format(output_path, jaeger_ver, tool, storageOrSampling) | ||
) | ||
f'{output_path}/data/cli/{jaeger_ver}/{tool}.yaml', | ||
f'{output_path}/data/cli/{jaeger_ver}/{tool}-{feature_name}.yaml') | ||
|
||
|
||
for tool in cfg['tools']: | ||
tool_cfg = cfg[tool] | ||
storage_types=tool_cfg['storage'] | ||
sampling_types=tool_cfg['sampling'] | ||
if storage_types: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These |
||
for s in storage_types: | ||
generate(tool=tool, storage=s) | ||
if sampling_types: | ||
for s in sampling_types: | ||
generate(tool=tool, sampling=s) | ||
storage_types = tool_cfg['storage'] | ||
sampling_types = tool_cfg['sampling'] | ||
metrics_storage_types = tool_cfg['metrics-storage'] | ||
|
||
for s in storage_types: | ||
generate(tool=tool, storage=s) | ||
for s in sampling_types: | ||
generate(tool=tool, sampling=s) | ||
for s in metrics_storage_types: | ||
generate(tool=tool, metrics_storage=s) | ||
generate(tool=tool) | ||
|
||
print('Deleting _env/_docs/_version files') | ||
os.system('bash -c "rm -rf data/cli/{}/*_*"'.format(jaeger_ver)) | ||
os.system(f'bash -c "rm -rf data/cli/{jaeger_ver}/*_*"') |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
{{ $cli := index $data $tool }} | ||
{{ $storage_types := index (index $config $tool) "storage" }} | ||
{{ $sampling_types := index (index $config $tool) "sampling" }} | ||
{{ $metrics_storage_types := index (index $config $tool) "metrics-storage" }} | ||
|
||
<h2 id="{{ $tool }}"> | ||
{{ $tool }} | ||
|
@@ -49,17 +50,32 @@ <h2 id="{{ $tool }}"> | |
<p>{{ $tool }} can be used with these sampling types:</p> | ||
<ul> | ||
{{ range $sampling_types }} | ||
{{ $storage := . }} | ||
{{ $file := printf "%s-%s" $tool $storage }} | ||
{{ $sampling := . }} | ||
{{ $file := printf "%s-%s" $tool $sampling }} | ||
<li> | ||
<a href="#{{ $file }}"> | ||
{{ $tool }} with <code>{{ $storage }}</code> | ||
{{ $tool }} with <code>{{ $sampling }}</code> sampling | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before: "... with adaptive" |
||
</a> | ||
</li> | ||
{{ end }} | ||
</ul> | ||
{{ end }} | ||
|
||
{{ if $metrics_storage_types }} | ||
<p>(Experimental) {{ $tool }} can be used with these metrics storage types:</p> | ||
<ul> | ||
{{ range $metrics_storage_types }} | ||
{{ $metrics_storage := . }} | ||
{{ $file := printf "%s-%s" $tool $metrics_storage }} | ||
<li> | ||
<a href="#{{ $file }}"> | ||
{{ $tool }} with <code>{{ $metrics_storage }}</code> metrics storage | ||
</a> | ||
</li> | ||
{{ end }} | ||
</ul> | ||
{{ end }} | ||
|
||
{{ range $storage_types }} | ||
{{ $storage := . }} | ||
{{ $file := printf "%s-%s" $tool $storage }} | ||
|
@@ -80,11 +96,25 @@ <h3 id="{{ $file }}"> | |
|
||
<!-- TODO right sidebar gets too long, we should use tabs here --> | ||
<h3 id="{{ $file }}"> | ||
{{ $tool }} with <code>{{ $sampling }}</code> sampling type | ||
{{ $tool }} with <code>{{ $sampling }}</code> sampling | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before: "... with adaptive sampling type" |
||
</h3> | ||
|
||
{{ partial "options-table.html" $cli.options }} | ||
{{ end }} | ||
|
||
{{ range $metrics_storage_types }} | ||
{{ $metrics_storage := . }} | ||
{{ $file := printf "%s-%s" $tool $metrics_storage }} | ||
{{ $cli := index $data $file }} | ||
|
||
<!-- TODO right sidebar gets too long, we should use tabs here --> | ||
<h3 id="{{ $file }}"> | ||
{{ $tool }} with <code>{{ $metrics_storage }}</code> metrics storage | ||
</h3> | ||
|
||
{{ partial "options-table.html" $cli.options }} | ||
{{ end }} | ||
|
||
{{ else }} | ||
{{ partial "options-table.html" $cli.options }} | ||
{{ end }} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using
kwargs
would be simpler and cleaner than adding another "optional" parameter to support metrics storage, especially avoiding the need to extend thestorageOrSampling
variable.