Skip to content

Commit 6a1393d

Browse files
authored
Add spans to the longest running key methods (#90)
# Summary The changes add spans to the longest running key methods. The most important updates are grouped below by theme. ### Tracing Initialization: * Added a `TRACER` instance using `trace.get_tracer("evergreen-agent")` in `mongodb.py` and `opsmanager.py` to enable distributed tracing. [[1]](diffhunk://#diff-3c2088327c59d8b95e3068cb652586e006cca037f3553dd6ad9d99a33e5f762bL32-R32) [[2]](diffhunk://#diff-49b2d2368845a77541db91b50ade54101db603a4251fd6ed81adf9042751c557L43-R43) ### Tracing Key Method Calls: * Added a span for the `wait_for` method in `MongoDBCommon` to trace its execution. * Added a span for the `in_desired_state` function to trace state transitions. * Added a span for the `assert_monitoring_data_exists` method in `MongoDBOpsManager` to trace monitoring data validation. * Added a span for the `wait_until_backup_pods_become_ready` method in `MongoDBOpsManager` to trace the readiness of backup pods. ## Proof of Work <!-- Enter your proof that it works here.--> ## Checklist - [ ] Have you linked a jira ticket and/or is the ticket in the title? - [ ] Have you checked whether your jira ticket required DOCSP changes? - [x] Have you checked for release_note changes? ## Reminder (Please remove this when merging) - Please try to Approve or Reject Changes the PR, keep PRs in review as short as possible - Our Short Guide for PRs: [Link](https://docs.google.com/document/d/1T93KUtdvONq43vfTfUt8l92uo4e4SEEvFbIEKOxGr44/edit?tab=t.0) - Remember the following Communication Standards - use comment prefixes for clarity: * **blocking**: Must be addressed before approval. * **follow-up**: Can be addressed in a later PR or ticket. * **q**: Clarifying question. * **nit**: Non-blocking suggestions. * **note**: Side-note, non-actionable. Example: Praise * --> no prefix is considered a question
1 parent d22e6cf commit 6a1393d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

docker/mongodb-kubernetes-tests/kubetester/mongodb.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
)
3030

3131
logger = test_logger.get_test_logger(__name__)
32+
TRACER = trace.get_tracer("evergreen-agent")
3233

3334

3435
class Phase(Enum):
@@ -41,6 +42,8 @@ class Phase(Enum):
4142

4243

4344
class MongoDBCommon:
45+
TRACER.start_as_current_span("wait_for")
46+
4447
def wait_for(self, fn, timeout=None, should_raise=True):
4548
if timeout is None:
4649
timeout = 600
@@ -584,6 +587,9 @@ def get_pods(podname, qty) -> List[str]:
584587
return [podname.format(i) for i in range(qty)]
585588

586589

590+
TRACER.start_as_current_span("in_desired_state")
591+
592+
587593
def in_desired_state(
588594
current_state: Phase,
589595
desired_state: Phase,

docker/mongodb-kubernetes-tests/kubetester/opsmanager.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
from tests.shardedcluster.conftest import read_deployment_state
4141

4242
logger = test_logger.get_test_logger(__name__)
43+
TRACER = trace.get_tracer("evergreen-agent")
4344

4445

4546
class MongoDBOpsManager(CustomObject, MongoDBCommon):
@@ -170,6 +171,8 @@ def no_automation_agents_have_registered() -> bool:
170171

171172
KubernetesTester.wait_until(no_automation_agents_have_registered, timeout=600, sleep_time=5)
172173

174+
TRACER.start_as_current_span("assert_monitoring_data_exists")
175+
173176
def assert_monitoring_data_exists(
174177
self, database_name: str = "admin", period: str = "P1DT12H", timeout: int = 120, all_hosts: bool = True
175178
):
@@ -589,6 +592,8 @@ def get_backup_daemon_container_status(
589592
) -> kubernetes.client.V1ContainerStatus:
590593
return next(filter(lambda c: c.name == "mongodb-backup-daemon", backup_daemon_pod.status.container_statuses))
591594

595+
TRACER.start_as_current_span("wait_until_backup_pods_become_ready")
596+
592597
def wait_until_backup_pods_become_ready(self, timeout=300):
593598
def backup_daemons_are_ready():
594599
try:

0 commit comments

Comments
 (0)