-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Description
Core or SDK?
Platform/SDK
Which part? Which one?
Python SDK 1.24.0
Description
I was trying to set up custom function profiling as described in profiling documentation
import sentry_sdk
functions_to_trace = [
"myrootmodule.eat_slice",
"myrootmodule.swallow",
"myrootmodule.chew",
"myrootmodule.someothermodule.another.some_function",
"myrootmodule.SomePizzaClass.some_method",
]
sentry_sdk.init(
dsn="https://749c186644be4fd98ba877b781c0427a@o259170.ingest.sentry.io/1454307",
functions_to_trace=functions_to_trace,
)
I got error
File "/usr/local/lib/python3.11/site-packages/sentry_sdk/client.py", line 161, in _setup_instrumentation
function_qualname = function["qualified_name"]
~~~~~~~~^^^^^^^^^^^^^^^^^^
TypeError: string indices must be integers, not 'str'
Turned out that actually a dict is expected as documented in 1.18.0 Changelog
functions_to_trace = [
{"qualified_name": "tests.test_basics._hello_world_counter"},
{"qualified_name": "time.sleep"},
{"qualified_name": "collections.Counter.most_common"},
]
sentry_sdk.init(
# ...
traces_sample_rate=1.0,
functions_to_trace=functions_to_trace,
)
Suggested Solution
Update documentation code sample from
import sentry_sdk
functions_to_trace = [
"myrootmodule.eat_slice",
"myrootmodule.swallow",
"myrootmodule.chew",
"myrootmodule.someothermodule.another.some_function",
"myrootmodule.SomePizzaClass.some_method",
]
sentry_sdk.init(
dsn="https://749c186644be4fd98ba877b781c0427a@o259170.ingest.sentry.io/1454307",
functions_to_trace=functions_to_trace,
)
to
import sentry_sdk
functions_to_trace = [
{"qualified_name": "myrootmodule.eat_slice"},
{"qualified_name": "myrootmodule.swallow"},
{"qualified_name": "myrootmodule.chew"},
{"qualified_name": "myrootmodule.someothermodule.another.some_function"},
{"qualified_name": "myrootmodule.SomePizzaClass.some_method"},
]
sentry_sdk.init(
dsn="https://749c186644be4fd98ba877b781c0427a@o259170.ingest.sentry.io/1454307",
functions_to_trace=functions_to_trace,
)
or update SDK to use list[str]. Looks like no keys other than "qualified_name" are used in SDK yet.
Metadata
Metadata
Assignees
Projects
Status
No status