traceloop / traceloop/openllmetry

๐Ÿ› Bug Report: OpenLLMetry doesn't work with MLFlow

Open
#1,750 0 comments 0 reactions 0 assignees View on GitHub

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.
img_1837

This is for POST span with path mlfowserver/api/mlfow/runs/log-inputs
img_1838

You can see it has association properties
But for the open ai one there is no properties

For OPENAI
img_1839

๐Ÿค– 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up โ€” it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.