Skip to content
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

CSM O11y: Enable Python #91

Merged
merged 4 commits into from
Jun 6, 2024
Merged
Changes from all 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
28 changes: 26 additions & 2 deletions tests/gamma/csm_observability_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import dataclasses
import logging
import time
from typing import Callable, Iterable, TextIO
from typing import Any, Callable, Iterable, TextIO
import unittest.mock

from absl import flags
Expand Down Expand Up @@ -176,7 +176,7 @@ class CsmObservabilityTest(xds_gamma_testcase.GammaXdsKubernetesTestCase):
def is_supported(config: skips.TestConfig) -> bool:
if config.client_lang == _Lang.CPP:
return config.version_gte("v1.62.x")
elif config.client_lang in _Lang.GO | _Lang.JAVA:
elif config.client_lang in _Lang.GO | _Lang.JAVA | _Lang.PYTHON:
return config.version_gte("v1.65.x")
return False

Expand Down Expand Up @@ -302,6 +302,9 @@ def test_csm_observability(self):
"otel_scope_version": ANY,
"pod": test_client.hostname,
}
self.filter_label_matcher_based_on_lang(
self.lang_spec.client_lang, expected_metric_labels
)
for metric in HISTOGRAM_CLIENT_METRICS:
actual_metric_labels = all_results[metric].metric_labels
self.assertDictEqual(
Expand All @@ -327,6 +330,9 @@ def test_csm_observability(self):
"otel_scope_version": ANY,
"pod": test_server.hostname,
}
self.filter_label_matcher_based_on_lang(
self.lang_spec.server_lang, expected_metric_labels
)
for metric in HISTOGRAM_SERVER_METRICS:
actual_metric_labels = all_results[metric].metric_labels
self.assertDictEqual(
Expand All @@ -343,6 +349,9 @@ def test_csm_observability(self):
"otel_scope_version": ANY,
"pod": test_client.hostname,
}
self.filter_label_matcher_based_on_lang(
self.lang_spec.client_lang, expected_metric_labels
)
for metric in COUNTER_CLIENT_METRICS:
actual_metric_labels = all_results[metric].metric_labels
self.assertDictEqual(
Expand All @@ -358,6 +367,9 @@ def test_csm_observability(self):
"otel_scope_version": ANY,
"pod": test_server.hostname,
}
self.filter_label_matcher_based_on_lang(
self.lang_spec.server_lang, expected_metric_labels
)
for metric in COUNTER_SERVER_METRICS:
actual_metric_labels = all_results[metric].metric_labels
self.assertDictEqual(
Expand Down Expand Up @@ -459,6 +471,18 @@ def build_counter_query(cls, metric_type: str, namespace: str) -> str:
f'resource.labels.namespace = "{namespace}"'
)

@classmethod
def filter_label_matcher_based_on_lang(
cls, language: _Lang, label_matcher: dict[str, Any]
) -> None:
"""
Filter label_matcher based on language.
"""
if language == _Lang.PYTHON:
# TODO(xuanwn): Remove this once https://github.com/open-telemetry/opentelemetry-python/issues/3072 is fixed.
label_matcher.pop("otel_scope_version", None)
label_matcher.pop("otel_scope_name", None)

def query_metrics(
self,
metric_names: Iterable[str],
Expand Down
Loading