Skip to content
This repository was archived by the owner on Jan 16, 2026. It is now read-only.
This repository was archived by the owner on Jan 16, 2026. It is now read-only.

senders.SDKMetricsTags() creates an Option that can change in unexpected ways. #86

@keep94

Description

@keep94

Consider these code snippets

map1 := map[string]string{"foo": "bar"}
option1 := senders.SDKMetricsTags(map1)
map1["foo"] = "wrong"

// option1 now represents adding "foo=wrong" tag, not "foo=bar"
sender, err := senders.NewSender("http://localhost", option1)
option1 := senders.SDKMetricsTags(map[string]string{"foo": "bar"})
option2 := senders.SDKMetricsTags(map[string]string{"baz": "none"})
sender, err := senders.NewSender("http://localhost", option1, option2)

// Now option1 represents adding both foo=bar and baz=none. badSender won't behave
// as user expects.
badSender, err := senders.NewSender("http://10.1.10.1", option1)

options in the API shouldn't change once created. User of API should be able to reuse a created option at any time knowing that it represents the same thing.

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