-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add hostname, uptime and gateway count providers (#40)
- Loading branch information
Showing
11 changed files
with
387 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package provider | ||
|
||
import ( | ||
"os" | ||
) | ||
|
||
const ( | ||
// HostnameKey is the report key that under which one can find hostname. | ||
HostnameKey = ReportKey("hn") | ||
) | ||
|
||
// NewHostnameProvider creates hostname provider. | ||
func NewHostnameProvider(name string) (Provider, error) { | ||
return &functor{ | ||
f: func() (Report, error) { | ||
hostname, err := os.Hostname() | ||
if err != nil { | ||
return nil, err | ||
} | ||
return Report{ | ||
HostnameKey: hostname, | ||
}, nil | ||
}, | ||
base: base{ | ||
name: name, | ||
kind: "hostname", | ||
}, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package provider | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"k8s.io/client-go/dynamic" | ||
) | ||
|
||
const ( | ||
// GatewayCountKey is report key under which the number of pods in the cluster | ||
// will be provided. | ||
GatewayCountKey = ReportKey("k8s_gateways_count") | ||
// GatewayCountKind represents the pod count provider kind. | ||
GatewayCountKind = Kind(GatewayCountKey) | ||
) | ||
|
||
// NewK8sGatewayCountProvider creates telemetry data provider that will query the | ||
// configured k8s cluster - using the provided client - to get a gateway count from | ||
// the cluster. | ||
func NewK8sGatewayCountProvider(name string, d dynamic.Interface) (Provider, error) { | ||
gvk := schema.GroupVersionResource{ | ||
Group: "gateway.networking.k8s.io", | ||
Version: "v1beta1", | ||
Resource: "gateways", | ||
} | ||
|
||
// TODO: | ||
// consider detecting what resource version is available on the cluster to | ||
// properly report. Alternatively consider reporting version together with | ||
// the count. | ||
return &k8sObjectCount{ | ||
resource: d.Resource(gvk), | ||
gvk: gvk, | ||
base: base{ | ||
name: name, | ||
kind: GatewayCountKind, | ||
}, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters