-
Notifications
You must be signed in to change notification settings - Fork 27
Add documentation for JsonImporter #146
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
Open
Phanindra899
wants to merge
13
commits into
apache:master
Choose a base branch
from
Phanindra899:json-importer-docs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
38f2d14
Add structured documentation homepage replacing directory listing
Phanindra899 d876ce6
Add documentation landing page replacing directory listing
Phanindra899 67fc0a9
Add initial Sphinx documentation setup with MyST support
Phanindra899 9241b07
Ignore Sphinx build and virtual environment files
Phanindra899 3017a85
Add documentation for JsonImporter
Phanindra899 14b45a8
Add Apache license header to JSON docs
Phanindra899 6bb5371
Add example JSON data and config for documentation validation
Phanindra899 682a4a4
Fix license header for YAML example
Phanindra899 d1efe5b
Improve JsonImporter docs: clarify timestamp semantics, simplify attr…
Phanindra899 68479e9
Fix Sphinx index to use docs/ as source
Phanindra899 1f550a4
Clean Sphinx config and add docs path
Phanindra899 a26b564
Use realistic multi-point JSON example for change-point detection
Phanindra899 ed63782
Merge branch 'sphinx-docs-setup' into json-importer-docs
Phanindra899 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,3 +31,5 @@ dist/ | |
| venv/ | ||
| .tox/ | ||
| .docker/ | ||
| docs_sphinx/venv/ | ||
| docs_sphinx/build/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| <!-- | ||
| Licensed to the Apache Software Foundation (ASF) under one | ||
| or more contributor license agreements. See the NOTICE file | ||
| distributed with this work for additional information | ||
| regarding copyright ownership. The ASF licenses this file | ||
| to you under the Apache License, Version 2.0 (the | ||
| "License"); you may not use this file except in compliance | ||
| with the License. You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, | ||
| software distributed under the License is distributed on an | ||
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| KIND, either express or implied. See the License for the | ||
| specific language governing permissions and limitations | ||
| under the License. | ||
| --> | ||
| # JSON Data Source | ||
|
|
||
| > **Tip** | ||
| > See [examples/](../examples/) for sample configuration files. | ||
|
|
||
| ## Overview | ||
|
|
||
| `JsonImporter` reads benchmark results from a local JSON file and feeds them into Otava for change-point analysis. It is a simple data source to set up — no external database or service is required. | ||
|
|
||
| The importer caches parsed file content in memory, so a file is only read once per session even if multiple tests reference the same path. | ||
|
|
||
| --- | ||
|
|
||
| ## Expected JSON Format | ||
|
|
||
| The input file must be a JSON array. Each element represents a single benchmark run. | ||
| ```json | ||
| [ | ||
| { | ||
| "timestamp": 1711929600, | ||
| "metrics": [ | ||
| { "name": "throughput", "value": 4821.0 }, | ||
| { "name": "p99_latency_ms", "value": 142.7 } | ||
| ], | ||
| "attributes": { | ||
| "branch": "main", | ||
| "commit": "a3f9c12" | ||
| } | ||
| }, | ||
| { | ||
| "timestamp": 1712016000, | ||
| "metrics": [ | ||
| { "name": "throughput", "value": 5013.0 }, | ||
| { "name": "p99_latency_ms", "value": 138.2 } | ||
| ], | ||
| "attributes": { | ||
| "branch": "main", | ||
| "commit": "b7d2e45" | ||
| } | ||
| } | ||
| ] | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Fields | ||
|
|
||
| ### `timestamp` | ||
|
|
||
| - **Type:** integer (Unix epoch seconds) | ||
| - **Required:** yes | ||
| - Identifies when the commit was merged into the tracked branch. This timestamp should remain constant for the same commit, even if benchmarks are rerun multiple times. | ||
|
|
||
| ### `metrics` | ||
|
|
||
| - **Type:** array of objects | ||
| - **Required:** yes | ||
| - Each object must have: | ||
| - `name` (string) — unique identifier for the metric within this result | ||
| - `value` (number) — the measured value | ||
| - Metric names must be consistent across results for change-point analysis to be meaningful. | ||
|
|
||
| > Note: A `unit` field (e.g., "ms") is not currently supported by JsonImporter. | ||
|
|
||
| ### `attributes` | ||
|
|
||
| - **Type:** object (string → string) | ||
| - **Required:** no | ||
| - Arbitrary key-value pairs describing the run context (e.g. branch, commit, version). | ||
| - The `branch` key is required only when using branch-based filtering. | ||
| --- | ||
|
|
||
| ## Configuration Example | ||
|
|
||
| Add a test with `type: json` to your `otava.yaml`: | ||
| ```yaml | ||
| tests: | ||
| my_benchmark: | ||
| type: json | ||
| file: otava/examples/json/data/sample.json | ||
| base_branch: main | ||
| ``` | ||
|
|
||
| | Field | Required | Description | | ||
| |---|---|---| | ||
| | `type` | yes | Must be `json` | | ||
| | `file` | yes | Path to the JSON file | | ||
| | `base_branch` | no | If set, only runs from this branch are analyzed by default | | ||
henrikingo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| --- | ||
|
|
||
| ## Limitations | ||
|
|
||
| - The entire file is read into memory at once. Very large files may cause high memory usage. | ||
| - There is no schema validation. Missing or malformed fields will cause a `KeyError` at runtime. | ||
| - The `branch` filter requires the key `"branch"` to exist inside `attributes` on every entry — if it is absent on any entry that would otherwise be included, the importer will raise a `KeyError`. | ||
| - Attribute values are expected to be strings. No type coercion is performed. | ||
| - The file path is resolved at config load time; a missing file raises a `TestConfigError` immediately. | ||
|
|
||
| --- | ||
|
|
||
| ## Example Usage | ||
|
|
||
| Analyze test results stored in JSON format: | ||
| ```bash | ||
| otava analyze my_benchmark --config otava/examples/json/config/otava.yaml | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
|
|
||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <title>Apache Otava Documentation</title> | ||
|
|
||
| <style> | ||
| body { | ||
| font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; | ||
| margin: 0; | ||
| background-color: #f6f8fa; | ||
| color: #24292e; | ||
| } | ||
|
|
||
| .container { | ||
| max-width: 900px; | ||
| margin: 40px auto; | ||
| padding: 30px; | ||
| background: #ffffff; | ||
| border-radius: 10px; | ||
| box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); | ||
| } | ||
|
|
||
| h1 { | ||
| margin-bottom: 10px; | ||
| font-size: 28px; | ||
| color: #1f2328; | ||
| } | ||
|
|
||
| p { | ||
| color: #57606a; | ||
| } | ||
|
|
||
| h2 { | ||
| margin-top: 30px; | ||
| border-bottom: 1px solid #d0d7de; | ||
| padding-bottom: 5px; | ||
| } | ||
|
|
||
| ul { | ||
| padding-left: 20px; | ||
| } | ||
|
|
||
| li { | ||
| margin: 8px 0; | ||
| } | ||
|
|
||
| a { | ||
| color: #0969da; | ||
| text-decoration: none; | ||
| font-weight: 500; | ||
| } | ||
|
|
||
| a:hover { | ||
| text-decoration: underline; | ||
| } | ||
|
|
||
| .section { | ||
| margin-top: 20px; | ||
| } | ||
| </style> | ||
| </head> | ||
|
|
||
| <body> | ||
| <div class="container"> | ||
|
|
||
| <h1>Apache Otava Documentation</h1> | ||
|
|
||
| <p> | ||
| Structured entry point to the Otava documentation, replacing the default directory listing. | ||
| </p> | ||
|
|
||
| <div class="section"> | ||
| <h2>Documentation</h2> | ||
| <ul> | ||
| <li><a href="https://github.com/apache/otava/blob/master/docs/GETTING_STARTED.md">Getting Started</a></li> | ||
| <li><a href="https://github.com/apache/otava/blob/master/docs/INSTALL.md">Installation</a></li> | ||
| <li><a href="https://github.com/apache/otava/blob/master/docs/BASICS.md">Basics</a></li> | ||
| <li><a href="https://github.com/apache/otava/blob/master/docs/MATH.md">Mathematics</a></li> | ||
| <li><a href="https://github.com/apache/otava/blob/master/docs/CSV.md">CSV</a></li> | ||
| <li><a href="https://github.com/apache/otava/blob/master/docs/BIG_QUERY.md">BigQuery</a></li> | ||
| <li><a href="https://github.com/apache/otava/blob/master/docs/POSTGRESQL.md">PostgreSQL</a></li> | ||
| <li><a href="https://github.com/apache/otava/blob/master/docs/GRAFANA.md">Grafana</a></li> | ||
| <li><a href="https://github.com/apache/otava/blob/master/docs/GRAPHITE.md">Graphite</a></li> | ||
| </ul> | ||
| </div> | ||
|
|
||
| <div class="section"> | ||
| <h2>Project</h2> | ||
| <ul> | ||
| <li><a href="https://github.com/apache/otava/blob/master/docs/CONTRIBUTING.md">Contributing</a></li> | ||
| <li><a href="https://github.com/apache/otava/blob/master/docs/RELEASE.md">Release Notes</a></li> | ||
| </ul> | ||
| </div> | ||
|
|
||
| </div> | ||
| </body> | ||
|
|
||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Minimal makefile for Sphinx documentation | ||
| # | ||
|
|
||
| # You can set these variables from the command line, and also | ||
| # from the environment for the first two. | ||
| SPHINXOPTS ?= | ||
| SPHINXBUILD ?= sphinx-build | ||
| SOURCEDIR = source | ||
| BUILDDIR = build | ||
|
|
||
| # Put it first so that "make" without argument is like "make help". | ||
| help: | ||
| @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
|
||
| .PHONY: help Makefile | ||
|
|
||
| # Catch-all target: route all unknown targets to Sphinx using the new | ||
| # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
| %: Makefile | ||
| @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| @ECHO OFF | ||
|
|
||
| pushd %~dp0 | ||
|
|
||
| REM Command file for Sphinx documentation | ||
|
|
||
| if "%SPHINXBUILD%" == "" ( | ||
| set SPHINXBUILD=sphinx-build | ||
| ) | ||
| set SOURCEDIR=source | ||
| set BUILDDIR=build | ||
|
|
||
| %SPHINXBUILD% >NUL 2>NUL | ||
| if errorlevel 9009 ( | ||
| echo. | ||
| echo.The 'sphinx-build' command was not found. Make sure you have Sphinx | ||
| echo.installed, then set the SPHINXBUILD environment variable to point | ||
| echo.to the full path of the 'sphinx-build' executable. Alternatively you | ||
| echo.may add the Sphinx directory to PATH. | ||
| echo. | ||
| echo.If you don't have Sphinx installed, grab it from | ||
| echo.https://www.sphinx-doc.org/ | ||
| exit /b 1 | ||
| ) | ||
|
|
||
| if "%1" == "" goto help | ||
|
|
||
| %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% | ||
| goto end | ||
|
|
||
| :help | ||
| %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% | ||
|
|
||
| :end | ||
| popd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # Configuration file for the Sphinx documentation builder. | ||
| import os | ||
| import sys | ||
|
|
||
| sys.path.insert(0, os.path.abspath('../..')) | ||
|
|
||
| # For the full list of built-in configuration values, see the documentation: | ||
| # https://www.sphinx-doc.org/en/master/usage/configuration.html | ||
|
|
||
| # -- Project information ----------------------------------------------------- | ||
| # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information | ||
|
|
||
| project = 'otava' | ||
| copyright = '2026, Apache Otava' | ||
| author = 'Apache Otava' | ||
| release = '0.1' | ||
|
|
||
| # -- General configuration --------------------------------------------------- | ||
| # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration | ||
|
|
||
| extensions = ["myst_parser"] | ||
|
|
||
| templates_path = ['_templates'] | ||
| exclude_patterns = [] | ||
|
|
||
|
|
||
|
|
||
| # -- Options for HTML output ------------------------------------------------- | ||
| # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output | ||
|
|
||
| html_theme = 'alabaster' | ||
| source_suffix = { | ||
| ".rst": "restructuredtext", | ||
| ".md": "markdown", | ||
| } | ||
| html_static_path = ['_static'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| Welcome to Apache Otava Documentation | ||
| ==================================== | ||
|
|
||
| .. toctree:: | ||
| :maxdepth: 2 | ||
|
|
||
| ../../docs/README.md | ||
| ../../docs/INSTALL.md | ||
| ../../docs/GETTING_STARTED.md | ||
| ../../docs/BASICS.md | ||
| ../../docs/CSV.md | ||
| ../../docs/BIG_QUERY.md | ||
| ../../docs/POSTGRESQL.md | ||
| ../../docs/GRAFANA.md | ||
| ../../docs/GRAPHITE.md | ||
|
|
||
|
|
||
| This documentation is powered by Sphinx and supports Markdown via MyST. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.