Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ env:
DEFAULT_GO_VERSION: 1.15
jobs:
lint:
strategy:
matrix:
arch: ["386", amd64]
env:
GOARCH: ${{ matrix.arch }}
runs-on: ubuntu-latest
steps:
- name: Install Go
Expand Down
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ linters:
- goimports
- revive
- gofmt
- govet

issues:
exclude-rules:
Expand All @@ -30,3 +31,6 @@ linters-settings:
- cancelled
goimports:
local-prefixes: go.opentelemetry.io
govet:
enable:
- atomicalign
6 changes: 4 additions & 2 deletions exporters/jaeger/reconnecting_udp_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ type reconnectingUDPConn struct {
closeChan chan struct{}
}

type resolveFunc func(network string, hostPort string) (*net.UDPAddr, error)
type dialFunc func(network string, laddr, raddr *net.UDPAddr) (*net.UDPConn, error)
type (
resolveFunc func(network string, hostPort string) (*net.UDPAddr, error)
dialFunc func(network string, laddr, raddr *net.UDPAddr) (*net.UDPConn, error)
)

// newReconnectingUDPConn returns a new udpConn that resolves hostPort every resolveTimeout, if the resolved address is
// different than the current conn then the new address is dialed and the conn is swapped.
Expand Down
2 changes: 2 additions & 0 deletions exporters/otlp/otlpmetric/internal/connection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import (
)

type Connection struct {
_ int32

// Ensure pointer is 64-bit aligned for atomic operations on both 32 and 64 bit machines.
lastConnectErrPtr unsafe.Pointer

Expand Down
2 changes: 2 additions & 0 deletions exporters/otlp/otlptrace/internal/connection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import (
)

type Connection struct {
_ int32

// Ensure pointer is 64-bit aligned for atomic operations on both 32 and 64 bit machines.
lastConnectErrPtr unsafe.Pointer

Expand Down
6 changes: 4 additions & 2 deletions exporters/trace/jaeger/reconnecting_udp_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ type reconnectingUDPConn struct {
closeChan chan struct{}
}

type resolveFunc func(network string, hostPort string) (*net.UDPAddr, error)
type dialFunc func(network string, laddr, raddr *net.UDPAddr) (*net.UDPConn, error)
type (
resolveFunc func(network string, hostPort string) (*net.UDPAddr, error)
dialFunc func(network string, laddr, raddr *net.UDPAddr) (*net.UDPConn, error)
)

// newReconnectingUDPConn returns a new udpConn that resolves hostPort every resolveTimeout, if the resolved address is
// different than the current conn then the new address is dialed and the conn is swapped.
Expand Down
10 changes: 7 additions & 3 deletions metric/metric_instrument.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ func (k InstrumentKind) PrecomputedSum() bool {
// values. Instances of this type should be created by asynchronous
// instruments (e.g., Int64ValueObserver.Observation()).
type Observation struct {
_ int32

// number needs to be aligned for 64-bit atomic operations.
number number.Number
instrument AsyncImpl
Expand Down Expand Up @@ -188,9 +190,11 @@ type AsyncBatchRunner interface {
AsyncRunner
}

var _ AsyncSingleRunner = (*Int64ObserverFunc)(nil)
var _ AsyncSingleRunner = (*Float64ObserverFunc)(nil)
var _ AsyncBatchRunner = (*BatchObserverFunc)(nil)
var (
_ AsyncSingleRunner = (*Int64ObserverFunc)(nil)
_ AsyncSingleRunner = (*Float64ObserverFunc)(nil)
_ AsyncBatchRunner = (*BatchObserverFunc)(nil)
)

// newInt64AsyncRunner returns a single-observer callback for integer Observer instruments.
func newInt64AsyncRunner(c Int64ObserverFunc) AsyncSingleRunner {
Expand Down
2 changes: 2 additions & 0 deletions metric/metrictest/meter.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ type (
}

Batch struct {
_ int32

// Measurement needs to be aligned for 64-bit atomic operations.
Measurements []Measurement
Ctx context.Context
Expand Down
2 changes: 2 additions & 0 deletions metric/number/number_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ func TestNumber(t *testing.T) {
cmpsForPos := [3]int{1, 1, 0}

type testcase struct {
_ int32

// n needs to be aligned for 64-bit atomic operations.
n Number
// nums needs to be aligned for 64-bit atomic operations.
Expand Down
16 changes: 10 additions & 6 deletions sdk/metric/aggregator/aggregatortest/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ type Profile struct {
Random func(sign int) number.Number
}

type NoopAggregator struct{}
type NoopAggregation struct{}
type (
NoopAggregator struct{}
NoopAggregation struct{}
)

var _ export.Aggregator = NoopAggregator{}
var _ aggregation.Aggregation = NoopAggregation{}
var (
_ export.Aggregator = NoopAggregator{}
_ aggregation.Aggregation = NoopAggregation{}
)

func newProfiles() []Profile {
rnd := rand.New(rand.NewSource(rand.Int63()))
Expand Down Expand Up @@ -93,6 +97,8 @@ func TestMain(m *testing.M) {
}

type Numbers struct {
_ int32

// numbers has to be aligned for 64-bit atomic operations.
numbers []number.Number
kind number.Kind
Expand Down Expand Up @@ -273,8 +279,6 @@ func SynchronizedMoveResetTest(t *testing.T, mkind metric.InstrumentKind, nf fun
require.Equal(t, input, v)
require.NoError(t, err)
}

})
})

}
8 changes: 6 additions & 2 deletions sdk/metric/aggregator/lastvalue/lastvalue.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ type (
// lastValueData stores the current value of a lastValue along with
// a sequence number to determine the winner of a race.
lastValueData struct {
_ int32

// value is the int64- or float64-encoded Set() data
//
// value needs to be aligned for 64-bit atomic operations.
Expand All @@ -51,8 +53,10 @@ type (
}
)

var _ export.Aggregator = &Aggregator{}
var _ aggregation.LastValue = &Aggregator{}
var (
_ export.Aggregator = &Aggregator{}
_ aggregation.LastValue = &Aggregator{}
)

// An unset lastValue has zero timestamp and zero value.
var unsetLastValue = &lastValueData{}
Expand Down
10 changes: 7 additions & 3 deletions sdk/metric/aggregator/sum/sum.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,18 @@ import (

// Aggregator aggregates counter events.
type Aggregator struct {
_ int32

// current holds current increments to this counter record
// current needs to be aligned for 64-bit atomic operations.
value number.Number
}

var _ export.Aggregator = &Aggregator{}
var _ export.Subtractor = &Aggregator{}
var _ aggregation.Sum = &Aggregator{}
var (
_ export.Aggregator = &Aggregator{}
_ export.Subtractor = &Aggregator{}
_ aggregation.Sum = &Aggregator{}
)

// New returns a new counter aggregator implemented by atomic
// operations. This aggregator implements the aggregation.Sum
Expand Down
2 changes: 2 additions & 0 deletions sdk/metric/refcount_mapped.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (
// keep the state of mapping ('1' is used for unmapped and '0' is for mapped) and
// the rest of the bits are used for refcounting.
type refcountMapped struct {
_ int32

// refcount has to be aligned for 64-bit atomic operations.
value int64
}
Expand Down
4 changes: 4 additions & 0 deletions sdk/metric/stress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ var Must = metric.Must

type (
testFixture struct {
_ int32

// stop has to be aligned for 64-bit atomic operations.
stop int64
expected sync.Map
Expand Down Expand Up @@ -95,6 +97,8 @@ type (
// where a race condition causes duplicate records. We always
// take the later timestamp.
lastValueState struct {
_ int32

// raw has to be aligned for 64-bit atomic operations.
raw number.Number
ts time.Time
Expand Down