{"record":{"id":"42343cf8da44544e","repo":"jaegertracing/jaeger","slug":"max-spans-count-reached","errorCode":null,"errorMessage":"max spans count reached","messagePattern":"max spans count reached","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/anonymizer/app/writer/writer.go","lineNumber":21,"sourceCode":"\npackage writer\n\nimport (\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"errors\"\n\t\"fmt\"\n\t\"os\"\n\t\"sync\"\n\n\t\"github.com/gogo/protobuf/jsonpb\"\n\t\"go.uber.org/zap\"\n\n\t\"github.com/jaegertracing/jaeger-idl/model/v1\"\n\t\"github.com/jaegertracing/jaeger/cmd/anonymizer/app/anonymizer\"\n)\n\nvar ErrMaxSpansCountReached = errors.New(\"max spans count reached\")\n\n// Config contains parameters to NewWriter.\ntype Config struct {\n\tMaxSpansCount  int                `yaml:\"max_spans_count\" name:\"max_spans_count\"`\n\tCapturedFile   string             `yaml:\"captured_file\" name:\"captured_file\"`\n\tAnonymizedFile string             `yaml:\"anonymized_file\" name:\"anonymized_file\"`\n\tMappingFile    string             `yaml:\"mapping_file\" name:\"mapping_file\"`\n\tAnonymizerOpts anonymizer.Options `yaml:\"anonymizer\" name:\"anonymizer\"`\n}\n\n// Writer is a span Writer that obfuscates the span and writes it to a JSON file.\ntype Writer struct {\n\tconfig         Config\n\tlock           sync.Mutex\n\tlogger         *zap.Logger\n\tcapturedFile   *os.File\n\tanonymizedFile *os.File\n\tanonymizer     *anonymizer.Anonymizer","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/cmd/anonymizer/app/writer/writer.go#L3-L39","documentation":"forThisEngine translates a regex-ish text pattern into an Elasticsearch wildcard/regexp query. Perl shorthand classes such as \\d, \\w, \\s are rejected with tracestore.ErrFilterUnsupported because the engine reads them as literal characters rather than character classes, so honoring them would silently match the wrong text. The error tells the caller to write the class out explicitly (e.g. [0-9] instead of \\d).","triggerScenarios":"Calling a trace search whose text comparison (attribute or field text match via attributeValueMatch or buildTextComparison) contains a pattern with Perl shorthand escapes like \\d, \\w, \\s in it.","commonSituations":"Copy-pasting a PCRE/RE2 regex into a Jaeger query; writing attribute 'http.url' =~ \"\\d+\" expecting digit matching; porting filters written for a regex-capable backend to the Elasticsearch backend.","solutions":["Replace the shorthand with an explicit character class: [0-9] for \\d, [a-zA-Z0-9_] for \\w, [ \\t] for \\s.","Catch the error with errors.Is(err, tracestore.ErrFilterUnsupported) and rewrite the pattern client-side before retrying.","Escape the backslash if a literal backslash-character match was actually intended."],"exampleFix":"// before\nservice_name =~ \"\\d+\"\n// after\nservice_name =~ \"[0-9]+\"","handlingStrategy":"validation","validationCode":"var perlShorthandRe = regexp.MustCompile(`\\\\[dwsDWS]`)\nfunc patternSafe(p string) bool { return !perlShorthandRe.MatchString(p) }","typeGuard":null,"tryCatchPattern":"vm, err := forThisEngine(pattern)\nif errors.Is(err, tracestore.ErrFilterUnsupported) {\n    pattern = expandPerlShorthand(pattern) // \\d -> [0-9], retry\n}","preventionTips":["Write character classes out: [0-9], [a-zA-Z0-9_], [ \\t].","Lint query patterns for backslash shorthands before submission.","Remember this engine reads &, @, ~, <n-m>, # as operators; quote or opt out where supported."],"tags":["regex","elasticsearch","unsupported-feature"],"backgroundTag":"unsupported-regex-syntax","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}