Skip to content

fix(otel): support tag flattening [AIT-9352] [backport 2.5] #8093

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 17, 2024

Conversation

github-actions[bot]
Copy link
Contributor

Backport 7c75365 from #8042 to 2.5.

Ensures otel tags/attribute values with the type List, Tuple and/or set are flattened. This operation is already done by the Datadog UI when displaying tags. However we should also do this in the tracer to better align with other languages.

The flattening logic must follow this spec:

Array values must decay into as many keys as there are entries in the array. The keys must be mapped by concatenating the outer and inner key values together, recursively, separated by a dot. In pseudo-code:
fn addArrayAttribute(key, array):
for (subkey, value) in array:
addScalarOrArrayAttribute(key + "." + subkey, value)
Example: Given attributes {"key": [[1,2], ["3", "4"]]}, we will have {"key.0.0": "1", "key.0.1": 2, "key.1.0": 3, "key.1.1":4}.

Checklist

  • Change(s) are motivated and described in the PR description.
  • Testing strategy is described if automated tests are not included in the PR.
  • Risk is outlined (performance impact, potential for breakage, maintainability, etc).
  • Change is maintainable (easy to change, telemetry, documentation).
  • Library release note guidelines are followed. If no release note is required, add label changelog/no-changelog.
  • Documentation is included (in-code, generated user docs, public corp docs).
  • Backport labels are set (if applicable)

Reviewer Checklist

  • Title is accurate.
  • No unnecessary changes are introduced.
  • Description motivates each change.
  • Avoids breaking API changes unless absolutely necessary.
  • Testing strategy adequately addresses listed risk(s).
  • Change is maintainable (easy to change, telemetry, documentation).
  • Release note makes sense to a user of the library.
  • Reviewer has explicitly acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment.
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy
  • If this PR touches code that signs or publishes builds or packages, or handles credentials of any kind, I've requested a review from @DataDog/security-design-and-guidance.
  • This PR doesn't touch any of that.

Ensures otel tags/attribute values with the type List, Tuple and/or set
are flattened. This operation is already done by the Datadog UI when
displaying tags. However we should also do this in the tracer to better
align with other languages.

The flattening logic must follow this spec:

```
Array values must decay into as many keys as there are entries in the array. The keys must be mapped by concatenating the outer and inner key values together, recursively, separated by a dot. In pseudo-code:
fn addArrayAttribute(key, array):
for (subkey, value) in array:
addScalarOrArrayAttribute(key + "." + subkey, value)
Example: Given attributes {"key": [[1,2], ["3", "4"]]}, we will have {"key.0.0": "1", "key.0.1": 2, "key.1.0": 3, "key.1.1":4}.
```

## Checklist

- [x] Change(s) are motivated and described in the PR description.
- [x] Testing strategy is described if automated tests are not included
in the PR.
- [x] Risk is outlined (performance impact, potential for breakage,
maintainability, etc).
- [x] Change is maintainable (easy to change, telemetry, documentation).
- [x] [Library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
are followed. If no release note is required, add label
`changelog/no-changelog`.
- [x] Documentation is included (in-code, generated user docs, [public
corp docs](https://github.com/DataDog/documentation/)).
- [x] Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist

- [ ] Title is accurate.
- [ ] No unnecessary changes are introduced.
- [ ] Description motivates each change.
- [ ] Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes unless absolutely necessary.
- [ ] Testing strategy adequately addresses listed risk(s).
- [ ] Change is maintainable (easy to change, telemetry, documentation).
- [ ] Release note makes sense to a user of the library.
- [ ] Reviewer has explicitly acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment.
- [ ] Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
- [ ] If this PR touches code that signs or publishes builds or
packages, or handles credentials of any kind, I've requested a review
from `@DataDog/security-design-and-guidance`.
- [ ] This PR doesn't touch any of that.

(cherry picked from commit 7c75365)
@github-actions github-actions bot requested review from a team as code owners January 12, 2024 16:08
@github-actions github-actions bot added the changelog/no-changelog A changelog entry is not required for this PR. label Jan 12, 2024
@mabdinur mabdinur enabled auto-merge (squash) January 12, 2024 17:12
@pr-commenter
Copy link

pr-commenter bot commented Jan 12, 2024

Benchmarks

Benchmark execution time: 2024-01-17 04:36:16

Comparing candidate commit a0da092 in PR branch backport-8042-to-2.5 with baseline commit ce1cbf4 in branch 2.5.

Found 14 performance improvements and 13 performance regressions! Performance is the same for 168 metrics, 9 unstable metrics.

scenario:coreapiscenario-context_with_data_listeners_and_all_listeners

  • 🟩 max_rss_usage [-788.029KB; -625.500KB] or [-2.681%; -2.128%]

scenario:coreapiscenario-core_dispatch_listeners

  • 🟩 max_rss_usage [-857.156KB; -712.841KB] or [-2.912%; -2.422%]

scenario:coreapiscenario-core_dispatch_listeners_and_all_listeners

  • 🟩 max_rss_usage [-789.196KB; -628.839KB] or [-2.687%; -2.141%]

scenario:coreapiscenario-core_dispatch_with_results_listeners_and_all_listeners

  • 🟩 max_rss_usage [-917.818KB; -769.734KB] or [-3.120%; -2.616%]

scenario:coreapiscenario-core_dispatch_with_results_no_listeners

  • 🟥 max_rss_usage [+648.979KB; +849.747KB] or [+2.264%; +2.965%]

scenario:coreapiscenario-core_dispatch_with_results_only_all_listeners

  • 🟩 max_rss_usage [-853.613KB; -670.509KB] or [-2.907%; -2.283%]

scenario:coreapiscenario-get_item_missing

  • 🟩 max_rss_usage [-802.701KB; -622.707KB] or [-2.734%; -2.121%]

scenario:httppropagationextract-b3_headers

  • 🟥 max_rss_usage [+727.921KB; +934.645KB] or [+2.553%; +3.278%]

scenario:httppropagationextract-empty_headers

  • 🟥 max_rss_usage [+575.447KB; +768.041KB] or [+2.007%; +2.679%]

scenario:httppropagationextract-invalid_trace_id_header

  • 🟩 max_rss_usage [-874.576KB; -652.413KB] or [-2.977%; -2.221%]

scenario:httppropagationextract-wsgi_empty_headers

  • 🟩 max_rss_usage [-807.231KB; -609.166KB] or [-2.754%; -2.078%]

scenario:httppropagationextract-wsgi_invalid_span_id_header

  • 🟥 max_rss_usage [+593.043KB; +787.719KB] or [+2.073%; +2.753%]

scenario:httppropagationinject-with_priority_and_origin

  • 🟩 max_rss_usage [-855.237KB; -707.387KB] or [-2.914%; -2.410%]

scenario:httppropagationinject-with_tags_invalid

  • 🟩 max_rss_usage [-810.487KB; -661.206KB] or [-2.764%; -2.255%]

scenario:httppropagationinject-with_tags_max_size

  • 🟩 max_rss_usage [-774.037KB; -624.338KB] or [-2.647%; -2.135%]

scenario:otelspan-add-metrics

  • 🟥 execution_time [+43.474ms; +47.404ms] or [+16.138%; +17.597%]

scenario:otelspan-add-tags

  • 🟥 execution_time [+41.924ms; +46.325ms] or [+16.570%; +18.310%]

scenario:sethttpmeta-no-useragentvariant

  • 🟥 max_rss_usage [+741.620KB; +832.883KB] or [+2.558%; +2.873%]

scenario:sethttpmeta-obfuscation-regular-case-explicit-query

  • 🟩 max_rss_usage [-827.412KB; -729.887KB] or [-2.764%; -2.438%]

scenario:sethttpmeta-obfuscation-worst-case-explicit-query

  • 🟥 max_rss_usage [+619.789KB; +722.470KB] or [+2.118%; +2.469%]

scenario:sethttpmeta-useragentvariant_exists_1

  • 🟩 max_rss_usage [-793.747KB; -670.164KB] or [-2.669%; -2.253%]

scenario:sethttpmeta-useragentvariant_exists_2

  • 🟥 max_rss_usage [+597.481KB; +722.250KB] or [+2.058%; +2.487%]

scenario:sethttpmeta-useragentvariant_exists_3

  • 🟥 max_rss_usage [+620.896KB; +731.603KB] or [+2.139%; +2.520%]

scenario:span-start-finish

  • 🟩 max_rss_usage [-796.645KB; -674.638KB] or [-2.715%; -2.299%]

scenario:tracer-large

  • 🟥 max_rss_usage [+802.475KB; +951.842KB] or [+2.718%; +3.224%]

scenario:tracer-medium

  • 🟥 max_rss_usage [+573.470KB; +762.645KB] or [+2.013%; +2.677%]

scenario:tracer-small

  • 🟥 max_rss_usage [+643.420KB; +847.115KB] or [+2.252%; +2.965%]

@mabdinur mabdinur merged commit 1a9f1ce into 2.5 Jan 17, 2024
@mabdinur mabdinur deleted the backport-8042-to-2.5 branch January 17, 2024 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog A changelog entry is not required for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants