Skip to content

Commit

Permalink
updating default and depending on sample rate
Browse files Browse the repository at this point in the history
  • Loading branch information
link04 committed Oct 25, 2024
1 parent 093ef34 commit fe12510
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ext/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ enum ddtrace_sampling_rules_format {
CONFIG(SET, DD_TRACE_RESOURCE_URI_QUERY_PARAM_ALLOWED, "") \
CONFIG(SET, DD_TRACE_HTTP_URL_QUERY_PARAM_ALLOWED, "*") \
CONFIG(SET, DD_TRACE_HTTP_POST_DATA_PARAM_ALLOWED, "") \
CONFIG(INT, DD_TRACE_RATE_LIMIT, "0", .ini_change = zai_config_system_ini_change) \
CONFIG(INT, DD_TRACE_RATE_LIMIT, "100", .ini_change = zai_config_system_ini_change) \
CONFIG(DOUBLE, DD_TRACE_SAMPLE_RATE, "-1", .ini_change = ddtrace_alter_DD_TRACE_SAMPLE_RATE, \
.env_config_fallback = ddtrace_conf_otel_sample_rate) \
CONFIG(JSON, DD_TRACE_SAMPLING_RULES, "[]") \
Expand Down
4 changes: 4 additions & 0 deletions ext/limiter/limiter.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ static ddtrace_limiter* dd_limiter;


void ddtrace_limiter_create() {
if (zai_config_memoized_entries[DDTRACE_CONFIG_DD_TRACE_SAMPLE_RATE].name_index < 0) {
return;
}

uint32_t limit = (uint32_t) get_global_DD_TRACE_RATE_LIMIT();

if (!limit) {
Expand Down
1 change: 1 addition & 0 deletions tests/ext/limiter/001-limiter-disabled.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ rate limiter disabled
--ENV--
DD_TRACE_GENERATE_ROOT_SPAN=1
DD_TRACE_RATE_LIMIT=0
DD_TRACE_SAMPLE_RATE=1
--FILE--
<?php
$root = \DDTrace\root_span();
Expand Down
1 change: 1 addition & 0 deletions tests/ext/limiter/002-limiter-reached.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ rate limiter reached
DD_TRACE_AUTO_FLUSH_ENABLED=0
DD_TRACE_GENERATE_ROOT_SPAN=0
DD_TRACE_RATE_LIMIT=10
DD_TRACE_SAMPLE_RATE=1
--FILE--
<?php
$spans = [];
Expand Down

0 comments on commit fe12510

Please sign in to comment.