Reimplement jaeger-anonymizer on OTLP
Requirement
jaeger-anonymizer (cmd/anonymizer) still runs on the v1 data model end to end: it fetches spans through the api_v2.QueryService gRPC stream as model.Span, hashes fields with hand-written code over model.KeyValue and model.Log, writes a custom newline-delimited span file, and then runs a separate uiconv pass that reads that file back, filters spans by a string compare on the trace ID, and emits a UI-format trace. Every stage of that pipeline is legacy code that the rest of Jaeger v2 has moved off, and it keeps breaking in ways that have nothing to do with anonymization (#9539, #9542, #9526, #9543, #9029).
The tool should be reimplemented on OTLP so that it shares its data model, query API, and file format with the rest of Jaeger v2 and with the UI.
Proposal
- Fetch. Query through
api_v3.QueryService.GetTrace, which streamsptrace.Traces, instead of theapi_v2stream ofmodel.Span. The--trace-idflag is parsed once into apcommon.TraceID, so the spelling accepted by the query and the spelling written to the file are the same value and cannot drift. - Anonymize. Walk the
ptrace.Tracestree and hash resource attributes (the v1 "process"), span attributes (tags), and span event attributes (logs) in place. The existing options (hash_standard_tags,hash_custom_tags,hash_logs,hash_process) keep their meaning, mapped onto the OTLP structure. - Persist. Write the captured and anonymized traces as OTLP JSON via
ptrace.JSONMarshaler, one document per file, replacing thewriterpackage's custom span-per-line format and theuiconvreader that parses it. - Drop
uiconv. Jaeger UI already accepts an OTLP JSON upload and converts it client-side, so the anonymized OTLP file is the file a user drags into the UI. The extractor, its trace-ID string match, and the third output file go away. - Keep the CLI surface. Flag names and the three-file output layout under
--output-dirstay, so existing usage instructions remain valid apart from the file contents.
Open questions
- Whether
--max-spans-counttruncates the trace at fetch time (drop spans beyond the limit while iterating the stream) or is removed, since OTLP JSON is a single document rather than a line-per-span file. - Whether the mapping file (hash to original value) stays as is or moves to a per-attribute-key layout.
Effect on the v1 tool
Until this lands, bug reports and fixes against the v1 anonymizer are not accepted: the review backlog is better spent on the rewrite than on patching a pipeline that the rewrite deletes. Open v1 anonymizer issues and PRs are being closed with a pointer here.
Source: jaegertracing/jaeger