Skip to content

Improvement: sample by attribute key, message or any hash #3

@samber

Description

@samber

Some ideas:

slogsampling.ThresholdSamplingOption{
	Rate: 100,
        ByHash: func(r *slog.Record) []byte {
              return []byte(r.Message)
        },
}
slogsampling.ThresholdSamplingOption{
	Rate: 100,
        ByHash: func(r *slog.Record) []byte {
              return BloomFilter([]byte(r.Message))
        },
}
slogsampling.ThresholdSamplingOption{
	Rate: 100,
        ByAttributeKey: []string{"http", "request", "header", "cf-connecting-ip"},
}
slogsampling.ThresholdSamplingOption{
	Rate: 100,
        BySource: true,   // might be very costly to look for stacktrace
}
slogsampling.ThresholdSamplingOption{
	Rate: 100,
        ByDistance: slogsampling.LevenshteinDistance(xxx),   // just brainstorming - definitely a VERY bad idea 😁
}

We have to keep track of hash/keys. A garbage collector must remove old entries in LRU or LFU manner.

The bloom filter could be embedded into the library on behalf of the developer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions