Repository navigation
fix(telemetry): preserve span kinds in SQLite traces - #7504
Open
BichengWang wants to merge 1 commit into
Open
BichengWang wants to merge 1 commit into
BichengWang wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to Issue or Description of Change
Problem: SQLite trace export drops
ReadableSpan.kind. A real OpenTelemetry SDK CLIENT span is reconstructed as INTERNAL after the exporter is shut down and reopened. SERVER, PRODUCER and CONSUMER spans lose their kind as well. This changes persisted tracing semantics, not just the in-memory representation.Expected: Preserve each span kind across SQLite export and exporter restart.
Solution: Persist the SpanKind name in a non-null column and reconstruct the enum on read. Existing nine-column databases are upgraded in place, with INTERNAL as the historical default; old span rows are retained. Serialize the schema check/add transaction so independent constructors do not race the additive migration. The API docstring documents the upgrade behavior.
Scope: Kind persistence only. Status/events persistence is already addressed by #7486; this PR does not duplicate that change or claim to close #7484. No provider calls or new dependencies.
Testing Plan
Unit Tests:
bca4a425b1b0abccddf8af26735773394a808427: 2 failed, 16 deselected, with actual kind mismatches.tests/unittests/telemetrysuite after formatting: 878 passed, 7 xfailed, no failures. The repository-wide unit suite was not run.Manual End-to-End (E2E):
Use an isolated temporary SQLite file, a real TracerProvider with SimpleSpanProcessor and SqliteSpanExporter, and a span with
SpanKind.CLIENTplus session_idsynthetic-session. Shut the provider/exporter down, reopen the same file with SqliteSpanExporter, and callget_all_spans_for_session.Observed before:
{"expectedKind":"CLIENT","reloadedKind":"INTERNAL","name":"local-http-request","session":"synthetic-session"}Observed after:
{"expectedKind":"CLIENT","reloadedKind":"CLIENT","name":"local-http-request","session":"synthetic-session"}Environment: macOS arm64, Python 3.13.7, OpenTelemetry SDK 1.42.1. No external model/network requests. This exercises the SQLite exporter itself; adk web uses a different in-memory exporter, so no web-UI proof is claimed.
Checklist
Additional context
Historical kinds cannot be recovered for already-saved spans; the migration explicitly retains INTERNAL for those rows. Changelog generation is left to release-please via the conventional
fix(telemetry)commit. No historical release entry is edited.Additional real-SQLite smoke: two simultaneous exporter constructors upgraded the same legacy database, both retained its original INTERNAL span, and the kind column was added exactly once.
{"concurrentLegacyInitializers": 2, "legacySpanPreserved": true, "legacyDefaultKind": "INTERNAL", "kindColumnAddedOnce": true}