diff --git a/instrumentation/go.mongodb.org/mongo-driver/mongo.go b/instrumentation/go.mongodb.org/mongo-driver/mongo.go index 34d7de62166..9c74d59969e 100644 --- a/instrumentation/go.mongodb.org/mongo-driver/mongo.go +++ b/instrumentation/go.mongodb.org/mongo-driver/mongo.go @@ -44,7 +44,7 @@ func (m *monitor) Started(ctx context.Context, evt *event.CommandStartedEvent) { b, _ := bson.MarshalExtJSON(evt.Command, false, false) attrs := []label.KeyValue{ ServiceName(m.serviceName), - ResourceName("mongo." + evt.CommandName), + DBOperation(evt.CommandName), DBInstance(evt.DatabaseName), DBStatement(string(b)), DBSystem("mongodb"), diff --git a/instrumentation/go.mongodb.org/mongo-driver/mongo_test.go b/instrumentation/go.mongodb.org/mongo-driver/mongo_test.go index 28b5fe6bc39..b98b6c34a6b 100644 --- a/instrumentation/go.mongodb.org/mongo-driver/mongo_test.go +++ b/instrumentation/go.mongodb.org/mongo-driver/mongo_test.go @@ -67,7 +67,7 @@ func Test(t *testing.T) { s := spans[0] assert.Equal(t, "mongo", s.Attributes[ServiceNameKey].AsString()) - assert.Equal(t, "mongo.insert", s.Attributes[ResourceNameKey].AsString()) + assert.Equal(t, "insert", s.Attributes[DBOperationKey].AsString()) assert.Equal(t, hostname, s.Attributes[PeerHostnameKey].AsString()) assert.Equal(t, port, s.Attributes[PeerPortKey].AsString()) assert.Contains(t, s.Attributes[DBStatementKey].AsString(), `"test-item":"test-value"`) diff --git a/instrumentation/go.mongodb.org/mongo-driver/tags.go b/instrumentation/go.mongodb.org/mongo-driver/tags.go index f9c8639c515..6fb7b708224 100644 --- a/instrumentation/go.mongodb.org/mongo-driver/tags.go +++ b/instrumentation/go.mongodb.org/mongo-driver/tags.go @@ -17,16 +17,12 @@ package mongo import "go.opentelemetry.io/otel/label" const ( - TargetHostKey = label.Key("out.host") - TargetPortKey = label.Key("out.port") - HTTPMethodKey = label.Key("http.method") - HTTPCodeKey = label.Key("http.code") - HTTPURLKey = label.Key("http.url") - SpanTypeKey = label.Key("span.type") - ServiceNameKey = label.Key("service.name") - ResourceNameKey = label.Key("resource.name") - ErrorKey = label.Key("error") - ErrorMsgKey = label.Key("error.msg") + TargetHostKey = label.Key("out.host") + TargetPortKey = label.Key("out.port") + ServiceNameKey = label.Key("service.name") + DBOperationKey = label.Key("db.operation") + ErrorKey = label.Key("error") + ErrorMsgKey = label.Key("error.msg") ) // TargetHost sets the target host address. @@ -39,34 +35,14 @@ func TargetPort(targetPort string) label.KeyValue { return TargetPortKey.String(targetPort) } -// HTTPMethod specifies the HTTP method used in a span. -func HTTPMethod(httpMethod string) label.KeyValue { - return HTTPMethodKey.String(httpMethod) -} - -// HTTPCode sets the HTTP status code as a attribute. -func HTTPCode(httpCode string) label.KeyValue { - return HTTPCodeKey.String(httpCode) -} - -// HTTPURL sets the HTTP URL for a span. -func HTTPURL(httpURL string) label.KeyValue { - return HTTPURLKey.String(httpURL) -} - -// SpanType defines the Span type (web, db, cache). -func SpanType(spanType string) label.KeyValue { - return SpanTypeKey.String(spanType) -} - // ServiceName defines the Service name for this Span. func ServiceName(serviceName string) label.KeyValue { return ServiceNameKey.String(serviceName) } -// ResourceName defines the Resource name for the Span. -func ResourceName(resourceName string) label.KeyValue { - return ResourceNameKey.String(resourceName) +// DBOperation defines the name of the operation. +func DBOperation(operation string) label.KeyValue { + return DBOperationKey.String(operation) } // Error specifies whether an error occurred.