snap-plugin-lib

module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2021 License: Apache-2.0

README

Snap Plugin Library

Snap Plugin Library helps developers writing plugins (like collectors and publishers) that are able to work in Snap environment:

  • a collector is a small application whose role is to gather metrics from a monitored system (like CPU usage, db metrics, etc.)
  • a publisher is a small application whose role is to send metrics to a specific backend

The library natively supports Go language, although writing Python plugins is also supported via Cgo integration. There is a plan for supporting other programming languages as well.

The currently active and maintained version is v2.

Development setup

For a simple development setup you don't need any dependencies outside this repository. Please refer to Testing for more information.

For a complete development setup please refer to AppOptics Knowledge Base

Example

Writing a simple plugin code in Go is very straightforward:

package main

import (
    "github.com/solarwinds/snap-plugin-lib/v2/plugin"
    "github.com/solarwinds/snap-plugin-lib/v2/runner"
)

type myCollector struct {}

func (c *myCollector) Collect(ctx plugin.CollectContext) error {
    _ = ctx.AddMetric("/example/static/value", 34)
    return nil
}

func main() {
    runner.StartCollector(&myCollector{}, "example-collector", "1.0.0")
}

The same functionality in Python:

from swisnap_plugin_lib_py import BaseCollector, start_collector


class ExamplePlugin(BaseCollector):

    def collect(self, ctx):
        ctx.add_metric("/example/metric/value", 45)


if __name__ == '__main__':
    start_collector(ExamplePlugin("example", "0.0.1"))

More complicated examples can be found in:

Documentation

Plugin Library contains a comprehensive tutorial describing how to write custom plugins.

Covered topics:

Contributing Guide

Issue Reporting Guidelines
  • Always check if the problem wasn't already reported by other developers.
  • Please fill in Issue submission form.
Pull Request Guidelines
  • General:

    • Make sure that the library is compiling without errors,
    • Make sure that ALL unit tests pass,
    • Try to add the accompanying test case,
    • It's OK to have multiple small commits as you work on the PR - they will be squashed before merging,
    • Provide meaningful commit messages.
  • For issues:

    • Add issue number to your PR title for a better release log.
  • For a new development:

    • Provide a convincing reason to add this feature.

Version 1

The repository contains a legacy version of Plugin Library (v1) which is no longer supported either by SolarWinds or Intel (which is originally forked from). New defects raised for v1 won't be fixed by maintainers.

Please use v2 for new development.

Links:

Directories

Path Synopsis
examples module
v1
v2
tutorial Module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL