npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@traceai/fi-semantic-conventions

v1.0.0

Published

Semantic conventions for OpenTelemetry instrumentation

Readme

@traceai/fi-semantic-conventions

Semantic conventions for OpenTelemetry instrumentation attributes used in TraceAI prototype and observe projects.

Installation

npm install @traceai/fi-semantic-conventions
# or
yarn add @traceai/fi-semantic-conventions
# or
pnpm add @traceai/fi-semantic-conventions

Overview

This package provides standardized attribute names for instrumenting AI/LLM applications with OpenTelemetry. Using consistent semantic conventions ensures traces are correctly parsed and displayed in the TraceAI platform.

Module System Support

This package supports both CommonJS and ESM module systems.

ESM (ES Modules)

import {
    SemanticAttributePrefixes,
    LLMAttributePostfixes,
    EmbeddingAttributePostfixes,
} from '@traceai/fi-semantic-conventions';

CommonJS

const {
    SemanticAttributePrefixes,
    LLMAttributePostfixes,
} = require('@traceai/fi-semantic-conventions');

Attribute Prefixes

import { SemanticAttributePrefixes } from '@traceai/fi-semantic-conventions';

| Prefix | Usage | |--------|-------| | input | Input data attributes | | output | Output data attributes | | llm | LLM-specific attributes | | retrieval | Retrieval/RAG attributes | | reranker | Reranking attributes | | messages | Message list attributes | | message | Single message attributes | | document | Document attributes | | embedding | Embedding attributes | | tool | Tool/function attributes | | tool_call | Tool call attributes | | metadata | Custom metadata | | tag | Tag attributes | | session | Session tracking | | user | User tracking | | traceai | TraceAI-specific | | fi | Future AGI namespace | | message_content | Message content | | image | Image attributes | | audio | Audio attributes | | prompt | Prompt attributes |

LLM Attributes

import { LLMAttributePostfixes } from '@traceai/fi-semantic-conventions';

| Postfix | Full Attribute | Description | |---------|----------------|-------------| | provider | llm.provider | LLM provider (aws, azure, google) | | system | llm.system | LLM system (openai, anthropic) | | model_name | llm.model_name | Model identifier | | token_count | llm.token_count.* | Token usage | | input_messages | llm.input_messages | Input message array | | output_messages | llm.output_messages | Output message array | | invocation_parameters | llm.invocation_parameters | Model parameters | | prompts | llm.prompts | Prompt strings | | prompt_template | llm.prompt_template.* | Template tracking | | function_call | llm.function_call | Function call details | | tools | llm.tools | Available tools |

Token Count Attributes

| Attribute | Description | |-----------|-------------| | llm.token_count.prompt | Input/prompt tokens | | llm.token_count.completion | Output/completion tokens | | llm.token_count.total | Total tokens | | llm.token_count.cache_read | Cached tokens read | | llm.token_count.cache_creation | Cached tokens created |

Prompt Template Attributes

| Attribute | Description | |-----------|-------------| | llm.prompt_template.template | Template string | | llm.prompt_template.version | Template version | | llm.prompt_template.variables | Template variables |

Message Attributes

import { MessageAttributePostfixes } from '@traceai/fi-semantic-conventions';

| Postfix | Full Attribute | Description | |---------|----------------|-------------| | role | message.role | Message role (user, assistant, system) | | content | message.content | Message content | | contents | message.contents | Multiple content blocks | | name | message.name | Participant name | | function_call_name | message.function_call.name | Function name | | function_call_arguments | message.function_call.arguments | Function args | | tool_calls | message.tool_calls | Tool call array | | tool_call_id | message.tool_call_id | Tool call identifier |

Embedding Attributes

import { EmbeddingAttributePostfixes } from '@traceai/fi-semantic-conventions';

| Postfix | Full Attribute | Description | |---------|----------------|-------------| | embeddings | embedding.embeddings | Vector array | | text | embedding.text | Input text | | model_name | embedding.model_name | Embedding model | | vector | embedding.vector | Single vector |

Retrieval Attributes

import { RetrievalAttributePostfixes } from '@traceai/fi-semantic-conventions';

| Postfix | Full Attribute | Description | |---------|----------------|-------------| | documents | retrieval.documents | Retrieved documents |

Tool Attributes

import { ToolAttributePostfixes } from '@traceai/fi-semantic-conventions';

| Postfix | Full Attribute | Description | |---------|----------------|-------------| | name | tool.name | Tool name | | description | tool.description | Tool description | | parameters | tool.parameters | Tool parameters | | json_schema | tool.json_schema | JSON schema |

Usage Example

import { trace } from '@opentelemetry/api';
import {
    SemanticAttributePrefixes,
    LLMAttributePostfixes,
} from '@traceai/fi-semantic-conventions';

const tracer = trace.getTracer('my-app');

// Create a span with semantic attributes
const span = tracer.startSpan('llm.chat');

// Set attributes using conventions
span.setAttributes({
    [`${SemanticAttributePrefixes.llm}.${LLMAttributePostfixes.system}`]: 'openai',
    [`${SemanticAttributePrefixes.llm}.${LLMAttributePostfixes.model_name}`]: 'gpt-4',
    [`${SemanticAttributePrefixes.llm}.${LLMAttributePostfixes.token_count}.prompt`]: 100,
    [`${SemanticAttributePrefixes.llm}.${LLMAttributePostfixes.token_count}.completion`]: 50,
    [`${SemanticAttributePrefixes.input}.value`]: 'User input text',
    [`${SemanticAttributePrefixes.output}.value`]: 'Model response',
});

span.end();

Span Kind Attribute

The fi.span_kind attribute indicates the type of operation:

// Set span kind
span.setAttribute('fi.span_kind', 'LLM');

| Value | Description | |-------|-------------| | LLM | Language model call | | AGENT | Agent orchestration | | TOOL | Tool/function execution | | CHAIN | Workflow chain | | RETRIEVER | Document retrieval | | EMBEDDING | Embedding generation | | RERANKER | Result reranking | | GUARDRAIL | Safety check | | VECTOR_DB | Vector database operation |

Resource Attributes

import { ResourceAttributes } from '@traceai/fi-semantic-conventions';

Standard OpenTelemetry resource attributes for service identification:

| Attribute | Description | |-----------|-------------| | service.name | Service name | | service.version | Service version | | deployment.environment | Deployment environment |

TypeScript Configuration

For optimal compatibility:

{
  "compilerOptions": {
    "moduleResolution": "node",
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true
  }
}

Related Packages

  • @traceai/fi-core - Core tracing library
  • @traceai/openai - OpenAI instrumentation
  • @traceai/anthropic - Anthropic instrumentation
  • @traceai/langchain - LangChain instrumentation

License

GPL-3.0