MCPcopy Create free account
hub / github.com/prometheus/common / escapingFor

Function escapingFor

expfmt/encode.go:161–172  ·  view source on GitHub ↗

escapingFor returns the escaping term for the Accept clause that matched f.

(ac goautoneg.Accept, f Format)

Source from the content-addressed store, hash-verified

159
160// escapingFor returns the escaping term for the Accept clause that matched f.
161func escapingFor(ac goautoneg.Accept, f Format) Format {
162 switch p := ac.Params[model.EscapingKey]; p {
163 case model.AllowUTF8, model.EscapeUnderscores, model.EscapeDots, model.EscapeValues:
164 // An explicit request always wins, also for OpenMetrics 2.0.
165 return Format("; escaping=" + p)
166 }
167 if f.FormatType() == TypeOpenMetrics && isOpenMetrics20Version(f.Version()) {
168 // OpenMetrics 2.0 is UTF-8 native, so asking for it implies UTF-8 name support.
169 return Format("; escaping=" + model.AllowUTF8)
170 }
171 return Format("; escaping=" + model.NameEscapingScheme.String())
172}
173
174// matchFormat checks if a parsed accept clause matches a given Format.
175func matchFormat(ac goautoneg.Accept, f Format) bool {

Callers 1

NegotiateAcceptFunction · 0.85

Calls 5

isOpenMetrics20VersionFunction · 0.85
FormatTypeMethod · 0.80
VersionMethod · 0.80
FormatTypeAlias · 0.70
StringMethod · 0.65

Tested by

no test coverage detected