Skip to content
Agentmart
Submit a tool

observability-instrument

Add OpenTelemetry spans with user_id and tenant_id in baggage to any new code path that handles requests, runs agents, or performs billable operations.

Skill by MILTONADINA

IndexedMIT
Write a review

Chalk Labs

Need help deploying observability-instrument?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

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/miltonadina-observability-instrument

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

Add OpenTelemetry spans with user_id and tenant_id in baggage to any new code path that handles requests, runs agents, or performs billable operations. Use whenever creating a new API endpoint, background job, agent invocation, or external API call. Inline PII redaction at the span exporter is mandatory before any production deploy.

Use cases: backend, devops, agent-building

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. 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/observability-instrument

What's inside

Skill name
observability-instrument
Description
Add OpenTelemetry spans with user_id and tenant_id in baggage to any new code path that handles requests, runs agents, or performs billable operations. Use whenever creating a new API endpoint, background job, agent invocation, or external API call. Inline PII redaction at the span exporter is mandatory before any production deploy.
License
MIT
Instructions
155 lines in SKILL.md · view on GitHub

Files (3)

  • SKILL.md
  • SKILL.md.bundle
  • SKILL.md.sig

SKILL.md (first lines)

# Observability Instrument

> OpenTelemetry, OpenInference semantic conventions, baggage for per-tenant
> attribution, PII redaction inline. Production-grade from day one.

**Tradeoff:** Every new code path needs instrumentation. Worth it: full tracing
catches more agent quality regressions before users see them.

---

## Why baggage matters

Baggage propagates `user_id` and `tenant_id` through the trace context. Every
span automatically inherits them through the call tree. Teams that try to
propagate identity through ad-hoc argument passing always lose it at the first
tool boundary.

Decision: add baggage in week one. Costs two days. Buys per-tenant cost
attribution forever.

---

## Setup (TypeScript / Node)

```typescript
// otel-setup.ts
import { NodeSDK } from '@opentelemetry/sdk-node';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
import { propagation, ROOT_CONTEXT } from '@opentelemetry/api';
import { W3CBaggagePropagator, W3CTraceContextPropagator, CompositePropagator } from '@opentelemetry/core';
import { resourceFromAttributes } from '@opentelemetry/resources';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { piiRedactingExporter } from './pii-redaction.js';

propagation.setGlobalPropagator(new CompositePropagator({
  propagators: [new W3CTraceContextPropagator(), new W3CBaggagePropagator()],
}));

const sdk = new NodeSDK({
  resource: resourceFromAttributes({
    [SemanticResourceAttributes.SERVICE_NAME]: 'auth-service',
    [SemanticResourceAttributes.SERVICE_VERSION]: process.env.GIT_SHA,
    [SemanticResourceAttributes.DEPLOYMENT_ENVIRONMENT]: process.env.ENV,
  }),
  traceExporter: piiRedactingExporter(new OTLPTraceExporter({
    url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT,
  })),
  instrumentations: [getNodeAutoInstrumentations()],
});
sdk.start();
```

---

## Adding baggage

At the request entry point:

```typescript
import { context, propagation } from '@opentelemetry/api';

app.use(async (req, res, next) => {
  const baggage = propagation.createBaggage({
    'user.id': { value: req.user?.id ?? 'anonymous' },
    'tenant.id': { value: req.tenant?.id ?? 'unknown' },
    'session.id': { value: req.session?.id ?? 'none' },
  });
  const ctx = propagation.setBaggage(context.active(), baggage);
  context.with(ctx, () => next());
});
```

From this point on, every child span (HTTP call, DB query, agent invocation,
external API) inherits user.id and tenant.id automatically.

---

## OpenInference for LLM calls

Use the OpenInference semantic conventions so you can swap observability
backends (Langfuse, Laminar, Arize Phoenix) without re-instrumenting:

```typescript
import { OpenAI } from 'openai';
import { OpenAIInstrumentation } from '@arizeai/openinference-instrumentation-openai';
// or @arizeai/openinference-instrumentation-anthropic for Anthropic

registerInstrumentations({ instrumentations: [new OpenAIInstrumentation()] });
```

This adds spans like:
- `llm.provider`: anthropic
- `llm.model`: claude-sonnet-4-6
- `llm.input_messages.0.role`: user
- `llm.input_messages.0.content`: (redacted)
- `llm.token_count.prompt`: 1234
- `llm.token_count.completion`: 567
- `llm.cost_usd`: 0.0122

---

## PII redaction (mandatory)

PII never reaches the observability backend. Implement an inline-redacting
exporter at `observability/pii-redaction.ts`:

```typescript
export function piiRedactingExporter(baseExporter) {
  return {
    export(spans, cb) {
      const redacted = spans.map(span => ({
        ...span,
        attributes: redactObject(span.attributes),
        events: span.events?.map(e => ({ ...e, attributes: redactObject(e.attributes) })),
      }));
      return baseExporter.export(redacted, cb);
    },
    shutdown() { return baseExporter.shutdown(); },

From MILTONADINA/DevOPs, MIT.

More from MILTONADINA/DevOPs

Signals

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

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from MILTONADINA

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get observability-instrument running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying observability-instrument?

CallGet help
Cite this page

observability-instrument skill. Agent Mart. https://agentmart.dev/skills/miltonadina-observability-instrument (last updated 2026-10-24)