Skip to content
Agentmart
Submit a tool

autotel-request-logging

Accumulates request-scoped context and emits one wide-event snapshot per request with getRequestLogger(), set(), setLevel(), info/warn/error, and emitNow().

Skill by jagreehal

IndexedApache-2.0★ 8
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/jagreehal-autotel-request-logging

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Accumulates request-scoped context and emits one wide-event snapshot per request with getRequestLogger(), set(), setLevel(), info/warn/error, and emitNow(). Use this skill when adding request-scoped attributes, building canonical log lines, or replacing scattered console.log. Do not use for product and analytics events — use skill autotel-events — or for span creation itself, which skill autotel-instrumentation covers.

Use cases: data

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/autotel-request-logging

What's inside

Skill name
autotel-request-logging
Description
Accumulates request-scoped context and emits one wide-event snapshot per request with getRequestLogger(), set(), setLevel(), info/warn/error, and emitNow(). Use this skill when adding request-scoped attributes, building canonical log lines, or replacing scattered console.log. Do not use for product and analytics events — use skill autotel-events — or for span creation itself, which skill autotel-instrumentation covers.
License
Apache-2.0
Instructions
132 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

# Autotel: Request Logging

This skill builds on autotel-instrumentation. Read it first for init and span creation.

Accumulate context with `getRequestLogger(ctx)`, `.set()`, and `.info()`/`.warn()`/`.error()`. Call `.emitNow()` (or rely on middleware) to emit one snapshot per request. Request logger requires an active span. Use inside `trace()` or framework middleware.

Preferred event model: treat request logger emissions as the default way to capture request-correlated events in new code. If a backend still expects span-event rendering, keep compatibility at export/processor level rather than adding new `span.addEvent()` calls in application code.

## Setup

```typescript
import { init, withTracing, getRequestLogger } from 'autotel';

init({ service: 'my-app' });

const handler = withTracing({ name: 'http.request' })(
  (ctx) => async (req: Request, res: Response) => {
    const log = getRequestLogger(ctx);
    log.set({ method: req.method, path: req.url });

    const user = await getAuth(req);
    log.set({ user: { id: user.id } });

    const result = await doWork(req);
    log.set({ result: { id: result.id } });
    log.emitNow();
    return res.json(result);
  },
);
```

When the framework creates the span (e.g. Hono's `otel()` middleware), call `getRequestLogger()` with no args:

```typescript
import { otel } from 'autotel-hono';

app.use('*', otel());
app.get('/api/users', (c) => {
  const log = getRequestLogger();
  log.set({ route: 'users' });
  log.emitNow();
  return c.json({ users: [] });
});
```

Adapters that emit for you (`autotelMiddleware()` from `autotel-adapters/hono`, `withAutotel()` from `autotel-adapters/express` / `fastify`, …) own the request logger: read it with the adapter's `useLogger()`, and don't call `emitNow()` yourself. See `autotel-frameworks`.

## Correlate pino / winston logs with traces

The request logger is autotel's own wide event. To get `trace_id` / `span_id` on your existing app logs, and export them as OTel log records, instrument the logger library:

```typescript
// instrumentation.ts, loaded first (ESM: node --import autotel/register)
import { init } from 'autotel';

init({
  service: 'api',
  endpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT,
  autoInstrumentations: ['http', 'pino'], // or 'winston'
  logs: true, // OTLP log export; off by default
});

// logger.ts: its own module, imported after instrumentation.ts
import pino from 'pino';
export const logger = pino();
```

- `autoInstrumentations` needs `@opentelemetry/auto-instrumentations-node` installed, and patches pino as it loads, so the logger must be created after `init()`. `init()` warns if pino / winston were already loaded.
- Winston needs `@opentelemetry/winston-transport` installed to export log records over OTLP.
- `init({ logger })` is not this: that logger only receives autotel's own diagnostics.

## Core Patterns

**Accumulate then emit:**

```typescript
const log = getRequestLogger(ctx);
log.set({ cart: { items: body.items.length } });
log.set({ payment: { method: body.method } });
log.error(err, { step: 'payment' });
log.emitNow();
```

**Set severity without logging:** `.warn()` and `.error()` set `autotel.log.level` for you. Use `setLevel()` when the request degraded but there is nothing to log, or when a warning should not colour the whole snapshot.

```typescript
if (inventory.stale) log.setLevel('warn'); // served from a stale cache
```

Takes `'debug' | 'info' | 'warn' | 'error'`. Adds no log event and records no exception. An explicit level wins: a later `.warn()` / `.error()` leaves it alone. Ignored after `emitNow()`.

**RequestLogSnapshot:** `emitNow()` returns `{ timestamp, traceId, spanId, correlationId, context }`. You can pass `onEmit` in options to forward it.

**Options:** `getRequestLogger(ctx?, { onEmit?: (snapshot) => void })` for custom fan-out on emit.

## Common Mistakes

### HIGH Call getRequestLogger() outside a span

Wrong:

```typescript
function helper() {
  const log = getRequestLogger();
  log.set({ step: 'helper' });
}
```

Correct:

```typescript
// Ensure helper runs inside trace() or middleware-created span
function helper(ctx?: TraceContext) {
  const log = getRequestLogger(ctx);
  log.set({ step: 'helper' });
}
```

Request logger attaches to the active span. If there is no active span, it throws. Wrap the call path with `trace()` or register middleware that creates a span per request.

From jagreehal/autotel, Apache-2.0.

More from jagreehal/autotel

Signals

Stars
8
Forks
3
Open issues
0
Last commit (this folder)
Oct 19, 2026 (8 days ago)
Last release
Sep 27, 2026 (1 month ago)

From GitHub (fetched Oct 24, 2026).

Details

License
Apache-2.0
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from jagreehal

Cite this page

autotel-request-logging skill. Agent Mart. https://agentmart.dev/skills/jagreehal-autotel-request-logging (last updated 2026-10-24)