Skip to content

feat(redis): add DD_TRACE_REDIS_LIFECYCLE_COMMANDS_ENABLED to disable lifecycle spans #3753

@jbdelhommeau

Description

@jbdelhommeau

Summary

Add DD_TRACE_REDIS_LIFECYCLE_COMMANDS_ENABLED (boolean, default true) to allow users to disable tracing of Redis lifecycle/admin/introspection operations independently from data commands.

Motivation

Applications using Redis heavily generate many low-value spans (connect, close, auth, ping, getHost, isConnected, bgSave, etc.) that add noise without observability value. Users want to reduce span volume without disabling the entire Redis integration.

Proposed behaviour

When DD_TRACE_REDIS_LIFECYCLE_COMMANDS_ENABLED=false:

  • PHPRedis: 27 lifecycle methods NOT traced: connect, pconnect, open, popen, close, auth, select, ping, echo, isConnected, getHost, getPort, getDbNum, getTimeout, getReadTimeout, bgRewriteAOF, bgSave, flushAll, flushDb, save, restore, swapdb, _serialize, _unserialize, getLastError, clearLastError, RedisCluster.__construct
  • Predis: 3 methods NOT traced: __construct, connect, executePipeline
  • Connection metadata (ObjectKVStore) is preserved so data command spans still have out.host tags
  • All 120+ data commands (get, set, hGet, etc.), multi, exec remain traced

Prior art

Same pattern as DD_TRACE_PDO_PREPARED_STATEMENTS_ENABLED (PR #3752) and Go tracer's WithIgnoreQueryTypes.

Implementation scope

  • ext/configuration.h — declare CONFIG(BOOL, DD_TRACE_REDIS_LIFECYCLE_COMMANDS_ENABLED, "true")
  • src/DDTrace/Integrations/PHPRedis/PHPRedisIntegration.php — conditional hook registration
  • src/DDTrace/Integrations/Predis/PredisIntegration.php — conditional hook registration
  • metadata/supported-configurations.json — document the variable
  • Tests for both integrations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions