Skip to content

Commit 5549df5

Browse files
committed
Merge branch 'main' of https://github.com/kaiban-ai/KaibanJS into workflow-driven-agent
2 parents d0000b1 + dac0753 commit 5549df5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+18381
-152
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Opentelemetry - Release Package
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Enter the version for this release'
8+
required: true
9+
10+
jobs:
11+
release:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v2
16+
with:
17+
ref: 'main'
18+
token: ${{ secrets.PAT_GITHUB }}
19+
20+
- name: Set up Node.js
21+
uses: actions/setup-node@v2
22+
with:
23+
node-version: '18'
24+
registry-url: 'https://registry.npmjs.org/'
25+
26+
- name: Reset local changes
27+
run: |
28+
git fetch origin main
29+
git reset --hard origin/main
30+
git clean -fdx
31+
32+
- name: Configure git user
33+
run: |
34+
git config user.name "Dariel Noel"
35+
git config user.email "[email protected]"
36+
37+
- name: Install dependencies
38+
run: cd packages/opentelemetry && npm install --also=dev
39+
40+
- name: Build production version
41+
run: cd packages/opentelemetry && npm run build
42+
43+
- name: Display changes
44+
run: |
45+
echo "Showing status..."
46+
git status
47+
echo "Showing diff..."
48+
git diff
49+
50+
- name: Update package.json version
51+
run: |
52+
cd packages/opentelemetry
53+
npm version ${{ github.event.inputs.version }}
54+
55+
- name: Push changes and tags
56+
run: |
57+
git push origin main
58+
git tag -a "opentelemetry-v${{ github.event.inputs.version }}" -m "Release version ${{ github.event.inputs.version }} for @kaibanjs/opentelemetry"
59+
git push origin "opentelemetry-v${{ github.event.inputs.version }}"
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.PAT_GITHUB }}
62+
63+
- name: Publish to npm
64+
run: |
65+
cd packages/opentelemetry
66+
npm publish --access=public
67+
env:
68+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "kaibanjs",
3-
"version": "0.22.1",
3+
"version": "0.22.2",
44
"description": "AI Multi-Agent library for Javascript Developers.",
55
"main": "./dist/bundle.cjs",
66
"types": "./dist/bundle.d.ts",

packages/opentelemetry/EXAMPLES.md

Lines changed: 298 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,298 @@
1+
# KaibanJS OpenTelemetry Examples
2+
3+
This document provides a comprehensive overview of the OpenTelemetry examples available in the KaibanJS package.
4+
5+
## 🚀 Quick Start
6+
7+
```bash
8+
# Install dependencies
9+
npm install
10+
11+
# Set up environment variables
12+
export OPENAI_API_KEY="your-openai-key"
13+
14+
# Run console example (no external dependencies)
15+
npm run example:console
16+
17+
# Run Langfuse example
18+
export LANGFUSE_PUBLIC_KEY="your-public-key"
19+
export LANGFUSE_SECRET_KEY="your-secret-key"
20+
npm run example:langfuse
21+
```
22+
23+
## 📋 Available Examples
24+
25+
### 1. Console Export (`console-example.ts`)
26+
27+
**Perfect for development and debugging**
28+
29+
- ✅ No external dependencies
30+
- ✅ Immediate console output
31+
- ✅ Development debugging
32+
- ✅ Multiple team complexity levels
33+
34+
**Usage:**
35+
36+
```bash
37+
npm run example:console
38+
```
39+
40+
### 2. Langfuse Export (`langfuse-example.ts`)
41+
42+
**LLM observability and trace visualization**
43+
44+
- ✅ OTLP export to Langfuse
45+
- ✅ LLM observability
46+
- ✅ Trace visualization
47+
- ✅ Performance monitoring
48+
49+
**Setup:**
50+
51+
```bash
52+
export LANGFUSE_PUBLIC_KEY="your-public-key"
53+
export LANGFUSE_SECRET_KEY="your-secret-key"
54+
npm run example:langfuse
55+
```
56+
57+
### 3. SigNoz Export (`signoz-example.ts`)
58+
59+
**Distributed tracing and service monitoring**
60+
61+
- ✅ OTLP export to SigNoz
62+
- ✅ Distributed tracing
63+
- ✅ Service map visualization
64+
- ✅ Performance metrics
65+
66+
**Setup:**
67+
68+
```bash
69+
export SIGNOZ_ACCESS_TOKEN="your-access-token"
70+
npm run example:signoz
71+
```
72+
73+
### 4. Phoenix Export (`phoenix-example.ts`)
74+
75+
**LLM observability and debugging**
76+
77+
- ✅ OTLP export to Phoenix
78+
- ✅ LLM observability
79+
- ✅ Trace visualization
80+
- ✅ Error tracking
81+
82+
**Setup:**
83+
84+
```bash
85+
export PHOENIX_API_KEY="your-api-key"
86+
export PHOENIX_ENDPOINT="https://your-phoenix-instance.com/otel"
87+
npm run example:phoenix
88+
```
89+
90+
### 5. Braintrust Export (`braintrust-example.ts`)
91+
92+
**LLM observability and cost tracking**
93+
94+
- ✅ OTLP export to Braintrust
95+
- ✅ LLM observability
96+
- ✅ Cost tracking
97+
- ✅ Performance optimization
98+
99+
**Setup:**
100+
101+
```bash
102+
export BRAINTRUST_API_KEY="your-api-key"
103+
export BRAINTRUST_ENDPOINT="https://www.braintrust.dev/api/v1/otel"
104+
npm run example:braintrust
105+
```
106+
107+
## 🏗️ Shared Teams
108+
109+
All examples use shared teams that range from simple to complex:
110+
111+
### Simple Teams
112+
113+
- **`simple-data`** - Single agent, single task
114+
- **`content-creation`** - Two agents working in sequence
115+
116+
### Intermediate Teams
117+
118+
- **`resume-creation`** - Multi-agent resume creation
119+
- **`sports-news`** - Research and content creation
120+
121+
### Complex Teams
122+
123+
- **`trip-planning`** - Multi-phase trip planning
124+
- **`product-spec`** - Product specification workflow
125+
126+
## 🎯 Usage Examples
127+
128+
### Run Specific Team
129+
130+
```bash
131+
# Set team name
132+
export TEAM_NAME="trip-planning"
133+
npm run example:langfuse
134+
```
135+
136+
### Run Multiple Examples
137+
138+
```bash
139+
# Run multiple teams
140+
export RUN_TYPE="multiple"
141+
npm run example:langfuse
142+
```
143+
144+
### Run Complex Examples
145+
146+
```bash
147+
# Run complex teams only
148+
export RUN_TYPE="complex"
149+
npm run example:langfuse
150+
```
151+
152+
## 🔧 Configuration
153+
154+
### Environment Variables
155+
156+
#### Required for all examples:
157+
158+
- `OPENAI_API_KEY` - OpenAI API key for LLM calls
159+
160+
#### Langfuse:
161+
162+
- `LANGFUSE_PUBLIC_KEY` - Langfuse public key
163+
- `LANGFUSE_SECRET_KEY` - Langfuse secret key
164+
165+
#### SigNoz:
166+
167+
- `SIGNOZ_ACCESS_TOKEN` - SigNoz access token
168+
169+
#### Phoenix:
170+
171+
- `PHOENIX_API_KEY` - Phoenix API key
172+
- `PHOENIX_ENDPOINT` - Phoenix OTLP endpoint (optional)
173+
174+
#### Braintrust:
175+
176+
- `BRAINTRUST_API_KEY` - Braintrust API key
177+
- `BRAINTRUST_ENDPOINT` - Braintrust OTLP endpoint (optional)
178+
179+
### Custom Configuration
180+
181+
```typescript
182+
import { createOpenTelemetryIntegration } from '@kaibanjs/opentelemetry';
183+
184+
const config = {
185+
enabled: true,
186+
sampling: {
187+
rate: 1.0,
188+
strategy: 'always',
189+
},
190+
attributes: {
191+
includeSensitiveData: false,
192+
customAttributes: {
193+
'service.name': 'my-kaiban-service',
194+
'service.version': '1.0.0',
195+
},
196+
},
197+
exporters: {
198+
console: true,
199+
otlp: {
200+
endpoint: 'https://your-service.com',
201+
headers: {
202+
Authorization: 'Bearer your-token',
203+
},
204+
serviceName: 'my-service',
205+
},
206+
},
207+
};
208+
209+
const integration = createOpenTelemetryIntegration(config);
210+
```
211+
212+
## 📊 Semantic Conventions
213+
214+
All examples use KaibanJS semantic conventions:
215+
216+
### LLM Request Attributes (`kaiban.llm.request.*`)
217+
218+
- `kaiban.llm.request.messages` - Input messages
219+
- `kaiban.llm.request.model` - Model name
220+
- `kaiban.llm.request.provider` - Provider (openai, anthropic, etc.)
221+
- `kaiban.llm.request.iteration` - Iteration number
222+
- `kaiban.llm.request.start_time` - Start time
223+
- `kaiban.llm.request.status` - Request status
224+
225+
### LLM Usage Attributes (`kaiban.llm.usage.*`)
226+
227+
- `kaiban.llm.usage.input_tokens` - Input tokens
228+
- `kaiban.llm.usage.output_tokens` - Output tokens
229+
- `kaiban.llm.usage.total_tokens` - Total tokens
230+
- `kaiban.llm.usage.cost` - Cost in USD
231+
232+
### LLM Response Attributes (`kaiban.llm.response.*`)
233+
234+
- `kaiban.llm.response.messages` - Output messages
235+
- `kaiban.llm.response.duration` - Response duration
236+
- `kaiban.llm.response.status` - Response status
237+
238+
### Span Types
239+
240+
- `kaiban.agent.thinking` - Agent thinking spans
241+
- `task.execute` - Task execution spans
242+
243+
## 🐛 Troubleshooting
244+
245+
### Common Issues
246+
247+
1. **Missing Environment Variables**
248+
249+
```
250+
Error: Missing required environment variables: OPENAI_API_KEY
251+
```
252+
253+
**Solution:** Set the required environment variables
254+
255+
2. **OTLP Export Failures**
256+
257+
```
258+
Error: OTLP export failed
259+
```
260+
261+
**Solution:** Check your API keys and endpoints
262+
263+
3. **Team Not Found**
264+
```
265+
Error: Team 'invalid-team' not found
266+
```
267+
**Solution:** Use a valid team name from the available teams
268+
269+
### Debug Mode
270+
271+
Enable debug mode for detailed logging:
272+
273+
```bash
274+
export DEBUG=true
275+
npm run example:langfuse
276+
```
277+
278+
## 📚 Additional Resources
279+
280+
- [OpenTelemetry Documentation](https://opentelemetry.io/docs/)
281+
- [Langfuse Documentation](https://langfuse.com/docs)
282+
- [SigNoz Documentation](https://signoz.io/docs)
283+
- [Phoenix Documentation](https://phoenix.arize.com/docs)
284+
- [Braintrust Documentation](https://www.braintrust.dev/docs)
285+
286+
## 🤝 Contributing
287+
288+
To add a new example:
289+
290+
1. Create a new file: `new-service-example.ts`
291+
2. Follow the existing pattern
292+
3. Add configuration and validation
293+
4. Export from `index.ts`
294+
5. Update this README
295+
296+
## 📄 License
297+
298+
MIT License - see LICENSE file for details.

0 commit comments

Comments
 (0)