xBis7 commented on code in PR #56150:
URL: https://github.com/apache/airflow/pull/56150#discussion_r2795432259
##########
shared/observability/tests/observability/metrics/test_otel_logger.py:
##########
@@ -307,3 +311,95 @@ def test_timer_start_and_stop_manually_send_true(self,
mock_time, name):
assert timer.duration == expected_value
assert mock_time.call_count == 2
self.meter.get_meter().create_gauge.assert_called_once_with(name=full_name(name))
+
+ @pytest.mark.parametrize(
+ ("provided_env_vars", "expected_endpoint", "expected_exporter_module"),
+ [
+ pytest.param(
+ {
+ "OTEL_EXPORTER_OTLP_ENDPOINT": "http://localhost:1234",
+ "OTEL_EXPORTER_OTLP_PROTOCOL": "grpc",
+ "AIRFLOW__METRICS__OTEL_HOST": "breeze-otel-collector",
+ "AIRFLOW__METRICS__OTEL_PORT": "4318",
+ },
+ "localhost:1234",
+ "grpc",
+ id="env_vars_with_grpc",
+ ),
+ pytest.param(
+ {
+ "OTEL_EXPORTER_OTLP_PROTOCOL": "grpc",
+ "AIRFLOW__METRICS__OTEL_HOST": "breeze-otel-collector",
+ "AIRFLOW__METRICS__OTEL_PORT": "4318",
+ },
+ "http://breeze-otel-collector:4318/v1/metrics",
+ "http",
+ id="protocol_is_ignored_if_no_env_endpoint",
+ ),
+ pytest.param(
+ {
+ "OTEL_EXPORTER_OTLP_ENDPOINT": "http://localhost:1234",
+ "OTEL_EXPORTER_OTLP_PROTOCOL": "http/protobuf",
+ "AIRFLOW__METRICS__OTEL_HOST": "breeze-otel-collector",
+ "AIRFLOW__METRICS__OTEL_PORT": "4318",
+ },
+ "http://localhost:1234/v1/metrics",
+ "http",
+ id="for_http_with_env_vars_otel_builds_full_url",
+ ),
+ pytest.param(
+ {
+ "AIRFLOW__METRICS__OTEL_HOST": "breeze-otel-collector",
+ "AIRFLOW__METRICS__OTEL_PORT": "4318",
+ },
+ "http://breeze-otel-collector:4318/v1/metrics",
+ "http",
+ id="use_airflow_config",
+ ),
+ pytest.param(
+ {
+ "OTEL_EXPORTER_OTLP_ENDPOINT": "http://localhost:1234",
+ "OTEL_EXPORTER_OTLP_PROTOCOL": "http/protobuf",
+ },
+ "http://localhost:1234/v1/metrics",
+ "http",
+ id="only_env_vars",
+ ),
+ pytest.param(
+ {
+ "OTEL_EXPORTER_OTLP_ENDPOINT": "http://localhost:1234",
+ "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT":
"http://localhost:2222",
+ "OTEL_EXPORTER_OTLP_PROTOCOL": "http/protobuf",
+ "OTEL_EXPORTER_OTLP_METRICS_PROTOCOL": "grpc",
+ },
+ "localhost:2222",
+ "grpc",
+ id="type_specific_vars_take_precedence",
+ ),
+ ],
+ )
+ def test_config_priorities(self, provided_env_vars, expected_endpoint,
expected_exporter_module):
+ with env_vars(provided_env_vars):
+ otel_env_config = load_metrics_env_config()
+
+ from airflow.configuration import conf
Review Comment:
I just realized that this test lives under `shared` and it's importing here
from `airflow-core`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]