Skip to main content

Overview

The III SDK provides a context-aware Logger that automatically attaches trace IDs, span IDs, and function names to every log message. Access it via getContext().logger inside function handlers.

Quick Start

Logger API

Methods

Parameters

  • message (string): Human-readable log message
  • data (optional): Structured data to attach (objects, arrays, primitives)

Automatic Context Attributes

The Logger automatically attaches these attributes to every log:

Context Propagation

1

Logger is created per function invocation

Each function call gets a unique Logger instance with its own trace context:
2

Trace IDs propagate across services

When function A calls function B, the trace context is automatically propagated:

Severity Levels

Structured Logging

Always pass structured data (objects) instead of interpolating strings:

Fallback Behavior

When OpenTelemetry is disabled or not initialized, the Logger falls back to standard console/logging:

Accessing the Active Span

Consuming Logs

Best Practices

Logging Best Practices:
  • ✅ Use getContext().logger instead of console.log
  • ✅ Always pass structured data (objects) to the data parameter
  • ✅ Use appropriate severity levels (info for normal flow, error for failures)
  • ✅ Log at decision points (validation, errors, external calls)
  • ✅ Include relevant IDs (userId, orderId, requestId) in log data
  • ✅ Avoid logging sensitive data (passwords, tokens, PII)
  • ✅ Use trace?.recordException(error) for automatic error tracking
  • ✅ Keep log messages concise and searchable (don’t include dynamic data in message)

Example: Full Context Usage