|
1 | 1 | import argparse |
| 2 | +import os |
2 | 3 | from pathlib import Path |
3 | 4 | from typing import Literal |
4 | 5 |
|
5 | 6 | import tranco |
| 7 | +from honeycomb.opentelemetry import HoneycombOptions, configure_opentelemetry |
| 8 | +from opentelemetry import trace |
6 | 9 |
|
7 | 10 | from custom_command import LinkCountingCommand |
8 | 11 | from openwpm.command_sequence import CommandSequence |
|
29 | 32 | latest_list = t.list() |
30 | 33 | sites = ["http://" + x for x in latest_list.top(10)] |
31 | 34 |
|
32 | | - |
33 | 35 | display_mode: Literal["native", "headless", "xvfb"] = "native" |
34 | 36 | if args.headless: |
35 | 37 | display_mode = "headless" |
|
67 | 69 | # manager_params.memory_watchdog = True |
68 | 70 | # manager_params.process_watchdog = True |
69 | 71 |
|
| 72 | +_tracer = trace.get_tracer(__name__) |
70 | 73 |
|
71 | 74 | # Commands time out by default after 60 seconds |
72 | 75 | with TaskManager( |
|
77 | 80 | ) as manager: |
78 | 81 | # Visits the sites |
79 | 82 | for index, site in enumerate(sites): |
80 | | - |
81 | | - def callback(success: bool, val: str = site) -> None: |
82 | | - print( |
83 | | - f"CommandSequence for {val} ran {'successfully' if success else 'unsuccessfully'}" |
| 83 | + with _tracer.start_as_current_span("command_issuing"): |
| 84 | + span = trace.get_current_span() |
| 85 | + |
| 86 | + def callback(success: bool, val: str = site) -> None: |
| 87 | + print( |
| 88 | + f"CommandSequence for {val} ran {'successfully' if success else 'unsuccessfully'}" |
| 89 | + ) |
| 90 | + |
| 91 | + # Parallelize sites over all number of browsers set above. |
| 92 | + command_sequence = CommandSequence( |
| 93 | + site, |
| 94 | + site_rank=index, |
| 95 | + callback=callback, |
84 | 96 | ) |
85 | 97 |
|
86 | | - # Parallelize sites over all number of browsers set above. |
87 | | - command_sequence = CommandSequence( |
88 | | - site, |
89 | | - site_rank=index, |
90 | | - callback=callback, |
91 | | - ) |
92 | | - |
93 | | - # Start by visiting the page |
94 | | - command_sequence.append_command(GetCommand(url=site, sleep=3), timeout=60) |
95 | | - # Have a look at custom_command.py to see how to implement your own command |
96 | | - command_sequence.append_command(LinkCountingCommand()) |
| 98 | + # Start by visiting the page |
| 99 | + command_sequence.append_command(GetCommand(url=site, sleep=3), timeout=60) |
| 100 | + # Have a look at custom_command.py to see how to implement your own command |
| 101 | + command_sequence.append_command(LinkCountingCommand()) |
97 | 102 |
|
98 | | - # Run commands across all browsers (simple parallelization) |
99 | | - manager.execute_command_sequence(command_sequence) |
| 103 | + # Run commands across all browsers (simple parallelization) |
| 104 | + manager.execute_command_sequence(command_sequence) |
0 commit comments