-
Notifications
You must be signed in to change notification settings - Fork 155
Trying to use same span through inject/extract across scripts to update additional details using jaeger-client #144
Comments
I'm not sure I follow, what is the problem you are trying to solve? From my understanding, you have one script that creates a root and child span and it finishes them. Then you are sending context via inject to a second script which extracts the 2 spans. I don't follow the next steps. |
In the first script In the second script, Both the span use same span-id/context Here i expect collector/GUI will list only two spans (root and child ), Child span contain all the tags and logs updated by both the script. But result is opentracing-tutorial/python /usr/bin/python master_app.py [dhineshm@devws274 solution]$ PYTHONPATH=/repo/dhineshm/python-libraries/env/lib/python2.7/site-packages/:/repo/dhineshm/sample_programs/opentracing-tutorial/python /usr/bin/python receiver.py |
Understood. At the moment, if you emit the same traceid-spanid span, they aren't combined into one span. This ticket might be of interest to you: jaegertracing/jaeger#729. |
Hi @black-adder , I see lot of commentary on the upserting span entries it in ES storage in jaegertracing/jaeger#729 , is this features already released ? thanks |
Having two separate scripts...
First one to create span before execute/process something and
Second one to update some more details on the same span at end
In first script, Created root span and child span. Update some portion details in child span and injected
root and child spans were flushed with currently updated details in my execution
I have tried zipkin, as well as OPEN_TEXT format to inject and extract the same to use and treat single span.
import opentracing
from lib.tracing import init_tracer
from opentracing_instrumentation.request_context import get_current_span, span_in_context
from opentracing.ext import tags
from opentracing.propagation import Format
import json
import time
from datetime import datetime
global tracer
def get_current_time():
get_current_time = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
return get_current_time;
def create_root_span(process_name):
global tracer
tracer = init_tracer(process_name)
tracer.one_span_per_rpc = 1
tracer.one_span_per_rpc = 1
span_name = process_name
with tracer.start_span(span_name) as root_span:
with span_in_context(root_span):
root_span.set_tag('start_time', get_current_time() );
root_span.set_tag('test', 'data' );
time.sleep(2)
root_span.set_tag('span', span_name)
root_span.info('Root span created...');
with tracer.start_span( 'rpc_span', child_of=root_span.context) as child_span:
with span_in_context(child_span):
child_span.set_tag('span', span_name)
child_span.set_tag('start-time', get_current_time());
time.sleep(2)
child_span.set_tag(tags.SPAN_KIND, tags.SPAN_KIND_RPC_CLIENT)
text_carrier = {}
tracer.inject(child_span.context, 'zipkin-span-format', text_carrier)
update_header_as_json( text_carrier );
#child_span.finish()
def update_header_as_json( text_carrier ):
filename='./rpc_tracing.txt'
with open(filename, 'w') as f:
json.dump(text_carrier, f)
f.close();
process_name = 'master-app'
create_root_span(process_name)
yield to IOLoop to flush the spans
time.sleep(5)
#tracer.close()
In second independent script, extracted the span, trying to update some portion in the span.
When it flush, it has created as child for same span-id and has details updated only in the script
from lib.tracing import init_tracer
from opentracing.ext import tags
from opentracing_instrumentation.request_context import get_current_span, span_in_context
from opentracing.propagation import Format
import time
from datetime import datetime
import json
import collections
def get_current_time():
get_current_time = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
return get_current_time;
filename='./rpc_tracing.txt'
with open(filename, 'r') as f:
text_carrier = json.load(f)
f.close()
def get_reference_object(referenced_context):
Reference(ctx=spanCtxForSpanA, refType="decorates")
tracer = init_tracer('master-app')
tracer.one_span_per_rpc = 1
extracted_context = tracer.extract(
#Format.TEXT_MAP,
'zipkin-span-format',
text_carrier
)
span_tags = {tags.SPAN_KIND: tags.SPAN_KIND_RPC_SERVER}
span_name = 'rpc-span'
with tracer.start_span(span_name,tags=span_tags, references=get_reference_object(extracted_context)) as span:
with span_in_context(span):
span.set_tag('span', span_name)
time.sleep(5)
span.set_tag('end-time', get_current_time());
time.sleep(2)
tracer.close()
The text was updated successfully, but these errors were encountered: