Skip to content
This repository has been archived by the owner on Oct 17, 2023. It is now read-only.

Latest commit

 

History

History
208 lines (146 loc) · 5.68 KB

README.md

File metadata and controls

208 lines (146 loc) · 5.68 KB
**Warning** This repository is moving to official Sidekick Org https://github.com/runsidekick/sidekick-client-node :shipit:

you can get the package from the npm: https://www.npmjs.com/package/@runsidekick/sidekick-client


Logo

Sidekick Node.js client

Node.js client for Sidekick. Send your Sidekick logs and traces to any target in seconds!
Explore the docs »

Sidekick Home · Report Bug & Request Feature

Table of Contents
  1. About
  2. Getting Started
  3. Roadmap
  4. Contact

About Sidekick

Sidekick is a production debugging and on-demand logging tool where you can debug your running applications while they keep on running. Sidekick provides the ability to add logs and put non-breaking breakpoints in your application code which captures the snapshot of the application state, the call stack, variables, etc.

Sidekick Actions:

  • A tracepoint is basically a non-breaking remote breakpoint. In short, it takes a snapshot of the variables when the code hits that line.
  • Logpoints open the way for dynamic logging to Sidekick users. Replacing traditional logging with dynamic logging has the potential to lower stage sizes, costs, and time for log searching while adding the ability to add new logpoints without editing the source code, redeploying or restarting the application

Client Features

  • A tracepoint is basically a non-breaking remote breakpoint. In short, it takes a screenshot of the variables when the code hits that line.
  • Logpoints open the way for dynamic logging to Sidekick users. Replacing

(back to top)

Built With

(back to top)

Prerequisites

tested with node v16.14.2

  • npm
    npm install npm@latest -g

Getting Started

Installation

  1. Install sidekick-client

    npm i sidekick-client
  2. Import sidekickConnect from sidekick-client

        const { sidekickConnect } = require('sidekick-client')
  3. Create an ingest function that will send collected data to desired target:

        function ingestFunc () {
            return async function (data) {
                // Implement your own function to send data to any target
            }
        }
  4. Initialize Sidekick client with proper parameters.

        const { sidekickConnect } = require('sidekickingesterbeta')
    
        const sidekickClient = {
            sidekick_email : <sidekick_email>, 
            sidekick_password : <sidekick_password>, 
            tracepointFunction : ingestFunc(),
            logpointFunction : ingestFunc(),
            stdout : false // enable console log
        }
    
        sidekickConnect(sidekickClient);
        ```

If you have an on-premise setup add the fields below to client object:

 "sidekick_host": "ws://127.0.0.1",
 "sidekick_port": "7777"

If have your user token you can use it instead of email & password :

 "sidekick_token": "<>"

Example usage

You can use Sidekick client with any db integration, here is a elasticsearch integration example:

  1. Create a config.json according to your needs

     "sidekick_tracepoint_index": "sidekick_tracepoint",
     "sidekick_logpoint_index": "sidekick_logpoint",
     "sidekick_email":"<>",
     "sidekick_password":"<>",
  2. Create an ingest function with using elasticsearch client:

        function ingestFunc (index) {
            return async function (data) {
                console.log(JSON.stringify({index,data}));
            }
        }
  3. Call sidekickconnect function with proper parameters.

        const { sidekickConnect } = require('sidekickingesterbeta')
    
        const sidekickClient = {
            sidekick_email : config['sidekick_email'], 
            sidekick_password : config['sidekick_password'], 
            tracepointFunction : ingestFunc(config['sidekick_tracepoint_index']),
            logpointFunction : ingestFunc(config['sidekick_logpoint_index'])
        }
    
        sidekickConnect(sidekickClient);
        ```
    
  4. Run your app!

(back to top)

Roadmap

  • Add websocket support
  • Custom ingest function
  • Add support for programattically putting logpoints & tracepoints

(back to top)

Contact

Barış Kaya - @boroskoyo

Sidekick: website

Special Thanks

Emin Bilgiç - linkedin

(back to top)