clientmiddleware

package
v0.0.0-kmdagger2 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueryPubdash   = "pubdash"
	QueryDashboard = "dashboard"
)

Variables

View Source
var QueryCachingRequestHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{
	Namespace: metrics.ExporterName,
	Subsystem: "caching",
	Name:      "query_caching_request_duration_seconds",
	Help:      "histogram of grafana query endpoint requests in seconds",
	Buckets:   []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 25, 50, 100},
}, []string{"datasource_type", "cache", "query_type"})
View Source
var ResourceCachingRequestHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{
	Namespace: metrics.ExporterName,
	Subsystem: "caching",
	Name:      "resource_caching_request_duration_seconds",
	Help:      "histogram of grafana resource endpoint requests in seconds",
	Buckets:   []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 25, 50, 100},
}, []string{"plugin_id", "cache"})

Functions

func NewCachingMiddleware

func NewCachingMiddleware(cachingService caching.CachingService) plugins.ClientMiddleware

NewCachingMiddleware creates a new plugins.ClientMiddleware that will attempt to read and write query results to the cache

func NewClearAuthHeadersMiddleware

func NewClearAuthHeadersMiddleware() plugins.ClientMiddleware

NewClearAuthHeadersMiddleware creates a new plugins.ClientMiddleware that will clear any outgoing HTTP headers that was part of the incoming HTTP request and used when authenticating to Grafana.

func NewCookiesMiddleware

func NewCookiesMiddleware(skipCookiesNames []string) plugins.ClientMiddleware

NewCookiesMiddleware creates a new plugins.ClientMiddleware that will forward incoming HTTP request Cookies to outgoing plugins.Client requests if the datasource has enabled forwarding of cookies (keepCookies).

func NewHTTPClientMiddleware

func NewHTTPClientMiddleware() plugins.ClientMiddleware

NewHTTPClientMiddleware creates a new plugins.ClientMiddleware that will forward plugin request headers as outgoing HTTP headers.

func NewOAuthTokenMiddleware

func NewOAuthTokenMiddleware(oAuthTokenService oauthtoken.OAuthTokenService) plugins.ClientMiddleware

NewOAuthTokenMiddleware creates a new plugins.ClientMiddleware that will set OAuth token headers on outgoing plugins.Client requests if the datasource has enabled Forward OAuth Identity (oauthPassThru).

func NewResourceResponseMiddleware

func NewResourceResponseMiddleware() plugins.ClientMiddleware

NewResourceResponseMiddleware creates a new plugins.ClientMiddleware that will enforce HTTP header rules for backend.CallResourceResponse's.

func NewTracingHeaderMiddleware

func NewTracingHeaderMiddleware() plugins.ClientMiddleware

NewTracingHeaderMiddleware creates a new plugins.ClientMiddleware that will populate useful tracing headers on outgoing plugins.Client and HTTP requests. Tracing headers are X-Datasource-Uid, X-Dashboard-Uid, X-Panel-Id, X-Grafana-Org-Id.

func NewTracingMiddleware

func NewTracingMiddleware(tracer tracing.Tracer) plugins.ClientMiddleware

NewTracingMiddleware returns a new middleware that creates a new span on every method call.

func NewUserHeaderMiddleware

func NewUserHeaderMiddleware() plugins.ClientMiddleware

NewUserHeaderMiddleware creates a new plugins.ClientMiddleware that will populate the X-Grafana-User header on outgoing plugins.Client requests.

Types

type CachingMiddleware

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

func (*CachingMiddleware) CallResource

CallResource receives a resource request and attempts to access results already stored in the cache for that request. If data is found, it will return it immediately. Otherwise, it will perform the request as usual. The caller of CallResource is expected to explicitly update the cache with any responses. If the cache service is implemented, we capture the request duration as a metric. The service is expected to write any response headers.

func (*CachingMiddleware) CheckHealth

func (*CachingMiddleware) CollectMetrics

func (*CachingMiddleware) PublishStream

func (*CachingMiddleware) QueryData

QueryData receives a data request and attempts to access results already stored in the cache for that request. If data is found, it will return it immediately. Otherwise, it will perform the queries as usual, then write the response to the cache. If the cache service is implemented, we capture the request duration as a metric. The service is expected to write any response headers.

func (*CachingMiddleware) RunStream

func (*CachingMiddleware) SubscribeStream

type ClearAuthHeadersMiddleware

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

func (*ClearAuthHeadersMiddleware) CallResource

func (*ClearAuthHeadersMiddleware) CheckHealth

func (*ClearAuthHeadersMiddleware) CollectMetrics

func (*ClearAuthHeadersMiddleware) PublishStream

func (*ClearAuthHeadersMiddleware) QueryData

func (*ClearAuthHeadersMiddleware) RunStream

func (*ClearAuthHeadersMiddleware) SubscribeStream

type CookiesMiddleware

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

func (*CookiesMiddleware) CallResource

func (*CookiesMiddleware) CheckHealth

func (*CookiesMiddleware) CollectMetrics

func (*CookiesMiddleware) PublishStream

func (*CookiesMiddleware) QueryData

func (*CookiesMiddleware) RunStream

func (*CookiesMiddleware) SubscribeStream

type HTTPClientMiddleware

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

func (*HTTPClientMiddleware) CallResource

func (*HTTPClientMiddleware) CheckHealth

func (*HTTPClientMiddleware) CollectMetrics

func (*HTTPClientMiddleware) PublishStream

func (*HTTPClientMiddleware) QueryData

func (*HTTPClientMiddleware) RunStream

func (*HTTPClientMiddleware) SubscribeStream

type OAuthTokenMiddleware

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

func (*OAuthTokenMiddleware) CallResource

func (*OAuthTokenMiddleware) CheckHealth

func (*OAuthTokenMiddleware) CollectMetrics

func (*OAuthTokenMiddleware) PublishStream

func (*OAuthTokenMiddleware) QueryData

func (*OAuthTokenMiddleware) RunStream

func (*OAuthTokenMiddleware) SubscribeStream

type ResourceResponseMiddleware

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

func (*ResourceResponseMiddleware) CallResource

func (*ResourceResponseMiddleware) CheckHealth

func (*ResourceResponseMiddleware) CollectMetrics

func (*ResourceResponseMiddleware) PublishStream

func (*ResourceResponseMiddleware) QueryData

func (*ResourceResponseMiddleware) RunStream

func (*ResourceResponseMiddleware) SubscribeStream

type TracingHeaderMiddleware

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

func (*TracingHeaderMiddleware) CallResource

func (*TracingHeaderMiddleware) CheckHealth

func (*TracingHeaderMiddleware) CollectMetrics

func (*TracingHeaderMiddleware) PublishStream

func (*TracingHeaderMiddleware) QueryData

func (*TracingHeaderMiddleware) RunStream

func (*TracingHeaderMiddleware) SubscribeStream

type TracingMiddleware

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

func (*TracingMiddleware) CallResource

func (*TracingMiddleware) CheckHealth

func (*TracingMiddleware) CollectMetrics

func (*TracingMiddleware) PublishStream

func (*TracingMiddleware) QueryData

func (*TracingMiddleware) RunStream

func (*TracingMiddleware) SubscribeStream

type UserHeaderMiddleware

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

func (*UserHeaderMiddleware) CallResource

func (*UserHeaderMiddleware) CheckHealth

func (*UserHeaderMiddleware) CollectMetrics

func (*UserHeaderMiddleware) PublishStream

func (*UserHeaderMiddleware) QueryData

func (*UserHeaderMiddleware) RunStream

func (*UserHeaderMiddleware) SubscribeStream

Jump to

Keyboard shortcuts

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