Skip to content

Conversation

@purple4reina
Copy link
Contributor

@purple4reina purple4reina commented Jan 16, 2025

What does this PR do?

Adds all global tags to the top level trace tags hash map.

Working in conjunction with the apm-trace-intake team, intake will ensure that these tags are placed onto all spans in the trace and then are made available for our usage metric.

Motivation

Part of the usage metrics tagging which will allow us to include more tags (including custom tags) on the datadog.serverless.traced_invocations metric.

Additional Notes

Note that this change will duplicate the location of the global tags in the trace payload sent to intake. Currently, these payloads look like

TracePayload {
  ...
  Chunk {
    ...
    Span {
      ...
      Meta {
        ...
        "key1": "value1",
        "key2": "value2",
        "key3": "value3"
      }
    }
  }
  Tags {}
}

After this change they will look like

TracePayload {
  ...
  Chunk {
    ...
    Span {
      ...
      Meta {
        ...
        "key1": "value1",
        "key2": "value2",
        "key3": "value3"
      }
    }
  }
  Tags {
    "_dd.tags.function": "key1:value1,key2:value2,key3:value3"
  }
}

Once the changes are in place in intake, we can remove the tags from the spans themselves. The intake pipeline will manage unpacking and copying these tags for us, at which point trace payloads will look like

TracePayload {
  ...
  Chunk {
    ...
    Span {
      ...
      Meta {
        ...
      }
    }
  }
  Tags {
    "_dd.tags.function": "key1:value1,key2:value2,key3:value3"
  }
}

@purple4reina purple4reina force-pushed the rey.abolofia/fn-tags branch 10 times, most recently from d485d63 to d3bdf5d Compare January 16, 2025 20:24
@purple4reina purple4reina marked this pull request as ready for review January 16, 2025 20:58
@purple4reina purple4reina requested a review from a team as a code owner January 16, 2025 20:58
.map(|(k, v)| format!("{k}:{v}"))
.collect::<Vec<String>>()
.join(",");
hash_map::HashMap::from_iter([(FUNCTION_TAGS_KEY.to_string(), tags)])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hash_map:: scope could be imported once for readability

Copy link
Contributor

@duncanista duncanista left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clippy is not passing

@purple4reina
Copy link
Contributor Author

Clippy is not passing

@duncanista can you help with this? I don't understand the error and I don't see how it has anything to do with my PR.

@purple4reina purple4reina merged commit 9ab8308 into main Jan 17, 2025
23 checks passed
@purple4reina purple4reina deleted the rey.abolofia/fn-tags branch January 17, 2025 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants