Topic 4 of 5 · 5 min read
Retention for logs, traces and embeddings
Goal: Map every store where a user's PII lands in an LLM app and set a retention period and deletion path for each.
List every place a user's text is copied to, give each place a retention period, and build one path that deletes a user's data from all of them. If you cannot delete it, you should not store it.
Check yourself · 1 of 3
A user asks to delete their account. Their chats were also embedded into a vector index with no user_id metadata. What is the problem?
Why it matters
An LLM app copies text far more than a normal app. One chat message can land in the app database, request logs, a tracing tool, an evaluation set, a prompt cache, a vector store and the provider's side. GDPR Article 5 asks for storage limitation, and Article 17 gives people the right to erasure. A deletion request that clears only the main database is a failed request.
How to do it
- Draw the map. Follow one message end to end and write each store on a list: database, application logs, traces (spans often hold full prompts), analytics events, error reports, eval and fine-tuning datasets, caches, vector index, backups, provider storage.
- Choose what to keep. For each store ask: is the raw text needed at all? Often a trace only needs the model name, token counts and latency. OpenTelemetry's guidance on sensitive data suggests filtering attributes before export.
- Set a time to live (TTL). Short for debugging stores (days), explicit for the rest. Write the number next to the store in your docs, and enforce it in the system, not in a calendar reminder.
- Key everything by user id. Embeddings are the easy one to forget: a chunk with no
user_idin its metadata cannot be found and deleted later. - Build one delete path. A
deleteUser(userId)job that touches every store on the list and reports what it removed. - Handle backups honestly. State how long backups live, so deletion completes within a known window.
// one entry per store: owner of the rule, TTL, how to delete by user
export const stores = [
{ name: "chat_messages", ttlDays: 90, deleteByUser: (id) => db.messages.deleteMany({ userId: id }) },
{ name: "traces", ttlDays: 7, deleteByUser: (id) => tracing.deleteByAttr("user.id", id) },
{ name: "vector_index", ttlDays: 90, deleteByUser: (id) => index.delete({ filter: { user_id: id } }) },
{ name: "eval_set", ttlDays: 30, deleteByUser: (id) => evals.purge(id) },
];
Before and after
Before: traces keep full prompts forever, the vector index has no user key, and "delete account" removes one table.
After: traces keep metadata for seven days, every chunk carries user_id, and the delete job runs through the whole list and logs a count per store.
What goes wrong
- Embeddings treated as anonymous. A vector can often be traced back to the source text, so treat it as personal data.
- Eval sets built from production. Real conversations copied into a test set outlive every TTL.
- Caches nobody owns. A semantic cache can serve one user's answer, containing their data, to another.
Examples
Mapping one chat message
A support chat message lands in six places: the messages table, request logs, a tracing span, a chunk in the vector index, a nightly eval export and the semantic cache. Only the first had a delete path. The team added the other five to the store list and gave each a TTL.
Metadata-only traces
Traces stored the full prompt as a span attribute. A collector processor now drops prompt and completion and keeps model, token counts and latency. Debugging still works for most issues, and the trace store no longer needs PII-level controls.
Key points
- Follow one message through the app and list every store that holds a copy.
- Give each store a written TTL and enforce it in the system, not by memory.
- Tag every embedding chunk with the user id so it can be found and deleted.
- Build one delete-by-user job that covers all stores and reports counts.
- Treat embeddings, eval sets and caches as personal data when they come from user text.
Common mistakes
- Deleting from the main database only and calling the request complete.
- Storing embeddings with no user id, so they can never be located.
- Copying production conversations into eval sets that never expire.
- Setting no TTL because 'we may need it for debugging'.
Check yourself · 2 of 3
Traces currently store the full prompt as a span attribute. Which change reduces risk most while keeping debugging useful?
Check yourself · 3 of 3
Which is the best way to make retention rules reliable?
Practice items, not counted towards your mastery.
Start here
- Microsoft Presidio: PII detection and anonymization (opens in a new tab)ToolFree
The open-source analyzer and anonymizer used in the redaction examples, with recognizers and operators.
- LLM02:2025 Sensitive Information Disclosure (OWASP GenAI) (opens in a new tab)StandardFree
Names how LLM apps leak personal data and lists sanitization and access-control mitigations.
- Your data (OpenAI API guide) (opens in a new tab)DocsFree
Shows what an API provider stores, for how long, and which controls (retention, storage flags) you can change.
More for this topic
- Art. 17 GDPR: Right to erasure (opens in a new tab)StandardFree
What a delete-my-data request requires, which your vector stores and logs must be able to meet.
- Art. 5 GDPR: Principles relating to processing of personal data (opens in a new tab)StandardFree
The legal text behind data minimisation and storage limitation, in plain reading order.
- Handling sensitive data (OpenTelemetry) (opens in a new tab)DocsFree
How to keep personal data out of traces and logs with attribute filtering and processors.