Skip to content

Commit

Permalink
feat: add metrics for provider
Browse files Browse the repository at this point in the history
Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>

chore: update to latest version of otel

Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
  • Loading branch information
aramase committed Sep 9, 2021
1 parent 385f9d4 commit bd713cd
Show file tree
Hide file tree
Showing 14 changed files with 899 additions and 450 deletions.
16 changes: 13 additions & 3 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"syscall"
"time"

"github.com/Azure/secrets-store-csi-driver-provider-azure/pkg/metrics"
"github.com/Azure/secrets-store-csi-driver-provider-azure/pkg/provider"
"github.com/Azure/secrets-store-csi-driver-provider-azure/pkg/server"
"github.com/Azure/secrets-store-csi-driver-provider-azure/pkg/utils"
Expand Down Expand Up @@ -41,6 +42,9 @@ var (
// driverWriteSecrets feature is enabled by default in v0.1.0 release. All writes to the pod filesystem will now be done by the CSI driver instead of provider.
// this flag will be removed in the future.
driverWriteSecrets = flag.Bool("driver-write-secrets", true, "[DEPRECATED] Return secrets in gRPC response to the driver (supported in driver v0.0.21+) instead of writing to filesystem")

metricsBackend = flag.String("metrics-backend", "Prometheus", "Backend used for metrics")
prometheusPort = flag.Int("prometheus-port", 8898, "Prometheus port for metrics backend")
)

func main() {
Expand Down Expand Up @@ -71,6 +75,11 @@ func main() {
klog.ErrorS(http.ListenAndServe(addr, nil), "unable to start profiling server")
}()
}
// initialize metrics exporter before creating measurements
err := metrics.InitMetricsExporter(*metricsBackend, *prometheusPort)
if err != nil {
klog.Fatalf("failed to initialize metrics exporter, error: %+v", err)
}

if *provider.ConstructPEMChain {
klog.Infof("construct pem chain feature enabled")
Expand Down Expand Up @@ -103,12 +112,13 @@ func main() {
}

opts := []grpc.ServerOption{
grpc.UnaryInterceptor(utils.LogGRPC),
grpc.UnaryInterceptor(utils.LogInterceptor()),
}
s := grpc.NewServer(opts...)
k8spb.RegisterCSIDriverProviderServer(s, &server.CSIDriverProviderServer{})
csiDriverProviderServer := server.New()
k8spb.RegisterCSIDriverProviderServer(s, csiDriverProviderServer)
// Register the health service.
grpc_health_v1.RegisterHealthServer(s, &server.CSIDriverProviderServer{})
grpc_health_v1.RegisterHealthServer(s, csiDriverProviderServer)

klog.Infof("Listening for connections on address: %v", listener.Addr())
go s.Serve(listener)
Expand Down
59 changes: 36 additions & 23 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,52 @@ go 1.17

require (
github.com/Azure/azure-sdk-for-go v52.4.0+incompatible
github.com/Azure/go-autorest/autorest v0.11.1
github.com/Azure/go-autorest/autorest/adal v0.9.5
github.com/Azure/go-autorest/autorest v0.11.18
github.com/Azure/go-autorest/autorest/adal v0.9.13
github.com/Azure/go-autorest/autorest/to v0.4.0 // indirect
github.com/Azure/go-autorest/autorest/validation v0.3.1 // indirect
github.com/google/go-cmp v0.5.2
github.com/kubernetes-csi/csi-lib-utils v0.7.1
github.com/google/go-cmp v0.5.5
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.6.1
golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b
google.golang.org/grpc v1.31.0
gopkg.in/yaml.v2 v2.3.0
k8s.io/component-base v0.20.2
k8s.io/klog/v2 v2.5.0
sigs.k8s.io/secrets-store-csi-driver v0.0.21
github.com/stretchr/testify v1.7.0
go.opentelemetry.io/otel v0.20.0
go.opentelemetry.io/otel/exporters/metric/prometheus v0.20.0
go.opentelemetry.io/otel/metric v0.20.0
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83
golang.org/x/net v0.0.0-20210520170846-37e1c6afe023
google.golang.org/grpc v1.38.0
gopkg.in/yaml.v2 v2.4.0
k8s.io/component-base v0.22.0
k8s.io/klog/v2 v2.9.0
sigs.k8s.io/secrets-store-csi-driver v0.3.0
)

require (
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
github.com/Azure/go-autorest/logger v0.2.0 // indirect
github.com/Azure/go-autorest/logger v0.2.1 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/form3tech-oss/jwt-go v3.2.2+incompatible // indirect
github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect
github.com/go-logr/logr v0.4.0 // indirect
github.com/golang/protobuf v1.4.3 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
go.uber.org/atomic v1.6.0 // indirect
go.uber.org/multierr v1.5.0 // indirect
go.uber.org/zap v1.15.0 // indirect
golang.org/x/sys v0.0.0-20201112073958-5cba982894dd // indirect
golang.org/x/text v0.3.4 // indirect
google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a // indirect
google.golang.org/protobuf v1.25.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
github.com/prometheus/client_golang v1.11.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.26.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
go.opentelemetry.io/otel/sdk v0.20.0 // indirect
go.opentelemetry.io/otel/sdk/export/metric v0.20.0 // indirect
go.opentelemetry.io/otel/sdk/metric v0.20.0 // indirect
go.opentelemetry.io/otel/trace v0.20.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.17.0 // indirect
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 // indirect
golang.org/x/text v0.3.6 // indirect
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect
google.golang.org/protobuf v1.26.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)

0 comments on commit bd713cd

Please sign in to comment.