You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe your environment.
python 3.9.5
Ubuntu 20.04 via WSL
PyCharm 2021.3.3 (Professional Edition)
opencensus==0.8.0
Steps to reproduce.
from opencensus.trace.tracer import Tracer
from opencensus.trace.propagation.text_format import TextFormatPropagator
tracer = Tracer()
propagator = TextFormatPropagator()
# Serialize the SpanContext to send somewhere else
carrier = propagator.to_carrier(tracer.span_context, {})
# Deserialize the SpanContext, this changes the trace_options.trace_options_byte from "1" (string) to True (bool)
span_2 = propagator.from_carrier(carrier)
# Next line raises ValueError: invalid literal for int() with base10: 'Tru1'
tracer_2 = Tracer(span_context=span_2)
What is the expected behavior?
from_carrier() should set trace_options_byte to "1" not True, allowing tracer_2 to be instantiated
What is the actual behavior?
ValueError - from opencensus/trace/trace_options.py line 65 in get_enabled: enabled = bool(int(self.trace_options_byte) & _ENABLED_BITMASK)
Additional context.
The example above is minimal, the real implementation creates a Tracer with an Exporter to Azure. The serialization is done in one service, and we'd like to propagate the span context to other downstream services. That's where the deserialization and creation of a second tracer from that SpanContext would happen.
Some of our services are separated via Azure EventGrid, so it's preferable to pass the serialized SpanContext as part of our payload rather than as part of the headers as it's more difficult for us to make changes to EventGrid headers than to just modify an existing payload. If there's an alternative recommended way to use opencensus for this we're not wedded to using TextFormatPropagator (especially if this behaviour is expected and we're just using it incorrectly).
Here's the Traceback for the ValueError:
Traceback (most recent call last):
File "/mnt/c/Program Files/JetBrains/PyCharm 2020.2.3/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_exec2.py", line 3, in Exec
exec(exp, global_vars, local_vars)
File "<input>", line 1, in <module>
File "/home/ben/dev/<my-project>/venv/lib/python3.9/site-packages/opencensus/trace/tracer.py", line 63, in __init__
self.tracer = self.get_tracer()
File "/home/ben/dev/<my-project>/venv/lib/python3.9/site-packages/opencensus/trace/tracer.py", line 81, in get_tracer
self.span_context.trace_options.set_enabled(True)
File "/home/ben/dev/<my-project>/venv/lib/python3.9/site-packages/opencensus/trace/trace_options.py", line 78, in set_enabled
self.enabled = self.get_enabled()
File "/home/ben/dev/<my-project>/venv/lib/python3.9/site-packages/opencensus/trace/trace_options.py", line 65, in get_enabled
enabled = bool(int(self.trace_options_byte) & _ENABLED_BITMASK)
ValueError: invalid literal for int() with base 10: 'Tru1'
The text was updated successfully, but these errors were encountered:
Describe your environment.
python 3.9.5
Ubuntu 20.04 via WSL
PyCharm 2021.3.3 (Professional Edition)
opencensus==0.8.0
Steps to reproduce.
What is the expected behavior?
from_carrier() should set
trace_options_byte
to "1" not True, allowingtracer_2
to be instantiatedWhat is the actual behavior?
ValueError - from opencensus/trace/trace_options.py line 65 in get_enabled:
enabled = bool(int(self.trace_options_byte) & _ENABLED_BITMASK)
Additional context.
The example above is minimal, the real implementation creates a Tracer with an Exporter to Azure. The serialization is done in one service, and we'd like to propagate the span context to other downstream services. That's where the deserialization and creation of a second tracer from that SpanContext would happen.
Some of our services are separated via Azure EventGrid, so it's preferable to pass the serialized SpanContext as part of our payload rather than as part of the headers as it's more difficult for us to make changes to EventGrid headers than to just modify an existing payload. If there's an alternative recommended way to use opencensus for this we're not wedded to using TextFormatPropagator (especially if this behaviour is expected and we're just using it incorrectly).
Here's the Traceback for the ValueError:
The text was updated successfully, but these errors were encountered: