Skip to content

Commit

Permalink
gofmt
Browse files Browse the repository at this point in the history
  • Loading branch information
moh-osman3 committed Aug 12, 2024
1 parent 71607aa commit b1cbe2c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 29 deletions.
11 changes: 4 additions & 7 deletions lightstep/sdk/trace/exporters/otlp/otelcol/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ package otelcol
import (
"context"
"errors"
"fmt"
"time"

"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/otelarrowexporter"
"github.com/open-telemetry/otel-arrow/collector/processor/concurrentbatchprocessor"
"github.com/open-telemetry/otel-arrow/collector/admission"
"github.com/open-telemetry/otel-arrow/collector/processor/concurrentbatchprocessor"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configcompression"
"go.opentelemetry.io/collector/config/configgrpc"
Expand Down Expand Up @@ -123,8 +122,6 @@ func (c *client) ExportSpans(ctx context.Context, spans []trace.ReadOnlySpan) (r
for _, span := range spans {
spanSz += sizeOfROSpan(span)
}
fmt.Println("SPAN SIZE")
fmt.Println(spanSz)
retErr = c.boundedQueue.Acquire(ctx, int64(spanSz))
if retErr != nil {
return
Expand Down Expand Up @@ -154,10 +151,10 @@ func (c *client) Shutdown(ctx context.Context) error {

func NewDefaultConfig() Config {
cfg := Config{
SelfMetrics: true,
SelfSpans: true,
SelfMetrics: true,
SelfSpans: true,
AdmissionLimitMiB: 64,
WaiterLimit: 1000,
WaiterLimit: 1000,
Batcher: concurrentbatchprocessor.Config{
Timeout: time.Second,
SendBatchSize: 1000,
Expand Down
19 changes: 11 additions & 8 deletions lightstep/sdk/trace/exporters/otlp/otelcol/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/otelarrowreceiver"
// "github.com/open-telemetry/otel-arrow/collector/admission"
"github.com/stretchr/testify/suite"
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/config/confignet"
Expand All @@ -44,7 +45,6 @@ import (
resourcev1 "go.opentelemetry.io/proto/otlp/resource/v1"
tracev1 "go.opentelemetry.io/proto/otlp/trace/v1"

// "google.golang.org/protobuf/encoding/prototext"
"google.golang.org/protobuf/proto"
)

Expand Down Expand Up @@ -201,15 +201,15 @@ func (t *clientTestSuite) TestSpan() {
{
Resource: &resourcev1.Resource{
Attributes: []*commonpb.KeyValue{
&commonpb.KeyValue{
{
Key: "property",
Value: &commonpb.AnyValue{
Value: &commonpb.AnyValue_StringValue{
StringValue: "value",
},
},
},
&commonpb.KeyValue{
{
Key: "service.name",
Value: &commonpb.AnyValue{
Value: &commonpb.AnyValue_StringValue{
Expand All @@ -220,12 +220,12 @@ func (t *clientTestSuite) TestSpan() {
},
},
ScopeSpans: []*tracev1.ScopeSpans{
&tracev1.ScopeSpans{
{
Scope: &commonpb.InstrumentationScope{
Name: "test-tracer",
},
Spans: []*tracev1.Span{
&tracev1.Span{
{
SpanId: []byte(unqSpanID),
TraceId: []byte(unqTraceID),
Kind: tracev1.Span_SPAN_KIND_SERVER,
Expand All @@ -235,7 +235,7 @@ func (t *clientTestSuite) TestSpan() {
Message: "failed",
},
Attributes: []*commonpb.KeyValue{
&commonpb.KeyValue{
{
Key: "test-attribute-1",
Value: &commonpb.AnyValue{
Value: &commonpb.AnyValue_StringValue{
Expand Down Expand Up @@ -388,6 +388,9 @@ func (t *clientTestSuite) TestSpanSizeTooLarge() {

// AdmissionLimitMiB is 0 so we should have no traces arriving.
t.Equal(0, len(t.sink.AllTraces()))

t.assertTimestamps()
}

roSpans := []sdktrace.ReadOnlySpan{span.(sdktrace.ReadOnlySpan), child.(sdktrace.ReadOnlySpan)}
err = exp.ExportSpans(ctx, roSpans)
t.ErrorContains(err, "request size larger than configured limit")
}
4 changes: 0 additions & 4 deletions lightstep/sdk/trace/exporters/otlp/otelcol/size.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package otelcol

import (
"fmt"
math_bits "math/bits"

"go.opentelemetry.io/otel/attribute"
Expand Down Expand Up @@ -81,8 +80,6 @@ func sizeOfSpanLinks(links []trace.Link) int {
sz += 1 + sovTrace(uint64(link.DroppedAttributeCount))
}
}
fmt.Println("LINK SZ")
fmt.Println(sz)
return sz
}

Expand All @@ -101,7 +98,6 @@ func sizeOfSpanEvents(events []trace.Event) int {
return sz
}


func sizeOfROSpan(span trace.ReadOnlySpan) int {
sz := 0
sz += sizeOfSpanString(span.Name())
Expand Down
19 changes: 9 additions & 10 deletions lightstep/sdk/trace/exporters/otlp/otelcol/size_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"go.opentelemetry.io/collector/pdata/ptrace/ptraceotlp"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/sdk/resource"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
"go.opentelemetry.io/otel/trace"
)

func TestSizeOfSimpleROSpan(t *testing.T) {
Expand All @@ -26,23 +26,23 @@ func TestSizeOfSimpleROSpan(t *testing.T) {
numSpanLinks int
}{
{
name: "simple",
name: "simple",
numSpanAttrs: 10,
},
{
name: "many_attributes",
name: "many_attributes",
numSpanAttrs: 100000,
},
{
name: "with_events",
numSpanAttrs: 100000,
name: "with_events",
numSpanAttrs: 100000,
numSpanEvents: 10000,
},
{
name: "with_links",
numSpanAttrs: 100000,
name: "with_links",
numSpanAttrs: 100000,
numSpanEvents: 10000,
numSpanLinks: 1000,
numSpanLinks: 1000,
},
}
for _, tt := range tests {
Expand Down Expand Up @@ -90,10 +90,9 @@ func TestSizeOfSimpleROSpan(t *testing.T) {

protobufSz := float64(len(data))
ROSpanSz := float64(sizeOfROSpan(roSpan))
percentDiff := math.Abs((ROSpanSz - protobufSz)/protobufSz)
percentDiff := math.Abs((ROSpanSz - protobufSz) / protobufSz)

assert.LessOrEqual(t, percentDiff, 0.1)
fmt.Println(percentDiff)
})
}
}

0 comments on commit b1cbe2c

Please sign in to comment.