openllmetry: πŸ› Bug Report: Metrics wasn't sent when use chatmodel (openai , chatopenai ) from langchain

Which component is this bug for?

Langchain Instrumentation

πŸ“œ Description

When I use OpenAI or ChatOpenAI from the Langchain_OpenAI library for normal tasks, there is no issue with spans, but the metrics are not being sent to my Prometheus. However, if I use OpenAI directly, it works without any problems.

πŸ‘Ÿ Reproduction steps

It should have some metrics come out after running this code. But it didn’t.

from langchain_openai import OpenAI

llm = OpenAI()


from langchain_core.prompts import PromptTemplate

prompt = PromptTemplate.from_template("How to say {input} in {output_language}:\n")

chain = prompt | llm
chain.invoke(
    {
        "output_language": "German",
        "input": "I love programming.",
    }
)


πŸ‘ Expected behavior

it should have metrics as usual.

πŸ‘Ž Actual Behavior with Screenshots

from above code I can’t see any metrics was sent from that

πŸ€– Python Version

3.11

πŸ“ƒ Provide any additional context for the Bug.

I sent it to Prometheus

πŸ‘€ 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?

Yes I am willing to submit a PR!

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (4 by maintainers)

Most upvoted comments

Mo worry. Im having fun talking with dosu.

@nitin302 already opened #2166 πŸ˜ƒ