Marqo

Marqo is an end-to-end tensor search engine that combines vector search with traditional keyword search. It handles embedding generation, storage, and retrieval in a single platform, supporting text, images, and multimodal search. Respan gives you full observability over every index operation, search query, and embedding step.

Create an account at platform.respan.ai and grab an API key.

Run npx @respan/cli setup to set up with your coding agent.

Setup

1

Install packages

$pip install respan-ai opentelemetry-instrumentation-marqo marqo
2

Set environment variables

$export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"

RESPAN_API_KEY is used to export traces to Respan.

3

Initialize and run

1import marqo
2from respan import Respan
3from opentelemetry.instrumentation.marqo import MarqoInstrumentor
4
5respan = Respan(instrumentations=[MarqoInstrumentor()])
6
7client = marqo.Client(url="http://localhost:8882")
8
9client.create_index("documents", model="hf/e5-base-v2")
10
11client.index("documents").add_documents(
12 [
13 {"title": "AI Observability", "description": "Respan provides tracing for AI applications."},
14 {"title": "Tensor Search", "description": "Marqo combines vector and keyword search."},
15 {"title": "Embeddings", "description": "Embeddings capture semantic meaning as vectors."},
16 ],
17 tensor_fields=["title", "description"],
18)
19
20results = client.index("documents").search("How does AI tracing work?")
21for hit in results["hits"]:
22 print(f"{hit['title']} (score: {hit['_score']:.4f})")
23
24respan.flush()
4

View your trace

Open the Traces page to see your Marqo operation spans with index operations, queries, and embeddings.

Configuration

ParameterTypeDefaultDescription
api_keystr | NoneNoneFalls back to RESPAN_API_KEY env var.
base_urlstr | NoneNoneFalls back to RESPAN_BASE_URL env var.
instrumentationslist[]Plugin instrumentations to activate (e.g. MarqoInstrumentor()).
customer_identifierstr | NoneNoneDefault customer identifier for all spans.
metadatadict | NoneNoneDefault metadata attached to all spans.
environmentstr | NoneNoneEnvironment tag (e.g. "production").

Attributes

In Respan()

1from respan import Respan
2from opentelemetry.instrumentation.marqo import MarqoInstrumentor
3
4respan = Respan(
5 instrumentations=[MarqoInstrumentor()],
6 customer_identifier="user_123",
7 metadata={"service": "search-api", "version": "1.0.0"},
8)

With propagate_attributes

1from respan import Respan, propagate_attributes
2from opentelemetry.instrumentation.marqo import MarqoInstrumentor
3
4respan = Respan(instrumentations=[MarqoInstrumentor()])
5
6def search(user_id: str, query: str):
7 with propagate_attributes(
8 customer_identifier=user_id,
9 thread_identifier="conv_abc_123",
10 metadata={"plan": "pro"},
11 ):
12 return client.index("documents").search(query)
AttributeTypeDescription
customer_identifierstrIdentifies the end user in Respan analytics.
thread_identifierstrGroups related messages into a conversation.
metadatadictCustom key-value pairs. Merged with default metadata.