From 2a2a49e6616c0d8b4c0e30de88b16bdb6ba31945 Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Thu, 14 Dec 2023 19:35:44 -0800 Subject: [PATCH] [chore] Replace usage of opencensus trace with otel trace in signalfxreceiver (#29903) Signed-off-by: Bogdan Drutu --- receiver/signalfxreceiver/go.mod | 5 ++--- receiver/signalfxreceiver/go.sum | 1 - receiver/signalfxreceiver/receiver.go | 19 +------------------ 3 files changed, 3 insertions(+), 22 deletions(-) diff --git a/receiver/signalfxreceiver/go.mod b/receiver/signalfxreceiver/go.mod index a6287a10cd46..52731ec51692 100644 --- a/receiver/signalfxreceiver/go.mod +++ b/receiver/signalfxreceiver/go.mod @@ -11,7 +11,6 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/signalfx v0.91.0 github.com/signalfx/com_signalfx_metrics_protobuf v0.0.3 github.com/stretchr/testify v1.8.4 - go.opencensus.io v0.24.0 go.opentelemetry.io/collector/component v0.91.0 go.opentelemetry.io/collector/config/confighttp v0.91.0 go.opentelemetry.io/collector/config/configtls v0.91.0 @@ -20,7 +19,6 @@ require ( go.opentelemetry.io/collector/exporter v0.91.0 go.opentelemetry.io/collector/pdata v1.0.0 go.opentelemetry.io/collector/receiver v0.91.0 - go.opentelemetry.io/collector/semconv v0.91.0 go.uber.org/zap v1.26.0 ) @@ -35,7 +33,6 @@ require ( github.com/go-ole/go-ole v1.2.6 // indirect github.com/gobwas/glob v0.2.3 // 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.3 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/hashicorp/go-version v1.6.0 // indirect @@ -62,6 +59,7 @@ require ( github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect github.com/yusufpapurcu/wmi v1.2.3 // indirect + go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/collector v0.91.0 // indirect go.opentelemetry.io/collector/config/configauth v0.91.0 // indirect go.opentelemetry.io/collector/config/configcompression v0.91.0 // indirect @@ -71,6 +69,7 @@ require ( go.opentelemetry.io/collector/extension v0.91.0 // indirect go.opentelemetry.io/collector/extension/auth v0.91.0 // indirect go.opentelemetry.io/collector/featuregate v1.0.0 // indirect + go.opentelemetry.io/collector/semconv v0.91.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect go.opentelemetry.io/otel v1.21.0 // indirect go.opentelemetry.io/otel/metric v1.21.0 // indirect diff --git a/receiver/signalfxreceiver/go.sum b/receiver/signalfxreceiver/go.sum index 6fde3d5d6394..157cc87e34d2 100644 --- a/receiver/signalfxreceiver/go.sum +++ b/receiver/signalfxreceiver/go.sum @@ -36,7 +36,6 @@ github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69 github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= diff --git a/receiver/signalfxreceiver/receiver.go b/receiver/signalfxreceiver/receiver.go index 23cf6f637da9..419112058577 100644 --- a/receiver/signalfxreceiver/receiver.go +++ b/receiver/signalfxreceiver/receiver.go @@ -17,13 +17,11 @@ import ( "github.com/gorilla/mux" sfxpb "github.com/signalfx/com_signalfx_metrics_protobuf/model" - "go.opencensus.io/trace" "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/pdata/plog" "go.opentelemetry.io/collector/receiver" "go.opentelemetry.io/collector/receiver/receiverhelper" - conventions "go.opentelemetry.io/collector/semconv/v1.6.1" "go.uber.org/zap" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/splunk" @@ -329,22 +327,7 @@ func (r *sfxReceiver) failRequest( // Use the same pattern as strings.Builder String(). msg := *(*string)(unsafe.Pointer(&jsonResponse)) - reqSpan := trace.FromContext(ctx) - reqSpan.AddAttributes( - trace.Int64Attribute(conventions.AttributeHTTPStatusCode, int64(httpStatusCode)), - trace.StringAttribute("http.status_text", msg)) - traceStatus := trace.Status{ - Code: trace.StatusCodeInvalidArgument, - } - if httpStatusCode == http.StatusInternalServerError { - traceStatus.Code = trace.StatusCodeInternal - } - if err != nil { - traceStatus.Message = err.Error() - } - reqSpan.SetStatus(traceStatus) - reqSpan.End() - + r.obsrecv.EndMetricsOp(ctx, metadata.Type, 0, err) r.settings.Logger.Debug( "SignalFx receiver request failed", zap.Int("http_status_code", httpStatusCode),