@@ -119,3 +119,44 @@ async def async_pipeline():
119
119
assert ai_pipeline_span ["tags" ]["user" ] == "czyber"
120
120
assert ai_pipeline_span ["data" ]["some_data" ] == "value"
121
121
assert ai_run_span ["description" ] == "my async tool"
122
+
123
+
124
+ def test_ai_track_with_explicit_op (sentry_init , capture_events ):
125
+ sentry_init (traces_sample_rate = 1.0 )
126
+ events = capture_events ()
127
+
128
+ @ai_track ("my tool" , op = "custom.operation" )
129
+ def tool (** kwargs ):
130
+ pass
131
+
132
+ with sentry_sdk .start_transaction ():
133
+ tool ()
134
+
135
+ transaction = events [0 ]
136
+ assert transaction ["type" ] == "transaction"
137
+ assert len (transaction ["spans" ]) == 1
138
+ span = transaction ["spans" ][0 ]
139
+
140
+ assert span ["description" ] == "my tool"
141
+ assert span ["op" ] == "custom.operation"
142
+
143
+
144
+ @pytest .mark .asyncio
145
+ async def test_ai_track_async_with_explicit_op (sentry_init , capture_events ):
146
+ sentry_init (traces_sample_rate = 1.0 )
147
+ events = capture_events ()
148
+
149
+ @ai_track ("my async tool" , op = "custom.async.operation" )
150
+ async def async_tool (** kwargs ):
151
+ pass
152
+
153
+ with sentry_sdk .start_transaction ():
154
+ await async_tool ()
155
+
156
+ transaction = events [0 ]
157
+ assert transaction ["type" ] == "transaction"
158
+ assert len (transaction ["spans" ]) == 1
159
+ span = transaction ["spans" ][0 ]
160
+
161
+ assert span ["description" ] == "my async tool"
162
+ assert span ["op" ] == "custom.async.operation"
0 commit comments