Closed kleysonr closed 4 years ago
I also see curious behaviour. I have adapted the example code to demonstrate (I am using the all-in-one binary with this):
tracer = config.initialize_tracer()
do_stuff = lambda x: int(x)
do_other_stuff = lambda x : print(x)
with tracer.start_span('TestSpan') as span:
span.log_kv({'event': 'test message', 'life': 42})
with tracer.start_span('ChildSpan', child_of=span) as child_span:
for c in 'xy2z4':
with tracer.start_span('SubSpanExampleA', child_of=child_span) as a_span:
try:
do_stuff(c)
except ValueError:
do_other_stuff(c)
for c in 'xy2z4':
try:
with tracer.start_span('SubSpanExampleB', child_of=child_span) as b_span:
do_stuff(c)
except ValueError:
do_other_stuff(c)
Notice where the span is created inside or outside of the try except block. Exceptions in python propagate and i would like to see that behaviour as an option on the created spans/tracer. I don't always want an error reported if it is handled by the code, even if the span is on the inside of a try except block; I may not always have control of the code I run inside the block but I can catch the errors. I am not sure what the correct strategy would be here or whether or not i am missing something that would answer this problem?
@kleysonr if you're catching exception you need to log it to the span yourself.
I may not always have control of the code I run inside the block but I can catch the errors
@Giohn if you don't have control over code that creates b_span, then you can't affect anything on that span either, it's invisible to your code. But the code that starts a span and raises the error also has the option of logging that error to that span.
Closing this since none of these examples require changes to the tracer. There's no magic in how exceptions are handled.
Autologing works fine using the code below and I can see also the span set as a error in the Jaeger UI
But in case I use try/except clause, like the example below, jaeger is not reporting the span as error.
How can I force the jaeger client report the span as error and get a error span with a log exception event in the Jaeger UI ?