Skip to content

Commit

Permalink
Merge branch 'main' into en/zipkin-custom-headers
Browse files Browse the repository at this point in the history
  • Loading branch information
srijan-27 authored Jun 24, 2024
2 parents 4606683 + f6a5aa2 commit bf66dcd
Show file tree
Hide file tree
Showing 24 changed files with 46 additions and 48 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ jobs:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
file: ./coverage.txt
fail_ci_if_error: true
verbose: true
- name: Store coverage test output
uses: actions/upload-artifact@v4
Expand Down
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ linters:
- staticcheck
- tenv
- typecheck
- unconvert
- unused
- unparam

issues:
# Maximum issues count per one linter.
Expand Down
2 changes: 1 addition & 1 deletion bridge/opencensus/internal/ocmetric/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func convertKV(key string, value any) attribute.KeyValue {
case uintptr:
return uint64KV(key, uint64(typedVal))
case uint64:
return uint64KV(key, uint64(typedVal))
return uint64KV(key, typedVal)
case float32:
return attribute.Float64(key, float64(typedVal))
case float64:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ func TestConfigs(t *testing.T) {
{
name: "Test With Timeout",
opts: []GenericOption{
WithTimeout(time.Duration(5 * time.Second)),
WithTimeout(5 * time.Second),
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, 5*time.Second, c.Metrics.Timeout)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func metric(m metricdata.Metrics) (*mpb.Metric, error) {
out := &mpb.Metric{
Name: m.Name,
Description: m.Description,
Unit: string(m.Unit),
Unit: m.Unit,
}
switch a := m.Data.(type) {
case metricdata.Gauge[int64]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ func TestConfigs(t *testing.T) {
{
name: "Test With Timeout",
opts: []GenericOption{
WithTimeout(time.Duration(5 * time.Second)),
WithTimeout(5 * time.Second),
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, 5*time.Second, c.Metrics.Timeout)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func metric(m metricdata.Metrics) (*mpb.Metric, error) {
out := &mpb.Metric{
Name: m.Name,
Description: m.Description,
Unit: string(m.Unit),
Unit: m.Unit,
}
switch a := m.Data.(type) {
case metricdata.Gauge[int64]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ func TestConfigs(t *testing.T) {
{
name: "Test With Timeout",
opts: []GenericOption{
WithTimeout(time.Duration(5 * time.Second)),
WithTimeout(5 * time.Second),
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, 5*time.Second, c.Traces.Timeout)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ func TestConfigs(t *testing.T) {
{
name: "Test With Timeout",
opts: []GenericOption{
WithTimeout(time.Duration(5 * time.Second)),
WithTimeout(5 * time.Second),
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, 5*time.Second, c.Traces.Timeout)
Expand Down
4 changes: 2 additions & 2 deletions exporters/stdout/stdouttrace/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type config struct {
}

// newConfig creates a validated Config configured with options.
func newConfig(options ...Option) (config, error) {
func newConfig(options ...Option) config {
cfg := config{
Writer: defaultWriter,
PrettyPrint: defaultPrettyPrint,
Expand All @@ -38,7 +38,7 @@ func newConfig(options ...Option) (config, error) {
for _, opt := range options {
cfg = opt.apply(cfg)
}
return cfg, nil
return cfg
}

// Option sets the value of an option for a Config.
Expand Down
5 changes: 1 addition & 4 deletions exporters/stdout/stdouttrace/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ var _ trace.SpanExporter = &Exporter{}

// New creates an Exporter with the passed options.
func New(options ...Option) (*Exporter, error) {
cfg, err := newConfig(options...)
if err != nil {
return nil, err
}
cfg := newConfig(options...)

enc := json.NewEncoder(cfg.Writer)
if cfg.PrettyPrint {
Expand Down
2 changes: 1 addition & 1 deletion internal/shared/otlp/otlpmetric/oconf/options_test.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ func TestConfigs(t *testing.T) {
{
name: "Test With Timeout",
opts: []GenericOption{
WithTimeout(time.Duration(5 * time.Second)),
WithTimeout(5 * time.Second),
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, 5*time.Second, c.Metrics.Timeout)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func metric(m metricdata.Metrics) (*mpb.Metric, error) {
out := &mpb.Metric{
Name: m.Name,
Description: m.Description,
Unit: string(m.Unit),
Unit: m.Unit,
}
switch a := m.Data.(type) {
case metricdata.Gauge[int64]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ func TestConfigs(t *testing.T) {
{
name: "Test With Timeout",
opts: []GenericOption{
WithTimeout(time.Duration(5 * time.Second)),
WithTimeout(5 * time.Second),
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, 5*time.Second, c.Traces.Timeout)
Expand Down
34 changes: 17 additions & 17 deletions log/keyvalue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ func TestEmptyGroupsPreserved(t *testing.T) {
}

func TestBool(t *testing.T) {
const key, val = "key", true
const key, val = "boolKey", true
kv := log.Bool(key, val)
testKV(t, key, val, kv)
testKV(t, key, kv)

v, k := kv.Value, log.KindBool
t.Run("AsBool", func(t *testing.T) {
Expand All @@ -148,9 +148,9 @@ func TestBool(t *testing.T) {
}

func TestFloat64(t *testing.T) {
const key, val = "key", 3.0
const key, val = "float64Key", 3.0
kv := log.Float64(key, val)
testKV(t, key, val, kv)
testKV(t, key, kv)

v, k := kv.Value, log.KindFloat64
t.Run("AsBool", testErrKind(v.AsBool, "AsBool", k))
Expand All @@ -165,9 +165,9 @@ func TestFloat64(t *testing.T) {
}

func TestInt(t *testing.T) {
const key, val = "key", 1
const key, val = "intKey", 1
kv := log.Int(key, val)
testKV[int64](t, key, val, kv)
testKV(t, key, kv)

v, k := kv.Value, log.KindInt64
t.Run("AsBool", testErrKind(v.AsBool, "AsBool", k))
Expand All @@ -182,9 +182,9 @@ func TestInt(t *testing.T) {
}

func TestInt64(t *testing.T) {
const key, val = "key", 1
const key, val = "int64Key", 1
kv := log.Int64(key, val)
testKV[int64](t, key, val, kv)
testKV(t, key, kv)

v, k := kv.Value, log.KindInt64
t.Run("AsBool", testErrKind(v.AsBool, "AsBool", k))
Expand All @@ -199,9 +199,9 @@ func TestInt64(t *testing.T) {
}

func TestString(t *testing.T) {
const key, val = "key", "test string value"
const key, val = "stringKey", "test string value"
kv := log.String(key, val)
testKV(t, key, val, kv)
testKV(t, key, kv)

v, k := kv.Value, log.KindString
t.Run("AsBool", testErrKind(v.AsBool, "AsBool", k))
Expand All @@ -216,10 +216,10 @@ func TestString(t *testing.T) {
}

func TestBytes(t *testing.T) {
const key = "key"
const key = "bytesKey"
val := []byte{3, 2, 1}
kv := log.Bytes(key, val)
testKV(t, key, val, kv)
testKV(t, key, kv)

v, k := kv.Value, log.KindBytes
t.Run("AsBool", testErrKind(v.AsBool, "AsBool", k))
Expand All @@ -234,10 +234,10 @@ func TestBytes(t *testing.T) {
}

func TestSlice(t *testing.T) {
const key = "key"
const key = "sliceKey"
val := []log.Value{log.IntValue(3), log.StringValue("foo")}
kv := log.Slice(key, val...)
testKV(t, key, val, kv)
testKV(t, key, kv)

v, k := kv.Value, log.KindSlice
t.Run("AsBool", testErrKind(v.AsBool, "AsBool", k))
Expand All @@ -252,13 +252,13 @@ func TestSlice(t *testing.T) {
}

func TestMap(t *testing.T) {
const key = "key"
const key = "mapKey"
val := []log.KeyValue{
log.Slice("l", log.IntValue(3), log.StringValue("foo")),
log.Bytes("b", []byte{3, 5, 7}),
}
kv := log.Map(key, val...)
testKV(t, key, val, kv)
testKV(t, key, kv)

v, k := kv.Value, log.KindMap
t.Run("AsBool", testErrKind(v.AsBool, "AsBool", k))
Expand Down Expand Up @@ -339,7 +339,7 @@ func testErrKind[T any](f func() T, msg string, k log.Kind) func(*testing.T) {
}
}

func testKV[T any](t *testing.T, key string, val T, kv log.KeyValue) {
func testKV(t *testing.T, key string, kv log.KeyValue) {
t.Helper()

assert.Equal(t, key, kv.Key, "incorrect key")
Expand Down
2 changes: 1 addition & 1 deletion sdk/internal/x/x_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func run(steps ...func(*testing.T)) func(*testing.T) {
}
}

func setenv(k, v string) func(t *testing.T) {
func setenv(k, v string) func(t *testing.T) { //nolint:unparam
return func(t *testing.T) { t.Setenv(k, v) }
}

Expand Down
4 changes: 2 additions & 2 deletions sdk/metric/internal/exemplar/reservoir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ func ReservoirTest[N int64 | float64](f factory) func(*testing.T) {
want := Exemplar{
Time: staticTime,
Value: NewValue(N(10)),
SpanID: []byte(sID[:]),
TraceID: []byte(tID[:]),
SpanID: sID[:],
TraceID: tID[:],
}
require.Len(t, dest, 1, "number of collected exemplars")
assert.Equal(t, want, dest[0])
Expand Down
2 changes: 1 addition & 1 deletion sdk/trace/batch_span_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ func (bsp *batchSpanProcessor) enqueueBlockOnQueueFull(ctx context.Context, sd R
}
}

func (bsp *batchSpanProcessor) enqueueDrop(ctx context.Context, sd ReadOnlySpan) bool {
func (bsp *batchSpanProcessor) enqueueDrop(_ context.Context, sd ReadOnlySpan) bool {
if !sd.SpanContext().IsSampled() {
return false
}
Expand Down
4 changes: 2 additions & 2 deletions sdk/trace/batch_span_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ func createAndRegisterBatchSP(option testOption, te *testBatchExporter) sdktrace
return sdktrace.NewBatchSpanProcessor(te, options...)
}

func generateSpan(t *testing.T, tr trace.Tracer, option testOption) {
func generateSpan(_ *testing.T, tr trace.Tracer, option testOption) {
sc := getSpanContext()

for i := 0; i < option.genNumSpans; i++ {
Expand All @@ -353,7 +353,7 @@ func generateSpan(t *testing.T, tr trace.Tracer, option testOption) {
}
}

func generateSpanParallel(t *testing.T, tr trace.Tracer, option testOption) {
func generateSpanParallel(_ *testing.T, tr trace.Tracer, option testOption) {
sc := getSpanContext()

wg := &sync.WaitGroup{}
Expand Down
2 changes: 1 addition & 1 deletion sdk/trace/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func traceBenchmark(b *testing.B, name string, fn func(*testing.B, trace.Tracer)
})
}

func tracer(b *testing.B, name string, sampler sdktrace.Sampler) trace.Tracer {
func tracer(_ *testing.B, name string, sampler sdktrace.Sampler) trace.Tracer {
tp := sdktrace.NewTracerProvider(sdktrace.WithSampler(sampler))
return tp.Tracer(name)
}
2 changes: 1 addition & 1 deletion sdk/trace/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
sdktrace "go.opentelemetry.io/otel/sdk/trace"
)

func basicTracerProvider(t *testing.T) *sdktrace.TracerProvider {
func basicTracerProvider(_ *testing.T) *sdktrace.TracerProvider {
tp := sdktrace.NewTracerProvider(sdktrace.WithSampler(sdktrace.AlwaysSample()))
return tp
}
4 changes: 2 additions & 2 deletions semconv/internal/v2/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (c *NetConv) Host(address string) []attribute.KeyValue {
attrs := make([]attribute.KeyValue, 0, n)
attrs = append(attrs, c.HostName(h))
if p > 0 {
attrs = append(attrs, c.HostPort(int(p)))
attrs = append(attrs, c.HostPort(p))
}
return attrs
}
Expand Down Expand Up @@ -252,7 +252,7 @@ func (c *NetConv) Peer(address string) []attribute.KeyValue {
attrs := make([]attribute.KeyValue, 0, n)
attrs = append(attrs, c.PeerName(h))
if p > 0 {
attrs = append(attrs, c.PeerPort(int(p)))
attrs = append(attrs, c.PeerPort(p))
}
return attrs
}
Expand Down
4 changes: 2 additions & 2 deletions semconv/internal/v3/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (c *NetConv) Host(address string) []attribute.KeyValue {
attrs := make([]attribute.KeyValue, 0, n)
attrs = append(attrs, c.HostName(h))
if p > 0 {
attrs = append(attrs, c.HostPort(int(p)))
attrs = append(attrs, c.HostPort(p))
}
return attrs
}
Expand Down Expand Up @@ -252,7 +252,7 @@ func (c *NetConv) Peer(address string) []attribute.KeyValue {
attrs := make([]attribute.KeyValue, 0, n)
attrs = append(attrs, c.PeerName(h))
if p > 0 {
attrs = append(attrs, c.PeerPort(int(p)))
attrs = append(attrs, c.PeerPort(p))
}
return attrs
}
Expand Down
4 changes: 2 additions & 2 deletions semconv/internal/v4/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (c *NetConv) Host(address string) []attribute.KeyValue {
attrs := make([]attribute.KeyValue, 0, n)
attrs = append(attrs, c.HostName(h))
if p > 0 {
attrs = append(attrs, c.HostPort(int(p)))
attrs = append(attrs, c.HostPort(p))
}
return attrs
}
Expand Down Expand Up @@ -252,7 +252,7 @@ func (c *NetConv) Peer(address string) []attribute.KeyValue {
attrs := make([]attribute.KeyValue, 0, n)
attrs = append(attrs, c.PeerName(h))
if p > 0 {
attrs = append(attrs, c.PeerPort(int(p)))
attrs = append(attrs, c.PeerPort(p))
}
return attrs
}
Expand Down

0 comments on commit bf66dcd

Please sign in to comment.