Skip to content

Commit 1a4171f

Browse files
marctcRoryCrispin
authored andcommitted
[connector/exceptions] Add trace id and span id to generated logs (open-telemetry#28670)
**Description:** <Describe what has changed.> The current implementation generates logs from recorded exceptions in spans, but is not possible to see which traces and spans generated those logs. This PR adds that information to the logs **Link to tracking Issue:** Fixes open-telemetry#24407
1 parent 6ca1320 commit 1a4171f

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: exceptionsconnector
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Add trace id and span id to generated logs from exceptions when using exceptionsconnector.
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [24407]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: []

connector/exceptionsconnector/connector_logs.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ func (c *logsConnector) attrToLogRecord(sl plog.ScopeLogs, serviceName string, s
9898
logRecord.SetTimestamp(event.Timestamp())
9999
logRecord.SetSeverityNumber(plog.SeverityNumberError)
100100
logRecord.SetSeverityText("ERROR")
101+
logRecord.SetSpanID(span.SpanID())
102+
logRecord.SetTraceID(span.TraceID())
101103
eventAttrs := event.Attributes()
102104
spanAttrs := span.Attributes()
103105

connector/exceptionsconnector/testdata/logs.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ resourceLogs:
2424
body: {}
2525
severityNumber: 17
2626
severityText: ERROR
27-
spanId: ""
28-
traceId: ""
27+
spanId: 2a00000000000000
28+
traceId: 2a000000000000000000000000000000
2929
- attributes:
3030
- key: span.kind
3131
value:
@@ -48,8 +48,8 @@ resourceLogs:
4848
body: {}
4949
severityNumber: 17
5050
severityText: ERROR
51-
spanId: ""
52-
traceId: ""
51+
spanId: 2a00000000000000
52+
traceId: 2a000000000000000000000000000000
5353
scope: {}
5454
- resource: {}
5555
scopeLogs:
@@ -76,6 +76,6 @@ resourceLogs:
7676
body: {}
7777
severityNumber: 17
7878
severityText: ERROR
79-
spanId: ""
80-
traceId: ""
79+
spanId: 2a00000000000000
80+
traceId: 2a000000000000000000000000000000
8181
scope: {}

0 commit comments

Comments
 (0)