-
Couldn't load subscription status.
- Fork 14
Add to OTel reporting for feature parity #5549
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
base: otel-pg-poc-metrics-test
Are you sure you want to change the base?
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 | ||||
|---|---|---|---|---|---|---|
| @@ -1,6 +1,9 @@ | ||||||
| import os | ||||||
| import time | ||||||
| import pytest | ||||||
| import yaml | ||||||
| from pathlib import Path | ||||||
|
|
||||||
| from utils import interfaces | ||||||
| from utils._context.component_version import ComponentVersion | ||||||
| from utils._context.containers import OpenTelemetryCollectorContainer | ||||||
|
|
@@ -38,8 +41,9 @@ def __init__(self, name: str): | |||||
| } | ||||||
| ) | ||||||
|
|
||||||
| self.collector_config_file = "./utils/build/docker/otelcol-config-with-postgres.yaml" | ||||||
| self.collector_container = OpenTelemetryCollectorContainer( | ||||||
| config_file="./utils/build/docker/otelcol-config-with-postgres.yaml", | ||||||
| config_file=self.collector_config_file, | ||||||
| environment=collector_env, | ||||||
| volumes={ | ||||||
| "./utils/build/docker/agent/ca-certificates.crt": { | ||||||
|
|
@@ -60,6 +64,61 @@ def configure(self, config: pytest.Config) -> None: | |||||
| "otel_collector", self.collector_container.image.labels["org.opencontainers.image.version"] | ||||||
| ) | ||||||
|
|
||||||
| def customize_feature_parity_dashboard(self, result: dict) -> None: | ||||||
| result["configuration"]["collector_version"] = str(self.library.version) | ||||||
|
|
||||||
| if hasattr(self.collector_container, "image") and self.collector_container.image: | ||||||
|
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. The is always an image here, no ? |
||||||
| result["configuration"]["collector_image"] = self.collector_container.image.name | ||||||
|
|
||||||
| # Extract image commit/revision if available from labels | ||||||
| if self.collector_container.image.labels: | ||||||
| image_labels = self.collector_container.image.labels | ||||||
| if "org.opencontainers.image.revision" in image_labels: | ||||||
| result["configuration"]["collector_image_commit"] = image_labels[ | ||||||
| "org.opencontainers.image.revision" | ||||||
| ] | ||||||
|
|
||||||
| # Parse OTel collector configuration file | ||||||
| config_file_path = Path(self.collector_config_file) | ||||||
| result["configuration"]["config_file"] = config_file_path.name | ||||||
|
|
||||||
| try: | ||||||
| with open(config_file_path, "r", encoding="utf-8") as f: | ||||||
| otel_config = yaml.safe_load(f) | ||||||
|
|
||||||
| if "receivers" in otel_config: | ||||||
| result["configuration"]["receivers"] = list(otel_config["receivers"].keys()) | ||||||
| if "postgresql" in otel_config["receivers"]: | ||||||
| pg_config = otel_config["receivers"]["postgresql"] | ||||||
| result["configuration"]["postgresql_receiver"] = { | ||||||
| "endpoint": pg_config.get("endpoint"), | ||||||
| "databases": pg_config.get("databases", []), | ||||||
| } | ||||||
|
|
||||||
| if "exporters" in otel_config: | ||||||
| result["configuration"]["exporters"] = list(otel_config["exporters"].keys()) | ||||||
| if "datadog" in otel_config["exporters"]: | ||||||
| dd_exporter_config = otel_config["exporters"]["datadog"] | ||||||
| result["configuration"]["datadog_exporter_config"] = { | ||||||
| "metrics": dd_exporter_config.get("metrics", {}), | ||||||
| } | ||||||
|
|
||||||
| if "service" in otel_config and "pipelines" in otel_config["service"]: | ||||||
| result["configuration"]["pipelines"] = list(otel_config["service"]["pipelines"].keys()) | ||||||
|
|
||||||
| except Exception as e: | ||||||
| logger.warning(f"Failed to parse OTel collector config: {e}") | ||||||
|
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. It should be an error :
Suggested change
|
||||||
|
|
||||||
| # Add PostgreSQL database version dynamically from container | ||||||
| if hasattr(self, "postgres_container") and self.postgres_container: | ||||||
|
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.
|
||||||
| postgres_version = "unknown" | ||||||
| if hasattr(self.postgres_container, "image") and self.postgres_container.image: | ||||||
|
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. I don't get this one, |
||||||
| # Extract version from image name | ||||||
| image_name = self.postgres_container.image.name | ||||||
| postgres_version = image_name.split(":")[-1].split("-")[0] if ":" in image_name else "alpine" | ||||||
|
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. This feels very fragile, there must be a way to get this version in a cleaner way |
||||||
|
|
||||||
| result["testedDependencies"].append({"name": "postgresql", "version": postgres_version}) | ||||||
|
|
||||||
| def _start_interfaces_watchdog(self): | ||||||
| super().start_interfaces_watchdog([interfaces.otel_collector]) | ||||||
|
|
||||||
|
|
||||||
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.
You'll dispatch this info in two places, can you rather rename
OpenTelemetryCollectorContainer._otel_config_host_pathtoOpenTelemetryCollectorContainer.config_file, and use in this classself.collector_container,config_file?