Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump go.opentelemetry.io/collector/pdata from 0.54.1-0.20220705210223-9f0d97ca5741 to 1.0.0-rcv0014 in /receiver/rabbitmqreceiver #5441

Closed
10 changes: 10 additions & 0 deletions processor/spanmetricsprocessor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,16 @@ func (p *processorImp) aggregateMetricsForServiceSpans(rspans ptrace.ResourceSpa
func (p *processorImp) aggregateMetricsForSpan(serviceName string, span ptrace.Span, resourceAttr pcommon.Map) {
latencyInMilliseconds := float64(span.EndTimestamp()-span.StartTimestamp()) / float64(time.Millisecond.Nanoseconds())

if latencyInMilliseconds > maxDurationMs {
p.logger.Warn("Latency exceeds max of int64",
zap.String("service.name", serviceName),
zap.Uint64("startTimeUnixNano", uint64(span.StartTimestamp().AsTime().UnixNano())),
zap.Uint64("endTimeUnixNano", uint64(span.EndTimestamp().AsTime().UnixNano())),
zap.String("span.kind", span.Kind().String()),
zap.String("operation", span.Name()))
return
}

// Binary search to find the latencyInMilliseconds bucket index.
index := sort.SearchFloat64s(p.latencyBounds, latencyInMilliseconds)

Expand Down
47 changes: 47 additions & 0 deletions processor/spanmetricsprocessor/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -842,3 +842,50 @@ func TestProcessorResetExemplarData(t *testing.T) {
assert.NoError(t, err)
assert.Empty(t, p.latencyExemplarsData[key])
}

// ------------------------------------------------------- start of additional block of tests -------------------------------------------------------

func TestTraceLatencyExceedsMaxInt64(t *testing.T) {
mexp := &mocks.MetricsExporter{}
tcon := &mocks.TracesConsumer{}

mexp.On("ConsumeMetrics", mock.Anything, mock.Anything).Return(nil)
tcon.On("ConsumeTraces", mock.Anything, mock.Anything).Return(nil)

defaultNullValue := "defaultNullValue"
p := newProcessorImp(mexp, tcon, &defaultNullValue, cumulative, t)

traces := buildTraceWithHighLatency()

// Test
ctx := metadata.NewIncomingContext(context.Background(), nil)

err := p.ConsumeTraces(ctx, traces)
// Validate
require.NoError(t, err)
}

func buildTraceWithHighLatency() pdata.Traces {
traces := pdata.NewTraces()
rs := traces.ResourceSpans().AppendEmpty()
rs.Resource().Attributes().
InsertString(conventions.AttributeServiceName, "test-service")
ils := rs.InstrumentationLibrarySpans().AppendEmpty()
span := ils.Spans().AppendEmpty()
span.SetName("/test")
span.SetKind(pdata.SpanKindClient)
span.Status().SetCode(pdata.StatusCodeOk)
span.SetStartTimestamp(0)
span.SetEndTimestamp(18446744073709551615)
span.Attributes().InsertString(stringAttrName, "stringAttrValue")
span.Attributes().InsertInt(intAttrName, 99)
span.Attributes().InsertDouble(doubleAttrName, 99.99)
span.Attributes().InsertBool(boolAttrName, true)
span.Attributes().InsertNull(nullAttrName)
span.Attributes().Insert(mapAttrName, pdata.NewAttributeValueMap())
span.Attributes().Insert(arrayAttrName, pdata.NewAttributeValueArray())
span.SetTraceID(pdata.NewTraceID([16]byte{byte(42)}))
return traces
}

// ------------------------------------------------------- end of additional block of tests -------------------------------------------------------
24 changes: 11 additions & 13 deletions receiver/rabbitmqreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ go 1.17

require (
github.com/open-telemetry/opentelemetry-collector-contrib/internal/scrapertest v0.54.0
github.com/stretchr/testify v1.8.0
github.com/stretchr/testify v1.8.4
github.com/testcontainers/testcontainers-go v0.13.0
go.opentelemetry.io/collector v0.54.1-0.20220705210223-9f0d97ca5741
go.opentelemetry.io/collector/pdata v0.54.1-0.20220705210223-9f0d97ca5741
go.uber.org/multierr v1.8.0
go.opentelemetry.io/collector/pdata v1.0.0-rcv0014
go.uber.org/multierr v1.11.0
go.uber.org/zap v1.21.0
)

Expand All @@ -30,7 +30,7 @@ require (
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand All @@ -53,23 +53,21 @@ require (
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.6.1 // indirect
github.com/rs/cors v1.8.2 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/stretchr/objx v0.4.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
go.opencensus.io v0.23.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.32.0 // indirect
go.opentelemetry.io/otel v1.7.0 // indirect
go.opentelemetry.io/otel/metric v0.30.0 // indirect
go.opentelemetry.io/otel/trace v1.7.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect
google.golang.org/grpc v1.47.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.56.2 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

Expand Down
Loading
Loading