Skip to content

Add typing for core utils, encoding, and AppSec::CompressedJson#5453

Draft
marcotc wants to merge 1 commit intomasterfrom
marcotc/type-core-utils-misc
Draft

Add typing for core utils, encoding, and AppSec::CompressedJson#5453
marcotc wants to merge 1 commit intomasterfrom
marcotc/type-core-utils-misc

Conversation

@marcotc
Copy link
Copy Markdown
Member

@marcotc marcotc commented Mar 13, 2026

What does this PR do?

Types several small utility files:

  • OnlyOnce: initializevoid, ran?bool, reset_ran_once_state_for_testsvoid
  • Sequence: initializevoid, next::Integer
  • TagNormalizer: normalize/normalize_process_value accept any (method calls .to_s on input, so intentionally open)
  • Encoding: encode/decode use any (intentionally open serialization API); join uses ::Array[::String]; added :: prefixes to all stdlib types
  • CompressedJson: dump accepts any (JSON-serializable payload)

Also applies the project any vs untyped convention: any for intentionally open types, untyped for undecided signatures.

How to test the change?

bundle exec steep check \
  lib/datadog/core/utils/only_once.rb \
  lib/datadog/core/utils/sequence.rb \
  lib/datadog/core/tag_normalizer.rb \
  lib/datadog/core/encoding.rb \
  lib/datadog/appsec/compressed_json.rb

Changelog

None.

- OnlyOnce: initialize/ran?/reset_ran_once_state_for_tests -> void/bool/void
- Sequence: initialize -> void, next -> ::Integer
- TagNormalizer: normalize/normalize_process_value accept any (calls .to_s)
- Encoding: encode/decode use any (intentionally open serialization),
  join uses ::Array[::String], add :: prefixes throughout
- CompressedJson: dump accepts any (JSON-serializable payload)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@marcotc marcotc added the AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos label Mar 13, 2026
@github-actions
Copy link
Copy Markdown

👋 Hey @marcotc, please fill "Change log entry" section in the pull request description.

If changes need to be present in CHANGELOG.md you can state it this way

**Change log entry**

Yes. A brief summary to be placed into the CHANGELOG.md

(possible answers Yes/Yep/Yeah)

Or you can opt out like that

**Change log entry**

None.

(possible answers No/Nope/None)

Visited at: 2026-03-13 19:45:53 UTC

@github-actions
Copy link
Copy Markdown

Typing analysis

Note: Ignored files are excluded from the next sections.

Untyped methods

This PR clears 4 untyped methods and 4 partially typed methods. It increases the percentage of typed methods from 61.14% to 61.52% (+0.38%).

Untyped methods (+0-4)Cleared:
sig/datadog/core/utils/only_once.rbs:8
└── def initialize: () -> untyped
sig/datadog/core/utils/only_once.rbs:12
└── def ran?: () -> untyped
sig/datadog/core/utils/only_once.rbs:16
└── def reset_ran_once_state_for_tests: () -> untyped
sig/datadog/core/utils/sequence.rbs:11
└── def next: () -> untyped
Partially typed methods (+0-4)Cleared:
sig/datadog/appsec/compressed_json.rbs:6
└── def self.dump: (untyped payload) -> ::String?
sig/datadog/core/tag_normalizer.rbs:11
└── def self.normalize: (untyped original_value, ?remove_digit_start_char: bool) -> ::String
sig/datadog/core/tag_normalizer.rbs:13
└── def self.normalize_process_value: (untyped value) -> ::String
sig/datadog/core/utils/sequence.rbs:9
└── def initialize: (?::Integer seed) ?{ (::Integer) -> ::Integer } -> untyped

@datadog-prod-us1-3
Copy link
Copy Markdown

datadog-prod-us1-3 bot commented Mar 13, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 95.15% (-0.01%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 536b793 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@pr-commenter
Copy link
Copy Markdown

pr-commenter bot commented Mar 13, 2026

Benchmarks

Benchmark execution time: 2026-03-13 20:20:03

Comparing candidate commit 536b793 in PR branch marcotc/type-core-utils-misc with baseline commit 6b340a0 in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 46 metrics, 0 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant