Skip to main content
Threadify is a service-delivery intelligence system. The Threadify SDK supports converting standard OpenTelemetry (OTel) traces into Threadify’s service-delivery concepts, thereby providing deep, actionable intelligence into exactly how you are delivering to your customers. If your application is already instrumented with OpenTelemetry (OTel), you do not need to manually add thread.step() calls throughout your codebase. Instead, you can use the Threadify OpenTelemetry Exporter to seamlessly translate your existing traces into Threadify execution graphs.

The Mapping Model

The Threadify Exporter automatically translates the highly technical OTel hierarchy into business-friendly language:
OpenTelemetry ConceptThreadify ConceptDescription
TraceThreadA Trace represents an entire business workflow (e.g., Customer Checkout).
SpanStepA Span represents a major operation (e.g., process_payment).
Span EventSub-StepAn Event is a specific milestone during the operation (e.g., validated_card).
Span LinkLinkComing Soon.

Status Mapping

The Exporter automatically translates the OpenTelemetry SpanStatus into Threadify step outcomes. This ensures that technical failures (and even ambiguous states) are correctly captured as service-delivery intelligence.
Span StatusThreadify OutcomeRationale
SpanStatus.OKsuccessExplicitly marked as successful by the developer.
SpanStatus.ERRORfailedExplicitly marked as a failure or exception.
SpanStatus.UNSETsuccessThe default status. Threadify treats “no error” as a successful delivery.
By following the standard OpenTelemetry convention where UNSET implies success, Threadify ensures zero-friction integration for existing instrumented applications.

1. Setup the Exporter

Integrating the exporter into your application takes just a few lines of code. You initialize the Exporter and register it with your global OpenTelemetry TracerProvider.
import { Threadify } from '@threadify/sdk';
import { trace } from '@opentelemetry/api';
import { BasicTracerProvider, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';

// 1. Establish your Threadify Connection
const connection = await Threadify.connect('your-api-key', 'your-service');

// 2. Create the Threadify Exporter
// Map span attributes to Threadify "Refs" using custom ref keys
const exporter = connection.createSpanExporter({
  refs: { orderId: 'order.id', customerId: 'customer.id' }
});

// Optionally filter out noisy spans by name (exact match or prefix wildcard with *)
const exporter = connection.createSpanExporter({
  refs: { orderId: 'order.id', customerId: 'customer.id' },
  filters: ['invoke_llm', 'adk.before*', 'llm.*']
});

// 3. Attach the Exporter to OpenTelemetry
const provider = new BasicTracerProvider({
  spanProcessors: [new SimpleSpanProcessor(exporter)]
});
trace.setGlobalTracerProvider(provider);
By default, the Exporter will automatically push Spans to Threadify whenever they end. It manages the underlying Threadify Thread lifecycles for you transparently.

2. Filtering Spans

Some applications generate a high volume of internal or utility spans that you may not want to send to Threadify. Use the filters (Node.js/Go) or "filters" (Python) option to drop spans by name before they are exported.
Filter PatternBehaviorExample Match
"invoke_llm"Exact matchinvoke_llm
"adk.before*"Prefix wildcard (*)adk.before_tool_call, adk.before
"llm.*"Prefix wildcard (*)llm.chat_completion, llm.
Filters are applied on the span name only. Trailing * acts as a prefix wildcard. Empty filters are skipped.

3. Using OpenTelemetry Natively

Once configured, you simply use the standard OpenTelemetry API. You do not need to import or call Threadify directly in your business logic!
// Get your standard OTel tracer
const tracer = trace.getTracer('my-service-tracer');

// Start a span (This automatically ensures a Thread exists in Threadify)
const span = tracer.startSpan('process_payment');

// Set explicit Threadify mapping overrides (Optional)
// This tells Threadify to validate this thread against the 'payment_workflow' contract
span.setAttribute('threadify.contract', 'payment_workflow');

// Tag the thread for filtering and categorization
span.setAttribute('threadify.tags', ['production', 'v2.1']);

// Set attributes
span.setAttribute('order.id', 'ORD-98765'); // Extracted as a Ref (based on setup)
span.setAttribute('payment.amount', 42.50); // Extracted as standard Context

// Add Span Events (These automatically become Threadify Sub-Steps!)
span.addEvent('validated_credit_card', {
  'card.type': 'visa',
  'fraud.score': 0.05
});

// Simulate work...
await processPayment();

// End the span (This triggers the Exporter and pushes the Step to Threadify)
span.end();

4. Advanced Attributes (Optional)

If you want finer control over how a specific Span maps to Threadify, you can set the following special threadify.* attributes on your Span. If omitted, the Exporter will use sensible defaults.
AttributeDescriptionDefault Fallback
threadify.contractThe Contract Name to validate this workflow against.null (Schema-less Thread)
threadify.step_nameOverride the Step name in Threadify.Uses span.name
threadify.thread_idForce the Span to attach to a specific existing Thread ID.Auto-generates a new Thread per Trace
threadify.labelThe human-readable label for the Thread.Uses span.name
threadify.serviceOverride the service name that executed this step.Uses the connection’s default service
threadify.tagsImmutable labels attached to the thread at creation time (e.g., production, v2.1).null
Any attributes starting with threadify.ref.* or threadify.context.* will be explicitly mapped to references or context respectively, bypassing the default configuration rules.