Decorators
Two decorators are available: @observe for tracing-only instrumentation, and @endpoint for functions that Rhesis can invoke from the platform (remote testing) while still emitting traces.
Observe vs endpoint
@observe follows the same mental model as typical observability tools (OpenTelemetry, Langfuse, and similar): the function runs inside your normal application context—database handles, auth, config, and dependency injection are already in place when your code calls the function. The decorator records spans; it does not change who triggers execution or supply missing infrastructure.
@endpoint does two things:
- Observability — Like
@observe, execution is traced (unless you turn tracing off). When your app calls the function locally, it behaves like other instrumented code. - Remote invocation from Rhesis — The function is registered with Rhesis so the platform can call it over the connector (WebSocket): for example when you start a test run from Rhesis and the runner needs to execute your LLM path in your environment. That path is not an HTTP request to your server—you are not required to expose a public URL—Rhesis triggers the decorated function directly from the product.
So observability-only frameworks never have to “create” your dependencies: they observe code that is already running in a full stack. Remote runs from Rhesis do not have FastAPI’s Depends(), Flask’s g, or an incoming request. Parameters your business logic needs (sessions, tenant DB, user) must still exist at invocation time. For that, use bind on @endpoint so infrastructure is injected while only the business arguments stay in the remote signature. See Parameter Binding.
When to use which
| Situation | Decorator |
|---|---|
| Helpers, retrieval, LLM wrappers: trace only, always called from your app | @observe (or @observe.* helpers) |
| Entry points Rhesis should list and run from test runs / the platform, with tracing | @endpoint |
You can compose them: an @endpoint handler often calls @observe-decorated helpers internally.
@endpoint
Functions decorated with @endpoint are registered for remote testing and are automatically traced by default. Use this for the code paths you want Rhesis to trigger from the platform (for example ad-hoc runs and automated test suites), not only for passive observation.
See the Connector documentation for full details on @endpoint.
Disabling Tracing
To register for remote testing without tracing:
@observe
Use @observe for functions that only need tracing: they are not registered as remotely invocable SDK endpoints. Typical examples are internal helpers, retrieval, and LLM calls your application orchestrates itself.
Convenience Decorators
Pre-configured decorators for common AI operations, organized by category.
AI Model Operations
@observe.llm()
For language model calls.
| Parameter | Required | Description |
|---|---|---|
provider | Yes | Provider name (openai, anthropic, google) |
model | Yes | Model name (gpt-4, claude-3-opus) |
@observe.embedding()
For embedding generation.
| Parameter | Required | Description |
|---|---|---|
model | Yes | Embedding model name |
dimensions | No | Vector dimensions |
Tool & Retrieval
@observe.tool()
For tool/function execution.
| Parameter | Required | Description |
|---|---|---|
name | Yes | Tool name |
tool_type | Yes | Type (http, function, database) |
@observe.retrieval()
For vector search and knowledge base queries.
| Parameter | Required | Description |
|---|---|---|
backend | Yes | Backend name (pinecone, weaviate, chroma) |
top_k | No | Number of results |
@observe.rerank()
For reranking search results.
| Parameter | Required | Description |
|---|---|---|
model | Yes | Reranker model name |
top_n | No | Number of results to return |
Quality & Safety
@observe.evaluation()
For response evaluation and scoring.
| Parameter | Required | Description |
|---|---|---|
metric | Yes | Metric name (relevance, faithfulness) |
evaluator | Yes | Evaluator model/service |
@observe.guardrail()
For content safety and moderation.
| Parameter | Required | Description |
|---|---|---|
guardrail_type | Yes | Type (content_safety, pii_detection, toxicity) |
provider | Yes | Provider name |
Data Processing
@observe.transform()
For data transformation and preprocessing.
| Parameter | Required | Description |
|---|---|---|
transform_type | Yes | Type (text, image, audio) |
operation | Yes | Operation (clean, normalize, tokenize) |
Comparison
| Feature | @observe | @endpoint |
|---|---|---|
| Traces execution | Yes | Yes (default; can disable) |
| Registered for Rhesis to invoke (e.g. test runs from the platform) | No | Yes |
Needs bind for infra when invoked remotely | N/A | Often (see binding) |
| Use case | Helpers, instrumented stack | Callable entry points for tests and connector |
Usage Pattern
Next: Learn about custom spans for advanced attribute configuration.