traceloop / traceloop/openllmetry
๐ Bug Report: OpenLLMetry doesn't work with MLFlow
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.4k
- Forks
- 1.1k
- Avg merge
- 8d 14h
- Merged PRs (30d)
- 2
Description
Which component is this bug for?
Traceloop SDK
๐ Description
Right now I'm working with Traceloop integration with mlfow. I'm trying to trace mlflow runs and mlflow evaluate and send the trace to qa tempo. My intention is that I want to add an attribute to the trace which is basically run_id of mlflow, now I tried Traceloop.set_association_properties But it seems that some traces can attach properties that I set some traces not attach (all of them are llmchain.workflow from mlflow evaluation ).
๐ Reproduction steps
Just want to run following code after Traceloop.init()
with mlflow.start_run(
run_name="trace_paralell"+"_v" +run_version,
tags={
"mlflow.source.git.commit": run_version,
}
) as started_run:
Traceloop.set_association_properties({ "mlflow_run_id": started_run.info.run_id, "mlflow_exp_id": started_run.info.experiment_id})
avg_tokens = count_tokens([PROMPT])
for input_var in INPUT_VARIABLES_LIST:
avg_tokens += count_tokens(dataset[input_var])
model_info = mlflow.langchain.log_model(
lc_model=create_model(),
artifact_path="model",
signature=SIGNATURE,
)
if len(dataset.index) <= max_threads:
max_threads = 1
try:
split_dataset = numpy.array_split(dataset, max_threads)
result = []
print(f"model uri: {model_info.model_uri}")
with concurrent.futures.ThreadPoolExecutor(max_workers=max_threads) as executor:
for chunk in split_dataset:
executor.submit(
evaluate_dataset,
chunk,
model_info.model_uri,
result
)
result_dataset = pd.concat(result)
mlflow.log_metrics({"latency_p50": numpy.percentile(result_dataset.latency_ms, 50)})
mlflow.log_metrics({"latency_p90": numpy.percentile(result_dataset.latency_ms, 90)})
results = mlflow.evaluate(
data=result_dataset,
predictions=RESULT_COLUMN,
targets=GROUND_TRUTH_COLUMN,
evaluators="default",
model_type="classifier",
validation_thresholds = {
"precision_score": MetricThreshold(
threshold=PRECISION_THRESHOLD,
greater_is_better=True,
),
},
extra_metrics=[ token_count(), latency(), precision_metric]
)
mlflow.log_metrics(results.metrics)
๐ Expected behavior
I expect that every span after tracing should have mlflow_run_id and mlflow_exp_id as I set in association_properties.
๐ Actual Behavior with Screenshots
There are mlflow_run_id and mlflow_exp_id for some traces not every trace that came from this run. For example , LLMChain.workflow which come from mlflow.evaluate has no assiciation_properties.
This is how all traces look like when I run above code.
This is for POST span with path mlfowserver/api/mlfow/runs/log-inputs
You can see it has association properties
But for the open ai one there is no properties
For OPENAI
๐ค Python Version
3.11
๐ Provide any additional context for the Bug.
From discussing with Nir. It seems like mlflow_runs and mlflow_evaluate may be messing up the context
๐ Have you spent some time to check if this bug has been raised before?
- I checked and didn't find similar issue
Are you willing to submit PR?
None
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.
Research direction
Start by reproducing the provided example after Traceloop.init(), focusing on Traceloop.set_association_properties, the ThreadPoolExecutor work, and mlflow.evaluate. Compare spans produced by the MLflow run and evaluation paths; done means every span from the run includes mlflow_run_id and mlflow_exp_id, including the reported LLMChain.workflow and OpenAI spans.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100