Skip to content

Docs: Mention that datadog metric tags replace default_tags #2990

Closed
@ecokes

Description

@ecokes

What were you searching in the docs?

First off, I've been enjoying this library and I think the docs are pretty great overall.

I did have one point of confusion I wanted to clarify. I've been using the DatadogMetrics class, (using this section of the docs) to add tags to metrics. I was surprised to find that adding tags in the add_metric method like this:

metrics.add_metric(name="SuccessfulBooking", value=1, tag2="bar", tag3="baz")

results in any default tags that were added to the metrics class, like this:

metrics.set_default_tags(tag1="foo")

getting removed from the metric. I assumed that default tags and additional one off tags would be combined in that case, so that the metric would end up as:

{
    "m": "SuccessfulBooking",
    "v": 1,
    "e": 1692736997,
    "t": [
        "tag1:foo",
        "tag2:bar",
        "tag3:baz"
    ]
}

However, the metric instead comes out as:

{
    "m": "SuccessfulBooking",
    "v": 1,
    "e": 1692736997,
    "t": [
        "tag2:bar",
        "tag3:baz"
    ]
}

I assumed I had configured something wrong for awhile, until I found this section of the code. So it looks like that's the intended behavior, but it would be helpful to add a line in the docs identifying that default_tags and metric tags are one or the other, not additive.

Is this related to an existing documentation section?

https://docs.powertools.aws.dev/lambda/python/latest/core/metrics/datadog/#adding-tags

How can we improve?

Mention that metric tags overwrite default tags instead of being appended.

Got a suggestion in mind?

No response

Acknowledgment

  • I understand the final update might be different from my proposed suggestion, or refused.

Metadata

Metadata

Labels

bugSomething isn't workingdocumentationImprovements or additions to documentationmetrics

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions