Skip to content

Commit

Permalink
npe fix and other touchups
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanfkeepers committed Nov 5, 2024
1 parent a7655de commit 79b145f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion clues.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
// such as OTEL communication. Clues will use these optimistically in the
// background to provide additional telemetry hook-ins.
//
// Clues will operate as expected in the event of an error, or of initialization
// Clues will operate as expected in the event of an error, or if initialization
// is not called. This is a purely optional step.
func Initialize(
ctx context.Context,
Expand Down
8 changes: 2 additions & 6 deletions datanode.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ func (dn *dataNode) addSpan(
name string,
) (context.Context, *dataNode) {
if dn == nil || dn.otel == nil {
return ctx, dn.spawnDescendant()
return ctx, dn
}

ctx, span := dn.otel.tracer.Start(ctx, name)
Expand All @@ -428,7 +428,7 @@ func (dn *dataNode) addSpan(
// If no span is present, no ops.
func (dn *dataNode) closeSpan(ctx context.Context) *dataNode {
if dn == nil || dn.span == nil {
return dn.spawnDescendant()
return dn
}

dn.span.End()
Expand All @@ -449,10 +449,6 @@ func (dn *dataNode) addSpanAttributes(
return
}

if len(values) == 0 {
return
}

for k, v := range values {
dn.span.SetAttributes(attribute.String(k, stringify.Marshal(v, false)))
}
Expand Down
6 changes: 3 additions & 3 deletions otel.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func newOTELClient(
config OTELConfig,
) (*otelClient, error) {
// -- Resource
resource, err := resource.New(ctx, resource.WithAttributes(
srvResource, err := resource.New(ctx, resource.WithAttributes(
semconv.ServiceNameKey.String(serviceName)))
if err != nil {
return nil, WrapWC(ctx, err, "creating otel resource")
Expand All @@ -88,7 +88,7 @@ func newOTELClient(
// Note the use of insecure transport here. TLS is recommended in production.
grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return nil, WrapWC(ctx, err, "creating new gRPC connection")
return nil, WrapWC(ctx, err, "creating new grpc connection")
}

exporter, err := otlptracegrpc.New(ctx, otlptracegrpc.WithGRPCConn(conn))
Expand All @@ -103,7 +103,7 @@ func newOTELClient(
batchSpanProcessor := sdkTrace.NewBatchSpanProcessor(exporter)

tracerProvider := sdkTrace.NewTracerProvider(
sdkTrace.WithResource(resource),
sdkTrace.WithResource(srvResource),
sdkTrace.WithSampler(sdkTrace.AlwaysSample()),
sdkTrace.WithSpanProcessor(batchSpanProcessor),
sdkTrace.WithRawSpanLimits(sdkTrace.SpanLimits{
Expand Down

0 comments on commit 79b145f

Please sign in to comment.