Skip to content

Commit

Permalink
[receiver/solace]: updated the relevant attribute keys to match the l…
Browse files Browse the repository at this point in the history
…atest semantic conventions - v1.25.0
  • Loading branch information
oodigie committed May 14, 2024
1 parent 0e2f434 commit cb5902b
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 69 deletions.
2 changes: 1 addition & 1 deletion receiver/solacereceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ status:
beta: [traces]
distributions: [contrib]
codeowners:
active: [djaglowski, mcardy]
active: [djaglowski, mcardy, oodigie]

# TODO: Update the receiver to pass the tests
tests:
Expand Down
29 changes: 16 additions & 13 deletions receiver/solacereceiver/unmarshaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,14 @@ const (

// span keys
const (
protocolAttrKey = "messaging.protocol"
protocolVersionAttrKey = "messaging.protocol_version"
messageIDAttrKey = "messaging.message_id"
conversationIDAttrKey = "messaging.conversation_id"
payloadSizeBytesAttrKey = "messaging.message_payload_size_bytes"
destinationAttrKey = "messaging.destination"
protocolAttrKey = "network.protocol.name"
protocolVersionAttrKey = "network.protocol.version"
messageIDAttrKey = "messaging.message.id"
conversationIDAttrKey = "messaging.message.conversation_id"
messageBodySizeBytesAttrKey = "messaging.message.body.size"
messageEnvelopeSizeBytesAttrKey = "messaging.message.envelope.size"
destinationNameAttrKey = "messaging.destination.name"
isUnknownAnonymousDistinationKey = "messaging.destination.anonymous"
clientUsernameAttrKey = "messaging.solace.client_username"
clientNameAttrKey = "messaging.solace.client_name"
replicationGroupMessageIDAttrKey = "messaging.solace.replication_group_message_id"
Expand All @@ -131,17 +133,18 @@ const (
receiveTimeAttrKey = "messaging.solace.broker_receive_time_unix_nano"
droppedUserPropertiesAttrKey = "messaging.solace.dropped_application_message_properties"
deliveryModeAttrKey = "messaging.solace.delivery_mode"
hostIPAttrKey = "net.host.ip"
hostPortAttrKey = "net.host.port"
peerIPAttrKey = "net.peer.ip"
peerPortAttrKey = "net.peer.port"
hostIPAttrKey = "server.address"
hostPortAttrKey = "server.port"
peerIPAttrKey = "network.peer.address"
peerPortAttrKey = "network.peer.port"
)

// constant attributes
const (
systemAttrKey = "messaging.system"
systemAttrValue = "SolacePubSub+"
operationAttrKey = "messaging.operation"
systemAttrKey = "messaging.system"
systemAttrValue = "SolacePubSub+"
operationNameAttrKey = "messaging.operation.name"
operationTypeAttrKey = "messaging.operation.type"
)

func setResourceSpanAttributes(attrMap pcommon.Map, routerName, version string, messageVpnName *string) {
Expand Down
12 changes: 7 additions & 5 deletions receiver/solacereceiver/unmarshaller_egress.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,19 @@ func (u *brokerTraceEgressUnmarshallerV1) mapSendSpan(sendSpan *egress_v1.SpanDa
outcomeKey = "messaging.solace.send.outcome"
)
const (
sendSpanOperation = "send"
sendNameSuffix = " send"
unknownSendName = "(unknown)"
anonymousSendName = "(anonymous)"
sendSpanOperationName = "send"
sendSpanOperationType = "publish"
sendNameSuffix = " send"
unknownSendName = "(unknown)"
anonymousSendName = "(anonymous)"
)
// hard coded to producer span
span.SetKind(ptrace.SpanKindProducer)

attributes := span.Attributes()
attributes.PutStr(systemAttrKey, systemAttrValue)
attributes.PutStr(operationAttrKey, sendSpanOperation)
attributes.PutStr(operationNameAttrKey, sendSpanOperationName)
attributes.PutStr(operationTypeAttrKey, sendSpanOperationType)
attributes.PutStr(protocolAttrKey, sendSpan.Protocol)
if sendSpan.ProtocolVersion != nil {
attributes.PutStr(protocolVersionAttrKey, *sendSpan.ProtocolVersion)
Expand Down
28 changes: 16 additions & 12 deletions receiver/solacereceiver/unmarshaller_egress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ var validEgressSpans = []struct {
span.SetKind(4)
spanAttrs := span.Attributes()
spanAttrs.PutStr("messaging.system", "SolacePubSub+")
spanAttrs.PutStr("messaging.operation", "send")
spanAttrs.PutStr("messaging.protocol", "SMF")
spanAttrs.PutStr("messaging.protocol_version", "3.0")
spanAttrs.PutStr("messaging.operation.name", "send") // Operation name
spanAttrs.PutStr("messaging.operation.type", "publish") // Operation type
spanAttrs.PutStr("network.protocol.name", "SMF")
spanAttrs.PutStr("network.protocol.version", "3.0")
spanAttrs.PutStr("messaging.source.name", "someQueue")
spanAttrs.PutStr("messaging.source.kind", "queue")
spanAttrs.PutStr("messaging.solace.client_username", "clientUsername")
Expand Down Expand Up @@ -174,9 +175,10 @@ var validEgressSpans = []struct {
span.Status().SetMessage("someErrorOccurred")
spanAttrs := span.Attributes()
spanAttrs.PutStr("messaging.system", "SolacePubSub+")
spanAttrs.PutStr("messaging.operation", "send")
spanAttrs.PutStr("messaging.protocol", "MQTT")
spanAttrs.PutStr("messaging.protocol_version", "5.0")
spanAttrs.PutStr("messaging.operation.name", "send")
spanAttrs.PutStr("messaging.operation.type", "publish")
spanAttrs.PutStr("network.protocol.name", "MQTT")
spanAttrs.PutStr("network.protocol.version", "5.0")
spanAttrs.PutStr("messaging.source.name", "queueName")
spanAttrs.PutStr("messaging.source.kind", "queue")
spanAttrs.PutStr("messaging.solace.client_username", "someClientUsername")
Expand Down Expand Up @@ -239,9 +241,10 @@ var validEgressSpans = []struct {
span.SetKind(4)
spanAttrs := span.Attributes()
spanAttrs.PutStr("messaging.system", "SolacePubSub+")
spanAttrs.PutStr("messaging.operation", "send")
spanAttrs.PutStr("messaging.protocol", "AMQP")
spanAttrs.PutStr("messaging.protocol_version", "1.0")
spanAttrs.PutStr("messaging.operation.name", "send")
spanAttrs.PutStr("messaging.operation.type", "publish")
spanAttrs.PutStr("network.protocol.name", "AMQP")
spanAttrs.PutStr("network.protocol.version", "1.0")
spanAttrs.PutStr("messaging.source.name", "topicEndpointName")
spanAttrs.PutStr("messaging.source.kind", "topic-endpoint")
spanAttrs.PutStr("messaging.solace.client_username", "someOtherClientUsername")
Expand Down Expand Up @@ -314,9 +317,10 @@ func TestEgressUnmarshallerSendSpanAttributes(t *testing.T) {
getSpan := func(attributes map[string]any, name string) ptrace.Span {
base := map[string]any{
"messaging.system": "SolacePubSub+",
"messaging.operation": "send",
"messaging.protocol": "MQTT",
"messaging.protocol_version": "5.0",
"messaging.operation.name": "send",
"messaging.operation.type": "publish",
"network.protocol.name": "MQTT",
"network.protocol.version": "5.0",
"messaging.solace.client_username": "someUser",
"messaging.solace.client_name": "someName",
"messaging.solace.message_replayed": false,
Expand Down
17 changes: 13 additions & 4 deletions receiver/solacereceiver/unmarshaller_receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,10 @@ func (u *brokerTraceReceiveUnmarshallerV1) mapClientSpanData(spanData *receive_v
// Will also copy any user properties stored in the SpanData with a best effort approach.
func (u *brokerTraceReceiveUnmarshallerV1) mapClientSpanAttributes(spanData *receive_v1.SpanData, attrMap pcommon.Map) {
// receive operation
const operationAttrValue = "receive"
const operationTypeAttrValue = "receive"
attrMap.PutStr(systemAttrKey, systemAttrValue)
attrMap.PutStr(operationAttrKey, operationAttrValue)
attrMap.PutStr(operationNameAttrKey, operationTypeAttrValue)
attrMap.PutStr(operationTypeAttrKey, operationTypeAttrValue)

attrMap.PutStr(protocolAttrKey, spanData.Protocol)
if spanData.ProtocolVersion != nil {
Expand All @@ -125,11 +126,19 @@ func (u *brokerTraceReceiveUnmarshallerV1) mapClientSpanAttributes(spanData *rec
if spanData.CorrelationId != nil {
attrMap.PutStr(conversationIDAttrKey, *spanData.CorrelationId)
}
attrMap.PutInt(payloadSizeBytesAttrKey, int64(spanData.BinaryAttachmentSize+spanData.XmlAttachmentSize+spanData.MetadataSize))
attrMap.PutInt(messageBodySizeBytesAttrKey, int64(spanData.BinaryAttachmentSize+spanData.XmlAttachmentSize)) // only message payload
attrMap.PutInt(messageEnvelopeSizeBytesAttrKey, int64(spanData.BinaryAttachmentSize+spanData.XmlAttachmentSize+spanData.MetadataSize)) // payload with metadata
attrMap.PutStr(clientUsernameAttrKey, spanData.ClientUsername)
attrMap.PutStr(clientNameAttrKey, spanData.ClientName)
attrMap.PutInt(receiveTimeAttrKey, spanData.BrokerReceiveTimeUnixNano)
attrMap.PutStr(destinationAttrKey, spanData.Topic)
attrMap.PutStr(destinationNameAttrKey, spanData.Topic)

// destination was to an anonymous/unknown queue/topic
var unknownAnonymousDistinationValue bool = false
if isAnonymousTopicEndpoint(spanData.Topic) {
unknownAnonymousDistinationValue = true
}
attrMap.PutBool(isUnknownAnonymousDistinationKey, unknownAnonymousDistinationValue)

var deliveryMode string
switch spanData.DeliveryMode {
Expand Down
55 changes: 32 additions & 23 deletions receiver/solacereceiver/unmarshaller_receive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,16 @@ func TestReceiveUnmarshallerMapClientSpanAttributes(t *testing.T) {
},
want: map[string]any{
"messaging.system": "SolacePubSub+",
"messaging.operation": "receive",
"messaging.protocol": "MQTT",
"messaging.protocol_version": "5.0",
"messaging.message_id": "someMessageID",
"messaging.conversation_id": "someConversationID",
"messaging.message_payload_size_bytes": int64(1234),
"messaging.destination": "someTopic",
"messaging.operation.name": "receive",
"messaging.operation.type": "receive",
"network.protocol.name": "MQTT",
"network.protocol.version": "5.0",
"messaging.message.id": "someMessageID",
"messaging.message.conversation_id": "someConversationID", // message correlation ID
"messaging.message.body.size": int64(1200), // payload (binary + xml attachments)
"messaging.message.envelope.size": int64(1234), // payload with metadata
"messaging.destination.name": "someTopic",
"messaging.destination.anonymous": false,
"messaging.solace.client_username": "someClientUsername",
"messaging.solace.client_name": "someClient1234",
"messaging.solace.replication_group_message_id": "rmid1:00010-40910192431-40516479-90a9c4e1",
Expand All @@ -202,10 +205,10 @@ func TestReceiveUnmarshallerMapClientSpanAttributes(t *testing.T) {
"messaging.solace.dropped_enqueue_events_failed": int64(24),
"messaging.solace.reply_to_topic": "someReplyToTopic",
"messaging.solace.delivery_mode": "persistent",
"net.host.ip": "1.2.3.4",
"net.host.port": int64(55555),
"net.peer.ip": "2345:425:2ca1::567:5673:23b5",
"net.peer.port": int64(12345),
"server.address": "1.2.3.4",
"server.port": int64(55555),
"network.peer.address": "2345:425:2ca1::567:5673:23b5",
"network.peer.port": int64(12345),
"messaging.solace.user_properties.special_key": true,
"messaging.solace.broker_receive_time_unix_nano": int64(1357924680),
"messaging.solace.dropped_application_message_properties": false,
Expand Down Expand Up @@ -241,20 +244,23 @@ func TestReceiveUnmarshallerMapClientSpanAttributes(t *testing.T) {
},
want: map[string]any{
"messaging.system": "SolacePubSub+",
"messaging.operation": "receive",
"messaging.protocol": "MQTT",
"messaging.message_payload_size_bytes": int64(1234),
"messaging.destination": "someTopic",
"messaging.operation.name": "receive",
"messaging.operation.type": "receive",
"network.protocol.name": "MQTT",
"messaging.message.body.size": int64(1200), // payload (binary + xml attachments)
"messaging.message.envelope.size": int64(1234), // payload with metadata
"messaging.destination.name": "someTopic",
"messaging.destination.anonymous": false,
"messaging.solace.client_username": "someClientUsername",
"messaging.solace.client_name": "someClient1234",
"messaging.solace.dmq_eligible": true,
"messaging.solace.delivery_mode": "non_persistent",
"messaging.solace.dropped_enqueue_events_success": int64(42),
"messaging.solace.dropped_enqueue_events_failed": int64(24),
"net.host.ip": "1.2.3.4",
"net.host.port": int64(55555),
"net.peer.ip": "2345:425:2ca1::567:5673:23b5",
"net.peer.port": int64(12345),
"server.address": "1.2.3.4",
"server.port": int64(55555),
"network.peer.address": "2345:425:2ca1::567:5673:23b5",
"network.peer.port": int64(12345),
"messaging.solace.broker_receive_time_unix_nano": int64(1357924680),
"messaging.solace.dropped_application_message_properties": true,
},
Expand Down Expand Up @@ -285,10 +291,13 @@ func TestReceiveUnmarshallerMapClientSpanAttributes(t *testing.T) {
// we no longer expect the port when the IP is not present
want: map[string]any{
"messaging.system": "SolacePubSub+",
"messaging.operation": "receive",
"messaging.protocol": "MQTT",
"messaging.message_payload_size_bytes": int64(1234),
"messaging.destination": "someTopic",
"messaging.operation.name": "receive",
"messaging.operation.type": "receive",
"network.protocol.name": "MQTT",
"messaging.message.body.size": int64(1200), // payload (binary + xml attachments)
"messaging.message.envelope.size": int64(1234), // payload with metadata
"messaging.destination.name": "someTopic",
"messaging.destination.anonymous": false,
"messaging.solace.client_username": "someClientUsername",
"messaging.solace.client_name": "someClient1234",
"messaging.solace.dmq_eligible": true,
Expand Down
25 changes: 14 additions & 11 deletions receiver/solacereceiver/unmarshaller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,16 @@ func TestSolaceMessageUnmarshallerUnmarshal(t *testing.T) {
spanAttrs := span.Attributes()
populateAttributes(t, spanAttrs, map[string]any{
"messaging.system": "SolacePubSub+",
"messaging.operation": "receive",
"messaging.protocol": "MQTT",
"messaging.protocol_version": "5.0",
"messaging.message_id": "someMessageID",
"messaging.conversation_id": "someConversationID",
"messaging.message_payload_size_bytes": int64(1234),
"messaging.destination": "someTopic",
"messaging.operation.name": "receive",
"messaging.operation.type": "receive",
"network.protocol.name": "MQTT",
"network.protocol.version": "5.0",
"messaging.message.id": "someMessageID",
"messaging.message.conversation_id": "someConversationID", // message correlation ID
"messaging.message.body.size": int64(1200), // payload (binary + xml attachments)
"messaging.message.envelope.size": int64(1234), // payload with metadata
"messaging.destination.name": "someTopic",
"messaging.destination.anonymous": false,
"messaging.solace.client_username": "someClientUsername",
"messaging.solace.client_name": "someClient1234",
"messaging.solace.replication_group_message_id": "rmid1:00010-40910192431-40516479-90a9c4e1",
Expand All @@ -241,10 +244,10 @@ func TestSolaceMessageUnmarshallerUnmarshal(t *testing.T) {
"messaging.solace.broker_receive_time_unix_nano": int64(1357924680),
"messaging.solace.dropped_application_message_properties": false,
"messaging.solace.delivery_mode": "direct",
"net.host.ip": "1.2.3.4",
"net.host.port": int64(55555),
"net.peer.ip": "2345:425:2ca1::567:5673:23b5",
"net.peer.port": int64(12345),
"server.address": "1.2.3.4",
"server.port": int64(55555),
"network.peer.address": "2345:425:2ca1::567:5673:23b5",
"network.peer.port": int64(12345),
"messaging.solace.user_properties.special_key": true,
})
populateEvent(t, span, "somequeue enqueue", 123456789, map[string]any{
Expand Down

0 comments on commit cb5902b

Please sign in to comment.