formatter

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package formatter provides result formatting for different analysis types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllocationFormatter

type AllocationFormatter struct{}

AllocationFormatter formats memory allocation analysis results.

func (*AllocationFormatter) Format

func (f *AllocationFormatter) Format(resp *model.AnalysisResponse, log utils.Logger)

Format outputs the allocation analysis result to the logger.

func (*AllocationFormatter) FormatSummary

func (f *AllocationFormatter) FormatSummary(resp *model.AnalysisResponse) map[string]interface{}

FormatSummary returns a summary map for serialization.

func (*AllocationFormatter) SupportedTypes

func (f *AllocationFormatter) SupportedTypes() []model.AnalysisDataType

SupportedTypes returns the data types this formatter supports.

type CPUFormatter

type CPUFormatter struct{}

CPUFormatter formats CPU profiling analysis results.

func (*CPUFormatter) Format

func (f *CPUFormatter) Format(resp *model.AnalysisResponse, log utils.Logger)

Format outputs the CPU profiling result to the logger.

func (*CPUFormatter) FormatSummary

func (f *CPUFormatter) FormatSummary(resp *model.AnalysisResponse) map[string]interface{}

FormatSummary returns a summary map for serialization.

func (*CPUFormatter) SupportedTypes

func (f *CPUFormatter) SupportedTypes() []model.AnalysisDataType

SupportedTypes returns the data types this formatter supports.

type DefaultFormatter

type DefaultFormatter struct{}

DefaultFormatter is a fallback formatter for unknown data types.

func (*DefaultFormatter) Format

func (f *DefaultFormatter) Format(resp *model.AnalysisResponse, log utils.Logger)

Format outputs a generic analysis result to the logger.

func (*DefaultFormatter) FormatSummary

func (f *DefaultFormatter) FormatSummary(resp *model.AnalysisResponse) map[string]interface{}

FormatSummary returns a summary map for serialization.

func (*DefaultFormatter) SupportedTypes

func (f *DefaultFormatter) SupportedTypes() []model.AnalysisDataType

SupportedTypes returns an empty slice as this is a fallback formatter.

type HeapFormatter

type HeapFormatter struct{}

HeapFormatter formats Java heap dump analysis results.

func (*HeapFormatter) Format

func (f *HeapFormatter) Format(resp *model.AnalysisResponse, log utils.Logger)

Format outputs the heap analysis result to the logger.

func (*HeapFormatter) FormatDetailedRetainers

func (f *HeapFormatter) FormatDetailedRetainers(resp *model.AnalysisResponse) map[string]interface{}

FormatDetailedRetainers generates detailed retainer analysis data. This should be called separately to write to retainer_analysis.json.

func (*HeapFormatter) FormatSummary

func (f *HeapFormatter) FormatSummary(resp *model.AnalysisResponse) map[string]interface{}

FormatSummary returns a lightweight summary map for serialization. Detailed retainer data is written to a separate file.

func (*HeapFormatter) SupportedTypes

func (f *HeapFormatter) SupportedTypes() []model.AnalysisDataType

SupportedTypes returns the data types this formatter supports.

func (*HeapFormatter) WriteDetailedRetainers

func (f *HeapFormatter) WriteDetailedRetainers(resp *model.AnalysisResponse, outputDir string) error

WriteDetailedRetainers writes detailed retainer analysis to a separate file.

type MemLeakFormatter

type MemLeakFormatter struct{}

MemLeakFormatter formats memory leak analysis results.

func (*MemLeakFormatter) Format

func (f *MemLeakFormatter) Format(resp *model.AnalysisResponse, log utils.Logger)

Format outputs the memory leak analysis result to the logger.

func (*MemLeakFormatter) FormatSummary

func (f *MemLeakFormatter) FormatSummary(resp *model.AnalysisResponse) map[string]interface{}

FormatSummary returns a summary map for serialization.

func (*MemLeakFormatter) SupportedTypes

func (f *MemLeakFormatter) SupportedTypes() []model.AnalysisDataType

SupportedTypes returns the data types this formatter supports.

type PProfBatchFormatter

type PProfBatchFormatter struct{}

PProfBatchFormatter formats pprof batch analysis results.

func (*PProfBatchFormatter) Format

func (f *PProfBatchFormatter) Format(resp *model.AnalysisResponse, log utils.Logger)

Format outputs the pprof batch analysis result to the logger.

func (*PProfBatchFormatter) FormatSummary

func (f *PProfBatchFormatter) FormatSummary(resp *model.AnalysisResponse) map[string]interface{}

FormatSummary returns a summary map for serialization.

func (*PProfBatchFormatter) SupportedTypes

func (f *PProfBatchFormatter) SupportedTypes() []model.AnalysisDataType

SupportedTypes returns the data types this formatter supports.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry manages formatter instances.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new formatter registry with default formatters.

func (*Registry) Format

func (r *Registry) Format(resp *model.AnalysisResponse, log utils.Logger)

Format formats the analysis response using the appropriate formatter.

func (*Registry) FormatSummary

func (r *Registry) FormatSummary(resp *model.AnalysisResponse) map[string]interface{}

FormatSummary returns a summary map using the appropriate formatter.

func (*Registry) Get

Get returns the formatter for a data type.

func (*Registry) Register

func (r *Registry) Register(f ResultFormatter)

Register registers a formatter.

type ResultFormatter

type ResultFormatter interface {
	// Format outputs the analysis result to the logger.
	Format(resp *model.AnalysisResponse, log utils.Logger)

	// FormatSummary returns a summary map for serialization.
	FormatSummary(resp *model.AnalysisResponse) map[string]interface{}

	// SupportedTypes returns the data types this formatter supports.
	SupportedTypes() []model.AnalysisDataType
}

ResultFormatter is the interface for formatting analysis results.

type TracingFormatter

type TracingFormatter struct{}

TracingFormatter formats tracing analysis results.

func (*TracingFormatter) Format

func (f *TracingFormatter) Format(resp *model.AnalysisResponse, log utils.Logger)

Format outputs the tracing analysis result to the logger.

func (*TracingFormatter) FormatSummary

func (f *TracingFormatter) FormatSummary(resp *model.AnalysisResponse) map[string]interface{}

FormatSummary returns a summary map for serialization.

func (*TracingFormatter) SupportedTypes

func (f *TracingFormatter) SupportedTypes() []model.AnalysisDataType

SupportedTypes returns the data types this formatter supports.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL