Skip to content

datarobot-oss/datarobot-agent-skills / skills/datarobot-external-agent-monitoring

datarobot-external-agent-monitoring

Verified

Instrument any external or existing AI agent with OpenTelemetry to send traces, logs, and metrics to DataRobot for monitoring, observability, and governance. Use when the user says "add tracing/observability/monitoring to my agent", wants to instrument an existing agent project in their IDE, wants to send agent traces, logs, or metrics to DataRobot, or wants to record and replay agent trajectories (Tensile) from DataRobot traces.

FileKindSize
SKILL.mdskill md19.1 KB
frameworks/crewai.mdmarkdown2.9 KB
frameworks/generic-python.mdmarkdown6.7 KB
frameworks/google-adk.mdmarkdown14.7 KB
frameworks/langchain-langgraph.mdmarkdown5.0 KB
frameworks/llamaindex.mdmarkdown3.3 KB
frameworks/pydantic-ai.mdmarkdown8.0 KB
reference/dr_otel_config.mdmarkdown8.5 KB
scripts/create_shell_deployment.pyexecutablescript6.3 KB
scripts/create_use_case.pyexecutablescript4.0 KB
scripts/verify_otel_connection.pyexecutablescript5.9 KB

scripts/create_use_case.py

View on GitHub
#!/usr/bin/env python3
# Copyright (c) 2026 DataRobot, Inc. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

"""Resolve a DataRobot Use Case to use as the OTel telemetry target.

A Use Case is the default (primary) telemetry entity for external agent
monitoring: telemetry is associated with it via the `experiment_container`
entity type, and traces appear under the Use Case's Tracing tab. This works
for both DataRobot-native agents and agents built elsewhere (brownfield).

Two modes:
    --use-case-id <id>   Validate an existing Use Case the user already has.
    --name "<name>"      Create a new Use Case (when the user has none yet).

Usage:
    python create_use_case.py --name "My Agent Monitoring"
    python create_use_case.py --use-case-id 6123abc...

Env vars:
    DATAROBOT_API_TOKEN  - DataRobot API token
    DATAROBOT_ENDPOINT   - DataRobot API endpoint (e.g. https://app.datarobot.com/api/v2)
"""

from __future__ import annotations

import argparse
import json
import os
import sys

import datarobot as dr


def _base_url(api_endpoint: str) -> str:
    """Strip a trailing /api/v2 to get the instance base URL."""
    base = api_endpoint.rstrip("/")
    base = base.removesuffix("/api/v2")
    return base


def _result(use_case: dr.UseCase, api_endpoint: str) -> dict:
    """Build the telemetry-target descriptor for a Use Case.

    Two id forms for the same Use Case, used in different places:
      * ``entity_id`` (``experiment_container-<id>``) — the OTel export header /
        ``DATAROBOT_ENTITY_ID`` at runtime.
      * ``view_command`` uses the *bare* ``use_case.id`` — ``dr xp`` expects the
        unprefixed id (``--entity-type`` defaults to ``experiment_container``).
    """
    return {
        "use_case_id": use_case.id,
        "entity_id": f"experiment_container-{use_case.id}",
        "otel_endpoint": f"{_base_url(api_endpoint)}/otel",
        "view_command": f"dr xp --entity-id {use_case.id} --enable-logs --enable-metrics",
    }


def resolve_use_case(
    name: str | None, description: str | None, use_case_id: str | None
) -> dict:
    """Validate an existing Use Case or create a new one for telemetry.

    Args:
        name: Display name for a Use Case to create (create mode).
        description: Optional description for the new Use Case (auto if omitted).
        use_case_id: Existing Use Case ID to validate and reuse (validate mode).

    Returns:
        Dict with use_case_id, entity_id, otel_endpoint, and view_command.
    """
    token = os.getenv("DATAROBOT_API_TOKEN")
    endpoint = os.getenv("DATAROBOT_ENDPOINT", "https://app.datarobot.com/api/v2")

    if not token:
        print("Error: DATAROBOT_API_TOKEN env var is required", file=sys.stderr)
        sys.exit(1)

    dr.Client(token=token, endpoint=endpoint)

    if use_case_id:
        # Validate mode: confirm the Use Case exists and is reachable.
        use_case = dr.UseCase.get(use_case_id)
    else:
        # Create mode: auto-describe when no description is provided.
        use_case = dr.UseCase.create(
            name=name,
            description=description
            or f"OTel telemetry target for external agent monitoring ({name})",
        )

    return _result(use_case, endpoint)


if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        description="Resolve a DataRobot Use Case as an external agent OTel target"
    )
    # Validate an existing Use Case or create a new one — exactly one, never both.
    target = parser.add_mutually_exclusive_group(required=True)
    target.add_argument(
        "--use-case-id",
        dest="use_case_id",
        help="Existing Use Case ID to validate and reuse (validate mode)",
    )
    target.add_argument(
        "--name",
        help="Display name for a new Use Case (create mode)",
    )
    parser.add_argument(
        "--description",
        default="",
        help="Optional description for the new Use Case (auto-generated if omitted)",
    )
    args = parser.parse_args()

    result = resolve_use_case(args.name, args.description, args.use_case_id)
    print(json.dumps(result, indent=2))
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 323kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 323kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 323kUpdated Claude CodeCodexVerifiedInstall