Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into pre-release
Browse files Browse the repository at this point in the history
  • Loading branch information
akvlad committed Oct 10, 2024
2 parents f0fc81b + b17cde3 commit e9bce2f
Show file tree
Hide file tree
Showing 16 changed files with 2,551 additions and 1,448 deletions.
33 changes: 27 additions & 6 deletions cmd/otel-collector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ import (
"log"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/confmap"
envprovider "go.opentelemetry.io/collector/confmap/provider/envprovider"
fileprovider "go.opentelemetry.io/collector/confmap/provider/fileprovider"
httpprovider "go.opentelemetry.io/collector/confmap/provider/httpprovider"
httpsprovider "go.opentelemetry.io/collector/confmap/provider/httpsprovider"
yamlprovider "go.opentelemetry.io/collector/confmap/provider/yamlprovider"
"go.opentelemetry.io/collector/otelcol"

_ "github.com/KimMachineGun/automemlimit" // default == 0.9 * cgroup_memory_limit
_ "go.uber.org/automaxprocs" // default == cgroup_cpu_limit
s3provider "github.com/open-telemetry/opentelemetry-collector-contrib/confmap/provider/s3provider"
secretsmanagerprovider "github.com/open-telemetry/opentelemetry-collector-contrib/confmap/provider/secretsmanagerprovider"
_ "go.uber.org/automaxprocs" // default == cgroup_cpu_limit
)

func main() {
Expand All @@ -18,18 +26,31 @@ func main() {
Version: "latest",
}

params := otelcol.CollectorSettings{
Factories: components,
set := otelcol.CollectorSettings{
BuildInfo: info,
Factories: components,
ConfigProviderSettings: otelcol.ConfigProviderSettings{
ResolverSettings: confmap.ResolverSettings{
ProviderFactories: []confmap.ProviderFactory{
envprovider.NewFactory(),
fileprovider.NewFactory(),
httpprovider.NewFactory(),
httpsprovider.NewFactory(),
yamlprovider.NewFactory(),
s3provider.NewFactory(),
secretsmanagerprovider.NewFactory(),
},
},
},
}

if err := run(params); err != nil {
if err := run(set); err != nil {
log.Fatal(err)
}
}

func runInteractive(params otelcol.CollectorSettings) error {
cmd := otelcol.NewCommand(params)
func runInteractive(set otelcol.CollectorSettings) error {
cmd := otelcol.NewCommand(set)
err := cmd.Execute()
if err != nil {
return fmt.Errorf("application run finished with error: %w", err)
Expand Down
4 changes: 2 additions & 2 deletions cmd/otel-collector/main_others.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package main

import "go.opentelemetry.io/collector/otelcol"

func run(params otelcol.CollectorSettings) error {
return runInteractive(params)
func run(set otelcol.CollectorSettings) error {
return runInteractive(set)
}
4 changes: 2 additions & 2 deletions exporter/clickhouseprofileexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (

type clickhouseProfileExporter struct {
cfg *Config
set *exporter.CreateSettings
set *exporter.Settings
logger *zap.Logger
meter metric.Meter

Expand All @@ -37,7 +37,7 @@ type clickhouseAccess interface {
}

// TODO: batch like this https://github.com/open-telemetry/opentelemetry-collector/issues/8122
func newClickhouseProfileExporter(ctx context.Context, set *exporter.CreateSettings, cfg *Config) (*clickhouseProfileExporter, error) {
func newClickhouseProfileExporter(ctx context.Context, set *exporter.Settings, cfg *Config) (*clickhouseProfileExporter, error) {
exp := &clickhouseProfileExporter{
cfg: cfg,
set: set,
Expand Down
2 changes: 1 addition & 1 deletion exporter/clickhouseprofileexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func createDefaultConfig() component.Config {
}
}

func createLogsExporter(ctx context.Context, set exporter.CreateSettings, cfg component.Config) (exporter.Logs, error) {
func createLogsExporter(ctx context.Context, set exporter.Settings, cfg component.Config) (exporter.Logs, error) {
c := cfg.(*Config)
exp, err := newClickhouseProfileExporter(ctx, &set, cfg.(*Config))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion exporter/qrynexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestLoadConfig(t *testing.T) {

sub, err := cm.Sub(tt.id.String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))
require.NoError(t, sub.Unmarshal(cfg))

assert.NoError(t, component.ValidateConfig(cfg))
assert.Equal(t, tt.expected, cfg)
Expand Down
6 changes: 3 additions & 3 deletions exporter/qrynexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func createDefaultConfig() component.Config {
// Traces are directly insert into clickhouse.
func createTracesExporter(
ctx context.Context,
set exporter.CreateSettings,
set exporter.Settings,
cfg component.Config,
) (exporter.Traces, error) {
c := cfg.(*Config)
Expand All @@ -77,7 +77,7 @@ func createTracesExporter(
// Logs are directly insert into clickhouse.
func createLogsExporter(
ctx context.Context,
set exporter.CreateSettings,
set exporter.Settings,
cfg component.Config,
) (exporter.Logs, error) {
c := cfg.(*Config)
Expand All @@ -102,7 +102,7 @@ func createLogsExporter(
// Metrics are directly insert into clickhouse.
func createMetricsExporter(
ctx context.Context,
set exporter.CreateSettings,
set exporter.Settings,
cfg component.Config,
) (exporter.Metrics, error) {
c := cfg.(*Config)
Expand Down
2 changes: 1 addition & 1 deletion exporter/qrynexporter/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type logsExporter struct {
cluster bool
}

func newLogsExporter(logger *zap.Logger, cfg *Config, set *exporter.CreateSettings) (*logsExporter, error) {
func newLogsExporter(logger *zap.Logger, cfg *Config, set *exporter.Settings) (*logsExporter, error) {
opts, err := clickhouse.ParseDSN(cfg.DSN)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion exporter/qrynexporter/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type metricsExporter struct {
cluster bool
}

func newMetricsExporter(logger *zap.Logger, cfg *Config, set *exporter.CreateSettings) (*metricsExporter, error) {
func newMetricsExporter(logger *zap.Logger, cfg *Config, set *exporter.Settings) (*metricsExporter, error) {
opts, err := clickhouse.ParseDSN(cfg.DSN)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion exporter/qrynexporter/traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type tracesExporter struct {
}

// newTracesExporter returns a SpanWriter for the database
func newTracesExporter(logger *zap.Logger, cfg *Config, set *exporter.CreateSettings) (*tracesExporter, error) {
func newTracesExporter(logger *zap.Logger, cfg *Config, set *exporter.Settings) (*tracesExporter, error) {
opts, err := clickhouse.ParseDSN(cfg.DSN)
if err != nil {
return nil, err
Expand Down
10 changes: 5 additions & 5 deletions extension/pyroscope/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import (

var pyroscopeType = component.MustNewType("pyroscope")

// NewNopCreateSettings returns a new nop settings for extension.Factory Create* functions.
func NewPyroscopeCreateSettings() extension.CreateSettings {
return extension.CreateSettings{
// NewNopSettings returns a new nop settings for extension.Factory Create* functions.
func NewPyroscopeCreateSettings() extension.Settings {
return extension.Settings{
ID: component.NewIDWithName(pyroscopeType, uuid.NewString()),
TelemetrySettings: componenttest.NewNopTelemetrySettings(),
BuildInfo: component.NewDefaultBuildInfo(),
Expand All @@ -29,7 +29,7 @@ func NewFactory() extension.Factory {
return extension.NewFactory(
pyroscopeType,
defaultConfig,
func(ctx context.Context, settings extension.CreateSettings, config component.Config) (extension.Extension, error) {
func(ctx context.Context, settings extension.Settings, config component.Config) (extension.Extension, error) {
return &PyroscopeExtension{
config: config.(*Config),
}, nil
Expand All @@ -39,7 +39,7 @@ func NewFactory() extension.Factory {

type PyroscopeExtension struct {
config *Config
settings extension.CreateSettings
settings extension.Settings
ctx context.Context
profiler *pyroscope.Profiler
}
Expand Down
Loading

0 comments on commit e9bce2f

Please sign in to comment.