traceloop / traceloop/openllmetry

πŸ› Bug Report: CohereInstrumentor do not instrument anything

Open
#2,338 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
7.4k
Forks
1.1k
Avg merge
8d 14h
Merged PRs (30d)
2

Description

Which component is this bug for?

Cohere Instrumentation

πŸ“œ Description

I use the CohereInstrumentor, but it does not create any spans for my trace.

πŸ‘Ÿ Reproduction steps
import logging

from azure.monitor.opentelemetry import configure_azure_monitor
from opentelemetry import trace
from opentelemetry.instrumentation.cohere import CohereInstrumentor
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
from opentelemetry.instrumentation.langchain import LangchainInstrumentor
from opentelemetry.instrumentation.logging import LoggingInstrumentor
from opentelemetry.instrumentation.openai import OpenAIInstrumentor
from opentelemetry.instrumentation.psycopg import PsycopgInstrumentor
from opentelemetry.instrumentation.requests import RequestsInstrumentor
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor, ConsoleSpanExporter
from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentor
from dataproduct.settings import settings
from opentelemetry.instrumentation.asyncio import AsyncioInstrumentor


def configure_tracing(app=None):
    if settings.APPLICATIONINSIGHTS_CONNECTION_STRING:
        configure_azure_monitor(
            connection_string=settings.APPLICATIONINSIGHTS_CONNECTION_STRING,
            enable_live_metrics=True,
            logger_name="dataproduct",
        )
        print("Config done")
    else:
        provider = TracerProvider()
        console_exporter = ConsoleSpanExporter()
        provider.add_span_processor(BatchSpanProcessor(console_exporter))
        trace.set_tracer_provider(provider)
    RequestsInstrumentor().instrument()
    HTTPXClientInstrumentor().instrument()
    AsyncioInstrumentor().instrument()
    CohereInstrumentor().instrument()
    OpenAIInstrumentor().instrument()
    # LangchainInstrumentor().instrument()
    PsycopgInstrumentor().instrument(enable_commenter=False, skip_dep_check=True)
    LoggingInstrumentor().instrument(
        set_logging_format=True,
        log_level=logging.DEBUG,
    )
    if app:
        FastAPIInstrumentor.instrument_app(app)
    return trace.get_tracer(
        __name__,
    )

_ = configure_tracing()

async def reranking(docs):
   co = cohere.AsyncClient(
                base_url=settings.COHERE_AZURE_ENDPOINT,
                api_key=settings.COHERE_AZURE_KEY,
            )
    rerank_response = await co.rerank(
                query=search.search,
                documents=sorted_data[:100],
                rank_fields=["chunk_text"],
                top_n=search.no_hits,
            )
     return rerank_response
πŸ‘ Expected behavior

It should give me any spans

πŸ‘Ž Actual Behavior with Screenshots

I just get the span for the HTTPXInstrumentor

image
πŸ€– Python Version

3.11

πŸ“ƒ Provide any additional context for the Bug.
opentelemetry-instrumentation-cohere = "^0.33.12"
πŸ‘€ 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 at CohereInstrumentor().instrument() and the co.rerank() call in the reproduction, then inspect how the Cohere instrumentation handles AsyncClient usage and compare it with the observed HTTPX span. Done means the reproduced asynchronous rerank operation emits the expected Cohere instrumentation spans.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
observability-sre
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.