Custom Attributes

neatlogs.* attributes for TOOL, RETRIEVER, RERANKER, GUARDRAIL, and VECTOR_STORE spans.

When building custom logic, set neatlogs.* attributes on your spans so the dashboard can render the right visualizations. These are the same attributes automatically populated by supported libraries. Setting them manually on custom implementations gives you identical dashboard views.

TOOL

The @span(kind="TOOL", tool_name="...", description="...") decorator sets these automatically. Use the context manager when you need finer control:

import neatlogs

with neatlogs.trace("search_web", kind="TOOL") as span:
    span.set_attribute("neatlogs.tool.name", "search_web")
    span.set_attribute("neatlogs.tool.description", "Search the web for information")
    result = my_search_api(query)
AttributeTypeDescription
neatlogs.tool.namestrTool identifier
neatlogs.tool.descriptionstrWhat the tool does
neatlogs.tool.parametersstr (JSON)Parameter schema

RETRIEVER

import neatlogs

with neatlogs.trace("retrieve_docs", kind="RETRIEVER") as span:
    span.set_attribute("neatlogs.retriever.query", query)
    span.set_attribute("neatlogs.retriever.top_k", top_k)
    docs = my_custom_retriever.search(query, k=top_k)
    for i, doc in enumerate(docs):
        span.set_attribute(f"neatlogs.retriever.documents.{i}", doc)
AttributeTypeDescription
neatlogs.retriever.querystrSearch query
neatlogs.retriever.top_kintNumber of results requested
neatlogs.retriever.documents.{i}strEach retrieved document, indexed (.0, .1, …)

RERANKER

import json
import neatlogs

with neatlogs.trace("rerank", kind="RERANKER") as span:
    span.set_attribute("neatlogs.reranker.query", query)
    span.set_attribute("neatlogs.reranker.top_k", top_n)
    span.set_attribute("neatlogs.reranker.model_name", "cohere-rerank-v3")
    span.set_attribute("neatlogs.reranker.input_documents", json.dumps(docs))
    reranked = my_reranker.rerank(query, docs, top_n=top_n)
    span.set_attribute("neatlogs.reranker.output_documents", json.dumps(reranked))
AttributeTypeDescription
neatlogs.reranker.querystrOriginal search query
neatlogs.reranker.top_kintNumber of results to keep
neatlogs.reranker.model_namestrReranker model name (optional)
neatlogs.reranker.input_documentsstr (JSON)Documents before reranking
neatlogs.reranker.output_documentsstr (JSON)Documents after reranking

GUARDRAIL

import neatlogs

with neatlogs.trace("safety_check", kind="GUARDRAIL") as span:
    span.set_attribute("neatlogs.guardrail.input", content_to_check)
    passed, message = run_safety_check(content_to_check)
    span.set_attribute("neatlogs.guardrail.passed", passed)
    span.set_attribute("neatlogs.guardrail.output", message)
AttributeTypeDescription
neatlogs.guardrail.inputstrContent being checked
neatlogs.guardrail.passedboolWhether the check passed (the dashboard shows Passed / Blocked)
neatlogs.guardrail.outputstrValidation result or failure reason

VECTOR_STORE

import neatlogs

with neatlogs.trace("index_documents", kind="VECTOR_STORE") as span:
    span.set_attribute("neatlogs.vectordb.index_name", "support_kb")
    span.set_attribute("neatlogs.vectordb.embedding_model", "text-embedding-3-small")
    span.set_attribute("neatlogs.vectordb.vector_dimension", 1536)
    my_custom_store.upsert(docs)
AttributeTypeDescription
neatlogs.vectordb.index_namestrCollection or index name
neatlogs.vectordb.embedding_modelstrEmbedding model used
neatlogs.vectordb.vector_dimensionintDimension of stored vectors
neatlogs.vectordb.similarity_algorithmstrDistance metric (e.g., cosine)

On this page

Ask Neatlogs AI

Answers from the docs

How can I help?

Ask anything about instrumenting, tracing, or the Neatlogs dashboard.