Skip to content

Conversation

@mikeldking
Copy link
Collaborator

@mikeldking mikeldking commented Oct 23, 2025

resolves #2228

Added tracing capabilities with decorators and function

  • Function Wrapping: withSpan(), withAgentSpan(), withToolSpan(), withChainSpan()
  • Decorators: @observe() for class methods

Examples

Function Wrapping:

const tracedLLM = withAgentSpan(callOpenAI, {
  attributes: { 'llm.model': 'gpt-4' }
});

Decorators:

class Agent {
  @trace({ kind: OpenInferenceSpanKind.AGENT })
  async makeDecision(context) { /* ... */ }
}

Custom Processing:

const traced = withSpan(fn, {
  attributes: { 'service.name': 'my-service' },
  processInput: (...args) => ({ 'input.count': args.length })
});
  • mime type inference
  • async function support
  • error propagation
  • chain
  • agent
  • tool

@mikeldking mikeldking requested a review from a team as a code owner October 23, 2025 21:03
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Oct 23, 2025
@mikeldking mikeldking marked this pull request as draft October 23, 2025 21:03
cursor[bot]

This comment was marked as outdated.

@mikeldking mikeldking force-pushed the feat/2228-js-decorators branch 2 times, most recently from 43591e8 to 5b5e856 Compare October 24, 2025 19:51
@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 24, 2025

Open in StackBlitz

@arizeai/openinference-core

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-core@2344

@arizeai/openinference-genai

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-genai@2344

@arizeai/openinference-instrumentation-anthropic

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-instrumentation-anthropic@2344

@arizeai/openinference-instrumentation-bedrock

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-instrumentation-bedrock@2344

@arizeai/openinference-instrumentation-bedrock-agent-runtime

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-instrumentation-bedrock-agent-runtime@2344

@arizeai/openinference-instrumentation-beeai

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-instrumentation-beeai@2344

@arizeai/openinference-instrumentation-langchain

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-instrumentation-langchain@2344

@arizeai/openinference-instrumentation-mcp

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-instrumentation-mcp@2344

@arizeai/openinference-instrumentation-openai

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-instrumentation-openai@2344

@arizeai/openinference-mastra

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-mastra@2344

@arizeai/openinference-semantic-conventions

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-semantic-conventions@2344

@arizeai/openinference-vercel

npm i https://pkg.pr.new/Arize-ai/openinference/@arizeai/openinference-vercel@2344

commit: 9abe364

@mikeldking mikeldking force-pushed the feat/2228-js-decorators branch from 6b49a48 to 7cf2cd2 Compare October 27, 2025 17:13
@mikeldking mikeldking marked this pull request as ready for review October 27, 2025 20:07
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Oct 27, 2025
cursor[bot]

This comment was marked as outdated.

@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Oct 27, 2025
constructor(name: string) {
this.name = name;
}
@observe()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is to avoid collision with otel's trace api

* });
* ```
*/
export function withSpan<Fn extends UnknownFn>(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name seems semantic but maybe we could alias observeFunction or something like that....

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[js] decorator support for openinference-core

1 participant