@@ -116,12 +116,10 @@ def process_job(self, job: Job) -> None:
116116 f"Job { job .id } failed: { e } " ,
117117 {"job_type" : job .type , "duration_s" : duration },
118118 )
119- self .client .add_span_event (
120- span_id , "job_failed" , {"error" : str (e )}
121- )
119+ self .client .add_span_event (span_id , "job_failed" , {"error" : str (e )})
122120 raise
123121
124- def _process_email_job (self , job : Job , parent_span_id : str ) -> None :
122+ def _process_email_job (self , job : Job , _parent_span_id : str ) -> None :
125123 """Process an email job."""
126124 with self .client .span ("email.send" , SpanKind .CLIENT ) as span_id :
127125 # Simulate email sending
@@ -135,7 +133,7 @@ def _process_email_job(self, job: Job, parent_span_id: str) -> None:
135133 },
136134 )
137135
138- def _process_notification_job (self , job : Job , parent_span_id : str ) -> None :
136+ def _process_notification_job (self , job : Job , _parent_span_id : str ) -> None :
139137 """Process a notification job."""
140138 with self .client .span ("notification.push" , SpanKind .CLIENT ) as span_id :
141139 # Simulate push notification
@@ -149,7 +147,7 @@ def _process_notification_job(self, job: Job, parent_span_id: str) -> None:
149147 },
150148 )
151149
152- def _process_report_job (self , job : Job , parent_span_id : str ) -> None :
150+ def _process_report_job (self , job : Job , _parent_span_id : str ) -> None :
153151 """Process a report generation job."""
154152 # Database query
155153 with self .client .span ("database.query" , SpanKind .CLIENT ) as span_id :
@@ -174,7 +172,9 @@ def _process_generic_job(self, job: Job, parent_span_id: str) -> None:
174172 """Process a generic job."""
175173 time .sleep (random .uniform (0.1 , 0.3 ))
176174 self .client .add_span_event (
177- parent_span_id , "generic_processing_complete" , {"payload_keys" : list (job .payload .keys ())}
175+ parent_span_id ,
176+ "generic_processing_complete" ,
177+ {"payload_keys" : list (job .payload .keys ())},
178178 )
179179
180180 def run (self ) -> None :
@@ -243,13 +243,38 @@ def main() -> None:
243243
244244 # Submit sample jobs
245245 sample_jobs = [
246- Job ("job-001" , "email" , {"to" : "user@example.com" , "subject" : "Welcome!" }, datetime .now ()),
247- Job ("job-002" , "notification" , {"channel" : "mobile" , "user_id" : "user-123" }, datetime .now ()),
248- Job ("job-003" , "report" , {"format" : "pdf" , "report_type" : "sales" }, datetime .now ()),
249- Job ("job-004" , "email" , {"to" : "admin@example.com" , "subject" : "Alert" }, datetime .now ()),
246+ Job (
247+ "job-001" ,
248+ "email" ,
249+ {"to" : "user@example.com" , "subject" : "Welcome!" },
250+ datetime .now (),
251+ ),
252+ Job (
253+ "job-002" ,
254+ "notification" ,
255+ {"channel" : "mobile" , "user_id" : "user-123" },
256+ datetime .now (),
257+ ),
258+ Job (
259+ "job-003" ,
260+ "report" ,
261+ {"format" : "pdf" , "report_type" : "sales" },
262+ datetime .now (),
263+ ),
264+ Job (
265+ "job-004" ,
266+ "email" ,
267+ {"to" : "admin@example.com" , "subject" : "Alert" },
268+ datetime .now (),
269+ ),
250270 Job ("job-005" , "generic" , {"data" : "test" }, datetime .now ()),
251271 Job ("job-006" , "error" , {}, datetime .now ()), # This will fail
252- Job ("job-007" , "notification" , {"channel" : "email" , "user_id" : "user-456" }, datetime .now ()),
272+ Job (
273+ "job-007" ,
274+ "notification" ,
275+ {"channel" : "email" , "user_id" : "user-456" },
276+ datetime .now (),
277+ ),
253278 ]
254279
255280 for job in sample_jobs :
0 commit comments