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
Ideally all trace spans in a request response cycle should be contained in one span. However because the tornado instrumentation library closes the span before calling the on_finish method. Orphaned spans from any instrumented code in on_finish method are created. Looking at the code a reordering would fix this situation.
import tornado.ioloop
import tornado.web
from opentelemetry import trace
from opentelemetry.trace import SpanKind
from opentelemetry import trace
from opentelemetry.exporter.cloud_trace import CloudTraceSpanExporter
from opentelemetry.exporter.zipkin.json import ZipkinExporter
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
ConsoleSpanExporter,
BatchSpanProcessor
)
from opentelemetry.instrumentation.tornado import TornadoInstrumentor
class MainHandler(tornado.web.RequestHandler):
def on_finish(self) -> None:
with trace.get_tracer(__name__).start_as_current_span("On finish test", kind=SpanKind.CLIENT) as span:
print("Testing on finish span")
super(MainHandler, self).on_finish()
def get(self):
self.write("Hello, world")
What is the expected behavior?
All traces in a request cycle should be contained in one span. However because the tornado instrumentation library closes the span before calling the on_finish method. This causes an orphaned span to be created.
What is the actual behavior?
Tornado instrumentation library should possibly run on_finish method before closing the main trace span
Additional context
I looked at the code and saw the affected part is here . Is there any reason to close the span before the parent on_finish method can be run?
The text was updated successfully, but these errors were encountered:
Ideally all trace spans in a request response cycle should be contained in one span. However because the tornado instrumentation library closes the span before calling the on_finish method. Orphaned spans from any instrumented code in on_finish method are created. Looking at the code a reordering would fix this situation.
Describe your environment
Python 3.8.5
requirements.txt
tornado==6.0.3
#tracing
opentelemetry-api==1.1.0
opentelemetry-sdk==1.1.0
opentelemetry-exporter-zipkin-json
opentelemetry-instrumentation
opentelemetry-instrumentation-dbapi
opentelemetry-instrumentation-tornado
opentelemetry-exporter-gcp-trace==1.0.0rc0
Steps to reproduce
Run the attached app below:
`
import tornado.ioloop
import tornado.web
from opentelemetry import trace
from opentelemetry.trace import SpanKind
from opentelemetry import trace
from opentelemetry.exporter.cloud_trace import CloudTraceSpanExporter
from opentelemetry.exporter.zipkin.json import ZipkinExporter
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
ConsoleSpanExporter,
BatchSpanProcessor
)
from opentelemetry.instrumentation.tornado import TornadoInstrumentor
class MainHandler(tornado.web.RequestHandler):
def init_tracing(is_deployment):
resource = Resource.create(attributes={SERVICE_NAME: "Profile Service"})
tracer_provider = TracerProvider(resource=resource)
trace.set_tracer_provider(tracer_provider)
def make_app():
return tornado.web.Application([
(r"/", MainHandler),
])
if name == "main":
`
What is the expected behavior?
All traces in a request cycle should be contained in one span. However because the tornado instrumentation library closes the span before calling the on_finish method. This causes an orphaned span to be created.
What is the actual behavior?
Tornado instrumentation library should possibly run on_finish method before closing the main trace span
Additional context
I looked at the code and saw the affected part is here . Is there any reason to close the span before the parent on_finish method can be run?
The text was updated successfully, but these errors were encountered: