Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export attribute names as keys #56

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scripts/generate_typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ TJS.compile(schema, schemaBaseName)
fs.mkdirSync(dirname, { recursive: true })
}
fs.writeFileSync(outputFilePath, ts);
fs.cpSync("schemas", "src/typescript/schemas", {recursive: true})
})
.catch((error) => console.error(error));

Expand Down
8 changes: 8 additions & 0 deletions src/typescript/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { properties as LLMSpanAttributesObj } from './schemas/llm_span_attributes.json'
import { properties as DatabaseSpanAttributesObj } from './schemas/database_span_attributes.json'
import { properties as FrameworkSpanAttributesObj } from './schemas/framework_span_attributes.json'


export const LLMSpanAttributeNames: Array<keyof typeof LLMSpanAttributesObj> = Object.keys(LLMSpanAttributesObj) as Array<keyof typeof LLMSpanAttributesObj>
export const DatabaseSpanAttributeNames: Array<keyof typeof DatabaseSpanAttributesObj> = Object.keys(DatabaseSpanAttributesObj) as Array<keyof typeof DatabaseSpanAttributesObj>
export const FrameworkSpanAttributeNames: Array<keyof typeof FrameworkSpanAttributesObj> = Object.keys(FrameworkSpanAttributesObj) as Array<keyof typeof FrameworkSpanAttributesObj>
6 changes: 6 additions & 0 deletions src/typescript/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {LLMSpanAttributes as LLMSpanAttributesInternal} from "./models/llm_span_attributes";
import {DatabaseSpanAttributes as DatabaseSpanAttributesInternal} from "./models/database_span_attributes";
import {FrameworkSpanAttributes as FrameworkSpanAttributesInternal} from "./models/framework_span_attributes";
import { LLMSpanAttributeNames, DatabaseSpanAttributeNames, FrameworkSpanAttributeNames } from "./constants";
/** Opentelemetry span attributes */

/**
Expand All @@ -21,3 +22,8 @@ export declare type AttributeValue = string | number | boolean | Array<null | un
export type LLMSpanAttributes = Attributes & ( LLMSpanAttributesInternal);
export type DatabaseSpanAttributes = Attributes & ( DatabaseSpanAttributesInternal);
export type FrameworkSpanAttributes = Attributes & ( FrameworkSpanAttributesInternal);
export {
LLMSpanAttributeNames,
DatabaseSpanAttributeNames,
FrameworkSpanAttributeNames
}
4 changes: 2 additions & 2 deletions src/typescript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@langtrase/trace-attributes",
"version": "5.0.0",
"version": "5.0.1",
"description": "LangTrace - Trace Attributes",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
65 changes: 65 additions & 0 deletions src/typescript/schemas/database_span_attributes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "DatabaseSpanAttributes",
"type": "object",
"additionalProperties": false,
"properties": {
"langtrace.service.name": {
"type": "string"
},
"langtrace.service.type": {
"type": "string"
},
"langtrace.service.version": {
"type": "string"
},
"langtrace.sdk.name": {
"type": "string"
},
"langtrace.version": {
"type": "string"
},
"server.address": {
"type": "string"
},
"db.query": {
"type": "string"
},
"db.response": {
"type": "string"
},
"db.operation": {
"type": "string"
},
"db.system": {
"type": "string"
},
"db.namespace": {
"type": "string"
},
"db.index": {
"type": "string"
},
"db.collection.name": {
"type": "string"
},
"db.top_k": {
"type": "number",
"format": "float"
},
"db.embedding_model": {
"type": "string"
},
"langtrace.testId": {
"type": "string"
}
},
"required": [
"langtrace.service.name",
"langtrace.service.type",
"langtrace.sdk.name",
"db.query",
"langtrace.version",
"db.system"
]
}
65 changes: 65 additions & 0 deletions src/typescript/schemas/framework_span_attributes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "FrameworkSpanAttributes",
"type": "object",
"additionalProperties": false,
"properties": {
"langtrace.service.name": {
"type": "string"
},
"langtrace.service.type": {
"type": "string"
},
"langtrace.service.version": {
"type": "string"
},
"langtrace.sdk.name": {
"type": "string"
},
"langtrace.version": {
"type": "string"
},
"langchain.task.name": {
"type": "string"
},
"langchain.inputs": {
"type": "string"
},
"langchain.outputs": {
"type": "string"
},
"langgraph.entrypoint": {
"type": "string"
},
"langgraph.node": {
"type": "string"
},
"langgraph.edge": {
"type": "string"
},
"langgraph.finishpoint": {
"type": "string"
},
"langgraph.task.name": {
"type": "string"
},
"llamaindex.task.name": {
"type": "string"
},
"llamaindex.inputs": {
"type": "string"
},
"llamaindex.outputs": {
"type": "string"
},
"langtrace.testId": {
"type": "string"
}
},
"required": [
"langtrace.service.name",
"langtrace.service.type",
"langtrace.sdk.name",
"langtrace.version"
]
}
159 changes: 159 additions & 0 deletions src/typescript/schemas/llm_span_attributes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "LLMSpanAttributes",
"type": "object",
"additionalProperties": false,
"properties": {
"langtrace.service.name": {
"type": "string"
},
"langtrace.service.type": {
"type": "string"
},
"langtrace.service.version": {
"type": "string"
},
"langtrace.version": {
"type": "string"
},
"langtrace.sdk.name": {
"type": "string"
},
"url.full": {
"type": "string"
},
"llm.api": {
"type": "string"
},
"llm.model": {
"type": "string"
},
"llm.temperature": {
"type": "number",
"format": "float"
},
"llm.top_p": {
"type": "number",
"format": "float"
},
"llm.top_k": {
"type": "number",
"format": "float"
},
"llm.user": {
"type": "string"
},
"llm.system.fingerprint": {
"type": "string"
},
"llm.prompts": {
"type": "string"
},
"llm.responses": {
"type": "string"
},
"llm.token.counts": {
"type": "string"
},
"llm.stream": {
"type": "boolean"
},
"llm.encoding.formats": {
"type": "string"
},
"llm.dimensions": {
"type": "string"
},
"llm.generation_id": {
"type": "string"
},
"llm.response_id": {
"type": "string"
},
"llm.citations": {
"type": "string"
},
"llm.documents": {
"type": "string"
},
"llm.is_search_required": {
"type": "boolean"
},
"llm.search_results": {
"type": "string"
},
"llm.tool_calls": {
"type": "string"
},
"llm.max_tokens": {
"type": "string"
},
"llm.max_input_tokens": {
"type": "string"
},
"llm.conversation_id": {
"type": "string"
},
"llm.seed": {
"type": "string"
},
"llm.frequency_penalty": {
"type": "string"
},
"llm.presence_penalty": {
"type": "string"
},
"llm.connectors": {
"type": "string"
},
"llm.tools": {
"type": "string"
},
"llm.tool_results": {
"type": "string"
},
"llm.embedding_inputs": {
"type": "string"
},
"llm.embedding_dataset_id": {
"type": "string"
},
"llm.embedding_input_type": {
"type": "string"
},
"llm.embedding_job_name": {
"type": "string"
},
"llm.retrieval.query": {
"type": "string"
},
"llm.retrieval.results": {
"type": "string"
},
"llm.image.size": {
"type": "string"
},
"llm.response_format": {
"type": "string"
},
"http.max.retries": {
"type": "integer",
"format": "int32"
},
"http.timeout": {
"type": "integer",
"format": "int64"
},
"langtrace.testId": {
"type": "string"
}
},
"required": [
"langtrace.service.name",
"langtrace.service.type",
"langtrace.sdk.name",
"langtrace.version",
"url.full",
"llm.api"
]
}
2 changes: 1 addition & 1 deletion src/typescript/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./",
"module": "commonjs",
"resolveJsonModule": true,
"target": "es5",
"declaration": true,
"sourceMap": true,
Expand Down
Loading