Skip to content

Make gauge metrics thread-safe #8386

@ashwingopalsamy

Description

@ashwingopalsamy

In pkg/gofr/metrics/register.go, the float64Gauge type maintains a map of observations without any synchronization mechanism.

For example: SetGauge modifies this map while HTTP handlers and other goroutines may concurrently read or update gauge values. As Go maps aren’t thread-safe for concurrent writes, simultaneous calls to SetGauge can lead to data races or undefined behaviors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions