howardyoo commented on code in PR #37948: URL: https://github.com/apache/airflow/pull/37948#discussion_r1518480222
########## tests/core/test_otel_tracer.py: ########## @@ -0,0 +1,155 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +from __future__ import annotations + +import json +import logging +from datetime import datetime +from unittest.mock import MagicMock, patch + +import pytest +from opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter + +from airflow.traces import TRACEPARENT, TRACESTATE, otel_tracer, utils +from airflow.traces.tracer import Trace +from tests.test_utils.config import env_vars + + [email protected] +def name(): + return "test_traces_run" + + +class TestOtelTrace: + @patch("opentelemetry.sdk.trace.export.ConsoleSpanExporter") + @patch("airflow.traces.otel_tracer.conf") + def test_tracer(self, conf_a, exporter): + # necessary to speed up the span to be emitted + with env_vars({"OTEL_BSP_SCHEDULE_DELAY": "1"}): + log = logging.getLogger("TestOtelTrace.test_tracer") + log.setLevel(logging.DEBUG) + # hijacking airflow conf with pre-defined + # values + conf_a.get.return_value = "abc" + conf_a.getint.return_value = 123 + """this will enable debug to set - which outputs the result Review Comment: Nothing particular, didn't know what the usual convention was. """ comment seemed better than # comment in many cases, as it was more outstanding and easy to detect. -- 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]
