Documentation
¶
Overview ¶
Package tags provides a concurrency-safe string tag map for AWS resource annotations.
Tags is built on safemap.Map and therefore inherits full Prometheus instrumentation via [lockmetrics.RWMutex].
Index ¶
- type KV
- type Tags
- func (t *Tags) Clone() map[string]string
- func (t *Tags) Close()
- func (t *Tags) Delete(key string)
- func (t *Tags) DeleteKeys(keys []string)
- func (t *Tags) Get(key string) (string, bool)
- func (t *Tags) HasTag(key string) bool
- func (t *Tags) Len() int
- func (t *Tags) MarshalJSON() ([]byte, error)
- func (t *Tags) MatchesFilter(filter map[string]string) bool
- func (t *Tags) Merge(src map[string]string)
- func (t *Tags) Range(f func(key, value string) bool)
- func (t *Tags) Set(key, value string)
- func (t *Tags) UnmarshalJSON(data []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KV ¶
KV is a key-value tag pair for use in JSON and XML serialization. It is the canonical representation of a single AWS resource tag and is used by handler types across service packages.
type Tags ¶
type Tags struct {
// contains filtered or unexported fields
}
Tags is a concurrency-safe collection of string key-value tag pairs.
The zero value is not usable; always create via New or FromMap.
func New ¶
New creates a new Tags collection. The name appears as the "lock" label in Prometheus metrics (e.g. "sqs.queue.my-queue.tags").
func (*Tags) Close ¶
func (t *Tags) Close()
Close releases resources associated with this Tags collection, removing the underlying lockmetrics.RWMutex from the global Prometheus registry. It should be called when the Tags instance is no longer needed to prevent unbounded growth of the global collector. After Close is called, the Tags must not be used.
func (*Tags) DeleteKeys ¶
DeleteKeys removes all tags whose key appears in keys.
func (*Tags) MarshalJSON ¶
MarshalJSON implements json.Marshaler. Tags serialises as a plain JSON object (e.g. {"env":"prod","team":"platform"}).
func (*Tags) MatchesFilter ¶
MatchesFilter reports whether t contains all key-value pairs in filter. An empty filter always returns true.
func (*Tags) Range ¶
Range calls f sequentially for each tag in unspecified order. The underlying map is read-locked for the entire iteration; f must not call methods on the same Tags to avoid deadlocks. Iteration stops early if f returns false.
func (*Tags) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. Tags deserialises from a plain JSON object (e.g. {"env":"prod","team":"platform"}). An empty or null JSON value produces an empty Tags with the zero-value name; callers that care about the Prometheus lock name should prefer FromMap for static data. Any keys previously present in t that are absent from the JSON payload are removed, so the result matches the JSON payload exactly.