zero/telemetry: add reporter (#4855)

This commit is contained in:
Denis Mishin 2023-12-20 14:53:06 -05:00 committed by GitHub
parent 3adbc65d37
commit faa2a8652b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 425 additions and 203 deletions

View file

@ -12,6 +12,7 @@ type Option func(*config)
type config struct {
clusterAPIEndpoint string
connectAPIEndpoint string
otelEndpoint string
apiToken string
httpClient *http.Client
downloadURLCacheTTL time.Duration
@ -31,6 +32,13 @@ func WithConnectAPIEndpoint(endpoint string) Option {
}
}
// WithOTELEndpoint sets the OTEL API endpoint
func WithOTELEndpoint(endpoint string) Option {
return func(cfg *config) {
cfg.otelEndpoint = endpoint
}
}
// WithAPIToken sets the API token
func WithAPIToken(token string) Option {
return func(cfg *config) {
@ -77,6 +85,9 @@ func (c *config) validate() error {
if c.connectAPIEndpoint == "" {
return fmt.Errorf("connect API endpoint is required")
}
if c.otelEndpoint == "" {
return fmt.Errorf("OTEL API endpoint is required")
}
if c.apiToken == "" {
return fmt.Errorf("API token is required")
}