diff --git a/sentry_sdk/client.py b/sentry_sdk/client.py index 0f2ddfb640..07ac164e80 100644 --- a/sentry_sdk/client.py +++ b/sentry_sdk/client.py @@ -507,6 +507,14 @@ def _setup_instrumentation( for function in functions_to_trace: class_name = None function_qualname = function["qualified_name"] + + if "." not in function_qualname: + logger.warning( + "Can not enable tracing for '%s'. Please provide the fully qualified name including the module (e.g. 'mymodule.my_function').", + function_qualname, + ) + continue + module_name, function_name = function_qualname.rsplit(".", 1) try: diff --git a/tests/test_basics.py b/tests/test_basics.py index f628d139d1..01d518eee6 100644 --- a/tests/test_basics.py +++ b/tests/test_basics.py @@ -1090,6 +1090,14 @@ def test_classmethod_instance_tracing(sentry_init, capture_events): assert span["description"] == "tests.test_basics.TracingTestClass.class_" +def test_functions_to_trace_no_dot_does_not_crash(sentry_init): + # A qualified_name with no dot should not raise ValueError during sentry_sdk.init() + sentry_init( + traces_sample_rate=1.0, + functions_to_trace=[{"qualified_name": "my_function"}], + ) + + def test_last_event_id(sentry_init): sentry_init(traces_sample_rate=1.0)