Skip to main content

LogAttributesValue

The allowed value types for key-value attributes on traces and spans. Attributes are used as Record<string, LogAttributesValue> throughout the observability API.

Import

import type { LogAttributesValue } from '@adaline/api';

Type Definition

type LogAttributesValue = string | number | boolean;
Attributes are flat key-value pairs where keys are strings and values are one of:
TypeDescriptionExample
stringText metadata'us-east-1', 'user-456'
numberNumeric metadata1234, 0.95, 3
booleanBoolean flagstrue, false

Usage

Attributes appear as Record<string, LogAttributesValue> in these methods:

Examples

Trace Attributes

const trace = monitor.logTrace({
  name: 'Chat Request',
  tags: ['chat', 'production'],
  attributes: {
    userId: 'user-456',
    region: 'us-east-1',
    promptVersion: 3,
    isPremium: true
  }
});

Span Attributes

const span = trace.logSpan({
  name: 'OpenAI Call',
  tags: ['llm'],
  attributes: {
    model: 'gpt-4o',
    temperature: 0.7,
    cached: false
  }
});

Updating Attributes

trace.update({
  attributes: {
    latencyMs: 1234,
    tokenCount: 567,
    cacheHit: true
  }
});

span.update({
  attributes: {
    retryCount: 2,
    statusCode: 200
  }
});

Typed Helper

import type { LogAttributesValue } from '@adaline/api';

function buildAttributes(
  userId: string,
  latencyMs: number,
  cached: boolean
): Record<string, LogAttributesValue> {
  return { userId, latencyMs, cached };
}

trace.update({
  attributes: buildAttributes('user-456', 320, false)
});

  • Trace — accepts attributes via logTrace() and trace.update()
  • Span — accepts attributes via logSpan() and span.update()
  • Monitor — entry point for creating traces with attributes