mirror of
https://github.com/hanzoai/otel-collector.git
synced 2026-11-03 02:20:04 +00:00
Modules declare go 1.27.1 and the build images follow. go fix applied the modernizers; omitzero is not applied, since it changes what the JSON says. Co-authored-by: Hanzo Dev <[email protected]>
54 lines
1.5 KiB
Go
54 lines
1.5 KiB
Go
// Copyright The OpenTelemetry Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package healthcheckextension // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension"
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"go.opentelemetry.io/collector/component"
|
|
"go.opentelemetry.io/collector/config/confignet"
|
|
"go.opentelemetry.io/collector/extension"
|
|
|
|
"github.com/hanzoai/otel-collector/extension/healthcheckextension/internal/metadata"
|
|
)
|
|
|
|
const defaultPort = 13133
|
|
|
|
// NewFactory creates a factory for HealthCheck extension.
|
|
func NewFactory() extension.Factory {
|
|
return extension.NewFactory(
|
|
metadata.Type,
|
|
createDefaultConfig,
|
|
createExtension,
|
|
metadata.ExtensionStability,
|
|
)
|
|
}
|
|
|
|
func createDefaultConfig() component.Config {
|
|
return &Config{
|
|
NetAddr: confignet.AddrConfig{
|
|
Endpoint: fmt.Sprintf("0.0.0.0:%d", defaultPort),
|
|
Transport: "tcp",
|
|
},
|
|
CheckCollectorPipeline: defaultCheckCollectorPipelineSettings(),
|
|
Path: "/",
|
|
}
|
|
}
|
|
|
|
func createExtension(_ context.Context, set extension.Settings, cfg component.Config) (extension.Extension, error) {
|
|
config := cfg.(*Config)
|
|
|
|
return newServer(*config, set.TelemetrySettings), nil
|
|
}
|
|
|
|
// defaultCheckCollectorPipelineSettings returns the default settings for CheckCollectorPipeline.
|
|
func defaultCheckCollectorPipelineSettings() checkCollectorPipelineSettings {
|
|
return checkCollectorPipelineSettings{
|
|
Enabled: false,
|
|
Interval: "5m",
|
|
ExporterFailureThreshold: 5,
|
|
}
|
|
}
|