mirror of
https://github.com/hanzoai/otel-collector.git
synced 2026-11-03 02:20:04 +00:00
## Pull Request This PR bumps collector version to `0.144.0` by upgrading upstream contrib components. The breaking change involves change in `ServerConfig` struct which adds `NetAddr` to streamline Endpoint string and Transport type, which is new OTel convention. This change affects all the Signoz components which were using ServerConfig to adapt to new convention, and thats why affects the respective test cases. Bug fix: #773 for more info. Component Initialisation had duplicate factory registration bug in case any components had deprecated alias. Which is also fixed in this PR. ### Related Issues <!-- Reference any related issues (e.g. Fixes #123, Closes #456) --> Closes #773 ### Resource Impact **Will this change affect the application's resource usage?** - [ ] Yes - [ ] No If **Yes**, describe: - **Resources impacted:** (CPU, Memory, Disk, Network, etc.) - **Expected change:** (e.g., +10% CPU, -150MB RAM) - **Benchmarks:** Provide before/after results and how they were measured. <!-- Ideally the test should be done where you keep ingestion rate and configuration same and observe the changes in CPU, Memory, Ingestion Rate and the Lag on Kafka>
76 lines
2.7 KiB
Go
76 lines
2.7 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 (
|
|
"errors"
|
|
"strings"
|
|
"time"
|
|
|
|
"go.opentelemetry.io/collector/component"
|
|
"go.opentelemetry.io/collector/config/confighttp"
|
|
)
|
|
|
|
type ResponseBodySettings struct {
|
|
// Healthy represents the body of the response returned when the collector is healthy.
|
|
// The default value is ""
|
|
Healthy string `mapstructure:"healthy"`
|
|
|
|
// Unhealthy represents the body of the response returned when the collector is unhealthy.
|
|
// The default value is ""
|
|
Unhealthy string `mapstructure:"unhealthy"`
|
|
}
|
|
|
|
// Config has the configuration for the extension enabling the health check
|
|
// extension, used to report the health status of the service.
|
|
type Config struct {
|
|
confighttp.ServerConfig `mapstructure:",squash"`
|
|
|
|
// Path represents the path the health check service will serve.
|
|
// The default path is "/".
|
|
Path string `mapstructure:"path"`
|
|
|
|
// ResponseBody represents the body of the response returned by the health check service.
|
|
// This overrides the default response that it would return.
|
|
ResponseBody *ResponseBodySettings `mapstructure:"response_body"`
|
|
|
|
// CheckCollectorPipeline contains the list of settings of collector pipeline health check
|
|
CheckCollectorPipeline checkCollectorPipelineSettings `mapstructure:"check_collector_pipeline"`
|
|
}
|
|
|
|
var _ component.Config = (*Config)(nil)
|
|
var (
|
|
errNoEndpointProvided = errors.New("bad config: endpoint must be specified")
|
|
errInvalidExporterFailureThresholdProvided = errors.New("bad config: exporter_failure_threshold expects a positive number")
|
|
errInvalidPath = errors.New("bad config: path must start with /")
|
|
)
|
|
|
|
// Validate checks if the extension configuration is valid
|
|
func (cfg *Config) Validate() error {
|
|
_, err := time.ParseDuration(cfg.CheckCollectorPipeline.Interval)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if cfg.NetAddr.Endpoint == "" {
|
|
return errNoEndpointProvided
|
|
}
|
|
if cfg.CheckCollectorPipeline.ExporterFailureThreshold <= 0 {
|
|
return errInvalidExporterFailureThresholdProvided
|
|
}
|
|
if !strings.HasPrefix(cfg.Path, "/") {
|
|
return errInvalidPath
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type checkCollectorPipelineSettings struct {
|
|
// Enabled indicates whether to not enable collector pipeline check.
|
|
Enabled bool `mapstructure:"enabled"`
|
|
// Interval the time range to check healthy status of collector pipeline
|
|
Interval string `mapstructure:"interval"`
|
|
// ExporterFailureThreshold is the threshold of exporter failure numbers during the Interval
|
|
ExporterFailureThreshold int `mapstructure:"exporter_failure_threshold"`
|
|
}
|