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
Setup: A flask app with both wsgi and flask instrumentations enabled. Flask app used (wsgi instrumentor called first)
# flask_example.py
import flask
import requests
from opentelemetry import trace
from opentelemetry.instrumentation.flask import FlaskInstrumentor
from opentelemetry.instrumentation.requests import RequestsInstrumentor
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
BatchSpanProcessor,
ConsoleSpanExporter,
)
from opentelemetry.instrumentation.wsgi import OpenTelemetryMiddleware
app = flask.Flask(__name__)
app.wsgi_app = OpenTelemetryMiddleware(app.wsgi_app)
FlaskInstrumentor().instrument_app(app)
RequestsInstrumentor().instrument()
trace.set_tracer_provider(TracerProvider())
trace.get_tracer_provider().add_span_processor(
BatchSpanProcessor(ConsoleSpanExporter())
)
tracer = trace.get_tracer(__name__)
@app.route("/")
def hello():
import time
time.sleep(0.5)
requests.get("http://www.example.com")
return "hello"
app.run(port=5000)
In the app above two traces are sent one for wsgi and other for flask. Start timestamp of spans of wsgi is later than that of flask spans. If the order of instrumentors called is reversed then the timestamps of the wsgi span comes becomes earlier than flask span.
Output of console span exporter for above app (wsgi instrumentor called first):
What is the expected behavior?
Order of instrumentors called should not affect span start timestamps. What is the actual behavior?
Order of instrumentors called is affecting span start timestamps.
Additional context
Found this issue while working on [#446]. Upon marking the flask spans as internal in presence of a server span by wsgi, the start timestamp of flask span(child) comes before wsgi span(parent).
Slack conversation for more details: https://cloud-native.slack.com/archives/C01PD4HUVBL/p1637134298083200
The text was updated successfully, but these errors were encountered:
Environment
opentelemetry-api/sdk: 1.7.1
opentelemetry-instrumentation-flask/wsgi/requests: 0.26b1
Steps to reproduce
Setup: A flask app with both wsgi and flask instrumentations enabled.
Flask app used (wsgi instrumentor called first)
In the app above two traces are sent one for wsgi and other for flask. Start timestamp of spans of wsgi is later than that of flask spans. If the order of instrumentors called is reversed then the timestamps of the wsgi span comes becomes earlier than flask span.
Output of console span exporter for above app (wsgi instrumentor called first):
What is the expected behavior?
Order of instrumentors called should not affect span start timestamps.
What is the actual behavior?
Order of instrumentors called is affecting span start timestamps.
Additional context
Found this issue while working on [#446]. Upon marking the flask spans as internal in presence of a server span by wsgi, the start timestamp of flask span(child) comes before wsgi span(parent).
Slack conversation for more details: https://cloud-native.slack.com/archives/C01PD4HUVBL/p1637134298083200
The text was updated successfully, but these errors were encountered: