Documentation ¶
Index ¶
- Constants
- Variables
- func Bind(ctx context.Context, instance *Telemetry) context.Context
- func CredentialsRequestMetric(factory CredentialsRequestMetricParameters) (metric.Int64Counter, error)
- func QueryDurationMetric(factory QueryDurationMetricParameters) (metric.Float64Histogram, error)
- func RequestDurationMetric(factory RequestDurationMetricParameters) (metric.Float64Histogram, error)
- func Unbind(ctx context.Context) context.Context
- type Attribute
- type AttributeConfiguration
- type CheckRequestInterface
- type CheckRequestTupleKeyInterface
- type Configuration
- type Counter
- type CredentialsRequestMetricParameters
- type Histogram
- type Metric
- type MetricConfiguration
- type MetricInterface
- type Metrics
- func (m *Metrics) AttributesFromQueryDuration(attrs map[*Attribute]string) (float64, map[*Attribute]string, error)
- func (m *Metrics) AttributesFromRequest(req *http.Request, params map[string]interface{}) (map[*Attribute]string, error)
- func (m *Metrics) AttributesFromRequestDuration(requestStarted time.Time, attrs map[*Attribute]string) (float64, map[*Attribute]string, error)
- func (m *Metrics) AttributesFromResendCount(resendCount int, attrs map[*Attribute]string) (map[*Attribute]string, error)
- func (m *Metrics) AttributesFromResponse(res *http.Response, attrs map[*Attribute]string) (map[*Attribute]string, error)
- func (m *Metrics) BuildTelemetryAttributes(requestMethod string, methodParameters map[string]interface{}, ...) (map[*Attribute]string, float64, float64, error)
- func (m *Metrics) CredentialsRequest(value int64, attrs map[*Attribute]string) (metric.Int64Counter, error)
- func (m *Metrics) GetCounter(name string, description string) (metric.Int64Counter, error)
- func (m *Metrics) GetHistogram(name string, description string, unit string) (metric.Float64Histogram, error)
- func (m *Metrics) PrepareAttributes(metric MetricInterface, attrs map[*Attribute]string, ...) (attribute.Set, error)
- func (m *Metrics) QueryDuration(value float64, attrs map[*Attribute]string) (metric.Float64Histogram, error)
- func (m *Metrics) RequestDuration(value float64, attrs map[*Attribute]string) (metric.Float64Histogram, error)
- type MetricsConfiguration
- type MetricsInterface
- type QueryDurationMetricParameters
- type RequestAuthorizationModelIdInterface
- type RequestDurationMetricParameters
- type Telemetry
- type TelemetryContextKey
- type TelemetryFactoryParameters
- type TelemetryInterface
Constants ¶
View Source
const ( ATTR_FGA_CLIENT_REQUEST_CLIENT_ID = "fga-client.request.client_id" ATTR_FGA_CLIENT_REQUEST_METHOD = "fga-client.request.method" ATTR_FGA_CLIENT_REQUEST_MODEL_ID = "fga-client.request.model_id" ATTR_FGA_CLIENT_REQUEST_STORE_ID = "fga-client.request.store_id" ATTR_FGA_CLIENT_RESPONSE_MODEL_ID = "fga-client.response.model_id" ATTR_FGA_CLIENT_USER = "fga-client.user" ATTR_HTTP_CLIENT_REQUEST_DURATION = "http.client.request.duration" ATTR_HTTP_HOST = "http.host" ATTR_HTTP_REQUEST_METHOD = "http.request.method" ATTR_HTTP_REQUEST_RESEND_COUNT = "http.request.resend_count" ATTR_HTTP_RESPONSE_STATUS_CODE = "http.response.status_code" ATTR_HTTP_SERVER_REQUEST_DURATION = "http.server.request.duration" ATTR_URL_SCHEME = "url.scheme" ATTR_URL_FULL = "url.full" ATTR_USER_AGENT_ORIGINAL = "user_agent.original" )
View Source
const ( METRIC_HISTOGRAM_REQUEST_DURATION string = "fga-client.request.duration" METRIC_HISTOGRAM_QUERY_DURATION string = "fga-client.query.duration" )
View Source
const (
METRIC_COUNTER_CREDENTIALS_REQUEST string = "fga-client.credentials.request"
)
Variables ¶
View Source
var ( FGAClientRequestClientID = &Attribute{Name: ATTR_FGA_CLIENT_REQUEST_CLIENT_ID} FGAClientRequestMethod = &Attribute{Name: ATTR_FGA_CLIENT_REQUEST_METHOD} FGAClientRequestModelID = &Attribute{Name: ATTR_FGA_CLIENT_REQUEST_MODEL_ID} FGAClientRequestStoreID = &Attribute{Name: ATTR_FGA_CLIENT_REQUEST_STORE_ID} FGAClientResponseModelID = &Attribute{Name: ATTR_FGA_CLIENT_RESPONSE_MODEL_ID} FGAClientUser = &Attribute{Name: ATTR_FGA_CLIENT_USER} HTTPClientRequestDuration = &Attribute{Name: ATTR_HTTP_CLIENT_REQUEST_DURATION} HTTPHost = &Attribute{Name: ATTR_HTTP_HOST} HTTPRequestMethod = &Attribute{Name: ATTR_HTTP_REQUEST_METHOD} HTTPRequestResendCount = &Attribute{Name: ATTR_HTTP_REQUEST_RESEND_COUNT} HTTPResponseStatusCode = &Attribute{Name: ATTR_HTTP_RESPONSE_STATUS_CODE} HTTPServerRequestDuration = &Attribute{Name: ATTR_HTTP_SERVER_REQUEST_DURATION} URLScheme = &Attribute{Name: ATTR_URL_SCHEME} URLFull = &Attribute{Name: ATTR_URL_FULL} UserAgent = &Attribute{Name: ATTR_USER_AGENT_ORIGINAL} )
View Source
var ( RequestDuration = &Histogram{ Name: METRIC_HISTOGRAM_REQUEST_DURATION, Unit: "milliseconds", Description: "The total time (in milliseconds) it took for the request to complete, including the time it took to send the request and receive the response.", } QueryDuration = &Histogram{ Name: METRIC_HISTOGRAM_QUERY_DURATION, Unit: "milliseconds", Description: "The total time it took (in milliseconds) for the FGA server to process and evaluate the request.", } )
View Source
var CredentialsRequest = &Counter{ Name: METRIC_COUNTER_CREDENTIALS_REQUEST, Description: "The total number of times new access tokens have been requested using ClientCredentials.", }
Functions ¶
func CredentialsRequestMetric ¶
func CredentialsRequestMetric(factory CredentialsRequestMetricParameters) (metric.Int64Counter, error)
func QueryDurationMetric ¶
func QueryDurationMetric(factory QueryDurationMetricParameters) (metric.Float64Histogram, error)
func RequestDurationMetric ¶
func RequestDurationMetric(factory RequestDurationMetricParameters) (metric.Float64Histogram, error)
Types ¶
type AttributeConfiguration ¶
type AttributeConfiguration struct {
Enabled bool `json:"enabled,omitempty"`
}
type CheckRequestInterface ¶
type CheckRequestInterface interface { GetTupleKey() CheckRequestTupleKeyInterface RequestAuthorizationModelIdInterface }
CheckRequestInterface is a simplified interface that defines the methods the CheckRequest struct implements, relevant to the context of the telemetry package.
type CheckRequestTupleKeyInterface ¶
type CheckRequestTupleKeyInterface interface {
GetUser() *string
}
CheckRequestTupleKeyInterface is a simplified interface that defines the methods the CheckRequestTupleKey struct implements, relevant to the context of the telemetry package.
type Configuration ¶
type Configuration struct {
Metrics *MetricsConfiguration `json:"metrics,omitempty"`
}
func DefaultTelemetryConfiguration ¶
func DefaultTelemetryConfiguration() *Configuration
type Counter ¶
func (*Counter) GetDescription ¶
type CredentialsRequestMetricParameters ¶
type CredentialsRequestMetricParameters struct { Value int64 Attrs map[*Attribute]string TelemetryFactoryParameters }
type Histogram ¶
func (*Histogram) GetDescription ¶
type Metric ¶
type Metric struct { Name string Description string MetricInterface }
func (*Metric) GetDescription ¶
type MetricConfiguration ¶
type MetricConfiguration struct { ATTR_FGA_CLIENT_REQUEST_CLIENT_ID *AttributeConfiguration `json:"fga_client_request_client_id,omitempty"` ATTR_FGA_CLIENT_REQUEST_METHOD *AttributeConfiguration `json:"fga_client_request_method,omitempty"` ATTR_FGA_CLIENT_REQUEST_MODEL_ID *AttributeConfiguration `json:"fga_client_request_model_id,omitempty"` ATTR_FGA_CLIENT_REQUEST_STORE_ID *AttributeConfiguration `json:"fga_client_request_store_id,omitempty"` ATTR_FGA_CLIENT_RESPONSE_MODEL_ID *AttributeConfiguration `json:"fga_client_response_model_id,omitempty"` ATTR_FGA_CLIENT_USER *AttributeConfiguration `json:"fga_client_user,omitempty"` ATTR_HTTP_CLIENT_REQUEST_DURATION *AttributeConfiguration `json:"http_client_request_duration,omitempty"` ATTR_HTTP_HOST *AttributeConfiguration `json:"http_host,omitempty"` ATTR_HTTP_REQUEST_METHOD *AttributeConfiguration `json:"http_request_method,omitempty"` ATTR_HTTP_REQUEST_RESEND_COUNT *AttributeConfiguration `json:"http_request_resend_count,omitempty"` ATTR_HTTP_RESPONSE_STATUS_CODE *AttributeConfiguration `json:"http_response_status_code,omitempty"` ATTR_HTTP_SERVER_REQUEST_DURATION *AttributeConfiguration `json:"http_server_request_duration,omitempty"` ATTR_URL_SCHEME *AttributeConfiguration `json:"url_scheme,omitempty"` ATTR_URL_FULL *AttributeConfiguration `json:"url_full,omitempty"` ATTR_USER_AGENT_ORIGINAL *AttributeConfiguration `json:"user_agent_original,omitempty"` }
type MetricInterface ¶
type Metrics ¶
type Metrics struct { Meter metric.Meter Counters map[string]metric.Int64Counter Histograms map[string]metric.Float64Histogram Configuration *MetricsConfiguration // contains filtered or unexported fields }
func (*Metrics) AttributesFromQueryDuration ¶
func (*Metrics) AttributesFromRequest ¶
func (*Metrics) AttributesFromRequestDuration ¶
func (*Metrics) AttributesFromResendCount ¶
func (*Metrics) AttributesFromResponse ¶
func (*Metrics) BuildTelemetryAttributes ¶
func (*Metrics) CredentialsRequest ¶
func (*Metrics) GetCounter ¶
func (*Metrics) GetHistogram ¶
func (*Metrics) PrepareAttributes ¶
func (m *Metrics) PrepareAttributes(metric MetricInterface, attrs map[*Attribute]string, config *MetricsConfiguration) (attribute.Set, error)
func (*Metrics) QueryDuration ¶
func (*Metrics) RequestDuration ¶
type MetricsConfiguration ¶
type MetricsConfiguration struct { METRIC_COUNTER_CREDENTIALS_REQUEST *MetricConfiguration `json:"fga_client_credentials_request,omitempty"` METRIC_HISTOGRAM_REQUEST_DURATION *MetricConfiguration `json:"fga_client_request_duration,omitempty"` METRIC_HISTOGRAM_QUERY_DURATION *MetricConfiguration `json:"fga_client_query_duration,omitempty"` }
type MetricsInterface ¶
type MetricsInterface interface { GetCounter(name string, description string) (metric.Int64Counter, error) GetHistogram(name string, description string, unit string) (metric.Float64Histogram, error) CredentialsRequest(value int64, attrs map[*Attribute]string) (metric.Int64Counter, error) RequestDuration(value float64, attrs map[*Attribute]string) (metric.Float64Histogram, error) QueryDuration(value float64, attrs map[*Attribute]string) (metric.Float64Histogram, error) BuildTelemetryAttributes(requestMethod string, methodParameters map[string]interface{}, req *http.Request, res *http.Response, requestStarted time.Time, resendCount int) (map[*Attribute]string, float64, float64, error) }
func GetMetrics ¶
func GetMetrics(factory TelemetryFactoryParameters) MetricsInterface
type QueryDurationMetricParameters ¶
type QueryDurationMetricParameters struct { Value float64 Attrs map[*Attribute]string TelemetryFactoryParameters }
type RequestAuthorizationModelIdInterface ¶
type RequestAuthorizationModelIdInterface interface {
GetAuthorizationModelId() *string
}
RequestAuthorizationModelIdInterface is a generic interface that defines the GetAuthorizationModelId() method a Request struct implements, relevant to the context of the telemetry package.
type RequestDurationMetricParameters ¶
type RequestDurationMetricParameters struct { Value float64 Attrs map[*Attribute]string TelemetryFactoryParameters }
type Telemetry ¶
type Telemetry struct { Metrics MetricsInterface Configuration *Configuration }
func Configure ¶
func Configure(configuration *Configuration) (*Telemetry, error)
func Get ¶
func Get(factory TelemetryFactoryParameters) *Telemetry
type TelemetryContextKey ¶
type TelemetryContextKey struct{}
var ( // Warning: do not use directly, it may cause data race. // Deprecated: this map will be renamed to telemetryInstances. TelemetryInstances map[*Configuration]*Telemetry TelemetryContext TelemetryContextKey )
type TelemetryFactoryParameters ¶
type TelemetryFactoryParameters struct {
Configuration *Configuration
}
type TelemetryInterface ¶
type TelemetryInterface interface { Configure(configuration *Configuration) (*Telemetry, error) Get(configuration *Configuration) *Telemetry }
Click to show internal directories.
Click to hide internal directories.