Skip to content

Commit

Permalink
Add telemetry endpoint and serve if defined
Browse files Browse the repository at this point in the history
For customers who have an agreement to disable telemetry,
they can "GET" the data and send it in another way.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Jul 10, 2024
1 parent 9a4a75a commit e7f4919
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ func Serve(ctx context.Context, handlers *types.FaaSHandlers, config *types.FaaS
handlers.Info = auth.DecorateWithBasicAuth(handlers.Info, credentials)
handlers.Secrets = auth.DecorateWithBasicAuth(handlers.Secrets, credentials)
handlers.Logs = auth.DecorateWithBasicAuth(handlers.Logs, credentials)

if handlers.Telemetry != nil {
handlers.Telemetry = auth.DecorateWithBasicAuth(handlers.Telemetry, credentials)
}
}

hm := newHttpMetrics()
Expand Down Expand Up @@ -102,6 +106,10 @@ func Serve(ctx context.Context, handlers *types.FaaSHandlers, config *types.FaaS
r.HandleFunc("/healthz", handlers.Health).Methods(http.MethodGet)
}

if handlers.Telemetry != nil {
r.HandleFunc("/system/telemetry", hm.InstrumentHandler(handlers.Telemetry, "")).Methods(http.MethodGet)
}

r.HandleFunc("/metrics", promhttp.Handler().ServeHTTP)

readTimeout := config.ReadTimeout
Expand Down
2 changes: 2 additions & 0 deletions types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ type FaaSHandlers struct {
Health http.HandlerFunc

Info http.HandlerFunc

Telemetry http.HandlerFunc
}

// FaaSConfig set config for HTTP handlers
Expand Down
4 changes: 4 additions & 0 deletions types/function_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,8 @@ type FunctionDeployment struct {
type FunctionResources struct {
Memory string `json:"memory,omitempty"`
CPU string `json:"cpu,omitempty"`

NvidiaGPU string `json:"nvidia.com/gpu,omitempty"`
AmdGPU string `json:"amd.com/gpu,omitempty"`
IntelGPU string `json:"intel.com/gpu,omitempty"`
}

0 comments on commit e7f4919

Please sign in to comment.