Skip to content

Commit

Permalink
[chore] make gofmt with go1.19 (open-telemetry#13131)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu authored Aug 9, 2022
1 parent 6a9cce7 commit 4dd1595
Show file tree
Hide file tree
Showing 89 changed files with 470 additions and 450 deletions.
6 changes: 3 additions & 3 deletions exporter/awsemfexporter/datapoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ type dataPoint struct {
}

// dataPoints is a wrapper interface for:
// - pmetric.NumberDataPointSlice
// - pmetric.HistogramDataPointSlice
// - pmetric.SummaryDataPointSlice
// - pmetric.NumberDataPointSlice
// - pmetric.HistogramDataPointSlice
// - pmetric.SummaryDataPointSlice
type dataPoints interface {
Len() int
// At gets the adjusted datapoint from the DataPointSlice at i-th index.
Expand Down
14 changes: 7 additions & 7 deletions exporter/awsxrayexporter/internal/translator/segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,13 @@ func determineAwsOrigin(resource pcommon.Resource) string {
//
// A trace ID unique identifier that connects all segments and subsegments
// originating from a single client request.
// * A trace_id consists of three numbers separated by hyphens. For example,
// 1-58406520-a006649127e371903a2de979. This includes:
// * The version number, that is, 1.
// * The time of the original request, in Unix epoch time, in 8 hexadecimal digits.
// * For example, 10:00AM December 2nd, 2016 PST in epoch time is 1480615200 seconds,
// or 58406520 in hexadecimal.
// * A 96-bit identifier for the trace, globally unique, in 24 hexadecimal digits.
// - A trace_id consists of three numbers separated by hyphens. For example,
// 1-58406520-a006649127e371903a2de979. This includes:
// - The version number, that is, 1.
// - The time of the original request, in Unix epoch time, in 8 hexadecimal digits.
// - For example, 10:00AM December 2nd, 2016 PST in epoch time is 1480615200 seconds,
// or 58406520 in hexadecimal.
// - A 96-bit identifier for the trace, globally unique, in 24 hexadecimal digits.
func convertToAmazonTraceID(traceID pcommon.TraceID) (string, error) {
const (
// maxAge of 28 days. AWS has a 30 day limit, let's be conservative rather than
Expand Down
4 changes: 2 additions & 2 deletions exporter/azuremonitorexporter/trace_to_envelope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ func TestSanitize(t *testing.T) {
}

/*
These methods are for handling some common validations
These methods are for handling some common validations
*/
func commonEnvelopeValidations(
t *testing.T,
Expand Down Expand Up @@ -755,7 +755,7 @@ func assertAttributesCopiedToPropertiesOrMeasurements(
}

/*
The remainder of these methods are for building up test assets
The remainder of these methods are for building up test assets
*/
func getSpan(spanName string, spanKind ptrace.SpanKind, initialAttributes map[string]interface{}) ptrace.Span {
span := ptrace.NewSpan()
Expand Down
13 changes: 6 additions & 7 deletions exporter/carbonexporter/metricdata_to_plaintext.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ const (
//
// Each metric point becomes a single string with the following format:
//
// "<path> <value> <timestamp>"
// "<path> <value> <timestamp>"
//
// The <path> contains the metric name and its tags and has the following,
// format:
//
// <metric_name>[;tag0;...;tagN]
// <metric_name>[;tag0;...;tagN]
//
// <metric_name> is the name of the metric and terminates either at the first ';'
// or at the end of the path.
Expand All @@ -77,10 +77,10 @@ const (
// The <timestamp> is the Unix time text of when the measurement was made.
//
// The returned values are:
// - a string concatenating all generated "lines" (each single one representing
// a single Carbon metric.
// - number of time series successfully converted to carbon.
// - number of time series that could not be converted to Carbon.
// - a string concatenating all generated "lines" (each single one representing
// a single Carbon metric.
// - number of time series successfully converted to carbon.
// - number of time series that could not be converted to Carbon.
func metricDataToPlaintext(mds []*agentmetricspb.ExportMetricsServiceRequest) (string, int, int) {
if len(mds) == 0 {
return "", 0, 0
Expand Down Expand Up @@ -266,7 +266,6 @@ func buildSummaryIntoBuilder(
// 1. The total count will be represented by a metric named "<metricName>.count".
//
// 2. The total sum will be represented by a metruc with the original "<metricName>".
//
func buildCountAndSumIntoBuilder(
sb *strings.Builder,
metricName string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion exporter/fileexporter/file_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion exporter/googlecloudexporter/legacyconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion exporter/googlecloudexporter/legacyconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion exporter/honeycombexporter/honeycomb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
3 changes: 2 additions & 1 deletion exporter/kafkaexporter/internal/awsmsk/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
// to be used with the Surama kafka producer.
//
// Further details on how the SASL connector works can be viewed here:
// https://github.com/aws/aws-msk-iam-auth#details
//
// https://github.com/aws/aws-msk-iam-auth#details
package awsmsk // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/kafkaexporter/internal/awsmsk"
2 changes: 1 addition & 1 deletion exporter/logzioexporter/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
4 changes: 2 additions & 2 deletions exporter/prometheusexporter/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func newCollector(config *Config, logger *zap.Logger) *collector {
func (c *collector) Describe(_ chan<- *prometheus.Desc) {}

/*
Processing
Processing
*/
func (c *collector) processMetrics(rm pmetric.ResourceMetrics) (n int) {
return c.accumulator.Accumulate(rm)
Expand Down Expand Up @@ -317,7 +317,7 @@ func (c *collector) createTargetInfoMetrics(resourceAttrs []pcommon.Map) ([]prom
}

/*
Reporting
Reporting
*/
func (c *collector) Collect(ch chan<- prometheus.Metric) {
c.logger.Debug("collect called")
Expand Down
8 changes: 4 additions & 4 deletions exporter/sumologicexporter/source_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ const sourceRegex = `\%\{([\w\.]+)\}`

// newSourceFormat builds sourceFormat basing on the regex and given text.
// Regex is basing on the `sourceRegex` const
// For given example text: `%{cluster}/%{namespace}``, it sets:
// - template to `%s/%s`, which can be used later by fmt.Sprintf
// - matches as map of (attribute) keys ({"cluster", "namespace"}) which will
// be used to put corresponding value into templates' `%s
// For given example text: `%{cluster}/%{namespace}, it sets:
// - template to `%s/%s`, which can be used later by fmt.Sprintf
// - matches as map of (attribute) keys ({"cluster", "namespace"}) which will
// be used to put corresponding value into templates' `%s
func newSourceFormat(r *regexp.Regexp, text string) sourceFormat {
matches := r.FindAllStringSubmatch(text, -1)
template := r.ReplaceAllString(text, "%s")
Expand Down
9 changes: 5 additions & 4 deletions exporter/zipkinexporter/zipkin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ import (
// This function tests that Zipkin spans that are received then processed roundtrip
// back to almost the same JSON with differences:
// a) Go's net.IP.String intentional shortens 0s with "::" but also converts to hex values
// so
// "7::0.128.128.127"
// becomes
// "7::80:807f"
//
// so
// "7::0.128.128.127"
// becomes
// "7::80:807f"
//
// The rest of the fields should match up exactly
func TestZipkinExporter_roundtripJSON(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions extension/observer/ecsobserver/internal/errctx/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ type ErrorWithValue interface {
//
// It is a good practice to define the key as a constant strange instead of inline literal.
//
// const taskErrKey = "task"
// return errctx.WithValue(taskErrKey, myTask)
// task, ok := errctx.ValueFrom(err, taskErrKey)
// const taskErrKey = "task"
// return errctx.WithValue(taskErrKey, myTask)
// task, ok := errctx.ValueFrom(err, taskErrKey)
func WithValue(err error, key string, val interface{}) error {
if err == nil {
return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/aws/containerinsight/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion internal/aws/containerinsight/ecsconst.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion internal/aws/containerinsight/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion internal/aws/containerinsight/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 0 additions & 2 deletions internal/aws/cwlogs/cwlog_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ func (svc *mockCloudWatchLogsClient) DescribeLogStreams(input *cloudwatchlogs.De
return args.Get(0).(*cloudwatchlogs.DescribeLogStreamsOutput), args.Error(1)
}

//
// Tests
//
var previousSequenceToken = "0000"
var expectedNextSequenceToken = "1111"
var logGroup = "logGroup"
Expand Down
8 changes: 2 additions & 6 deletions internal/aws/cwlogs/pusher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ func newMockPusherWithEventCheck(check func(msg string)) Pusher {
return p
}

//
// logEvent Tests
//
// logEvent Tests
func TestLogEvent_eventPayloadBytes(t *testing.T) {
testMessage := "test message"
logEvent := NewEvent(0, testMessage)
Expand Down Expand Up @@ -117,9 +115,7 @@ func TestValidateLogEventFailed(t *testing.T) {
assert.Equal(t, "the log entry's timestamp is older than 14 days or more than 2 hours in the future", err.Error())
}

//
// eventBatch Tests
//
// eventBatch Tests
func TestLogEventBatch_timestampWithin24Hours(t *testing.T) {
min := time.Date(2017, time.June, 20, 23, 38, 0, 0, time.Local)
max := min.Add(23 * time.Hour)
Expand Down
2 changes: 1 addition & 1 deletion internal/aws/k8s/k8sclient/replicaset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
11 changes: 6 additions & 5 deletions internal/coreinternal/goldendataset/span_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,12 @@ func generateSpanName(spanInputs *PICTSpanInputs) string {
}

// fillSpan generates a single ptrace.Span based on the input values provided. They are:
// traceID - the trace ID to use, should not be nil
// parentID - the parent span ID or nil if it is a root span
// spanName - the span name, should not be blank
// spanInputs - the pairwise combination of field value variations for this span
// random - the random number generator to use in generating ID values
//
// traceID - the trace ID to use, should not be nil
// parentID - the parent span ID or nil if it is a root span
// spanName - the span name, should not be blank
// spanInputs - the pairwise combination of field value variations for this span
// random - the random number generator to use in generating ID values
//
// The generated span is returned.
func fillSpan(traceID pcommon.TraceID, parentID pcommon.SpanID, spanName string, spanInputs *PICTSpanInputs, random io.Reader, span ptrace.Span) {
Expand Down
7 changes: 4 additions & 3 deletions internal/coreinternal/goldendataset/traces_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ func GenerateTraces(tracePairsFile string, spanPairsFile string) ([]ptrace.Trace
}

// generateResourceSpan generates a single PData ResourceSpans populated based on the provided inputs. They are:
// tracingInputs - the pairwise combination of field value variations for this ResourceSpans
// spanPairsFile - the file with the PICT-generated parameter combinations to generate spans for
// random - the random number generator to use in generating ID values
//
// tracingInputs - the pairwise combination of field value variations for this ResourceSpans
// spanPairsFile - the file with the PICT-generated parameter combinations to generate spans for
// random - the random number generator to use in generating ID values
//
// The generated resource spans. If err is not nil, some or all of the resource spans fields will be nil.
func appendResourceSpan(tracingInputs *PICTTracingInputs, spanPairsFile string,
Expand Down
26 changes: 14 additions & 12 deletions internal/coreinternal/processor/filterconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,21 @@ type MatchConfig struct {
// this requires all the properties to match for the inclusion/exclusion to
// occur.
// The following are examples of invalid configurations:
// attributes/bad1:
// # This is invalid because include is specified with neither services or
// # attributes.
// include:
// actions: ...
//
// span/bad2:
// exclude:
// # This is invalid because services, span_names and attributes have empty values.
// services:
// span_names:
// attributes:
// actions: ...
// attributes/bad1:
// # This is invalid because include is specified with neither services or
// # attributes.
// include:
// actions: ...
//
// span/bad2:
// exclude:
// # This is invalid because services, span_names and attributes have empty values.
// services:
// span_names:
// attributes:
// actions: ...
//
// Please refer to processor/attributesprocessor/testdata/config.yaml and
// processor/spanprocessor/testdata/config.yaml for valid configurations.
type MatchProperties struct {
Expand Down
3 changes: 2 additions & 1 deletion internal/coreinternal/processor/filterlog/filterlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import (
// Matcher is an interface that allows matching a log record against a
// configuration of a match.
// TODO: Modify Matcher to invoke both the include and exclude properties so
// calling processors will always have the same logic.
//
// calling processors will always have the same logic.
type Matcher interface {
MatchLogRecord(lr plog.LogRecord, resource pcommon.Resource, library pcommon.InstrumentationScope) bool
}
Expand Down
3 changes: 2 additions & 1 deletion internal/coreinternal/processor/filterspan/filterspan.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import (
// Matcher is an interface that allows matching a span against a configuration
// of a match.
// TODO: Modify Matcher to invoke both the include and exclude properties so
// calling processors will always have the same logic.
//
// calling processors will always have the same logic.
type Matcher interface {
MatchSpan(span ptrace.Span, resource pcommon.Resource, library pcommon.InstrumentationScope) bool
}
Expand Down
Loading

0 comments on commit 4dd1595

Please sign in to comment.