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

When batching, same object is mutated destroying exception information #1187

Merged
merged 4 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ def span_data_to_envelope(self, sd):
)
if sd.span_kind == SpanKind.SERVER:
if ERROR_MESSAGE in sd.attributes:
envelope.name = 'Microsoft.ApplicationInsights.Exception'
exc_env = Envelope(**envelope)
exc_env.name = 'Microsoft.ApplicationInsights.Exception'
data = ExceptionData(
exceptions=[{
'id': 1,
Expand All @@ -107,8 +108,8 @@ def span_data_to_envelope(self, sd):
'parsedStack': sd.attributes.get(STACKTRACE, None)
}],
)
envelope.data = Data(baseData=data, baseType='ExceptionData')
yield envelope
exc_env.data = Data(baseData=data, baseType='ExceptionData')
yield exc_env

envelope.name = 'Microsoft.ApplicationInsights.Request'
data = Request(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def test_span_data_to_envelope(self):
'RequestData')

# SpanKind.SERVER HTTP - with exceptions
envelopes = exporter.span_data_to_envelope(SpanData(
envelopes = list(exporter.span_data_to_envelope(SpanData(
name='test',
context=SpanContext(
trace_id='6e0c63257de34c90bf9efcd03927272e',
Expand Down Expand Up @@ -529,9 +529,10 @@ def test_span_data_to_envelope(self):
same_process_as_parent_span=None,
child_span_count=None,
span_kind=SpanKind.SERVER,
))
)))
self.assertEqual(len(envelopes), 2)

envelope = next(envelopes)
envelope = envelopes[0]
self.assertEqual(
envelope.iKey,
'12345678-1234-5678-abcd-12345678abcd')
Expand All @@ -551,7 +552,7 @@ def test_span_data_to_envelope(self):
envelope.data.baseType,
'ExceptionData')

envelope = next(envelopes)
envelope = envelopes[1]
self.assertEqual(
envelope.iKey,
'12345678-1234-5678-abcd-12345678abcd')
Expand Down