function instrumentInvokeChain({ langchain, shim }) {
  shim.record(
    langchain.RunnableSequence.prototype,
    'invoke',
    function wrapCall(shim, _invoke, fnName, args) {
      const [request, params] = args
      const metadata = params?.metadata ?? {}
      const tags = params?.tags ?? []

      return new RecorderSpec({
        name: `${LANGCHAIN.CHAIN}/${fnName}`,
        promise: true,
        after({ error: err, result: output, segment, transaction }) {
          recordChatCompletionEvents({
            transaction,
            segment,
            messages: [output],
            events: [request, output],
            metadata,
            tags,
            err,
            shim
          })
        }
      })
    }
  )
}
Instruments and records span and relevant LLM events for `chain.invoke`

@param {object} params function params
@param {object} params.langchain `@langchain/core/runnables/base` export
@param {Shim} params.shim instace of shim