Skip to content

Commit

Permalink
Update core/contrib deps to v0.58.0 (open-telemetry#1864)
Browse files Browse the repository at this point in the history
* Update core/contrib deps to v0.58.0

* Update config source provider

* Add make fmt tidy and adopt fixes

* create internal/tools module for project

* use wget instead of now missing curl in kafka tests

Co-authored-by: Ryan Fitzpatrick <[email protected]>
  • Loading branch information
jeffreyc-splunk and Ryan Fitzpatrick authored Aug 15, 2022
1 parent 970bd71 commit b392b5b
Show file tree
Hide file tree
Showing 18 changed files with 1,920 additions and 370 deletions.
28 changes: 20 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ALL_DOC := $(shell find . \( -name "*.md" -o -name "*.yaml" \) \
ALL_SRC := $(shell find . -name '*.go' \
-not -path './examples/*' \
-not -path './tests/*' \
-not -path './internal/tools/*' \
-type f | sort)

# ALL_PKGS is the list of all packages where ALL_SRC files reside.
Expand Down Expand Up @@ -158,6 +159,17 @@ misspell:
misspell-correction:
$(MISSPELL_CORRECTION) $(ALL_DOC)

.PHONY: tidy
tidy:
go mod tidy -compat=1.17
cd tests && go mod tidy -compat=1.17
cd internal/tools && go mod tidy -compat=1.17

.PHONY: fmt
fmt: addlicense misspell-correction
go fmt ./...
fieldalignment -fix ./... || true

.PHONY: lint
lint:
$(LINT) run
Expand All @@ -168,14 +180,14 @@ impi:

.PHONY: install-tools
install-tools:
go install github.com/client9/misspell/cmd/misspell@v0.3.4
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.45.0
go install github.com/google/addlicense@v0.0.0-20200906110928-a0294312aa76
go install github.com/jstemmer/go-junit-report@v0.9.1
go install github.com/ory/go-acc@v0.2.8
go install github.com/pavius/impi/cmd/impi@v0.0.3
go install github.com/tcnksm/ghr@v0.14.0
go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest
cd ./internal/tools && go install github.com/client9/misspell/cmd/misspell
cd ./internal/tools && go install github.com/golangci/golangci-lint/cmd/golangci-lint
cd ./internal/tools && go install github.com/google/addlicense
cd ./internal/tools && go install github.com/jstemmer/go-junit-report
cd ./internal/tools && go install github.com/ory/go-acc
cd ./internal/tools && go install github.com/pavius/impi/cmd/impi
cd ./internal/tools && go install github.com/tcnksm/ghr
cd ./internal/tools && go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment

.PHONY: otelcol
otelcol:
Expand Down
199 changes: 100 additions & 99 deletions go.mod

Large diffs are not rendered by default.

415 changes: 210 additions & 205 deletions go.sum

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion internal/configprovider/config_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"os"
"strings"
"sync"
"time"

"github.com/spf13/cast"
"go.uber.org/zap"
Expand Down Expand Up @@ -125,7 +126,8 @@ func (cs *configServer) start() error {
mux.HandleFunc(effectivePath, effectiveHandleFunc)

cs.server = &http.Server{
Handler: mux,
ReadHeaderTimeout: 20 * time.Second,
Handler: mux,
}
cs.doneCh = make(chan struct{})
go func() {
Expand Down
50 changes: 29 additions & 21 deletions internal/configprovider/config_source_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ type configSourceConfigMapProvider struct {
csm *Manager
configServer *configServer
wrappedProvider confmap.Provider
wrappedRetrieved confmap.Retrieved
retrieved confmap.Retrieved
wrappedRetrieved *confmap.Retrieved
retrieved *confmap.Retrieved
buildInfo component.BuildInfo
factories []Factory
}
Expand All @@ -46,48 +46,56 @@ type configSourceConfigMapProvider struct {
func NewConfigSourceConfigMapProvider(wrappedProvider confmap.Provider, logger *zap.Logger,
buildInfo component.BuildInfo, factories ...Factory) confmap.Provider {
return &configSourceConfigMapProvider{
wrappedProvider: wrappedProvider,
logger: logger,
factories: factories,
buildInfo: buildInfo,
wrappedProvider: wrappedProvider,
logger: logger,
factories: factories,
buildInfo: buildInfo,
wrappedRetrieved: &confmap.Retrieved{},
retrieved: &confmap.Retrieved{},
}
}

func (c *configSourceConfigMapProvider) Retrieve(
ctx context.Context,
location string,
onChange confmap.WatcherFunc,
) (confmap.Retrieved, error) {
wr, err := c.wrappedProvider.Retrieve(ctx, location, onChange)
if err != nil {
return confmap.Retrieved{}, err
) (*confmap.Retrieved, error) {
var tmpWR *confmap.Retrieved
var err error
newWrappedRetrieved := &confmap.Retrieved{}
if tmpWR, err = c.wrappedProvider.Retrieve(ctx, location, onChange); err != nil {
return nil, err
} else if tmpWR != nil {
newWrappedRetrieved = tmpWR
}

existingMap, err := c.wrappedRetrieved.AsConf()
if err != nil {
return confmap.Retrieved{}, err
return nil, err
}

// Need to merge config maps that we've encountered so far
if existingMap != nil {
wrMap, _ := wr.AsConf()
wrMap, _ := newWrappedRetrieved.AsConf()
wrMap.Merge(existingMap)
c.wrappedRetrieved, err = confmap.NewRetrieved(wrMap.ToStringMap())
if err != nil {
return confmap.Retrieved{}, err
if tmpWR, err = confmap.NewRetrieved(wrMap.ToStringMap()); err != nil {
return nil, err
} else if tmpWR != nil {
newWrappedRetrieved = tmpWR
}
} else {
c.wrappedRetrieved = wr
}
c.wrappedRetrieved = newWrappedRetrieved

cfg, err := c.Get(ctx)
if err != nil {
return confmap.Retrieved{}, err
var cfg *confmap.Conf
if cfg, err = c.Get(ctx); err != nil {
return nil, err
} else if cfg == nil {
cfg = &confmap.Conf{}
}

c.retrieved, err = confmap.NewRetrieved(
cfg.ToStringMap(),
confmap.WithRetrievedClose(wr.Close),
confmap.WithRetrievedClose(c.wrappedRetrieved.Close),
)
return c.retrieved, err
}
Expand Down
9 changes: 5 additions & 4 deletions internal/configprovider/config_source_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,14 @@ func TestConfigSourceConfigMapProvider(t *testing.T) {
configLocation = ""
}
r, err := pp.Retrieve(context.Background(), configLocation, nil)
rMap, _ := r.AsConf()
if tt.wantErr == nil {
require.NoError(t, err)
require.NotNil(t, r)
rMap, _ := r.AsConf()
require.NotNil(t, rMap)
} else {
assert.IsType(t, tt.wantErr, err)
assert.Nil(t, rMap)
assert.Nil(t, r)
return
}
i++
Expand Down Expand Up @@ -154,10 +155,10 @@ type mockParserProvider struct {

var _ confmap.Provider = (*mockParserProvider)(nil)

func (mpp *mockParserProvider) Retrieve(ctx context.Context, _ string, _ confmap.WatcherFunc) (confmap.Retrieved, error) {
func (mpp *mockParserProvider) Retrieve(ctx context.Context, _ string, _ confmap.WatcherFunc) (*confmap.Retrieved, error) {
m, err := mpp.Get(ctx)
if err != nil {
return confmap.Retrieved{}, err
return nil, err
}
return confmap.NewRetrieved(m.ToStringMap())
}
Expand Down
7 changes: 4 additions & 3 deletions internal/exporter/httpsinkexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ func createDefaultConfig() config.Exporter {
}

func createTracesExporter(
_ context.Context,
ctx context.Context,
set component.ExporterCreateSettings,
cfg config.Exporter,
) (component.TracesExporter, error) {
exp := &httpSinkExporter{endpoint: cfg.(*Config).Endpoint}
return exporterhelper.NewTracesExporter(
cfg,
return exporterhelper.NewTracesExporterWithContext(
ctx,
set,
cfg,
exp.ConsumeTraces,
exporterhelper.WithStart(exp.Start),
exporterhelper.WithShutdown(exp.Shutdown),
Expand Down
2 changes: 1 addition & 1 deletion internal/exporter/pulsarexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ type Authentication struct {

// Config defines configuration for pulsar exporter.
type Config struct {
exporterhelper.QueueSettings `mapstructure:"sending_queue"`
Authentication Authentication `mapstructure:"auth"`
config.ExporterSettings `mapstructure:",squash"`
Broker string `mapstructure:"broker"`
Topic string `mapstructure:"topic"`
Encoding string `mapstructure:"encoding"`
Producer Producer `mapstructure:"producer"`
exporterhelper.RetrySettings `mapstructure:"retry_on_failure"`
exporterhelper.QueueSettings `mapstructure:"sending_queue"`
exporterhelper.TimeoutSettings `mapstructure:",squash"`
OperationTimeout time.Duration `mapstructure:"operation_timeout"`
ConnectionTimeout time.Duration `mapstructure:"connection_timeout"`
Expand Down
7 changes: 4 additions & 3 deletions internal/exporter/pulsarexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func createDefaultConfig() config.Exporter {
}

func (f *pulsarExporterFactory) createMetricsExporter(
_ ctx.Context,
ctx ctx.Context,
settings component.ExporterCreateSettings,
cfg config.Exporter,
) (component.MetricsExporter, error) {
Expand All @@ -90,9 +90,10 @@ func (f *pulsarExporterFactory) createMetricsExporter(
if err != nil {
return nil, err
}
return exporterhelper.NewMetricsExporter(
cfg,
return exporterhelper.NewMetricsExporterWithContext(
ctx,
settings,
cfg,
exp.metricsDataPusher,
exporterhelper.WithCapabilities(consumer.Capabilities{MutatesData: false}),
exporterhelper.WithTimeout(exporterhelper.TimeoutSettings{Timeout: 0}),
Expand Down
3 changes: 2 additions & 1 deletion internal/extension/smartagentextension/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ const (
)

func NewFactory() component.ExtensionFactory {
return component.NewExtensionFactory(
return component.NewExtensionFactoryWithStabilityLevel(
typeStr,
createDefaultConfig,
createExtension,
component.StabilityLevelAlpha,
)
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b392b5b

Please sign in to comment.