Giter VIP home page Giter VIP logo

vscode-autometrics's Introduction

Autometrics

This extension enhances integration between your codebase and Autometrics enhanced functions. If you're new to autometrics, please see our documentation

Currently supported languages:

More languages will be supported in the future.

Features

After decorating your code with autometrics, this extension will enrich the information displayed for a given function on hover.

Enhanced autometrics information

Extension Settings

This extension contributes the following settings:

  • autometrics.prometheusUrl: configure your Prometheus URL. This URL is used to create links to your Prometheus including useful autometrics based queries

  • autometrics.experimentalRustSupport: this option allows you to use the embedded graphs with rust. However currently all functions are assumed to have been decorated with the autometrics macro. You probably don't want to enable this feature.

  • autometrics.graphPreferences: this option allows you to configure what to use to render graphs. The possibilities are:

  • embedded graph (which are demonstrated in the animation above)
  • prometheus (which links out to the prometheus UI)
  • autometrics explorer (which links to the web interface that is bundled with the autometrics CLI: see also local development)
  • autometrics.webServerURL this option is only relevant if you've configured autometrics.graphPreferences to use autometrics explorer. The autometrics CLI serves the web interface on port 6789, however if you use a different port or don't run it on localhost you can update this setting to point to whatever you want.

Developing this extension

This extension is built using:

In order to test the extension locally, you may want to install the following extensions:

If you want to install a release from GitHub manually, open the command palette via cmd + shift + p and pick the install visx option and point the filepicker to your local extension.

How to release a new version

Create a new release using Github which matches the version number it should be released under.

After tagging and releasing, merge main into the release branch. (The release branch should always reflect the latest released version on VSCode marketplate.)

vscode-autometrics's People

Contributors

arendjr avatar brettimus avatar flenter avatar keturiosakys avatar mies avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vscode-autometrics's Issues

๐Ÿ› VSCode extension creates dead Explorer links in function hovers

Environment information

TypeScript Autometrics
===
VSCode Info
Version: 1.80.2
Commit: 2ccd690cbff1569e4a83d7c43d45101f817401dc
Date: 2023-07-27T20:57:59.134Z
Electron: 22.3.14
ElectronBuildId: 22695494
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Darwin arm64 22.6.0

What happened?

Project:

.
โ”œโ”€โ”€ dist
โ”‚  โ”œโ”€โ”€ routes.js
โ”‚  โ”œโ”€โ”€ routes.js.map
โ”‚  โ”œโ”€โ”€ server.js
โ”‚  โ”œโ”€โ”€ server.js.map
โ”‚  โ”œโ”€โ”€ util.js
โ”‚  โ””โ”€โ”€ util.js.map
โ”œโ”€โ”€ package-lock.json
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ rome.json
โ”œโ”€โ”€ src
โ”‚  โ”œโ”€โ”€ routes.ts
โ”‚  โ”œโ”€โ”€ server.ts
โ”‚  โ””โ”€โ”€ util.ts
โ””โ”€โ”€ tsconfig.json

Repro:

  1. Set the graph preferences to Autometrics Explorer
  2. In server.ts when hovering over an Autometrics instrumented function VSCode generates a tooltip with the following link: http://localhost:6789/explorer/#/functions/details/handleGetAllUsers/requestRate

Expected result

This is the correct link it should generate, however:

http://localhost:6789/explorer/#/functions/details/m/%2Fdist%2Fserver.js/handleGetAllUsers

Note the dist in the module name missing.

In my mind there are two options:

  1. Either the extension needs to correctly figure out the module name (might be hard in different languages)
  2. Autometrics Explorer should handle links with just the function names: redirect to the complete URL with the module name or if there are multiple functions with the same names in different modules - show an intermediary selector screen

Clicking on a function in the Autometrics side bar does not show full graphs page

To reproduce:

  • Open the Autometrics side bar
  • Click on one of your functions listed in the sidebar
  • A new tab should open in your editor with the request rate graph
  • No other graphs are present

The issue seems to stem from this line, which calls "Open chart" with an argument of type "function". However, if you change the type to "function_graphs", then the page will not refresh when you click between functions

๐Ÿ› Issues with rendering existing function docstrings inside autometrics tooltips for typescript

Environment information

VS-Code autometrics 0.5.0 inside VSCode Version: 1.82.0 (Universal)

Specifically, looking at a typescript file

What happened?

I added a docstring to a function that was wrapped by autometrics. When I hovered over the function, the docstring I added had been added many, many times to the tooltip.

vscode-typescript-docstrings.mp4

Expected result

I would expect existing docstrings to be preserved, and not repeated tens of times.

Authenticated Prometheus requests

The extension should support using basic auth to authenticate with Prometheus. We may also want to support other auth mechanisms to talk to other hosted Prometheus-compatible solutions

If we support multiple environments (#26), we should also think about how to have the auth details on a per-environment basis.

๐Ÿ› Tooltip does not appear for async functions in Python

Environment information

Autometrics Python v0.5, using VSCode on macOS

What happened?

  1. Decorate an async function in python file
  2. Hover over that async function
  3. No autometrics tooltip appears!

Expected result

Autometrics tooltip should appear for decorated async functions in python

Implement graphs

With #10, the foundation is being laid for implementing graphs inside the VS Code extension. This is a tracking issue for progress. Also feel free to leave ideas and suggestions related to graphs here.

  • Create a TS library for rendering graphs. This will be based on the charts in our Studio product and open-sourced in the fiberplane repository. Done: fiberplane/fiberplane#48
  • Basic integration of the graph library into our extension. Done: #22
  • Update the design, making sure VS Code themes work well
    • add toggle for showing/hiding promql
    • add additional queries for called by metrics
    • add timerange selector/controls
    • make top bar sticky
    • fix resize issue where graphs don't shrink when window is resized
    • charts:
      • use vscode theme colors
      • x-axis should better respect the width (sometimes the tick text overlaps)
    • promql code block:
      • add copy button

Open charts from tooltips

Our Autometrics tooltips contain queries. Currently, those point to external URLs, but when we have charts inside the extension, we want to open them right there for a consistent experience.

One complicating factor is that different languages have different mechanisms for opening tooltips. Some rely on the extension itself, which is likely easier to intercept, but for instance Autometrics-rs generates Rustdoc strings, which we may need to detect somehow.

Charts should consistently open within the extension, regardless of language.

๐Ÿ› Errors from other Typescript extensions can cause Autometrics to show a toast error notification

Environment information

VSCode on macOS

What happened?

I received intermittent toast notifications of errors, and they suggested they were coming from the Autometrics extension.

When I investigated, it turns out they were coming from a tailwind intellisense extension, which had some sort of typescript incompatibility.

Expected result

I would not expect Autometrics to show errors that are due to other extensions. I thought that Autometrics was the culprit, but it was not

I needed to disable/enable the extension to make links appear in Typescript popovers

After I installed the language server plugin and added it to my tsconfig, I still did not see any links in the tooltips for autometrics functions. (I double checked that I was using the project's locally installed typescript.)

image

I restarted the language server, but that still didn't work. I had to disable/enable the Autometrics VSCode extension before links would appear in the popovers.

Filing this issue in case it is something that other people run into

Add Rust support

Before we have a believable beta we should at least support our flagship language: Rust

This is currently blocked by #29.

Finalizing this is also blocked by autometrics-dev/autometrics-rs#80, although we shouldn't have to wait with the implementation. Until the environment variable is supported, we would just have 2 doc tooltips which would be confusing.

Display error "toast" if we cannot connect to Prometheus

We should make sure that if Prometheus isn't configured yet or correctly, that we give some proper feedback to the user. Most likely we want to opt for a toast-like notification, which are built into VS Code. Clicking it should open the settings page.

Add support for linking to `am` cli's explorer

Right now the extensions supports:

  • using its builtin graphs
  • linking out to prometheus

But it would be good to add another option and that is to link to the am cli's explorer.

What needs to be done for this?

  • Add an option to the graph preferences option:
image * Add an option for specifying the am webserver URL (with the default value: http://localhost:6789) * Language support: for python, typescript (and if experimental rust support is enabled) the logic for tooltips should be updated to use localhost:6789 URL and for rust if experimental support isn't enabled, we should configure the prometheus URL by setting the PROMETHEUS_URL env var for the rust-analyzer

Add overview screen

We need some kind of a welcome screen for the extension, something that can show aggregates such as response times over all functions that are autometricized. Other ideas welcome :)

Add vscode command to open autometrics extension settings

To configure the prometheus url for my extension I needed to first open the extension, click the gear icon, and then manually edit the prometheus URL.

It would be nice to be able to use the command menu to open the config page, as other extensions do:

image

Export to Notebook

When the graphs are implemented, we also want to offer functionality to export a chart as a cell to a Fiberplane Notebook.

For now, this is blocked by #12

Support renamed metrics

All queries should be updated in the following way:

  • Any references to the function call counter should be identified using {__name__=~"function_calls(_count)?(_total)?"}
  • Any references to the histogram should be identified using {__name__=~"function_calls_duration(_seconds)?_bucket"} or _count/_sum

Implement parser for detecting Autometrics annotations

Currently the Python implementation uses a regular expression to detect Autometrics annotations. In order to implement Rust support, this approach would not be sufficient, since Rust can annotate entire impl blocks with a single annotation, which would be too complex to parse with a regex.

To solve this, we need to implement a proper parsing solution in the extension. Something like Tree-sitter might be an option, since it supports all the languages we want to support as well, but other options may be fine too.

Only functions with recent metrics are discovered in sidebar

The new Autometrics sidebar does function discovery by issuing an instant query for the function_calls_count metric and looking at the labels of the metrics coming back. Unfortunately, Prometheus only seems to return metrics for labels that have been recently used, so that functions that don't get used often/recently don't come back.

Related issue: prometheus/prometheus#11181

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.