You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#### Description
Adds trace propagation support to the MySQL receiver's query samples.
When a client sets the `@traceparent` user variable in a MySQL session
(W3C TraceContext format), the receiver extracts the TraceID and SpanID
and stamps them onto the emitted `db.server.query_sample` log record,
enabling correlation between DB query samples and distributed traces.
Query sample log records always carry a TraceID and SpanID. By default
these are the collector's own internal scrape span IDs, preserving the
original behavior. When `@traceparent` is set by the application, the
extracted trace context overrides the scrape span IDs on that record.
The `@traceparent` variable is read from
`performance_schema.user_variables_by_thread`. `VARIABLE_NAME` is
matched case-sensitively as `'traceparent'` (lowercase) — clients must
set the variable using exactly `SET @traceparent = '...'`.
#### Link to tracking issue
Fixes#46631
#### Testing
Added unit tests for `contextWithTraceparent`:
- Valid traceparent sets the correct TraceID and SpanID on the context
- Empty traceparent leaves the context unchanged
- Invalid traceparent returns an error and leaves the context unchanged
- When both a collector span and a traceparent are present, the
traceparent's IDs win
Updated existing scraper test data and fixtures to cover the new
`traceparent` field in query sample records.
#### Documentation
Updated `README.md` to document trace propagation behavior: log records
always carry trace/span IDs (scrape span by default); setting
`@traceparent` in the MySQL session overrides them with the
application's trace context. Includes a note on the case-sensitivity
requirement for the variable name.
# 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:
5
+
enhancement
6
+
7
+
# The name of the component, or a single word describing the area of concern, (e.g. receiver/filelog)
8
+
component:
9
+
receiver/mysql
10
+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
11
+
note:
12
+
Propagates W3C TraceContext from MySQL session variables to query sample log records. When a MySQL session sets `@traceparent`, the receiver extracts the TraceID and SpanID and stamps them onto the corresponding `db.server.query_sample` log record, enabling correlation between application traces and query samples.
13
+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
14
+
issues: [46631]
15
+
16
+
# (Optional) One or more lines of additional information to render under the primary note.
17
+
# These lines will be padded with 2 spaces and then inserted directly into the document.
18
+
# Use pipe (|) for multiline entries.
19
+
subtext:
20
+
Only samples from sessions where `@traceparent` is set will have non-zero `traceId` and `spanId` fields on the log record.
21
+
# If your change doesn't affect end users or the exported elements of any package,
22
+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
23
+
# Optional: The change log or logs in which this entry should be included.
24
+
# e.g. '[user]' or '[user, api]'
25
+
# Include 'user' if the change is relevant to end users.
26
+
# Include 'api' if there is a change to a library API.
0 commit comments