Skip to content

feat: enable Datadog memory profiling for connector builds - #74308

Closed
devin-ai-integration[bot] wants to merge 25 commits into
masterfrom
devin/1772724315-twilio-datadog-profiling
Closed

devin-ai-integration[bot] wants to merge 25 commits into
masterfrom
devin/1772724315-twilio-datadog-profiling

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Mar 5, 2026 •

Copy link
Copy Markdown
Contributor

What

Enables Datadog APM and memory profiling for manifest-only connector builds so we can investigate memory issues on connectors like Twilio. Follows the same pattern established in #48609 and #61344.

Also adds AIRBYTE_USE_IN_MEMORY_CACHE=true to force the CDK's requests_cache to use in-memory SQLite instead of file-based SQLite. This eliminates OS page cache growth from SQLite file I/O — confirmed via sandbox testing that RSS stays at ~300 MB while kubernetes.memory.usage previously grew to 2+ GB due to kernel page cache.

Companion CDK PR: airbytehq/airbyte-python-cdk#932 (adds ddtrace v3 to the source-declarative-manifest base image, respects AIRBYTE_USE_IN_MEMORY_CACHE env var, adds 1-hour TTL cache expiration, and periodically purges expired cache entries).

How

  1. docker-images/Dockerfile.manifest-only-connector: Adds a conditional entrypoint wrapper script that uses ddtrace-run python main.py if ddtrace is installed in the base image, otherwise falls back to plain python main.py. This allows the same Dockerfile to work with both ddtrace-enabled (prerelease) and standard base images. Sets Datadog profiling env vars (DD_PROFILING_ENABLED, DD_PROFILING_TIMELINE_ENABLED, DD_TRACE_SQLITE3_ENABLED=false, DD_PROFILING_HEAP_SAMPLE_SIZE=262144) and AIRBYTE_USE_IN_MEMORY_CACHE=true.
  2. build_customization.py: Adds the same DD env vars and AIRBYTE_USE_IN_MEMORY_CACHE=true for the airbyte-ci pipeline path. Uses plain python entrypoint (no ddtrace-run) since airbyte-ci builds may use standard base images without ddtrace.
  3. install-airbyte-ci/action.yml: Switches CI install mode from binary to source so CI picks up the pipeline changes from this branch.
  4. source-twilio/metadata.yaml: Pins baseImage to CDK prerelease 7.10.1.post13.dev22973317414 which includes ddtrace v3, AIRBYTE_USE_IN_MEMORY_CACHE support, 1-hour cache TTL, and periodic cache purging.

Updates since last revision

  • Updated CDK prerelease to 7.10.1.post13.dev22973317414: This prerelease adds periodic active purging of expired cache entries in the HTTP client. requests_cache uses lazy expiration — expired entries stay in the SQLite database until re-accessed, not automatically deleted. For connectors making thousands of unique paginated API calls, this caused expired entries to accumulate indefinitely in the in-memory SQLite database, growing RSS to ~2 GB and triggering OOM kills even with the 1-hour TTL. The fix calls session.cache.delete(expired=True) every 100 requests to actively reclaim memory.
  • Key finding from sandbox testing: With in-memory cache enabled, RSS now correctly matches kubernetes.memory.usage (no page cache gap), but RSS itself grew to ~2 GB due to the lazy expiration issue above. The periodic cache purging should keep the in-memory cache bounded to approximately the last hour of non-expired data.

Previous updates

  • Conditional entrypoint wrapper: Replaced direct ddtrace-run entrypoint with a shell wrapper script (entrypoint.sh) that checks command -v ddtrace-run at build time. Fixes CI test failures (exit code 127) when building against base images without ddtrace.
  • Removed DD_PROFILING_STACK_ENABLED=false: ddtrace v3 has full Python 3.13 stack profiling support.
  • Added 1-hour TTL cache expiration: CDK companion PR includes expire_after=3600 in CachedLimiterSession.
  • Upgraded ddtrace from v2 to v3: Full Python 3.13 profiling support (both heap and stack).
  • Reverted jemalloc: Did NOT reduce container memory growth AND broke ddtrace profiling.
  • Key finding — page cache confirmed: kubernetes.memory.rss stays at ~186 MiB avg / 300 MB max. The 2 GB kubernetes.memory.usage was RSS + OS page cache from SQLite file I/O. The ~1.7 GB gap was reclaimable kernel page cache, not a process memory leak.
  • Added AIRBYTE_USE_IN_MEMORY_CACHE=true: Forces in-memory SQLite, eliminating file I/O and OS page cache growth.

Review guide

  1. docker-images/Dockerfile.manifest-only-connector — key changes: conditional entrypoint wrapper script, DD env vars (stack profiling ENABLED with v3), heap sample size, and AIRBYTE_USE_IN_MEMORY_CACHE=true
  2. airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/connectors/build_image/steps/build_customization.py — DD env vars and AIRBYTE_USE_IN_MEMORY_CACHE=true, plain python entrypoint
  3. .github/actions/install-airbyte-ci/action.yml — CI install mode change
  4. airbyte-integrations/connectors/source-twilio/metadata.yaml — base image pinned to CDK prerelease 7.10.1.post13.dev22973317414

⚠️ Important review items

  • Periodic cache purging untested in production: The fix (purge expired entries every 100 requests) combined with 1-hour TTL should bound memory to ~1 hour of cached data, but hasn't been verified yet in sandbox. RSS should stay near ~300-500 MB instead of growing to 2+ GB.
  • Global scope for manifest-only connectors: Both docker-images/Dockerfile.manifest-only-connector and build_customization.py affect all manifest-only connectors, not just Twilio. DD_PROFILING_ENABLED=true and AIRBYTE_USE_IN_MEMORY_CACHE=true will apply to every manifest-only connector.
  • DD_PROFILING_ENABLED=true is hardcoded in the Dockerfile: Profiling will be active for every manifest-only connector built from this Dockerfile, not gated by LaunchDarkly. Verify this is the intended behavior vs. relying on the platform's connectors.apm-enabled feature flag.
  • Prerelease base image: Twilio is now pinned to a dev prerelease (7.10.1.post13.dev22973317414). The prerelease pin must be reverted to a stable release before merging to master.
  • install-mode=source: This changes CI behavior globally — all CI runs will install airbyte-ci from source instead of using the pre-built binary, which is slower. This should be reverted before merging to master.
  • DD_PROFILING_HEAP_SAMPLE_SIZE=262144 (256 KB): More aggressive than the default (~1 MB). Provides better visibility but increases profiling overhead slightly.
  • 1-hour cache TTL + periodic purging: HTTP responses are cached for 1 hour max, then actively purged. This prevents unbounded cache growth but may increase API usage for long-running syncs.

User Impact

When source-twilio is built from this branch and deployed with the updated prerelease base image:

  1. Memory profiling data (heap + stack) will be sent to Datadog during READ operations. Profiling is enabled by default in the Docker image (via hardcoded env vars), not gated by the LaunchDarkly flag. Heap profiling samples allocations every 256 KB on average (vs. the default of ~1 MB).
  2. HTTP response cache will be in-memory only (not persisted to disk), expire after 1 hour, and actively purge expired entries every 100 requests. This eliminates OS page cache growth from SQLite file I/O and prevents unbounded in-memory cache growth.

Expected result: kubernetes.memory.usage and RSS should both remain near ~300-500 MB instead of growing to 2+ GB, confirming that:

  • The previous kubernetes.memory.usage growth to 2+ GB was OS page cache from file-based SQLite (now eliminated with in-memory cache)
  • The RSS growth to 2 GB with in-memory cache was due to lazy expiration in requests_cache (now mitigated with periodic purging)

Can this PR be safely reverted and rolled back?

  • YES 💚

- Change entrypoint to use ddtrace-run wrapper
- Add DD_PROFILING_ENABLED, DD_PROFILING_TIMELINE_ENABLED env vars
- Disable sqlite3 tracing to avoid known issues
- Set airbyte-ci install mode to source to pick up pipeline changes

Co-Authored-By: gl_anatolii.yatsuk <gl_anatolii.yatsuk@airbyte.io>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@octavia-bot
octavia-bot Bot marked this pull request as draft March 5, 2026 15:26
@octavia-bot

octavia-bot Bot commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Note

📝 PR Converted to Draft

More info...

Thank you for creating this PR. As a policy to protect our engineers' time, Airbyte requires all PRs to be created first in draft status. Your PR has been automatically converted to draft status in respect for this policy.

As soon as your PR is ready for formal review, you can proceed to convert the PR to "ready for review" status by clicking the "Ready for review" button at the bottom of the PR page.

To skip draft status in future PRs, please include [ready] in your PR title or add the skip-draft-status label when creating your PR.

@github-actions

github-actions Bot commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

👋 Greetings, Airbyte Team Member!

Here are some helpful tips and reminders for your convenience.

💡 Show Tips and Tricks

PR Slash Commands

Airbyte Maintainers (that's you!) can execute the following slash commands on your PR:

  • 🛠️ Quick Fixes
    • /format-fix - Fixes most formatting issues.
    • /bump-version - Bumps connector versions, scraping changelog description from the PR title.
  • ❇️ AI Testing and Review (internal link: AI-SDLC Docs):
    • /ai-prove-fix - Runs prerelease readiness checks, including testing against customer connections.
    • /ai-canary-prerelease - Rolls out prerelease to 5-10 connections for canary testing.
    • /ai-review - AI-powered PR review for connector safety and quality gates.
  • 🚀 Connector Releases:
    • /publish-connectors-prerelease - Publishes pre-release connector builds (tagged as {version}-preview.{git-sha}) for all modified connectors in the PR.
    • /bump-progressive-rollout-version - Bumps connector version with an RC suffix (2.16.10-rc.1) for progressive rollouts (enableProgressiveRollout: true).
      • Example: /bump-progressive-rollout-version changelog="Add new feature for progressive rollout"
  • ☕️ JVM connectors:
    • /update-connector-cdk-version connector=<CONNECTOR_NAME> - Updates the specified connector to the latest CDK version.
      Example: /update-connector-cdk-version connector=destination-bigquery
  • 🐍 Python connectors:
    • /poe connector source-example lock - Run the Poe lock task on the source-example connector, committing the results back to the branch.
    • /poe source example lock - Alias for /poe connector source-example lock.
    • /poe source example use-cdk-branch my/branch - Pin the source-example CDK reference to the branch name specified.
    • /poe source example use-cdk-latest - Update the source-example CDK dependency to the latest available version.
  • ⚙️ Admin commands:
    • /force-merge reason="<REASON>" - Force merges the PR using admin privileges, bypassing CI checks. Requires a reason.
      Example: /force-merge reason="CI is flaky, tests pass locally"
📚 Show Repo Guidance

Helpful Resources

📝 Edit this welcome message.

devin-ai-integration Bot and others added 2 commits March 5, 2026 15:30
Co-Authored-By: gl_anatolii.yatsuk <gl_anatolii.yatsuk@airbyte.io>
Co-Authored-By: gl_anatolii.yatsuk <gl_anatolii.yatsuk@airbyte.io>
@github-actions

github-actions Bot commented Mar 5, 2026 •

Copy link
Copy Markdown
Contributor

source-twilio Connector Test Results

21 tests   18 ✅  35s ⏱️
 2 suites   3 💤
 2 files     0 ❌

Results for commit 35915f9.

♻️ This comment has been updated with latest results.

@tolik0

Copy link
Copy Markdown
Contributor

/publish-connectors-prerelease

@tolik0

Anatolii Yatsuk (tolik0) commented Mar 5, 2026 •

Copy link
Copy Markdown
Contributor

/publish-connectors-prerelease

Pre-release Connector Publish Started

Publishing pre-release build for connector source-twilio.
PR: #74308

Pre-release versions will be tagged as {version}-preview.bbfa264
and are available for version pinning via the scoped_configuration API.

View workflow run
Pre-release Publish: SUCCESS ✅

Docker image (pre-release):
airbyte/source-twilio:0.17.4-preview.bbfa264

Docker Hub: https://hub.docker.com/layers/airbyte/source-twilio/0.17.4-preview.bbfa264

Registry JSON:

The publish workflow uses docker-images/Dockerfile.manifest-only-connector
(not build_customization.py) to build manifest-only connector images.
Updated the Dockerfile to use ddtrace-run wrapper and set DD env vars
so Datadog profiling is active at runtime.

Co-Authored-By: gl_anatolii.yatsuk <gl_anatolii.yatsuk@airbyte.io>
@tolik0

Anatolii Yatsuk (tolik0) commented Mar 5, 2026 •

Copy link
Copy Markdown
Contributor

/publish-connectors-prerelease

Pre-release Connector Publish Started

Publishing pre-release build for connector source-twilio.
PR: #74308

Pre-release versions will be tagged as {version}-preview.3ef2643
and are available for version pinning via the scoped_configuration API.

View workflow run
Pre-release Publish: SUCCESS ✅

Docker image (pre-release):
airbyte/source-twilio:0.17.4-preview.3ef2643

Docker Hub: https://hub.docker.com/layers/airbyte/source-twilio/0.17.4-preview.3ef2643

Registry JSON:

…3.13 profiling fix)

Co-Authored-By: gl_anatolii.yatsuk <gl_anatolii.yatsuk@airbyte.io>
@tolik0

Anatolii Yatsuk (tolik0) commented Mar 5, 2026 •

Copy link
Copy Markdown
Contributor

/publish-connectors-prerelease

Pre-release Connector Publish Started

Publishing pre-release build for connector source-twilio.
PR: #74308

Pre-release versions will be tagged as {version}-preview.26c7d7f
and are available for version pinning via the scoped_configuration API.

View workflow run
Pre-release Publish: SUCCESS ✅

Docker image (pre-release):
airbyte/source-twilio:0.17.4-preview.26c7d7f

Docker Hub: https://hub.docker.com/layers/airbyte/source-twilio/0.17.4-preview.26c7d7f

Registry JSON:

…profiling

Co-Authored-By: gl_anatolii.yatsuk <gl_anatolii.yatsuk@airbyte.io>
…p sample size

Co-Authored-By: gl_anatolii.yatsuk <gl_anatolii.yatsuk@airbyte.io>
@tolik0

Anatolii Yatsuk (tolik0) commented Mar 9, 2026 •

Copy link
Copy Markdown
Contributor

/publish-connectors-prerelease

Pre-release Connector Publish Started

Publishing pre-release build for connector source-twilio.
PR: #74308

Pre-release versions will be tagged as {version}-preview.3aa042e
and are available for version pinning via the scoped_configuration API.

View workflow run
Pre-release Publish: SUCCESS ✅

Docker image (pre-release):
airbyte/source-twilio:0.17.4-preview.3aa042e

Docker Hub: https://hub.docker.com/layers/airbyte/source-twilio/0.17.4-preview.3aa042e

Registry JSON:

Co-Authored-By: gl_anatolii.yatsuk <gl_anatolii.yatsuk@airbyte.io>
… fragmentation

Co-Authored-By: gl_anatolii.yatsuk <gl_anatolii.yatsuk@airbyte.io>
@tolik0

Anatolii Yatsuk (tolik0) commented Mar 10, 2026 •

Copy link
Copy Markdown
Contributor

/publish-connectors-prerelease

Pre-release Connector Publish Started

Publishing pre-release build for connector source-twilio.
PR: #74308

Pre-release versions will be tagged as {version}-preview.0dbb7bc
and are available for version pinning via the scoped_configuration API.

View workflow run
Pre-release Publish: SUCCESS ✅

Docker image (pre-release):
airbyte/source-twilio:0.17.4-preview.0dbb7bc

Docker Hub: https://hub.docker.com/layers/airbyte/source-twilio/0.17.4-preview.0dbb7bc

Registry JSON:

…tter memory management

Co-Authored-By: gl_anatolii.yatsuk <gl_anatolii.yatsuk@airbyte.io>
Co-Authored-By: gl_anatolii.yatsuk <gl_anatolii.yatsuk@airbyte.io>
… TTL

Co-Authored-By: gl_anatolii.yatsuk <gl_anatolii.yatsuk@airbyte.io>
The CI test builds connector images using the Dockerfile.manifest-only-connector
with the base image from metadata.yaml. If the base image doesn't have ddtrace
installed, the ddtrace-run entrypoint fails with exit code 127 (command not found).

Fix: Use a wrapper script that checks for ddtrace-run at build time and falls back
to plain python if not available. Also revert build_customization.py to use plain
python entrypoint since it's used for CI test builds.

Co-Authored-By: gl_anatolii.yatsuk <gl_anatolii.yatsuk@airbyte.io>
Update base image to 7.10.1.post12.dev22961776456 which has ddtrace v3
installed (confirmed via docker inspection). Previous prerelease
(post19.dev22961350734) did not have ddtrace installed.

Co-Authored-By: gl_anatolii.yatsuk <gl_anatolii.yatsuk@airbyte.io>
@tolik0

Anatolii Yatsuk (tolik0) commented Mar 11, 2026 •

Copy link
Copy Markdown
Contributor

/publish-connectors-prerelease

Pre-release Connector Publish Started

Publishing pre-release build for connector source-twilio.
PR: #74308

Pre-release versions will be tagged as {version}-preview.f4fa24d
and are available for version pinning via the scoped_configuration API.

View workflow run
Pre-release Publish: SUCCESS ✅

Docker image (pre-release):
airbyte/source-twilio:0.17.4-preview.f4fa24d

Docker Hub: https://hub.docker.com/layers/airbyte/source-twilio/0.17.4-preview.f4fa24d

Registry JSON:

Updates base image to 7.10.1.post13.dev22973317414 which includes
periodic cache purging to prevent unbounded memory growth from
requests_cache lazy expiration.

Co-Authored-By: gl_anatolii.yatsuk <gl_anatolii.yatsuk@airbyte.io>
@tolik0

Anatolii Yatsuk (tolik0) commented Mar 11, 2026 •

Copy link
Copy Markdown
Contributor

/publish-connectors-prerelease

Pre-release Connector Publish Started

Publishing pre-release build for connector source-twilio.
PR: #74308

Pre-release versions will be tagged as {version}-preview.23d43ad
and are available for version pinning via the scoped_configuration API.

View workflow run
Pre-release Publish: SUCCESS ✅

Docker image (pre-release):
airbyte/source-twilio:0.17.4-preview.23d43ad

Docker Hub: https://hub.docker.com/layers/airbyte/source-twilio/0.17.4-preview.23d43ad

Registry JSON:

Co-Authored-By: gl_anatolii.yatsuk <gl_anatolii.yatsuk@airbyte.io>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

/publish-connectors-prerelease

@github-actions

Copy link
Copy Markdown
Contributor

Pre-release Connector Publish Started

Publishing pre-release build for connector source-twilio.
PR: #74308

Pre-release versions will be tagged as {version}-preview.9154a10
and are available for version pinning via the scoped_configuration API.

View workflow run

Co-Authored-By: gl_anatolii.yatsuk <gl_anatolii.yatsuk@airbyte.io>
@github-actions

github-actions Bot commented Mar 12, 2026 •

Copy link
Copy Markdown
Contributor

Pre-release Connector Publish Started

Publishing pre-release build for connector source-twilio.
PR: #74308

Pre-release versions will be tagged as {version}-preview.ec6efbd
and are available for version pinning via the scoped_configuration API.

View workflow run
Pre-release Publish: SUCCESS ✅

Docker image (pre-release):
airbyte/source-twilio:0.17.4-preview.ec6efbd

Docker Hub: https://hub.docker.com/layers/airbyte/source-twilio/0.17.4-preview.ec6efbd

Registry JSON:

…ng for testing

Co-Authored-By: gl_anatolii.yatsuk <gl_anatolii.yatsuk@airbyte.io>
…E support

Co-Authored-By: gl_anatolii.yatsuk <gl_anatolii.yatsuk@airbyte.io>
@github-actions

github-actions Bot commented Mar 12, 2026 •

Copy link
Copy Markdown
Contributor

Pre-release Connector Publish Started

Publishing pre-release build for connector source-twilio.
PR: #74308

Pre-release versions will be tagged as {version}-preview.16f969e
and are available for version pinning via the scoped_configuration API.

View workflow run
Pre-release Publish: SUCCESS ✅

Docker image (pre-release):
airbyte/source-twilio:0.17.4-preview.16f969e

Docker Hub: https://hub.docker.com/layers/airbyte/source-twilio/0.17.4-preview.16f969e

Registry JSON:

Co-Authored-By: gl_anatolii.yatsuk <gl_anatolii.yatsuk@airbyte.io>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

/publish-connectors-prerelease

@github-actions

github-actions Bot commented Mar 12, 2026 •

Copy link
Copy Markdown
Contributor

Pre-release Connector Publish Started

Publishing pre-release build for connector source-twilio.
PR: #74308

Pre-release versions will be tagged as {version}-preview.35915f9
and are available for version pinning via the scoped_configuration API.

View workflow run
Pre-release Publish: SUCCESS ✅

Docker image (pre-release):
airbyte/source-twilio:0.17.4-preview.35915f9

Docker Hub: https://hub.docker.com/layers/airbyte/source-twilio/0.17.4-preview.35915f9

Registry JSON:

@davinchia

Copy link
Copy Markdown
Contributor

Closing as stale.

This PR has been open and unreviewed for 3-5 months with no linked issue or ticket. Master has moved substantially since the branch was cut, so it would need re-verification rather than a straight rebase.

If the underlying need still stands, please reopen or raise a fresh PR against current master — the work here is preserved in the branch and this closure is reversible.

This branch was previously deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants