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

Adding Parametric tests for DOGSTATSD Configurations #3649

Merged
merged 7 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions manifests/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ tests/:
test_128_bit_traceids.py:
Test_128_Bit_Traceids: missing_feature (parametric app does not support trace/span/extract endpoint)
test_config_consistency.py:
Test_Config_Dogstatsd: missing_feature
Test_Config_RateLimit: v1.1.0
Test_Config_TraceAgentURL: v1.1.0
Test_Config_TraceEnabled: v1.1.0
Expand Down
1 change: 1 addition & 0 deletions manifests/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ tests/:
TestAdmisionControllerProfiling: missing_feature
parametric/:
test_config_consistency.py:
Test_Config_Dogstatsd: missing_feature (does not support hostname)
Test_Config_RateLimit: v3.4.1
Test_Config_TraceAgentURL: v3.4.1
Test_Config_TraceEnabled: v3.3.0
Expand Down
1 change: 1 addition & 0 deletions manifests/golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ tests/:
Test_Otel_Drop_In: missing_feature
parametric/:
test_config_consistency.py:
Test_Config_Dogstatsd: missing_feature
Test_Config_RateLimit: v1.67.0
Test_Config_TraceAgentURL: v1.70.0-dev
Test_Config_TraceEnabled: v1.67.0
Expand Down
1 change: 1 addition & 0 deletions manifests/java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1448,6 +1448,7 @@ tests/:
TestAdmisionControllerProfiling: v1.39.0
parametric/:
test_config_consistency.py:
Test_Config_Dogstatsd: missing_feature (default hostname is inconsistent)
Test_Config_RateLimit: v1.41.1
Test_Config_TraceAgentURL: v1.41.1
Test_Config_TraceEnabled: v1.39.0
Expand Down
1 change: 1 addition & 0 deletions manifests/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ tests/:
TestAdmisionControllerProfiling: *ref_5_22_0
parametric/:
test_config_consistency.py:
Test_Config_Dogstatsd: *ref_5_29_0
Test_Config_RateLimit: *ref_5_25_0
Test_Config_TraceAgentURL: *ref_5_25_0
Test_Config_TraceEnabled: *ref_4_3_0
Expand Down
1 change: 1 addition & 0 deletions manifests/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ tests/:
test_128_bit_traceids.py:
Test_128_Bit_Traceids: v0.84.0
test_config_consistency.py:
Test_Config_Dogstatsd: missing_feature
Test_Config_RateLimit: v1.5.0
Test_Config_TraceAgentURL: v1.4.0
Test_Config_TraceEnabled: v1.3.0 # Unknown initial version
Expand Down
1 change: 1 addition & 0 deletions manifests/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,7 @@ tests/:
test_128_bit_traceids.py:
Test_128_Bit_Traceids: v2.6.0
test_config_consistency.py:
Test_Config_Dogstatsd: missing_feature
Test_Config_RateLimit: v2.15.0
Test_Config_TraceAgentURL: v2.0.0
Test_Config_TraceEnabled: v2.12.2
Expand Down
1 change: 1 addition & 0 deletions manifests/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ tests/:
TestAdmisionControllerProfiling: missing_feature
parametric/:
test_config_consistency.py:
Test_Config_Dogstatsd: missing_feature
Test_Config_RateLimit: v2.0.0
Test_Config_TraceAgentURL: v2.5.0
Test_Config_TraceEnabled: v2.0.0
Expand Down
31 changes: 31 additions & 0 deletions tests/parametric/test_config_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,34 @@ def test_setting_trace_rate_limit(self, library_env, test_agent, test_library):
assert any(
trace[0]["metrics"]["_sampling_priority_v1"] == -1 for trace in traces
), "Expected at least one trace to be rate-limited with sampling priority -1."


@scenarios.parametric
@features.tracing_configuration_consistency
class Test_Config_Dogstatsd:
@parametrize(
"library_env", [{"DD_AGENT_HOST": "localhost"}]
) # Adding DD_AGENT_HOST because some SDKs use DD_AGENT_HOST to set the dogstatsd host if unspecified
def test_dogstatsd_default(self, library_env, test_agent, test_library):
with test_library as t:
resp = t.config()
assert resp["dd_dogstatsd_host"] == "localhost"
assert resp["dd_dogstatsd_port"] == "8125"

@parametrize("library_env", [{"DD_DOGSTATSD_HOST": "192.168.10.1"}])
def test_dogstatsd_custom_ip_address(self, library_env, test_agent, test_library):
with test_library as t:
resp = t.config()
assert resp["dd_dogstatsd_host"] == "192.168.10.1"

@parametrize("library_env", [{"DD_DOGSTATSD_HOST": "randomname"}])
def test_dogstatsd_custom_hostname(self, library_env, test_agent, test_library):
with test_library as t:
resp = t.config()
assert resp["dd_dogstatsd_host"] == "randomname"

@parametrize("library_env", [{"DD_DOGSTATSD_PORT": "8150"}])
def test_dogstatsd_custom_port(self, library_env, test_agent, test_library):
with test_library as t:
resp = t.config()
assert resp["dd_dogstatsd_port"] == "8150"
2 changes: 2 additions & 0 deletions tests/parametric/test_parametric_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ def test_config(self, test_agent, test_library):
"dd_version",
"dd_trace_agent_url",
"dd_trace_rate_limit",
"dd_dogstatsd_host",
"dd_dogstatsd_port",
]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public GetTraceConfigResult config() {
Method getLogLevel = configClass.getMethod("getLogLevel");
Method getAgentUrl = configClass.getMethod("getAgentUrl");
Method getTraceRateLimit = configClass.getMethod("getTraceRateLimit");
Method getJmxFetchStatsdPort = configClass.getMethod("getJmxFetchStatsdPort");
Method getJmxFetchStatsdHost = configClass.getMethod("getJmxFetchStatsdHost");

Method isTraceOtelEnabled = instrumenterConfigClass.getMethod("isTraceOtelEnabled");

Expand All @@ -68,6 +70,11 @@ public GetTraceConfigResult config() {
configMap.put("dd_trace_agent_url", getAgentUrl.invoke(configObject).toString());
// configMap.put("dd_trace_sample_ignore_parent", Config.get());

Object dogstatsdHost = getJmxFetchStatsdHost.invoke(configObject);
if (dogstatsdHost != null){
configMap.put("dd_dogstatsd_host", getJmxFetchStatsdHost.invoke(configObject).toString());
}

Object sampleRate = getTraceSampleRate.invoke(configObject);
if (sampleRate instanceof Double) {
configMap.put("dd_trace_sample_rate", String.valueOf((Double)sampleRate));
Expand All @@ -78,6 +85,11 @@ public GetTraceConfigResult config() {
configMap.put("dd_trace_rate_limit", Integer.toString((int)rateLimit));
}

Object statsPort = getJmxFetchStatsdPort.invoke(configObject);
if (statsPort instanceof Integer) {
configMap.put("dd_dogstatsd_port", Integer.toString((int)statsPort));
}

Object globalTags = getGlobalTags.invoke(configObject);
if (globalTags != null) {
String result = ((Map<String, String>)globalTags).entrySet()
Expand Down
4 changes: 3 additions & 1 deletion utils/build/docker/nodejs/parametric/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ app.get('/trace/config', (req, res) => {
'dd_env': config?.tags?.env !== undefined ? `${config.tags.env}` : 'null',
'dd_version': config?.tags?.version !== undefined ? `${config.tags.version}` : 'null',
'dd_trace_agent_url': config?.url !== undefined ? `${config.url.href}` : 'null',
'dd_trace_rate_limit': config?.sampler?.rateLimit !== undefined ? `${config?.sampler?.rateLimit}` :'null'
'dd_trace_rate_limit': config?.sampler?.rateLimit !== undefined ? `${config?.sampler?.rateLimit}` : 'null',
'dd_dogstatsd_host': config?.dogstatsd?.hostname !== undefined ? `${config.dogstatsd.hostname}` : 'null',
'dd_dogstatsd_port': config?.dogstatsd?.port !== undefined ? `${config.dogstatsd.port}` : 'null',
}
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ def trace_config() -> TraceConfigReturn:
"dd_version": config.version,
"dd_trace_rate_limit": str(config._trace_rate_limit),
"dd_trace_agent_url": config._trace_agent_url,
"dd_dogstatsd_host": config._stats_agent_hostname,
"dd_dogstatsd_port": config._stats_agent_port,
}
)

Expand Down
2 changes: 2 additions & 0 deletions utils/parametric/_library_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ def config(self) -> dict[str, Optional[str]]:
"dd_version": config_dict.get("dd_version", None),
"dd_trace_agent_url": config_dict.get("dd_trace_agent_url", None),
"dd_trace_rate_limit": config_dict.get("dd_trace_rate_limit", None),
"dd_dogstatsd_host": config_dict.get("dd_dogstatsd_host", None),
"dd_dogstatsd_port": config_dict.get("dd_dogstatsd_port", None),
}

def otel_current_span(self) -> Union[SpanResponse, None]:
Expand Down
Loading