mirror of
https://github.com/hanzoai/otel-collector.git
synced 2026-11-03 02:20:04 +00:00
- Go module: github.com/SigNoz/signoz-otel-collector → github.com/hanzoai/otel-collector - All signoz-prefixed packages → o11y-prefixed - Docker: signoz/* → ghcr.io/hanzoai/otel-collector - ClickHouse exporter → Hanzo Datastore - Env vars: SIGNOZ_* → HANZO_* - Directory renames for all processor/receiver/exporter packages
79 lines
2.2 KiB
Go
79 lines
2.2 KiB
Go
package o11ymeterconnector
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"go.opentelemetry.io/collector/component"
|
|
"go.opentelemetry.io/collector/connector"
|
|
"go.opentelemetry.io/collector/consumer"
|
|
|
|
"github.com/hanzoai/otel-collector/connectors/o11ymeterconnector/internal/metadata"
|
|
)
|
|
|
|
const (
|
|
defaultMetricsFlushInterval = time.Hour * 1
|
|
)
|
|
|
|
// NewFactory returns a ConnectorFactory.
|
|
func NewFactory() connector.Factory {
|
|
return connector.NewFactory(
|
|
metadata.Type,
|
|
createDefaultConfig,
|
|
connector.WithTracesToMetrics(createTracesToMetrics, metadata.TracesToMetricsStability),
|
|
connector.WithMetricsToMetrics(createMetricsToMetrics, metadata.MetricsToMetricsStability),
|
|
connector.WithLogsToMetrics(createLogsToMetrics, metadata.LogsToMetricsStability),
|
|
)
|
|
}
|
|
|
|
// createDefaultConfig creates the default configuration.
|
|
func createDefaultConfig() component.Config {
|
|
return &Config{
|
|
Dimensions: []Dimension{
|
|
{
|
|
Name: "service.name",
|
|
},
|
|
{
|
|
Name: "deployment.environment",
|
|
},
|
|
{
|
|
Name: "host.name",
|
|
},
|
|
},
|
|
MetricsFlushInterval: defaultMetricsFlushInterval,
|
|
}
|
|
}
|
|
|
|
// createTracesToMetrics creates a traces to metrics connector based on provided config.
|
|
func createTracesToMetrics(ctx context.Context, params connector.Settings, cfg component.Config, nextConsumer consumer.Metrics) (connector.Traces, error) {
|
|
c, err := newConnector(params.Logger, params, cfg)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
c.metricsConsumer = nextConsumer
|
|
|
|
return c, nil
|
|
}
|
|
|
|
// createLogsToMetrics creates a logs to metrics connector based on provided config.
|
|
func createLogsToMetrics(ctx context.Context, params connector.Settings, cfg component.Config, nextConsumer consumer.Metrics) (connector.Logs, error) {
|
|
c, err := newConnector(params.Logger, params, cfg)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
c.metricsConsumer = nextConsumer
|
|
|
|
return c, nil
|
|
}
|
|
|
|
// createMetricsToMetrics creates a metrics to metrics connector based on provided config.
|
|
func createMetricsToMetrics(ctx context.Context, params connector.Settings, cfg component.Config, nextConsumer consumer.Metrics) (connector.Metrics, error) {
|
|
c, err := newConnector(params.Logger, params, cfg)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
c.metricsConsumer = nextConsumer
|
|
|
|
return c, nil
|
|
}
|