-
Notifications
You must be signed in to change notification settings - Fork 26
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
Detect messaging.{system,operation} in TranslateTransaction #204
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -609,20 +609,56 @@ func TestRPCSpan(t *testing.T) { | |
} | ||
|
||
func TestMessagingTransaction(t *testing.T) { | ||
event := transformTransactionWithAttributes(t, map[string]interface{}{ | ||
"messaging.destination": "myQueue", | ||
}, func(s ptrace.Span) { | ||
s.SetKind(ptrace.SpanKindConsumer) | ||
// Set parentID to imply this isn't the root, but | ||
// kind==Consumer should still force the span to be translated | ||
// as a transaction. | ||
s.SetParentSpanID(pcommon.SpanID{3}) | ||
}) | ||
assert.Equal(t, "messaging", event.Transaction.Type) | ||
assert.Empty(t, event.Labels) | ||
assert.Equal(t, &modelpb.Message{ | ||
QueueName: "myQueue", | ||
}, event.Transaction.Message) | ||
for _, tc := range []struct { | ||
attrs map[string]interface{} | ||
|
||
expectedLabels map[string]*modelpb.LabelValue | ||
expectedTxnMessage *modelpb.Message | ||
}{ | ||
{ | ||
attrs: map[string]interface{}{ | ||
"messaging.destination": "myQueue", | ||
}, | ||
expectedLabels: nil, | ||
expectedTxnMessage: &modelpb.Message{ | ||
QueueName: "myQueue", | ||
}, | ||
}, | ||
{ | ||
attrs: map[string]interface{}{ | ||
"messaging.system": "kafka", | ||
}, | ||
expectedLabels: map[string]*modelpb.LabelValue{ | ||
"messaging_system": {Value: "kafka"}, | ||
}, | ||
expectedTxnMessage: nil, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [For reviewer] As demonstrated by the test case, this is a new case that doesn't exist before. When To rephrase the question, is it ok to have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes; this PR fixes the bug that the transaction type is not set although messaging attributes are sent. |
||
}, | ||
{ | ||
attrs: map[string]interface{}{ | ||
"messaging.operation": "publish", | ||
}, | ||
expectedLabels: map[string]*modelpb.LabelValue{ | ||
"messaging_operation": {Value: "publish"}, | ||
}, | ||
expectedTxnMessage: nil, | ||
}, | ||
} { | ||
tcName, err := json.Marshal(tc.attrs) | ||
require.NoError(t, err) | ||
t.Run(string(tcName), func(t *testing.T) { | ||
event := transformTransactionWithAttributes(t, tc.attrs, func(s ptrace.Span) { | ||
s.SetKind(ptrace.SpanKindConsumer) | ||
// Set parentID to imply this isn't the root, but | ||
// kind==Consumer should still force the span to be translated | ||
// as a transaction. | ||
s.SetParentSpanID(pcommon.SpanID{3}) | ||
}) | ||
assert.Equal(t, "messaging", event.Transaction.Type) | ||
assert.Equal(t, tc.expectedLabels, event.Labels) | ||
assert.Equal(t, tc.expectedTxnMessage, event.Transaction.Message) | ||
}) | ||
} | ||
|
||
} | ||
|
||
func TestMessagingSpan(t *testing.T) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this code back here. It is important to overwrite existing event.Transaction.Message to avoid breaking otel bridge test when event.Transaction.Message and the otel attribute exist at the same time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see how the message instance would already be non-nil at this point for otel data, so it should be fine.