Skip to content

Refactor Parser into specialized parsers for each StatsD syntax #576

@pedro-stanaka

Description

@pedro-stanaka

Description

The current Parser implementation in pkg/line/line.go handles multiple types of syntax (DogStatsD, InfluxDB, Librato, SignalFX) within a single parser. This makes the code complex and harder to maintain. We propose refactoring the Parser to separate parsers for each syntax type.

Goals

  1. Improve Code Maintainability: By separating the parsing logic for different syntax types, the code will be easier to understand and maintain.
  2. Allow for improvements for specific cases: The current parser is quite slow and heavy on allocations for parsing tags for Dogstatsd, for example. We could after refactoring ensure that we optimize that specific parser.
  3. Avoid Breaking Changes: Ensure that the refactoring does not break existing projects that use this repository as a library.

Proposed Solution

  1. Create Separate Parsers: Implement individual parsers for DogStatsD, InfluxDB, Librato, and SignalFX.
  2. Parser Interface: Define a Parser interface that each specific parser will implement.
  3. Stop-gap MultiParser: Define a MultiParser that will mimic the current behavior of the parser, and will check if the incoming line uses which type of tagging. This is necessary, if your instance needs to understand more than one type of syntax.
  4. Factory Method: Implement a factory method to create the appropriate parser based on configuration, here we could make sure to use only the specific parser, if only one syntax is enabled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementlibraryIssues pertaining to the use of the packages as a library more than the exporter itself

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions