youlessobserver

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

README

youless-observer

Latest release Build status Image size Go Report Card Documentation

Service youless-observer is a real-time utility usage observer for the YouLess energy meter device. It collects metrics data and can send it to any OTEL compatible backend, or expose it via a Prometheus compatible metrics endpoint.

Key features are:

  • export metrics via OTLP
  • expose metrics for Prometheus

Need to store the metrics data for a longer period of time? Have a look at youless-logger.

Installation

The recommended way to run youless-observer is by using the available Docker image. A Helm chart is also available to easily deploy the service inside a Kubernetes cluster.

Documentation

Additional detailed documentation is available at pkg.go.dev

Created with

License

Copyright © 2024 Roel Schut. All rights reserved.

This project is governed by a BSD-style license that can be found in the LICENSE file.

Documentation

Index

Constants

View Source
const (
	ErrAlreadyStarted errors.Msg = "observer is already started"
	ErrUnstartedStop  errors.Msg = "cannot stop observer that is not started"
)
View Source
const MeterReadingObserverName = "youless.observer.meter"
View Source
const PhaseReadingObserverName = "youless.observer.phase"
View Source
const Version = "0.2.0"

Version of the package and its app.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger interface {
	Register(name string)
	ObserverStart()
	ObserverStop()
}

func NopLogger

func NopLogger() Logger

type MeterReadingRegisterer

type MeterReadingRegisterer struct {
	ExcludePower bool
	ExcludeS0    bool
	ExcludeGas   bool
	ExcludeWater bool
	// contains filtered or unexported fields
}

func NewMeterReadingRegisterer

func NewMeterReadingRegisterer(client *youlessclient.Client) *MeterReadingRegisterer

func (*MeterReadingRegisterer) CanRegister added in v0.2.0

func (reg *MeterReadingRegisterer) CanRegister() bool

func (*MeterReadingRegisterer) Register

func (reg *MeterReadingRegisterer) Register(meter metric.Meter) (Registration, error)

Register registers metrics gauges to the provided meter and starts observing them by getting meter readings from the client.

func (*MeterReadingRegisterer) WithClient

type Observer

type Observer struct {
	// contains filtered or unexported fields
}

func NewObserver

func NewObserver(prov metric.MeterProvider, opts ...Option) (*Observer, error)

func (*Observer) RegisterHealthCheckers

func (o *Observer) RegisterHealthCheckers(registerer healthcheck.Registerer)

func (*Observer) Start

func (o *Observer) Start() error

Start the Observer by registering all the provided Registerer(s) to a metric.Meter created by the provided metric.Provider.

func (*Observer) Stop

func (o *Observer) Stop() error

Stop the Observer by unregistering all the previously registered callbacks.

type Option

type Option func(o *Observer) error

func WithLogger

func WithLogger(l Logger) Option

func WithMeterReading

func WithMeterReading(reg MeterReadingRegisterer, client *youlessclient.Client) Option

func WithPhaseReading

func WithPhaseReading(reg PhaseReadingRegisterer, client *youlessclient.Client) Option

func WithRegisterer

func WithRegisterer(name string, reg Registerer) Option

type PhaseReadingRegisterer

type PhaseReadingRegisterer struct {
	ExcludePower bool
	SinglePhase  bool
	// contains filtered or unexported fields
}

func NewPhaseReadingRegisterer

func NewPhaseReadingRegisterer(client *youlessclient.Client) *PhaseReadingRegisterer

func (*PhaseReadingRegisterer) CanRegister added in v0.2.0

func (reg *PhaseReadingRegisterer) CanRegister() bool

func (*PhaseReadingRegisterer) Register

func (reg *PhaseReadingRegisterer) Register(meter metric.Meter) (Registration, error)

Register registers metrics gauges to the provided meter and starts observing them by getting phase readings from the client.

func (*PhaseReadingRegisterer) WithClient

type Registerer

type Registerer interface {
	CanRegister() bool
	Register(meter metric.Meter) (Registration, error)
}

type Registration

type Registration interface {
	LastCheck() time.Time
	Unregister() error
}

Directories

Path Synopsis
app
cmd

Jump to

Keyboard shortcuts

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