Skip to content

Bug: ConsoleSpanExporter no longer printing traces to console #374

@YashKarthik

Description

@YashKarthik

Tracing calls to Bedrock and OpenAI does not work anymore.

Deps:

"@aws-sdk/client-bedrock-runtime": "^3.614.0",
"@traceloop/node-server-sdk": "^0.9.1",
"openai": "^4.52.7"

What I'm trying to do:

import * as traceloop from "@traceloop/node-server-sdk";
import { ConsoleSpanExporter } from "@opentelemetry/sdk-trace-node";

import * as bedrock from "@aws-sdk/client-bedrock-runtime";
import { OpenAI } from "openai"

import util from "util";

traceloop.initialize({
  disableBatching: true,
  exporter: new ConsoleSpanExporter(),
  instrumentModules: {
    bedrock: bedrock,
    openAI: OpenAI
  }
});

const client = new bedrock.BedrockRuntimeClient({
  credentials: {
    accessKeyId: "...",
    secretAccessKey: "...",
  },
  region: "us-east-1",
});

const input = { // ConverseRequest
  modelId: "meta.llama2-13b-chat-v1",
  messages: [
    {
      role: "user",
      content: [
        {
          text: "Hello wold, how are you doing?",
        },
      ],
    },
  ],
};

const command = new bedrock.ConverseCommand(input);
const response = await client.send(command);
console.log("------", util.inspect(response, { depth: null, colors: true }), "----------");

const openai = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
});

const completion = await openai.chat.completions.create(
  {
    messages: [
      {
        role: "user",
        content: "Generate an abstract for a course on space.",
      },
    ],
    model: "gpt-3.5-turbo",
  }
);

console.log("------", util.inspect(completion, { depth: null, colors: true }), "----------");

Lmk if I'm doing something.

This workflow was previously working with the following versions:

"@traceloop/node-server-sdk": "^0.8.6",
"openai": "^4.48.3"
"@aws-sdk/client-bedrock-runtime": "^3.590.0",

Also maybe this isn't just a ConsoleSpanExporter problem. I couldn't get the logs to show up in the Traceloop dashboard.

Edit: output with logLevel: "debug"

@opentelemetry/api: Registered a global for diag v1.8.0.
Traceloop exporting traces to a custom exporter
@traceloop/instrumentation-openai Manually instrumenting openai
@traceloop/instrumentation-bedrock Module @aws-sdk/client-bedrock-runtime has been loaded before @traceloop/instrumentation-bedrock so it might not work, please initialize it before requiring @aws-sdk/client-bedrock-runtime
@traceloop/instrumentation-bedrock Patching @aws-sdk/client-bedrock-runtime manually
@opentelemetry/api: Registered a global for trace v1.8.0.
@opentelemetry/api: Registered a global for context v1.8.0.
@opentelemetry/api: Registered a global for propagation v1.8.0.
EnvDetector found resource. Resource {
  _attributes: {},
  asyncAttributesPending: false,
  _syncAttributes: {},
  _asyncAttributesPromise: Promise {
    {},
    [Symbol(async_id_symbol)]: 444,
    [Symbol(trigger_async_id_symbol)]: 0
  }
}
ProcessDetector found resource. Resource {
  _attributes: {
    'process.pid': 20784,
    'process.executable.name': 'node',
    'process.executable.path': '/Users/Yash/.volta/tools/image/node/18.17.0/bin/node',
    'process.command_args': [
      '/Users/Yash/.volta/tools/image/node/18.17.0/bin/node',
      '/Users/Yash/Code/aws-bedrock-tracel/index.mjs'
    ],
    'process.runtime.version': '18.17.0',
    'process.runtime.name': 'nodejs',
    'process.runtime.description': 'Node.js',
    'process.command': '/Users/Yash/Code/aws-bedrock-tracel/index.mjs',
    'process.owner': 'Yash'
  },
  asyncAttributesPending: false,
  _syncAttributes: {},
  _asyncAttributesPromise: Promise {
    {
      'process.pid': 20784,
      'process.executable.name': 'node',
      'process.executable.path': '/Users/Yash/.volta/tools/image/node/18.17.0/bin/node',
      'process.command_args': [Array],
      'process.runtime.version': '18.17.0',
      'process.runtime.name': 'nodejs',
      'process.runtime.description': 'Node.js',
      'process.command': '/Users/Yash/Code/aws-bedrock-tracel/index.mjs',
      'process.owner': 'Yash'
    },
    [Symbol(async_id_symbol)]: 445,
    [Symbol(trigger_async_id_symbol)]: 0
  }
}
... //console logs I put

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions