Documentation
¶
Overview ¶
Package dtcmiddleware provides a middleware for the Developer Credit Tracker.
Index ¶
Constants ¶
View Source
const (
// EstimateCostKey is a context key for estimating cost
EstimateCostKey contextKey = "estimateCost"
)
Variables ¶
View Source
var ( // DCTRequestLatency measures the latency of DCT requests DCTRequestLatency = promauto.NewHistogramVec( prometheus.HistogramOpts{ Name: "telemetry_credit_tracker_grpc_request_latency_seconds", Help: "Latency of Credit Tracker GRPC requests in seconds", Buckets: prometheus.DefBuckets, }, []string{"operation"}, ) )
View Source
var ErrOperationNotSet = errors.New("operation not set")
Functions ¶
func EstimateCostHeaderMiddleware ¶ added in v0.1.22
EstimateCostHeaderMiddleware injects estimate cost header into the context
Types ¶
type DCT ¶
type DCT struct {
Tracker *credittracker.Client
CostCalculator *pricing.CostCalculator
}
DCT provides a GraphQL middleware for the Developer Credit Tracker.
func NewDCT ¶
func NewDCT(tracker *credittracker.Client, costCalculator *pricing.CostCalculator) *DCT
NewDCT creates a new DCT middleware with default values.
func (DCT) ExtensionName ¶
ExtensionName returns the name of this extension.
func (DCT) InterceptResponse ¶
func (d DCT) InterceptResponse( ctx context.Context, next graphql.ResponseHandler, ) *graphql.Response
InterceptResponse intercepts GraphQL responses to handle errors from the credit tracker.
type EstimateCostResponse ¶ added in v0.1.22
type EstimateCostResponse struct {
EstimatedCredits uint64 `json:"estimatedCredits"`
Message string `json:"message"`
QueryBreakdown *pricing.CostBreakdown `json:"queryBreakdown"`
}
Click to show internal directories.
Click to hide internal directories.