New Relic Node.js agent code base. Developers are welcome to create pull requests here, please see our contributing guidelines. For New Relic technical support, please go to http://support.newrelic.com.
Direct chains utilize BaseChain.prototype.invoke to kick off their work. We should instrument this method with an auto-injected BaseCallbackHandler that responds to the correct events.
Prompt chains utilize at least two invoke methods:
There are at least two chain concepts in LangChain:
Direct chains utilize
BaseChain.prototype.invoke
to kick off their work. We should instrument this method with an auto-injectedBaseCallbackHandler
that responds to the correct events.Prompt chains utilize at least two invoke methods:
BaseChatModel.prototype.invoke
when a model in the chain is invokedBasePromptTemplate.prototype.invoke
when the prompt chain is started/endedThese methods should be instrumented with an appropriate callback handler.
In all cases, the corresponding LLM event types should be created and recorded. In these cases, the LLM events should have
virtual_llm
set totrue
.Spans should be named
Llm/chain/Langchain/invoke
for chains andLlm/agent/Langchain/invoke
for models.This implementation should honor the feature flag
config.feature_flag.langchain_instrumentation
.