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

mongo: use db.operation instead of resource.name #337

Merged
merged 3 commits into from
Sep 13, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion instrumentation/go.mongodb.org/mongo-driver/mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/go.mongodb.org/mongo-driver/mongo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`)
Expand Down
26 changes: 13 additions & 13 deletions instrumentation/go.mongodb.org/mongo-driver/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ 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")
HTTPMethodKey = label.Key("http.method")
HTTPCodeKey = label.Key("http.code")
HTTPURLKey = label.Key("http.url")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like HTTP* keys are unused and look out of place (and http.code should be http.status_code). Should I remove them?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if they're unused there's no point keeping them around. There should be equivalents in the semconv package anyways.

SpanTypeKey = label.Key("span.type")
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.
Expand Down Expand Up @@ -64,9 +64,9 @@ 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.
Expand Down