Installation and setup
agentops.init sets up OpenTelemetry tracing and instruments LLM libraries. Its defaults export traces and metrics to AgentOps' servers, with or without a key.
pip install agentops 0.4.21
Install the SDK, the OpenAI client used in lesson 5, and pytest. The version is pinned so the spans you see match the lessons.
pip install "agentops==0.4.21" openai pytestOnly lesson 9, on the hosted dashboard, needs AGENTOPS_API_KEY from an AgentOps account, and you can read it without one. The other lessons send spans to a collector on your own machine.
Where init sends spans
import inspect
from agentops.sdk.core import setup_telemetry
for name, parameter in inspect.signature(setup_telemetry).parameters.items():
if "endpoint" in name:
print(f"{name:18} {parameter.default}")python endpoints.pysetup_telemetry is the function init calls to create the exporters. Traces and metrics go to otlp.agentops.ai unless you pass other endpoints. Reading the source matters here: init also accepts exporter and processor arguments, but in version 0.4.21 setup_telemetry never uses them, so a custom exporter does not stop the default one.
What init takes
| Argument | What it does |
|---|---|
api_key | Your AgentOps key, or AGENTOPS_API_KEY. Without it, the SDK logs a warning and still exports spans. |
exporter_endpoint | Where spans are sent. Lesson 2 points it at your machine. |
endpoint | The AgentOps API, used for authentication and log uploads. |
auto_start_session | Start a trace at init. The course starts traces explicitly. |
instrument_llm_calls | Patch installed LLM libraries such as openai to record their calls. On by default. |
env_data_opt_out | Stop collecting host details such as the operating system. |
- Print every parameter of
agentops.initwithinspect.signature. - Find
AuthenticatedOTLPExporterinagentops/sdk/and read what it adds to each request. - Look for
env_data_opt_outin the source and list what it collects.
Little by little, you're building something great.