@@ -254,3 +254,61 @@ def test_workflow_endpoint() -> str:
254254 assert spans [0 ].context is not None
255255 assert logs [0 ].log_record .span_id == spans [0 ].context .span_id
256256 assert logs [0 ].log_record .trace_id == spans [0 ].context .trace_id
257+
258+
259+ def test_disable_otlp_no_spans (config : DBOSConfig ) -> None :
260+ DBOS .destroy (destroy_registry = True )
261+ config ["otlp_attributes" ] = {"foo" : "bar" }
262+ config ["disable_otlp" ] = True
263+ DBOS (config = config )
264+ DBOS .launch ()
265+
266+ @DBOS .workflow ()
267+ def test_workflow () -> None :
268+ test_step ()
269+ DBOS .logger .info ("This is a test_workflow" )
270+
271+ @DBOS .step ()
272+ def test_step () -> None :
273+ DBOS .logger .info ("This is a test_step" )
274+ return
275+
276+ exporter = InMemorySpanExporter ()
277+ span_processor = SimpleSpanProcessor (exporter )
278+ provider = tracesdk .TracerProvider ()
279+ provider .add_span_processor (span_processor )
280+ dbos_tracer .set_provider (provider )
281+
282+ # Set up in-memory log exporter
283+ log_exporter = InMemoryLogExporter () # type: ignore
284+ log_processor = BatchLogRecordProcessor (log_exporter )
285+ log_provider = LoggerProvider ()
286+ log_provider .add_log_record_processor (log_processor )
287+ set_logger_provider (log_provider )
288+ dbos_logger .addHandler (LoggingHandler (logger_provider = log_provider ))
289+
290+ test_workflow ()
291+
292+ log_processor .force_flush (timeout_millis = 5000 )
293+ logs = log_exporter .get_finished_logs ()
294+ assert len (logs ) == 2
295+ for log in logs :
296+ assert log .log_record .attributes is not None
297+ assert (
298+ log .log_record .attributes ["applicationVersion" ] == GlobalParams .app_version
299+ )
300+ assert log .log_record .attributes ["executorID" ] == GlobalParams .executor_id
301+ assert log .log_record .attributes ["foo" ] == "bar"
302+ # We disable OTLP, so no span_id or trace_id should be present
303+ assert log .log_record .span_id is not None and log .log_record .span_id == 0
304+ assert log .log_record .trace_id is not None and log .log_record .trace_id == 0
305+ assert (
306+ log .log_record .body == "This is a test_step"
307+ or log .log_record .body == "This is a test_workflow"
308+ )
309+ assert log .log_record .attributes .get ("traceId" ) is None
310+
311+ spans = exporter .get_finished_spans ()
312+
313+ # No spans should be created since OTLP is disabled
314+ assert len (spans ) == 0
0 commit comments