Skip to content

Commit

Permalink
CSM O11y: Enable Python (#91)
Browse files Browse the repository at this point in the history
Ad-hoc run:
- [x]
[grpc/core/master/linux/psm-csm-python](https://source.cloud.google.com/results/invocations/ba5c2183-34e0-4442-89e9-afd65eff94b1)

### Note
* Removed `otel_scope_name` and `otel_scope_version` tag for Python
because python Prometheus exporter doesn't have them yet:
open-telemetry/opentelemetry-python#3072
  • Loading branch information
XuanWang-Amos authored Jun 6, 2024
1 parent 624948a commit 1e441a2
Showing 1 changed file with 26 additions and 2 deletions.
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

0 comments on commit 1e441a2

Please sign in to comment.