Skip to content

Commit d965a2a

Browse files
author
zoey
authored
feat: get_logs tool (#34)
1 parent 9896c5f commit d965a2a

16 files changed

Lines changed: 611 additions & 5358 deletions

.github/workflows/ci.yml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,24 @@ jobs:
1212
lint:
1313
runs-on: ubuntu-latest
1414

15-
strategy:
16-
matrix:
17-
node-version: [18, 20, 22]
18-
1915
steps:
2016
- name: Checkout code
2117
uses: actions/checkout@v4
2218

23-
- name: Set up Node.js
24-
uses: actions/setup-node@v4
25-
with:
26-
node-version: ${{ matrix.node-version }}
27-
cache: 'npm'
19+
- name: Setup Bun
20+
uses: oven-sh/setup-bun@v2
2821

2922
- name: Install dependencies
30-
run: npm ci
23+
run: bun install
3124

3225
- name: Check code formatting
33-
run: npm run format:check
26+
run: bun format:check
3427

3528
- name: Run ESLint
36-
run: npm run lint
29+
run: bun lint
3730

3831
- name: Type check
39-
run: npm run type:check
32+
run: bun type:check
4033

4134
test:
4235
runs-on: ubuntu-latest

.github/workflows/publish.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,80 @@ export const config = {
143143

144144
This exposes the MCP endpoint at `/tidewave/mcp`.
145145

146+
**Logging** (optional): To capture application logs for debugging via the
147+
`get_logs` MCP tool, add OpenTelemetry instrumentation.
148+
149+
Create an `instrumentation.ts` file in your project root:
150+
151+
```typescript
152+
// instrumentation.ts
153+
import { NodeSDK } from '@opentelemetry/sdk-node';
154+
155+
export async function register() {
156+
const runtime = process.env.NEXT_RUNTIME;
157+
const env = process.env.NODE_ENV;
158+
159+
if (runtime === 'nodejs' && env === 'development') {
160+
const { TidewaveSpanProcessor, TidewaveLogRecordProcessor } = await import(
161+
'tidewave/next-js/instrumentation'
162+
);
163+
164+
const sdk = new NodeSDK({
165+
spanProcessors: [new TidewaveSpanProcessor()],
166+
logRecordProcessors: [new TidewaveLogRecordProcessor()], // Optional
167+
});
168+
169+
sdk.start();
170+
}
171+
}
172+
```
173+
174+
This captures:
175+
176+
- Console logs (`console.log`, `console.error`, etc.) - automatic when you
177+
import the module
178+
- Next.js HTTP request/response spans (`GET /api/users 200 45ms`) - via
179+
`TidewaveSpanProcessor`
180+
- OpenTelemetry logger logs - via `TidewaveLogRecordProcessor` (optional)
181+
182+
#### With Existing OpenTelemetry Setup
183+
184+
If you already have custom OpenTelemetry instrumentation, simply add the
185+
Tidewave processors to your existing setup:
186+
187+
```typescript
188+
// instrumentation.ts
189+
import { NodeSDK } from '@opentelemetry/sdk-node';
190+
import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-node';
191+
192+
export async function register() {
193+
const runtime = process.env.NEXT_RUNTIME;
194+
const env = process.env.NODE_ENV;
195+
196+
// Your existing configuration
197+
const sdkConfig = {
198+
spanProcessors: [new BatchSpanProcessor(yourExporter)],
199+
logRecordProcessors: [],
200+
};
201+
202+
// Conditionally add Tidewave processors in development
203+
if (runtime === 'nodejs' && env === 'development') {
204+
const { TidewaveSpanProcessor, TidewaveLogRecordProcessor } = await import(
205+
'tidewave/next-js/instrumentation'
206+
);
207+
208+
sdkConfig.spanProcessors.push(new TidewaveSpanProcessor());
209+
sdkConfig.logRecordProcessors.push(new TidewaveLogRecordProcessor());
210+
}
211+
212+
const sdk = new NodeSDK(sdkConfig);
213+
sdk.start();
214+
}
215+
```
216+
217+
This allows Tidewave to capture logs alongside your existing OpenTelemetry setup
218+
without conflicts.
219+
146220
### CLI Usage
147221

148222
Tidewave also provides the MCP features over a CLI tool. Use it directly via

bun.lock

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

0 commit comments

Comments
 (0)