Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 60 additions & 1 deletion utils/_context/_scenarios/otel_collector.py
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
Expand Down Expand Up @@ -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": {
Expand All @@ -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:
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}")

# Add PostgreSQL database version dynamically from container
if hasattr(self, "postgres_container") and self.postgres_container:
postgres_version = "unknown"
if hasattr(self.postgres_container, "image") and self.postgres_container.image:
# 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"

result["testedDependencies"].append({"name": "postgresql", "version": postgres_version})

def _start_interfaces_watchdog(self):
super().start_interfaces_watchdog([interfaces.otel_collector])

Expand Down
2 changes: 1 addition & 1 deletion utils/interfaces/_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ def query_ui_timeseries(
sleep_interval_s *= sleep_interval_multiplier # increase the sleep time with each retry

raise ValueError(
f"Backend UI timeseries did not provide data after {retries} retries: {data['path']}. Status is {status_code}."
f"Backend UI timeseries did not provide data after {retries} retries: {data['path']}. Status is {status_code}." # noqa: E501
)

# Queries the backend log search API and returns the log matching the given query.
Expand Down
Loading