-
Notifications
You must be signed in to change notification settings - Fork 189
feat(docs): add v2 metrics reference for backwards compatibility tracking #1071
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
hharshhsaini
wants to merge
2
commits into
jaegertracing:main
Choose a base branch
from
hharshhsaini:feat/add-metrics-summary
base: main
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
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
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
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
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,13 @@ | ||
| --- | ||
|
hharshhsaini marked this conversation as resolved.
|
||
| title: Metrics Reference (v2) | ||
| navtitle: Metrics Reference | ||
| hasparent: true | ||
| --- | ||
|
|
||
| This page is intended to provide a reference of all metrics exposed by Jaeger v2. Once | ||
| populated, it is used to track **backwards compatibility across Jaeger v2 releases** — | ||
| i.e. ensuring metric names and labels do not change unexpectedly between versions. | ||
|
|
||
| > **Note:** The full metrics table is generated as part of the Jaeger release process and | ||
| > is not committed verbatim to this repository. Run `make fetch-metrics` after a release | ||
| > to populate this page with up-to-date data. | ||
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,184 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| # Copyright (c) 2026 The Jaeger Authors. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # This script fetches the v1-to-v2 metrics mapping tables from the jaegertracing/jaeger | ||
| # repository and publishes a reference page of current Jaeger v2 metrics. | ||
| # It is intended to be run as part of the RELEASE PROCESS so that the committed | ||
| # metrics-reference.md always reflects the state of a specific release tag. | ||
| # The purpose is to track BACKWARDS COMPATIBILITY of metrics across Jaeger v2 releases. | ||
| # | ||
| # NOTE: The source files under cmd/jaeger/docs/migration/ are v1-to-v2 mapping tables. | ||
| # Pin JAEGER_METRICS_REF to a specific release tag for reproducible, up-to-date output. | ||
|
|
||
| import logging | ||
| import os | ||
|
hharshhsaini marked this conversation as resolved.
|
||
| import re | ||
| import sys | ||
| import urllib.error | ||
| import urllib.request | ||
| from pathlib import Path | ||
|
|
||
| # Set up logging | ||
| logging.basicConfig(level=logging.INFO) | ||
| logger = logging.getLogger(__name__) | ||
|
|
||
| # Base URL template for the v1-to-v2 metrics mapping tables stored in the jaeger repository | ||
| # under cmd/jaeger/docs/migration/. These are committed markdown files. | ||
| # Set the JAEGER_METRICS_REF environment variable to a specific release tag/branch | ||
| # (e.g. export JAEGER_METRICS_REF=v2.1.0) for reproducible output; it defaults to "main". | ||
| BASE_RAW_URL_TEMPLATE = "https://raw.githubusercontent.com/jaegertracing/jaeger/{ref}/cmd/jaeger/docs/migration/" | ||
|
hharshhsaini marked this conversation as resolved.
|
||
| JAEGER_METRICS_REF = os.environ.get("JAEGER_METRICS_REF", "main") | ||
|
|
||
| TARGET_FILES = [ | ||
| {"filename": "all-in-one-metrics.md", "title": "Jaeger"}, | ||
| {"filename": "badger-metrics.md", "title": "Badger Storage"}, | ||
| {"filename": "cassandra-metrics.md", "title": "Cassandra Storage"}, | ||
| {"filename": "elasticsearch-metrics.md", "title": "Elasticsearch Storage"}, | ||
| {"filename": "opensearch-metrics.md", "title": "OpenSearch Storage"}, | ||
| ] | ||
|
|
||
|
|
||
| def fetch_markdown(filename): | ||
| url = BASE_RAW_URL_TEMPLATE.format(ref=JAEGER_METRICS_REF) + filename | ||
| req = urllib.request.Request(url) | ||
| try: | ||
| with urllib.request.urlopen(req, timeout=10) as response: | ||
| return response.read().decode("utf-8") | ||
| except urllib.error.HTTPError as e: | ||
| logger.error(f"HTTP Error fetching {filename}: {e.code} {e.reason}") | ||
|
hharshhsaini marked this conversation as resolved.
|
||
| return None | ||
| except Exception as e: | ||
| logger.error(f"Error fetching {filename}: {e}") | ||
| return None | ||
|
hharshhsaini marked this conversation as resolved.
|
||
|
|
||
|
|
||
| def extract_v2_metrics_table(raw_md): | ||
| """Parse the raw markdown and return a new table with only v2 Metric + v2 Labels columns. | ||
|
|
||
| The source files have 4 columns: V1 Metric | V1 Labels | V2 Metric | V2 Labels. | ||
| We extract only the columns that matter for v2 backwards-compatibility tracking, | ||
| dropping rows where V2 Metric is N/A (metric was removed in v2). | ||
| """ | ||
| output_lines = [] | ||
| in_table = False | ||
|
|
||
| for line in raw_md.split("\n"): | ||
| stripped = line.strip() | ||
|
|
||
| # Detect the start of a 4-column metrics table (V1 Metric header) | ||
| if "V1 Metric" in stripped and "V2 Metric" in stripped: | ||
| in_table = True | ||
| # Emit the new v2-only header | ||
| output_lines.append("| Metric | Labels |") | ||
| output_lines.append("|--------|--------|") | ||
| continue | ||
|
|
||
| # Skip the separator row (|---|---:|:---|...) | ||
| if in_table and re.fullmatch(r'[\|\-\s:]+', stripped): | ||
| continue | ||
|
|
||
| if in_table and stripped.startswith("|"): | ||
| # Strip leading/trailing pipes first to avoid empty first column from `|| ...` rows | ||
| cols = [c.strip() for c in stripped.strip('|').split("|")] | ||
| # cols[0]=V1 Metric, cols[1]=V1 Labels, cols[2]=V2 Metric, cols[3]=V2 Labels | ||
| if len(cols) >= 4: | ||
| v2_metric = cols[2] | ||
| v2_labels = cols[3] | ||
| # Skip metrics that don't exist in v2 | ||
| if v2_metric and v2_metric.lower() != "n/a": | ||
| output_lines.append(f"| {v2_metric} | {v2_labels} |") | ||
| elif in_table and stripped == "": | ||
| in_table = False | ||
| output_lines.append("") | ||
| elif in_table and not stripped.startswith("|"): | ||
| # A non-pipe, non-empty line ends the table even without a blank separator. | ||
| # Exit table mode and fall through to heading/content processing below. | ||
| in_table = False | ||
| output_lines.append("") | ||
| heading_match = re.match(r'^(#{1,6})\s+(.*)', stripped) | ||
| if heading_match: | ||
| hashes, text = heading_match.groups() | ||
| level = len(hashes) | ||
| if level == 1: | ||
| output_lines.append("### " + text.strip()) | ||
| else: | ||
| output_lines.append(stripped) | ||
| elif not in_table: | ||
|
hharshhsaini marked this conversation as resolved.
|
||
| # Carry over subsection headings, but downgrade H1 to H3 to avoid multiple page H1s. | ||
| # Preserve H2-H6 headings as-is to keep section boundaries clear. | ||
| heading_match = re.match(r'^(#{1,6})\s+(.*)', stripped) | ||
| if heading_match: | ||
| hashes, text = heading_match.groups() | ||
| level = len(hashes) | ||
| if level == 1: | ||
| # Downgrade H1 to H3 | ||
| output_lines.append("### " + text.strip()) | ||
| else: | ||
| # Preserve H2-H6 verbatim | ||
| output_lines.append(stripped) | ||
|
|
||
| return "\n".join(output_lines) | ||
|
hharshhsaini marked this conversation as resolved.
|
||
|
|
||
|
|
||
| def generate_metrics_reference(): | ||
| content = "---\n" | ||
| content += "title: Metrics Reference (v2)\n" | ||
| content += "navtitle: Metrics Reference\n" | ||
| content += "hasparent: true\n" | ||
| content += "---\n\n" | ||
| content += ( | ||
| "This page is intended to provide a reference of all metrics exposed by Jaeger v2. Once " | ||
| "populated, it is used to track **backwards compatibility across Jaeger v2 releases** — " | ||
| "i.e. ensuring metric names and labels do not change unexpectedly between versions.\n\n" | ||
| ) | ||
| content += ( | ||
| "> **Note:** The full metrics table is generated as part of the Jaeger release process and\n" | ||
| "> is not committed verbatim to this repository. Run `make fetch-metrics` after a release\n" | ||
| "> to populate this page with up-to-date data.\n\n" | ||
| ) | ||
|
|
||
| missing_files = False | ||
|
|
||
| for item in TARGET_FILES: | ||
| logger.info(f"Fetching {item['filename']}...") | ||
| raw_md = fetch_markdown(item["filename"]) | ||
| if raw_md is not None: | ||
| v2_table = extract_v2_metrics_table(raw_md) | ||
| content += f"## {item['title']} Metrics\n\n" | ||
| content += v2_table.strip() + "\n\n" | ||
| else: | ||
| logger.warning(f"Skipping {item['filename']} due to fetch failure.") | ||
| missing_files = True | ||
|
hharshhsaini marked this conversation as resolved.
|
||
|
|
||
| return content, missing_files | ||
|
|
||
|
|
||
| def save_metrics_reference(content): | ||
| # Resolve output path relative to the repository root (parent of the scripts/ dir) | ||
| # so the script works correctly regardless of the current working directory. | ||
| repo_root = Path(__file__).resolve().parent.parent | ||
| target_path = repo_root / "content/docs/v2/_dev/operations/metrics-reference.md" | ||
| os.makedirs(target_path.parent, exist_ok=True) | ||
| with open(target_path, "w", encoding="utf-8") as f: | ||
| f.write(content) | ||
|
hharshhsaini marked this conversation as resolved.
|
||
| logger.info(f"Successfully saved metrics reference to {target_path}") | ||
|
|
||
|
|
||
| def main(): | ||
| try: | ||
| content, missing_files = generate_metrics_reference() | ||
| save_metrics_reference(content) | ||
|
|
||
| if missing_files: | ||
| logger.error("Failed to fetch one or more metrics files. The generated page may be incomplete.") | ||
| sys.exit(1) | ||
|
|
||
| except Exception as e: | ||
| logger.error(f"An error occurred: {e}") | ||
| sys.exit(1) | ||
|
|
||
|
hharshhsaini marked this conversation as resolved.
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
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.