forked from gsn/predictor
added simulate stages. Changed GSN_PREDICTOR_GRIB_TTL to 48h
This commit is contained in:
parent
c4f355a32e
commit
fe207f3fab
21 changed files with 978 additions and 137 deletions
|
|
@ -9,16 +9,15 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-faster/errors"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
|
||||
"github.com/ogen-go/ogen/conv"
|
||||
ht "github.com/ogen-go/ogen/http"
|
||||
"github.com/ogen-go/ogen/otelogen"
|
||||
"github.com/ogen-go/ogen/uri"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.37.0"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
func trimTrailingSlashes(u *url.URL) {
|
||||
|
|
@ -103,8 +102,9 @@ func (c *Client) sendPerformPrediction(ctx context.Context, params PerformPredic
|
|||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("performPrediction"),
|
||||
semconv.HTTPRequestMethodKey.String("GET"),
|
||||
semconv.HTTPRouteKey.String("/api/v1/prediction"),
|
||||
semconv.URLTemplateKey.String("/api/v1/prediction"),
|
||||
}
|
||||
otelAttrs = append(otelAttrs, c.cfg.Attributes...)
|
||||
|
||||
// Run stopwatch.
|
||||
startTime := time.Now()
|
||||
|
|
@ -345,6 +345,32 @@ func (c *Client) sendPerformPrediction(ctx context.Context, params PerformPredic
|
|||
return res, errors.Wrap(err, "encode query")
|
||||
}
|
||||
}
|
||||
{
|
||||
// Encode "simulate_stages" parameter.
|
||||
cfg := uri.QueryParameterEncodingConfig{
|
||||
Name: "simulate_stages",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
}
|
||||
|
||||
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
if params.SimulateStages != nil {
|
||||
return e.EncodeArray(func(e uri.Encoder) error {
|
||||
for i, item := range params.SimulateStages {
|
||||
if err := func() error {
|
||||
return e.EncodeValue(conv.StringToString(string(item)))
|
||||
}(); err != nil {
|
||||
return errors.Wrapf(err, "[%d]", i)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return res, errors.Wrap(err, "encode query")
|
||||
}
|
||||
}
|
||||
{
|
||||
// Encode "interpolate" parameter.
|
||||
cfg := uri.QueryParameterEncodingConfig{
|
||||
|
|
@ -434,8 +460,9 @@ func (c *Client) sendReadinessCheck(ctx context.Context) (res *ReadinessResponse
|
|||
otelAttrs := []attribute.KeyValue{
|
||||
otelogen.OperationID("readinessCheck"),
|
||||
semconv.HTTPRequestMethodKey.String("GET"),
|
||||
semconv.HTTPRouteKey.String("/ready"),
|
||||
semconv.URLTemplateKey.String("/ready"),
|
||||
}
|
||||
otelAttrs = append(otelAttrs, c.cfg.Attributes...)
|
||||
|
||||
// Run stopwatch.
|
||||
startTime := time.Now()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue