Skip to content

Commit

Permalink
Update core and contrib dependancies to 0.49.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitryax committed Apr 15, 2022
1 parent 08e7e44 commit b18d63f
Show file tree
Hide file tree
Showing 27 changed files with 698 additions and 745 deletions.
48 changes: 27 additions & 21 deletions cmd/otelcol/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import (

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/config/configmapprovider"
"go.opentelemetry.io/collector/config/configunmarshaler"
"go.opentelemetry.io/collector/config/mapconverter/overwritepropertiesmapconverter"
"go.opentelemetry.io/collector/config/mapprovider/envmapprovider"
"go.opentelemetry.io/collector/config/mapprovider/filemapprovider"
"go.opentelemetry.io/collector/service"
Expand Down Expand Up @@ -86,7 +86,7 @@ func main() {
}

configMapConverters := []config.MapConverterFunc{
configmapprovider.NewOverwritePropertiesConverter(getSetProperties()),
overwritepropertiesmapconverter.New(getSetProperties()),
}

const noConvertConfigFlag = "--no-convert-config"
Expand All @@ -102,25 +102,31 @@ func main() {
)
}

serviceConfigProvider := service.MustNewConfigProvider(
[]string{configLocation()},
map[string]config.MapProvider{
"env": configprovider.NewConfigSourceConfigMapProvider(
envmapprovider.New(),
zap.NewNop(), // The service logger is not available yet, setting it to NoP.
info,
configsources.Get()...,
),
"file": configprovider.NewConfigSourceConfigMapProvider(
filemapprovider.New(),
zap.NewNop(), // The service logger is not available yet, setting it to NoP.
info,
configsources.Get()...,
),
},
configMapConverters,
configunmarshaler.NewDefault(),
)
emp := envmapprovider.New()
fmp := filemapprovider.New()
serviceConfigProvider, err := service.NewConfigProvider(
service.ConfigProviderSettings{
Locations: []string{configLocation()},
MapProviders: map[string]config.MapProvider{
emp.Scheme(): configprovider.NewConfigSourceConfigMapProvider(
emp,
zap.NewNop(), // The service logger is not available yet, setting it to NoP.
info,
configsources.Get()...,
),
fmp.Scheme(): configprovider.NewConfigSourceConfigMapProvider(
fmp,
zap.NewNop(), // The service logger is not available yet, setting it to NoP.
info,
configsources.Get()...,
),
},
MapConverters: configMapConverters,
Unmarshaler: configunmarshaler.NewDefault(),
})
if err != nil {
log.Fatal(err)
}

serviceParams := service.CollectorSettings{
BuildInfo: info,
Expand Down
211 changes: 107 additions & 104 deletions go.mod

Large diffs are not rendered by default.

517 changes: 220 additions & 297 deletions go.sum

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions internal/configprovider/config_source_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ func (c *configSourceConfigMapProvider) Retrieve(
return c.retrieved, err
}

func (c *configSourceConfigMapProvider) Scheme() string {
return c.wrappedProvider.Scheme()
}

func (c *configSourceConfigMapProvider) Shutdown(ctx context.Context) error {
return c.wrappedProvider.Shutdown(ctx)
}
Expand Down
4 changes: 4 additions & 0 deletions internal/configprovider/config_source_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ func (mpp *mockParserProvider) Shutdown(ctx context.Context) error {
return nil
}

func (mpp *mockParserProvider) Scheme() string {
return ""
}

func (mpp *mockParserProvider) Get(context.Context) (*config.Map, error) {
if mpp.ErrOnGet {
return nil, &errOnParserProviderGet{errors.New("mockParserProvider.Get() forced test error")}
Expand Down
4 changes: 2 additions & 2 deletions internal/exporter/httpsinkexporter/httpsink_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/jaegertracing/jaeger/model"
jaegertranslator "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/jaeger"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/model/pdata"
"go.opentelemetry.io/collector/pdata/ptrace"
)

var marshaler = &jsonpb.Marshaler{}
Expand All @@ -38,7 +38,7 @@ type httpSinkExporter struct {
mu sync.Mutex
}

func (e *httpSinkExporter) ConsumeTraces(_ context.Context, td pdata.Traces) error {
func (e *httpSinkExporter) ConsumeTraces(_ context.Context, td ptrace.Traces) error {
batches, err := jaegertranslator.ProtoFromTraces(td)
if err != nil {
return err
Expand Down

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

15 changes: 8 additions & 7 deletions internal/receiver/databricksreceiver/metrics_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ package databricksreceiver
import (
"fmt"

"go.opentelemetry.io/collector/model/pdata"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/pmetric"

"github.com/signalfx/splunk-otel-collector/internal/receiver/databricksreceiver/internal/metadata"
)
Expand All @@ -32,7 +33,7 @@ func newMetricsProvider(dbClient databricksClientInterface) metricsProvider {
return metricsProvider{dbClient: dbClient}
}

func (p metricsProvider) addJobStatusMetrics(ms pdata.MetricSlice) ([]int, error) {
func (p metricsProvider) addJobStatusMetrics(ms pmetric.MetricSlice) ([]int, error) {
jobs, err := p.dbClient.jobs()
if err != nil {
return nil, fmt.Errorf("metricsProvider.addJobStatusMetrics(): %w", err)
Expand All @@ -49,7 +50,7 @@ func (p metricsProvider) addJobStatusMetrics(ms pdata.MetricSlice) ([]int, error
jobPt := jobPts.AppendEmpty()
pauseStatus := pauseStatusToInt(j.Settings.Schedule.PauseStatus)
jobPt.SetIntVal(pauseStatus)
jobIDAttr := pdata.NewValueInt(int64(j.JobID))
jobIDAttr := pcommon.NewValueInt(int64(j.JobID))
jobPt.Attributes().Insert(metadata.A.JobID, jobIDAttr)
for _, task := range j.Settings.Tasks {
taskPt := taskPts.AppendEmpty()
Expand All @@ -61,11 +62,11 @@ func (p metricsProvider) addJobStatusMetrics(ms pdata.MetricSlice) ([]int, error
)
taskAttrs.Insert(
metadata.A.TaskID,
pdata.NewValueString(task.TaskKey),
pcommon.NewValueString(task.TaskKey),
)
taskAttrs.Insert(
metadata.A.TaskType,
pdata.NewValueString(taskType(task)),
pcommon.NewValueString(taskType(task)),
)
}
}
Expand All @@ -90,7 +91,7 @@ func taskType(task jobTask) string {
return ""
}

func (p metricsProvider) addNumActiveRunsMetric(ms pdata.MetricSlice) error {
func (p metricsProvider) addNumActiveRunsMetric(ms pmetric.MetricSlice) error {
runs, err := p.dbClient.activeJobRuns()
if err != nil {
return fmt.Errorf("metricsProvider.addNumActiveJobsMetric(): %w", err)
Expand All @@ -100,7 +101,7 @@ func (p metricsProvider) addNumActiveRunsMetric(ms pdata.MetricSlice) error {
return nil
}

func initGauge(ms pdata.MetricSlice, mi metadata.MetricIntf) pdata.NumberDataPointSlice {
func initGauge(ms pmetric.MetricSlice, mi metadata.MetricIntf) pmetric.NumberDataPointSlice {
m := ms.AppendEmpty()
mi.Init(m)
return m.Gauge().DataPoints()
Expand Down
8 changes: 4 additions & 4 deletions internal/receiver/databricksreceiver/metrics_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/model/pdata"
"go.opentelemetry.io/collector/pdata/pmetric"
)

func TestMetricsProvider(t *testing.T) {
const ignored = 25
mp := newMetricsProvider(newDatabricksClient(&testdataClient{}, ignored))
ms := pdata.NewMetricSlice()
ms := pmetric.NewMetricSlice()
_, err := mp.addJobStatusMetrics(ms)
require.NoError(t, err)
assert.Equal(t, ms.Len(), 3)
Expand Down Expand Up @@ -59,15 +59,15 @@ func TestMetricsProvider(t *testing.T) {
assertTaskTypeEquals(t, taskPts, 4, "PythonWheelTask")
assertTaskTypeEquals(t, taskPts, 5, "SparkSubmitTask")

ms = pdata.NewMetricSlice()
ms = pmetric.NewMetricSlice()
err = mp.addNumActiveRunsMetric(ms)
require.NoError(t, err)
activeRunsMetric := ms.At(0)
assert.Equal(t, "databricks.jobs.active.total", activeRunsMetric.Name())
assert.Equal(t, 1, activeRunsMetric.Gauge().DataPoints().Len())
}

func assertTaskTypeEquals(t *testing.T, taskPts pdata.NumberDataPointSlice, idx int, expected string) {
func assertTaskTypeEquals(t *testing.T, taskPts pmetric.NumberDataPointSlice, idx int, expected string) {
tskType, _ := taskPts.At(idx).Attributes().Get("task_type")
assert.EqualValues(t, expected, tskType.StringVal())
}
13 changes: 7 additions & 6 deletions internal/receiver/databricksreceiver/run_metrics_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ package databricksreceiver
import (
"fmt"

"go.opentelemetry.io/collector/model/pdata"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/pmetric"

"github.com/signalfx/splunk-otel-collector/internal/receiver/databricksreceiver/internal/metadata"
)
Expand All @@ -36,7 +37,7 @@ func newRunMetricsProvider(dbClient databricksClientInterface) runMetricsProvide
}
}

func (p runMetricsProvider) addMultiJobRunMetrics(ms pdata.MetricSlice, jobIDs []int) error {
func (p runMetricsProvider) addMultiJobRunMetrics(ms pmetric.MetricSlice, jobIDs []int) error {
jobPts := initGauge(ms, metadata.M.DatabricksJobsRunDuration)
taskPts := initGauge(ms, metadata.M.DatabricksTasksRunDuration)
for _, jobID := range jobIDs {
Expand All @@ -49,8 +50,8 @@ func (p runMetricsProvider) addMultiJobRunMetrics(ms pdata.MetricSlice, jobIDs [
}

func (p runMetricsProvider) addSingleJobRunMetrics(
jobPts pdata.NumberDataPointSlice,
taskPts pdata.NumberDataPointSlice,
jobPts pmetric.NumberDataPointSlice,
taskPts pmetric.NumberDataPointSlice,
jobID int,
) error {
startTime := p.tracker.getPrevStartTime(jobID)
Expand All @@ -66,14 +67,14 @@ func (p runMetricsProvider) addSingleJobRunMetrics(
}
jobPt := jobPts.AppendEmpty()
jobPt.SetIntVal(int64(run.ExecutionDuration))
jobIDAttr := pdata.NewValueInt(int64(jobID))
jobIDAttr := pcommon.NewValueInt(int64(jobID))
jobPt.Attributes().Insert(metadata.Attributes.JobID, jobIDAttr)
for _, task := range run.Tasks {
taskPt := taskPts.AppendEmpty()
taskPt.SetIntVal(int64(task.ExecutionDuration))
taskAttrs := taskPt.Attributes()
taskAttrs.Insert(metadata.Attributes.JobID, jobIDAttr)
taskAttrs.Insert(metadata.Attributes.TaskID, pdata.NewValueString(task.TaskKey))
taskAttrs.Insert(metadata.Attributes.TaskID, pcommon.NewValueString(task.TaskKey))
}
}
return nil
Expand Down
Loading

0 comments on commit b18d63f

Please sign in to comment.