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

feat: Kafka Integration #3004

Merged
merged 61 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
5f0f038
chore: Install `rdkafka` extension
PROFeNoM Dec 9, 2024
7b32722
chore: Install `librdkafka-dev` library
PROFeNoM Dec 9, 2024
ce0c0a6
Add a dirty first version
PROFeNoM Dec 12, 2024
47bb921
Refactor the integration
PROFeNoM Dec 12, 2024
a27d56c
Fix instances
PROFeNoM Dec 12, 2024
80752e0
Add destination kind
PROFeNoM Dec 12, 2024
f37c6ac
Upload snapshots
PROFeNoM Dec 13, 2024
40247ad
Install `librdkafka-dev` on some base images
PROFeNoM Dec 13, 2024
b8d18ad
ci: Increase timeout time from 1h to 4h
PROFeNoM Dec 16, 2024
dbedcc1
fix compile errors
PROFeNoM Dec 16, 2024
a56f4d9
fix compile errors
PROFeNoM Dec 16, 2024
c4003ae
fix compile errors in PHP 7
PROFeNoM Dec 16, 2024
915dba3
wrap everything to exclude windows
PROFeNoM Dec 16, 2024
c06906f
install librdkafka-devel on centos7 builds
PROFeNoM Dec 16, 2024
c41b9d8
fix segfault
PROFeNoM Dec 17, 2024
bde2d01
fix distributed tracing
PROFeNoM Dec 17, 2024
2c08ea5
fix windows compilation
PROFeNoM Dec 17, 2024
41b6160
Add DD_TRACE_KAFKA_DISTRIBUTED_TRACING
PROFeNoM Dec 17, 2024
470940c
Add v2 with debug logs
PROFeNoM Dec 18, 2024
096f1f4
only php 8+
PROFeNoM Dec 18, 2024
5417d1d
Support php 7
PROFeNoM Dec 18, 2024
1993871
Optimize RdKafka::purge lookup
PROFeNoM Dec 18, 2024
9560f6a
Remove unused imports
PROFeNoM Dec 18, 2024
5a01971
PHP 7 Compatibility
PROFeNoM Dec 18, 2024
a00b022
trigger integration tests in ci
PROFeNoM Dec 18, 2024
dba2dc0
fix distributed tracing
PROFeNoM Dec 18, 2024
f8c0f06
Fully leverage span links
PROFeNoM Dec 18, 2024
84a3cbf
fix ci config
PROFeNoM Dec 19, 2024
902b9c1
add distributed tracing
PROFeNoM Dec 19, 2024
5803a5d
remove comment
PROFeNoM Dec 19, 2024
19d9786
add ci image
PROFeNoM Dec 19, 2024
54caa26
Remove debug logs
PROFeNoM Dec 19, 2024
fbfb078
Update php api stubs
PROFeNoM Dec 19, 2024
02b2cbb
typo
PROFeNoM Dec 19, 2024
e0e5f05
fix docker commands
PROFeNoM Dec 19, 2024
bbb70a9
streamline php code
PROFeNoM Dec 19, 2024
e0552df
Add a ddSetUpBeforeClass
PROFeNoM Dec 19, 2024
971763b
fix namespaces
PROFeNoM Dec 19, 2024
669213d
Handle empty payloads
PROFeNoM Dec 19, 2024
114b7e5
KAFKA_AUTO_CREATE_TOPICS_ENABLE
PROFeNoM Dec 20, 2024
2417718
Add back warm up
PROFeNoM Dec 20, 2024
c0c2e35
KAFKA_AUTO_CREATE_TOPICS_ENABLE
PROFeNoM Dec 20, 2024
1867640
fix KAFKA_AUTO_CREATE_TOPICS_ENABLE
PROFeNoM Dec 20, 2024
c32de8a
change test order
PROFeNoM Dec 20, 2024
feb639e
fix UserAvailableConstantsTest
PROFeNoM Dec 20, 2024
3da77fa
Clean C Code
PROFeNoM Dec 20, 2024
12bff4c
Clean C Code further
PROFeNoM Dec 20, 2024
983f529
Add comment for legacy
PROFeNoM Dec 20, 2024
ec3612b
var_dump cleanup
PROFeNoM Dec 23, 2024
f570fef
Only load for supported kafka versions
PROFeNoM Dec 31, 2024
a8bcc6c
Update ext/handlers_kafka.c
PROFeNoM Jan 3, 2025
23448e4
Accept versions 6+
PROFeNoM Jan 3, 2025
d578b17
Enhance distributed tracing headers consumption
PROFeNoM Jan 3, 2025
cd63306
fix: Don't prevent ArgumentCountError
PROFeNoM Jan 3, 2025
f654464
style: function removal
PROFeNoM Jan 3, 2025
5237274
fix: Don't install handler if producev does not exist
PROFeNoM Jan 3, 2025
af7fe35
Remove _WIN32 exclusions
PROFeNoM Jan 3, 2025
5acae7b
Only inject headers if distributed tracing is enabled
PROFeNoM Jan 3, 2025
b978fc0
Use microtime(true)
PROFeNoM Jan 3, 2025
aaca1fc
Remove leftover header
PROFeNoM Jan 3, 2025
891fa03
fix: unpacking on float value
PROFeNoM Jan 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .circleci/continue_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ aliases:
image: kong/httpbin
name: httpbin_integration

- &IMAGE_DOCKER_KAFKA
image: confluentinc/cp-kafka:7.7.1
name: kafka_integration
environment:
- KAFKA_BROKER_ID=111
- KAFKA_CREATE_TOPICS=test-lowlevel:1:1,test-highlevel:1:1
- KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181
- KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka_integration:9092
- KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=PLAINTEXT:PLAINTEXT
- KAFKA_INTER_BROKER_LISTENER_NAME=PLAINTEXT
- KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1
- KAFKA_TRANSACTION_STATE_LOG_MIN_ISR=1
- KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR=1
- KAFKA_AUTO_CREATE_TOPICS_ENABLE=true

- &IMAGE_DOCKER_MEMCHACED
image: memcached:1.5-alpine
name: memcached_integration
Expand Down Expand Up @@ -100,6 +115,14 @@ aliases:
image: gcr.io/cloud-spanner-emulator/emulator:1.5.25
name: googlespanner_integration

- &IMAGE_DOCKER_ZOOKEEPER
image: confluentinc/cp-zookeeper:7.7.1
name: zookeeper
environment:
- ZOOKEEPER_CLIENT_PORT=2181
- ZOOKEEPER_TICK_TIME=2000


- &STEP_ATTACH_WORKSPACE
attach_workspace:
at: ~/datadog
Expand Down Expand Up @@ -537,6 +560,22 @@ commands:
-e ES_JAVA_OPTS="-Xms1g -Xmx1g" \
-e discovery.type=single-node \
--name elasticsearch7_integration elasticsearch:7.17.0
retry_docker run --detach --rm --net net \
-e ZOOKEEPER_CLIENT_PORT=2181 \
-e ZOOKEEPER_TICK_TIME=2000 \
--name zookeeper confluentinc/cp-zookeeper:7.7.1
retry_docker run --detach --rm --net net \
-e KAFKA_BROKER_ID=111 \
-e KAFKA_CREATE_TOPICS=test-lowlevel:1:1,test-highlevel:1:1 \
-e KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka_integration:9092 \
-e KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=PLAINTEXT:PLAINTEXT \
-e KAFKA_INTER_BROKER_LISTENER_NAME=PLAINTEXT \
-e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 \
-e KAFKA_TRANSACTION_STATE_LOG_MIN_ISR=1 \
-e KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR=1 \
-e KAFKA_AUTO_CREATE_TOPICS_ENABLE=true \
--name kafka_integration confluentinc/cp-kafka:7.7.1
retry_docker run --detach --rm --net net \
--name redis_integration datadog/dd-trace-ci:php-redis-5.0
retry_docker run --detach --rm --net net \
Expand Down Expand Up @@ -581,6 +620,8 @@ commands:
docker_image: elasticsearch2_integration
- docker_logs:
docker_image: elasticsearch7_integration
- docker_logs:
docker_image: kafka_integration
- docker_logs:
docker_image: redis_integration
- docker_logs:
Expand All @@ -595,6 +636,8 @@ commands:
docker_image: sqlsrv_integration
- docker_logs:
docker_image: googlespanner_integration
- docker_logs:
docker_image: zookeeper
- run:
name: Setup docker image << parameters.docker_image >>
command: |
Expand Down Expand Up @@ -732,6 +775,7 @@ executors:
- <<: *IMAGE_DOCKER_ELASTICSEARCH7
- <<: *IMAGE_DOCKER_HTTPBIN
- <<: *IMAGE_DOCKER_REDIS
- <<: *IMAGE_DOCKER_KAFKA
- <<: *IMAGE_DOCKER_MEMCHACED
- <<: *IMAGE_DOCKER_MYSQL
- <<: *IMAGE_DOCKER_RABBITMQ
Expand All @@ -740,6 +784,7 @@ executors:
- <<: *IMAGE_DOCKER_DD_TEST_AGENT
- <<: *IMAGE_DOCKER_SQLSRV
- <<: *IMAGE_DOCKER_GOOGLESPANNER
- <<: *IMAGE_DOCKER_ZOOKEEPER
with_redis:
environment:
DDAGENT_HOSTNAME: 127.0.0.1
Expand Down
8 changes: 4 additions & 4 deletions .gitlab/ci-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ CentOS:
- when: manual
needs: []
tags: ["arch:amd64"]
timeout: 1h
timeout: 4h
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/docker:24.0.4-gbi-focal
parallel:
matrix:
Expand All @@ -41,7 +41,7 @@ Alpine:
- when: manual
needs: []
tags: ["arch:amd64"]
timeout: 1h
timeout: 4h
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/docker:24.0.4-gbi-focal
parallel:
matrix:
Expand All @@ -68,7 +68,7 @@ Bookworm:
- when: manual
needs: []
tags: ["arch:amd64"]
timeout: 1h
timeout: 4h
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/docker:24.0.4-gbi-focal
parallel:
matrix:
Expand Down Expand Up @@ -97,7 +97,7 @@ Buster:
- when: manual
needs: []
tags: ["arch:amd64"]
timeout: 1h
timeout: 4h
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/docker:24.0.4-gbi-focal
parallel:
matrix:
Expand Down
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ TELEMETRY_ENABLED=0
TEST_INTEGRATIONS_70 := \
test_integrations_deferred_loading \
test_integrations_curl \
test_integrations_kafka \
test_integrations_memcache \
test_integrations_memcached \
test_integrations_mongodb1 \
Expand Down Expand Up @@ -588,6 +589,7 @@ TEST_INTEGRATIONS_71 := \
test_integrations_amqp2 \
test_integrations_amqp35 \
test_integrations_curl \
test_integrations_kafka \
test_integrations_memcache \
test_integrations_memcached \
test_integrations_mongodb1 \
Expand Down Expand Up @@ -639,6 +641,7 @@ TEST_INTEGRATIONS_72 := \
test_integrations_amqp2 \
test_integrations_amqp35 \
test_integrations_curl \
test_integrations_kafka \
test_integrations_memcache \
test_integrations_memcached \
test_integrations_mongodb1 \
Expand Down Expand Up @@ -697,6 +700,7 @@ TEST_INTEGRATIONS_73 :=\
test_integrations_amqp2 \
test_integrations_amqp35 \
test_integrations_curl \
test_integrations_kafka \
test_integrations_memcache \
test_integrations_memcached \
test_integrations_mongodb1 \
Expand Down Expand Up @@ -754,6 +758,7 @@ TEST_INTEGRATIONS_74 := \
test_integrations_amqp2 \
test_integrations_amqp35 \
test_integrations_curl \
test_integrations_kafka \
test_integrations_memcache \
test_integrations_memcached \
test_integrations_mongodb1 \
Expand Down Expand Up @@ -819,6 +824,7 @@ TEST_INTEGRATIONS_80 := \
test_integrations_amqp2 \
test_integrations_amqp35 \
test_integrations_curl \
test_integrations_kafka \
test_integrations_laminaslog2 \
test_integrations_memcache \
test_integrations_memcached \
Expand Down Expand Up @@ -871,6 +877,7 @@ TEST_INTEGRATIONS_81 := \
test_integrations_amqp35 \
test_integrations_curl \
test_integrations_deferred_loading \
test_integrations_kafka \
test_integrations_laminaslog2 \
test_integrations_memcache \
test_integrations_memcached \
Expand Down Expand Up @@ -925,6 +932,7 @@ TEST_INTEGRATIONS_82 := \
test_integrations_amqp35 \
test_integrations_curl \
test_integrations_deferred_loading \
test_integrations_kafka \
test_integrations_laminaslog2 \
test_integrations_memcache \
test_integrations_memcached \
Expand Down Expand Up @@ -987,6 +995,7 @@ TEST_INTEGRATIONS_83 := \
test_integrations_amqp35 \
test_integrations_curl \
test_integrations_deferred_loading \
test_integrations_kafka \
test_integrations_laminaslog2 \
test_integrations_memcache \
test_integrations_memcached \
Expand Down Expand Up @@ -1230,6 +1239,8 @@ test_integrations_guzzle6: global_test_run_dependencies tests/Integrations/Guzz
$(call run_tests_debug,tests/Integrations/Guzzle/V6)
test_integrations_guzzle7: global_test_run_dependencies tests/Integrations/Guzzle/V7/composer.lock-php$(PHP_MAJOR_MINOR)
$(call run_tests_debug,tests/Integrations/Guzzle/V7)
test_integrations_kafka: global_test_run_dependencies
$(call run_tests_debug,tests/Integrations/Kafka)
test_integrations_laminaslog2: global_test_run_dependencies tests/Integrations/Logs/LaminasLogV2/composer.lock-php$(PHP_MAJOR_MINOR)
$(call run_tests_debug,tests/Integrations/Logs/LaminasLogV2)
test_integrations_memcached: global_test_run_dependencies
Expand Down
1 change: 1 addition & 0 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ if test "$PHP_DDTRACE" != "no"; then
ext/handlers_api.c \
ext/handlers_exception.c \
ext/handlers_internal.c \
ext/handlers_kafka.c \
ext/handlers_pcntl.c \
ext/handlers_signal.c \
ext/integrations/exec_integration.c \
Expand Down
1 change: 1 addition & 0 deletions config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ if (PHP_DDTRACE != 'no') {
DDTRACE_EXT_SOURCES += " handlers_curl" + (version < 800 ? "_php7" : "") + ".c";
DDTRACE_EXT_SOURCES += " handlers_exception.c";
DDTRACE_EXT_SOURCES += " handlers_internal.c";
DDTRACE_EXT_SOURCES += " handlers_kafka.c";
DDTRACE_EXT_SOURCES += " handlers_pcntl.c";
DDTRACE_EXT_SOURCES += " ip_extraction.c";
DDTRACE_EXT_SOURCES += " standalone_limiter.c";
Expand Down
31 changes: 31 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ x-aliases:
- mysql_integration
- memcached_integration
- googlespanner_integration
- kafka_integration
environment:
- REDIS_HOSTNAME=redis_integration
- DDAGENT_HOSTNAME=ddagent_integration
Expand Down Expand Up @@ -169,6 +170,36 @@ services:
aliases:
- spanner.local

kafka_integration:
image: confluentinc/cp-kafka:7.7.1
ports:
- "9092:9092"
networks:
default:
aliases:
- kafka_integration
environment:
- KAFKA_BROKER_ID=111
- KAFKA_CREATE_TOPICS=test-lowlevel:1:1,test-highlevel:1:1
- KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181
- KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka_integration:9092
- KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=PLAINTEXT:PLAINTEXT
- KAFKA_INTER_BROKER_LISTENER_NAME=PLAINTEXT
- KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1
- KAFKA_TRANSACTION_STATE_LOG_MIN_ISR=1
- KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR=1
- KAFKA_AUTO_CREATE_TOPICS_ENABLE=true
depends_on:
- zookeeper

zookeeper:
image: confluentinc/cp-zookeeper:7.7.1
ports:
- "2181:2181"
environment:
- ZOOKEEPER_CLIENT_PORT=2181
- ZOOKEEPER_TICK_TIME=2000

mongodb_integration:
image: "circleci/mongo:4.0"
ports:
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/ci/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ RUN set -eux; \
libffi-dev \
libmemcached \
libmemcached-dev \
librdkafka-dev \
libsodium-dev \
libxml2-dev \
libzip-dev \
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/ci/alpine_compile_extension/base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ RUN set -eux; \
libedit-dev \
libffi-dev \
libmcrypt-dev \
librdkafka-dev \
libsodium-dev \
libxml2-dev \
gnu-libiconv-dev \
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/ci/buster/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ ENV DEVLIBS \
libpq-dev \
libpng-dev \
librabbitmq-dev \
librdkafka-dev \
libsodium-dev \
libsqlite3-dev \
libssl-dev \
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/ci/buster/build-extensions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ else
yes 'no' | pecl install memcached; echo "extension=memcached.so" >> ${iniDir}/memcached.ini;
yes '' | pecl install memcache$MEMCACHE_VERSION; echo "extension=memcache.so" >> ${iniDir}/memcache.ini;
pecl install mongodb$MONGODB_VERSION; echo "extension=mongodb.so" >> ${iniDir}/mongodb.ini;
pecl install rdkafka; echo "extension=rdkafka.so" >> ${iniDir}/rdkafka.ini;
pecl install sqlsrv$SQLSRV_VERSION;
# Xdebug is disabled by default
for VERSION in "${XDEBUG_VERSIONS[@]}"; do
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/ci/centos/7/base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ RUN set -eux; \
bzip2-devel \
httpd-devel \
libmemcached-devel \
librdkafka-devel \
libsodium-devel \
libsqlite3x-devel \
libxml2-devel \
Expand Down
10 changes: 10 additions & 0 deletions ext/compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,16 @@ static zend_always_inline zend_result zend_call_function_with_return_value(zend_

#define Z_PARAM_ZVAL_OR_NULL(dest) Z_PARAM_ZVAL_EX(dest, 1, 0)

#ifndef Z_PARAM_STRING_OR_NULL
#define Z_PARAM_STRING_OR_NULL(dest, dest_len) \
Z_PARAM_STRING_EX(dest, dest_len, 1, 0)
#endif

#ifndef Z_PARAM_STR_OR_NULL
#define Z_PARAM_STR_OR_NULL(dest) \
Z_PARAM_STR_EX(dest, 1, 0)
#endif

#define ZEND_GUARD_PROPERTY_MASK 0xf

// strip const
Expand Down
1 change: 1 addition & 0 deletions ext/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ enum ddtrace_sampling_rules_format {
CONFIG(STRING, DD_TRACE_MEMORY_LIMIT, "") \
CONFIG(BOOL, DD_TRACE_REPORT_HOSTNAME, "false") \
CONFIG(BOOL, DD_TRACE_FLUSH_COLLECT_CYCLES, "false") \
CONFIG(BOOL, DD_TRACE_KAFKA_DISTRIBUTED_TRACING, "true") \
CONFIG(BOOL, DD_TRACE_LARAVEL_QUEUE_DISTRIBUTED_TRACING, "true") \
CONFIG(BOOL, DD_TRACE_SYMFONY_MESSENGER_DISTRIBUTED_TRACING, "true") \
CONFIG(BOOL, DD_TRACE_SYMFONY_MESSENGER_MIDDLEWARES, "false") \
Expand Down
2 changes: 2 additions & 0 deletions ext/handlers_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ void ddtrace_free_unregistered_class(zend_class_entry *ce) {
void ddtrace_curl_handlers_startup(void);
void ddtrace_exception_handlers_startup(void);
void ddtrace_pcntl_handlers_startup(void);
void ddtrace_kafka_handlers_startup(void);
#ifndef _WIN32
void ddtrace_signal_block_handlers_startup(void);
#endif
Expand Down Expand Up @@ -150,6 +151,7 @@ void ddtrace_internal_handlers_startup() {
ddtrace_exception_handlers_startup();

ddtrace_exec_handlers_startup();
ddtrace_kafka_handlers_startup();
#ifndef _WIN32
// Block remote-config signals of some functions
ddtrace_signal_block_handlers_startup();
Expand Down
Loading
Loading