restapireceiver

package module
v0.0.0-...-6d0ef27 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

README

restapireceiver

A generic open telemetry receiver to scrape metrics from REST API endpoints based on description

Documentation

Index

Constants

View Source
const (
	HEADER_KEY_AUTHORIZATION = "Authorization"
	HEADER_KEY_CONTENT_TYPE  = "Content-Type"
	CONTENT_TYPE_JSON        = "application/json"
)

Variables

This section is empty.

Functions

func NewFactory

func NewFactory() receiver.Factory

NewFactory creates a new receiver factory for SNMP

Types

type Config

type Config struct {
	scraperhelper.ControllerConfig `mapstructure:",squash"`
	Endpoint                       string `mapstructure:"endpoint"`
	AuthToken                      string `mapstructure:"auth_token"`
	Username                       string `mapstructure:"username"`
	Password                       string `mapstructure:"password"`
}

func (*Config) Validate

func (c *Config) Validate() error

type HttpClient

type HttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type HttpClientHelper

type HttpClientHelper struct {
	Client        HttpClient
	CommonHeaders map[string]string
}

func NewHttpClientHelper

func NewHttpClientHelper() *HttpClientHelper

func (*HttpClientHelper) ExecuteJsonRequest

func (h *HttpClientHelper) ExecuteJsonRequest(req *http.Request) (map[string]interface{}, error)

func (*HttpClientHelper) NewGetRequest

func (h *HttpClientHelper) NewGetRequest(url string) (*http.Request, error)

func (*HttpClientHelper) NewJsonRequest

func (h *HttpClientHelper) NewJsonRequest(method, url, body string) (*http.Request, error)

func (*HttpClientHelper) NewPostJsonRequest

func (h *HttpClientHelper) NewPostJsonRequest(url, body string) (*http.Request, error)

func (*HttpClientHelper) NewPutJsonRequest

func (h *HttpClientHelper) NewPutJsonRequest(url, body string) (*http.Request, error)

func (*HttpClientHelper) NewRequest

func (h *HttpClientHelper) NewRequest(method, url string, body io.Reader) (*http.Request, error)

func (*HttpClientHelper) SetAuthToken

func (h *HttpClientHelper) SetAuthToken(token string)

func (*HttpClientHelper) SetBasicAuth

func (h *HttpClientHelper) SetBasicAuth(username, password string)

type MetricsBuilder

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

func NewMetricsBuilder

func NewMetricsBuilder() *MetricsBuilder

func (MetricsBuilder) GetMetrics

func (builder MetricsBuilder) GetMetrics() pmetric.Metrics

func (*MetricsBuilder) GetOrCreateResource

func (builder *MetricsBuilder) GetOrCreateResource(resourceAttributes map[string]any, scope_name, scope_version string) (*ResourceBuilder, error)

type ResourceBuilder

type ResourceBuilder struct {
	pmetric.ResourceMetrics
}

func (*ResourceBuilder) AddGaugeMetricDouble

func (rb *ResourceBuilder) AddGaugeMetricDouble(metricName, unit string, value float64, timestamp time.Time)

func (*ResourceBuilder) AddGaugeMetricInt

func (rb *ResourceBuilder) AddGaugeMetricInt(metricName, unit string, value int64, timestamp time.Time)

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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