1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15+ import pytest
1516from newrelic .core .application import Application
1617from newrelic .core .config import global_settings
1718from newrelic .network .exceptions import ForceAgentDisconnect
1819
19- from testing_support .fixtures import (override_generic_settings ,
20- failing_endpoint )
20+ from testing_support .fixtures import (
21+ override_generic_settings ,
22+ validate_internal_metrics ,
23+ failing_endpoint
24+ )
25+
2126
2227
2328SETTINGS = global_settings ()
@@ -34,3 +39,38 @@ def test_http_gone_stops_connect():
3439 # The agent must not reattempt a connection after a ForceAgentDisconnect.
3540 # If it does, we'll end up with a session here.
3641 assert not app ._active_session
42+
43+
44+ _logging_settings_matrix = [
45+ (True , True ),
46+ (True , False ),
47+ (False , True ),
48+ (False , False ),
49+ ]
50+
51+
52+ @override_generic_settings (SETTINGS , {
53+ 'developer_mode' : True ,
54+ })
55+ @pytest .mark .parametrize ("feature_setting,subfeature_setting" , _logging_settings_matrix )
56+ def test_logging_connect_supportability_metrics (feature_setting , subfeature_setting ):
57+ metric_value = "enabled" if feature_setting and subfeature_setting else "disabled"
58+
59+ @override_generic_settings (SETTINGS , {
60+ "application_logging.enabled" : feature_setting ,
61+ "application_logging.forwarding.enabled" : subfeature_setting ,
62+ "application_logging.metrics.enabled" : subfeature_setting ,
63+ "application_logging.local_decorating.enabled" : subfeature_setting ,
64+ })
65+ @validate_internal_metrics ([
66+ ("Supportability/Logging/Forwarding/Python/%s" % metric_value , 1 ),
67+ ("Supportability/Logging/LocalDecorating/Python/%s" % metric_value , 1 ),
68+ ("Supportability/Logging/Metrics/Python/%s" % metric_value , 1 ),
69+ ])
70+ def test ():
71+ app = Application ('Python Agent Test (agent_unittests-connect)' )
72+ app .connect_to_data_collector (None )
73+
74+ assert app ._active_session
75+
76+ test ()
0 commit comments