Skip to content
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

DEBUG-2334 custom ActiveRecord model serialization #4088

Merged
merged 19 commits into from
Nov 11, 2024

Conversation

p-datadog
Copy link
Member

@p-datadog p-datadog commented Nov 7, 2024

What does this PR do?

  • Adds a custom serializer for ActiveRecord models
  • Adds serializers for Time, Date and DateTime (needed for ActiveRecord timestamps)

Motivation:
AR models have many fields that are not interesting for DI, and serializing them would 1) consume a lot of resources 2) cause the serialized payload to exceed the limits of the backend 3) not serialize actual attributes due to depth limits (actual attributes are already 3 levels down from the AR model). The custom serializer currently only serializes the attributes, though additional fields can be added in the future such as the new_record? flag.

Change log entry

None

Additional Notes:

This PR is extracted from #4063 since the test failures there are difficult to troubleshoot.

How to test the change?
Unit tests are included

@p-datadog p-datadog requested a review from a team as a code owner November 7, 2024 18:08
lib/datadog/di/serializer.rb Show resolved Hide resolved
spec/datadog/di/serializer_rails_spec.rb Outdated Show resolved Hide resolved
spec/datadog/di/serializer_spec.rb Show resolved Hide resolved
spec/datadog/di/serializer_helper.rb Show resolved Hide resolved
spec/datadog/di/serializer_spec.rb Show resolved Hide resolved
lib/datadog/di/serializer.rb Show resolved Hide resolved
spec/datadog/di/serializer_helper.rb Show resolved Hide resolved
@pr-commenter
Copy link

pr-commenter bot commented Nov 7, 2024

Benchmarks

Benchmark execution time: 2024-11-11 16:19:51

Comparing candidate commit 9d8830a in PR branch di-config-serialize with baseline commit 347bc45 in branch master.

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

@p-datadog p-datadog force-pushed the di-config-serialize branch from 5c5c41e to 72c07d3 Compare November 7, 2024 22:12
@p-datadog p-datadog merged commit 3a5f21e into master Nov 11, 2024
261 of 263 checks passed
@p-datadog p-datadog deleted the di-config-serialize branch November 11, 2024 19:09
@github-actions github-actions bot added this to the 2.7.0 milestone Nov 11, 2024
@p-datadog p-datadog added the dev/internal Other internal work that does not need to be included in the changelog label Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev/internal Other internal work that does not need to be included in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants