Files
flagger/pkg/metrics/factory.go
T
Yusuke Kuoka 6661406b75 Metrics provider for deployments and services behind Envoy
Assumes `envoy:smi` as the mesh provider name as I've successfully tested the progressive delivery for Envoy + Crossover with it.

This enhances Flagger to translate it to the metrics provider name of `envoy` for deployment targets, or `envoy:service` for service targets.

The `envoy` metrics provider is equivalent to `appmesh`, as both relies on the same set of standard metrics exposed by Envoy itself.

The `envoy:service` is almost the same as the `envoy` provider, but removing the condition on pod name, as we only need to filter on the backing service name = envoy_cluster_name. We don't consider other Envoy xDS implementations that uses anything that is different to original servicen ames as `envoy_cluster_name`, for now.

Ref #385
2019-11-30 13:03:01 +09:00

59 lines
1.1 KiB
Go

package metrics
import (
"strings"
"time"
)
type Factory struct {
Client *PrometheusClient
}
func NewFactory(metricsServer string, timeout time.Duration) (*Factory, error) {
client, err := NewPrometheusClient(metricsServer, timeout)
if err != nil {
return nil, err
}
return &Factory{
Client: client,
}, nil
}
func (factory Factory) Observer(provider string) Interface {
switch {
case provider == "none":
return &HttpObserver{
client: factory.Client,
}
case provider == "kubernetes":
return &HttpObserver{
client: factory.Client,
}
case provider == "appmesh", provider == "envoy":
return &EnvoyObserver{
client: factory.Client,
}
case provider == "nginx":
return &NginxObserver{
client: factory.Client,
}
case strings.HasPrefix(provider, "gloo"):
return &GlooObserver{
client: factory.Client,
}
case provider == "appmesh:service", provider == "envoy:service":
return &EnvoyServiceObserver{
client: factory.Client,
}
case provider == "linkerd":
return &LinkerdObserver{
client: factory.Client,
}
default:
return &IstioObserver{
client: factory.Client,
}
}
}