[BUG] Potential incompatible with mlflow>=2.13.1
@zhengfeiwang is already working on this.
Since Jun 13, 2024.
Assessment
This issue has not been assessed yet.
Description
Describe the bug
In mlflow>=2.13.1, mlflow supports to force reset the global tracer provider in some operations (related PR: https://github.com/mlflow/mlflow/pull/12137), this might break/disable tracing feature in prompt flow.
How To Reproduce the bug
Setup mlflow after prompt flow will result in the issue. Below snippet can demonstrate on that:
from mlflow.tracing.provider import reset_tracer_setup
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor, SpanExporter, SpanExportResult
from promptflow.tracing import trace as pf_trace
class StdoutSpanExporter(SpanExporter):
def export(self, spans):
for span in spans:
print("trace id:", span.context.trace_id)
print("span id:", span.context.span_id)
return SpanExportResult.SUCCESS
def shutdown(self):
pass
@pf_trace
def do_something():
print("Doing something")
def setup_exporter():
trace.set_tracer_provider(TracerProvider())
tracer_provider: TracerProvider = trace.get_tracer_provider()
stdout_span_exporter = StdoutSpanExporter()
tracer_provider.add_span_processor(BatchSpanProcessor(stdout_span_exporter))
def main():
setup_exporter()
reset_tracer_setup() # this line will force reset tracer provider to NoOpTracerProvider
do_something()
if __name__ == "__main__":
main()
When reset_tracer_setup is executed, all registered exporter will be reset, so there will be no stdout when traces are closed. We are not sure how/when mlflow will call this function, but seems it will break/disable tracing feature in prompt flow as it reset the exporter.
Expected behavior
Operations in mlflow shall not modify global tracer provider, and this should break Open Telemetry standard. Looks prompt flow have no action can be taken for this, and this issue might work as a FYI. for now.
Additional context
Elder versions will run into AttributeError complaining about "NoOpTracerProvider has no add_span_processor", there is a PR working on that to skip setup and log a warning: #3407
- Dominant language
- Python
- Stars
- 11.2k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/promptflow
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
microsoft/promptflow#4219 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
microsoft/promptflow#4218 ·
-
Difficulty 5/5 Over a week Newbie friendliness 28/100
microsoft/promptflow#4216 ·
-
no-recent-activity
Difficulty 3/5 1-2 days Newbie friendliness 72/100
microsoft/promptflow#4213 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
microsoft/promptflow#3931 · 38 comments ·
All issues in microsoft/promptflow
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bancolombia/sentinel#23 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100