Skip to content
Open
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
3 changes: 3 additions & 0 deletions .github/workflows/run-end-to-end.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ jobs:
- name: Run INTEGRATIONS_AWS scenario
if: steps.build.outcome == 'success' && !cancelled() && contains(inputs.scenarios, '"INTEGRATIONS_AWS"')
run: ./run.sh INTEGRATIONS_AWS
- name: Run DBM_DYNAMIC_SERVICE scenario
if: steps.build.outcome == 'success' && !cancelled() && contains(inputs.scenarios, '"DBM_DYNAMIC_SERVICE"')
run: ./run.sh DBM_DYNAMIC_SERVICE
- name: Run APM_TRACING_E2E_OTEL scenario
if: steps.build.outcome == 'success' && !cancelled() && contains(inputs.scenarios, '"APM_TRACING_E2E_OTEL"')
run: |
Expand Down
1 change: 1 addition & 0 deletions manifests/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ manifest:
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Mysqldb: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Psycopg: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Pymysql: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_DynamicService_Postgres: irrelevant
tests/integrations/test_dsm.py::Test_DsmKafka::test_dsm_kafka_without_cluster_id: irrelevant
tests/integrations/test_dsm.py::Test_DsmRabbitmq::test_dsm_rabbitmq_dotnet_legacy: irrelevant (legacy dotnet behavior)
tests/integrations/test_mongo.py::Test_Mongo: missing_feature (Endpoint is not implemented on weblog)
Expand Down
1 change: 1 addition & 0 deletions manifests/cpp_nginx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ manifest:
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Mysqldb: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Psycopg: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Pymysql: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_DynamicService_Postgres: irrelevant
tests/integrations/test_dsm.py::Test_DsmContext_Extraction_Base64: missing_feature
tests/integrations/test_dsm.py::Test_DsmContext_Injection_Base64: missing_feature
tests/integrations/test_dsm.py::Test_DsmHttp: missing_feature
Expand Down
1 change: 1 addition & 0 deletions manifests/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,7 @@ manifest:
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Mysqldb: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Psycopg: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Pymysql: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_DynamicService_Postgres: irrelevant
tests/integrations/test_dsm.py::Test_DsmContext_Extraction_Base64: missing_feature
tests/integrations/test_dsm.py::Test_DsmContext_Injection_Base64: missing_feature
tests/integrations/test_dsm.py::Test_DsmHttp: missing_feature
Expand Down
1 change: 1 addition & 0 deletions manifests/golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,7 @@ manifest:
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Mysqldb: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Psycopg: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Pymysql: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_DynamicService_Postgres: irrelevant
tests/integrations/test_dsm.py::Test_DsmContext_Extraction_Base64:
- weblog_declaration:
"*": irrelevant
Expand Down
4 changes: 4 additions & 0 deletions manifests/java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3504,6 +3504,10 @@ manifest:
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Mysqldb: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Psycopg: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Pymysql: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_DynamicService_Postgres:
- weblog_declaration:
"*": irrelevant
spring-boot: missing_feature
tests/integrations/test_dsm.py::Test_DsmContext_Extraction_Base64:
- weblog_declaration:
"*": irrelevant
Expand Down
1 change: 1 addition & 0 deletions manifests/java_otel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ manifest:
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Mysqldb: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Psycopg: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Pymysql: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_DynamicService_Postgres: irrelevant
tests/integrations/test_dsm.py::Test_DsmKafka::test_dsm_kafka_without_cluster_id: irrelevant
tests/integrations/test_dsm.py::Test_DsmRabbitmq::test_dsm_rabbitmq_dotnet_legacy: irrelevant (legacy dotnet behavior)
tests/integrations/test_mongo.py::Test_Mongo: missing_feature (Endpoint is not implemented on weblog)
Expand Down
1 change: 1 addition & 0 deletions manifests/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1823,6 +1823,7 @@ manifest:
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Mysqldb: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Psycopg: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Pymysql: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_DynamicService_Postgres: missing_feature
tests/integrations/test_dsm.py::Test_DsmContext_Extraction_Base64:
- weblog_declaration:
"*": irrelevant
Expand Down
1 change: 1 addition & 0 deletions manifests/nodejs_otel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ manifest:
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Mysqldb: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Psycopg: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Pymysql: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_DynamicService_Postgres: irrelevant
tests/integrations/test_dsm.py::Test_DsmKafka::test_dsm_kafka_without_cluster_id: irrelevant
tests/integrations/test_dsm.py::Test_DsmRabbitmq::test_dsm_rabbitmq_dotnet_legacy: irrelevant (legacy dotnet behavior)
tests/integrations/test_mongo.py::Test_Mongo: missing_feature (Endpoint is not implemented on weblog)
Expand Down
1 change: 1 addition & 0 deletions manifests/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,7 @@ manifest:
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Mysqldb: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Psycopg: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Pymysql: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_DynamicService_Postgres: missing_feature
tests/integrations/test_dsm.py::Test_DsmContext_Extraction_Base64: missing_feature
tests/integrations/test_dsm.py::Test_DsmContext_Injection_Base64: missing_feature
tests/integrations/test_dsm.py::Test_DsmHttp: missing_feature
Expand Down
1 change: 1 addition & 0 deletions manifests/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1605,6 +1605,7 @@ manifest:
- weblog_declaration:
flask-poc: bug (APMAPI-1058)
uds-flask: bug (APMAPI-1058)
tests/integrations/test_dbm.py::Test_Dbm_DynamicService_Postgres: missing_feature
tests/integrations/test_dbm.py::_BaseDbmComment::test_dbm_comment:
- weblog_declaration:
flask-poc: bug (APMAPI-1058)
Expand Down
1 change: 1 addition & 0 deletions manifests/python_otel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ manifest:
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Mysqldb: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Psycopg: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Pymysql: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_DynamicService_Postgres: irrelevant
tests/integrations/test_dsm.py::Test_DsmKafka::test_dsm_kafka_without_cluster_id: irrelevant
tests/integrations/test_dsm.py::Test_DsmRabbitmq::test_dsm_rabbitmq_dotnet_legacy: irrelevant (legacy dotnet behavior)
tests/integrations/test_mongo.py::Test_Mongo: missing_feature (Endpoint is not implemented on weblog)
Expand Down
7 changes: 7 additions & 0 deletions manifests/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1899,6 +1899,13 @@ manifest:
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Mysqldb: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Psycopg: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Pymysql: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_DynamicService_Postgres:
- weblog_declaration:
"*": irrelevant
sinatra14: missing_feature
sinatra22: missing_feature
sinatra32: missing_feature
sinatra41: missing_feature
tests/integrations/test_dsm.py::Test_DsmContext_Extraction_Base64:
- weblog_declaration:
"*": irrelevant
Expand Down
1 change: 1 addition & 0 deletions manifests/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ manifest:
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Mysqldb: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Psycopg: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_Comment_Python_Pymysql: irrelevant (These are python only tests.)
tests/integrations/test_dbm.py::Test_Dbm_DynamicService_Postgres: irrelevant
tests/integrations/test_dsm.py::Test_DsmKafka::test_dsm_kafka_without_cluster_id: irrelevant
tests/integrations/test_dsm.py::Test_DsmRabbitmq::test_dsm_rabbitmq_dotnet_legacy: irrelevant (legacy dotnet behavior)
tests/integrations/test_mongo.py::Test_Mongo: missing_feature (Endpoint is not implemented on weblog)
Expand Down
72 changes: 72 additions & 0 deletions tests/integrations/test_dbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,75 @@ def integration(self):
@property
def dddbs(self):
return self._LIBRARY_CONFIG.get(context.library.name, (None, None))[1]


class _BaseDbmDynamicService:
"""Verify DD_DBM_PROPAGATION_MODE=dynamic_service:
- injects ddsh='<hash>' into the SQL comment
- sets _dd.propagated_hash=<same_hash> on the SQL span
"""

operation: str = "execute"

@property
def integration(self):
return None

def setup_dbm_dynamic_service(self):
self.r = weblog.get("/stub_dbm", params={"integration": self.integration, "operation": self.operation})

def test_dbm_dynamic_service(self):
assert self.r.status_code == 200, f"Request: {self.r.request.url} wasn't successful."

try:
data = json.loads(self.r.text)
except json.decoder.JSONDecodeError as e:
raise ValueError(f"Response from {self.r.request.url} should have been JSON") from e

assert data.get("status") == "ok"
comment = data.get("dbm_comment", "")
assert comment, "dbm_comment is empty"

# ddsh field is present and non-empty in the SQL comment
match = re.search(r"ddsh='([^']*)'", comment)
assert match, f"ddsh field not found in SQL comment: {comment}"
ddsh_value = match.group(1)
assert ddsh_value, "ddsh value is empty"

# SQL span carries _dd.propagated_hash equal to ddsh
sql_spans = [
span
for _, trace in interfaces.library.get_traces(request=self.r)
for span in trace
if span.get("type") == "sql"
]
assert sql_spans, "No SQL span found for the /stub_dbm request"

for span in sql_spans:
propagated_hash = span.get("meta", {}).get("_dd.propagated_hash")
if propagated_hash is not None:
assert propagated_hash == ddsh_value, f"_dd.propagated_hash '{propagated_hash}' != ddsh '{ddsh_value}'"
return

raise AssertionError(
f"_dd.propagated_hash not found in any SQL span. "
f"Span meta keys: {[list(s.get('meta', {}).keys()) for s in sql_spans]}"
)


@features.database_monitoring_dynamic_service
@scenarios.dbm_dynamic_service
class Test_Dbm_DynamicService_Postgres(_BaseDbmDynamicService):
"""DBM dynamic_service mode — PostgreSQL integration across all languages."""

_LIBRARY_CONFIG = {
"python": "psycopg",
"nodejs": "pg",
"java": "postgresql",
"ruby": "pg",
"php": "pdo-pgsql",
}

@property
def integration(self):
return self._LIBRARY_CONFIG.get(context.library.name)
8 changes: 7 additions & 1 deletion utils/_context/_scenarios/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
from .core import Scenario, scenario_groups
from .default import DefaultScenario
from .endtoend import DockerScenario, EndToEndScenario
from .integrations import CrossedTracingLibraryScenario, IntegrationsScenario, AWSIntegrationsScenario
from .integrations import (
CrossedTracingLibraryScenario,
DbmDynamicServiceScenario,
IntegrationsScenario,
AWSIntegrationsScenario,
)
from .open_telemetry import OpenTelemetryScenario
from .otel_collector import OtelCollectorScenario
from .parametric import ParametricScenario
Expand Down Expand Up @@ -55,6 +60,7 @@ class _Scenarios:
)
integrations = IntegrationsScenario()
integrations_aws = AWSIntegrationsScenario("INTEGRATIONS_AWS")
dbm_dynamic_service = DbmDynamicServiceScenario()
Comment thread
amarziali marked this conversation as resolved.
crossed_tracing_libraries = CrossedTracingLibraryScenario()

otel_integrations = OpenTelemetryScenario(
Expand Down
16 changes: 16 additions & 0 deletions utils/_context/_scenarios/integrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,22 @@ def configure(self, config: pytest.Config):
self.unique_id = _get_unique_id(self.host_log_folder, replay=self.replay)


class DbmDynamicServiceScenario(EndToEndScenario):
def __init__(self) -> None:
super().__init__(
"DBM_DYNAMIC_SERVICE",
weblog_env={
"DD_DBM_PROPAGATION_MODE": "dynamic_service",
},
other_weblog_containers=(PostgresContainer,),
doc=(
"Verifies DD_DBM_PROPAGATION_MODE=dynamic_service injects ddsh into SQL comments "
"and sets _dd.propagated_hash on SQL spans with the same value."
),
scenario_groups=[scenario_groups.integrations],
)


class AWSIntegrationsScenario(EndToEndScenario):
unique_id: str = ""

Expand Down
9 changes: 9 additions & 0 deletions utils/_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -1920,6 +1920,15 @@ def database_monitoring_support(test_object):
test_object, feature_id=296, owner=_Owner.idm
) # tracing/context-propagation, apm/dbm, idm-sugar

@staticmethod
def database_monitoring_dynamic_service(test_object):
"""DBM: dynamic_service propagation mode — injects ddsh into SQL comments and _dd.propagated_hash onto spans

https://feature-parity.us1.prod.dog/#/?feature=558
https://docs.google.com/document/d/1v-NuhF_0LNCY3zkSQlL6nPxrvlKfvm9LDkeZlEOyO3w/edit?tab=t.0
"""
return _mark_test_object(test_object, feature_id=558, owner=_Owner.idm)

@staticmethod
def rasp_stack_trace(test_object):
"""Appsec RASP: Stack Trace
Expand Down
Loading