Skip to main content
Set threadId, userId, and custom metadata when you open a trace so Lemma can group turns, filter by person, and search extra attributes.

Threads

When one user has a back-and-forth with your agent, each turn is its own trace. Give related turns the same threadId so Lemma groups them into one conversation.

Attach a user id

Set userId / user_id on the trace so Lemma can filter conversations by person.

Attach custom metadata

Attach any custom keys on the trace or a child span. Keys such as firm.slug and plan work; ingest copies each key onto that span as an attribute, so you can filter with attr.<key>:<value>. Use dotted string keys, not nested objects. metadata: { "firm.slug": "acme" } becomes the attribute firm.slug. metadata: { firm: { slug: "acme" } } becomes one object-valued firm attribute and will not filter cleanly.
Filter those traces with attr.firm.slug:acme.
To keep staging data out of production, use a separate Lemma project. The SDK ingest path always stores service_name: "lemma-sdk"; set a custom service name through the OTLP resource service.name.

Context fields

See the trace contract for how each field is sent and normalized.

Next steps

Trace contract

What clients send, what ingest requires, and what Lemma normalizes.

Building high-quality traces

The ideal instrumentation path, with bad → better → best examples.