Skip to content

monocle2ai/examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Monocle examples

This repo contains examples applications with steps to run these with Monocle tracing enabled in VS Code. Follow the steps listed below to configure dev environment and VS Code. Then navigate to individual examples folders to try out various agentic apps with Monocle.

alt text

Setup dev enviroment

This section illustrates steps to setup your VS Code to use Monocle.

Pre-requistis

  • Visual Studio Code, version 1.102 or above
  • Python, version 3.10 or above
  • Github Copilot for VS Code enabled
  • VS Code has MCP server enabled
  • UV package installed
    • Use pip command to install UV package. Note that you should be installing this in a global python env on your machine and not in a local/virtual python env
    • pip install uv
    • Restart VS Code if it's already running.

Install Monocle VS code extension

The Monocle VS Code extension makes it super simple to setup the instrumentation and visualize the traces

  • Navigate to 'Extensions' open in VS Code
  • In the search box, type Monocle
  • From the search result list, choose extension 'Monocle' and click install

Setup Monocle MCP server

The Monocle MCP server contains a set of prompts to analyze traces and provide a recommendations. The MCP server is part of the monocle pip package that can be installed in VS Code and invoked by the VS Code's Github Copilot.

  • Goto VS code Command Pelette by using following keystrokes
    • Windows and Linux: Press Ctl + Shift + P
    • MacOS: Press Cmd + Shift + P
  • Type following command and press enter
    • MCP: Add Server
  • Select 'Pip package' option
  • When prompted for package name, enter monocle_apptrace
  • Allow VS Code to install this package
  • When prompted to 'Enter Server ID', enter monocle
  • When prompted for 'Select where to install', choose Global
  • At thist point, VS Code will open a file called mcp.json which contains the list of configured MCP servers.
  • Verify that the file has an entry monocle

Setup Python virtual env

  • Open a shell/terminal window
  • Clone this git repository
  • Goto repository folder (eg cd examples)
  • Create python virtual envirmonment python -m venv .env

Monocle Examples

Following are the python agentic examples. Please follow the steps in individual example Readme file to install the required libraries and run the app.

Python

  1. Travel agent example implemented using Google ADK
  2. Travel agent example implemented using Langgraph

Get trace summary using Github copilot and Monocle MCP

After you run the example, these steps outlines how to get insights from the trace.

  • Open the trace json file under .monocle folder under the repository root
  • Open Github copilot window pane
    • Linux and Windows: Ctl + Shift + I
    • Mac: Cmd + Shift + I
  • Look up Monocle prompt to analyze trace from Monocle MCP server:
    • Press '/' in the copilot chat windows
    • It will list the available prompts.
    • Select mcp.monocle.analyze from that list
  • This will extract a prompt from Monocle MCP server and show it in the Agent chat box
  • Click the Send button at the bottom of the Agent chat box
  • Review the trace analysis generated by the Github copilot

About

Samples to demonstrate how Monocle works for agentic applications

Topics

Resources

License

Stars

Watchers

Forks

Languages