|
1 | 1 | --TEST-- |
2 | | -Client-side SHM span stats include peer tags configured via agent info |
| 2 | +Client-side SHM span stats include peer tags configured via agent info, wherever they sit in the key list |
3 | 3 | --SKIPIF-- |
4 | 4 | <?php include __DIR__ . '/../includes/skipif_no_dev_env.inc'; ?> |
5 | 5 | <?php |
6 | 6 | if (PHP_VERSION_ID < 70400) die("skip: Before PHP 7.4, the skip-task would cause the sidecar to fetch the info already."); |
7 | 7 | if (PHP_VERSION_ID >= 80100) { |
8 | 8 | echo "nocache\n"; |
9 | 9 | } |
| 10 | +// Keys are looked up in the order the agent sent them. The real list is derived from the agent's |
| 11 | +// semantic registry, is sorted alphabetically and is currently 44 keys long, so pad the list here |
| 12 | +// and keep one matching key at each end: that catches any truncation of the key scan (a regression |
| 13 | +// that dropped, among others, network.destination.name and out.host). |
| 14 | +$peerTags = ['db.hostname']; |
| 15 | +for ($i = 0; $i < 40; $i++) { |
| 16 | + $peerTags[] = sprintf('peer.unused.%02d', $i); |
| 17 | +} |
| 18 | +$peerTags[] = 'out.host'; |
| 19 | + |
10 | 20 | $ctx = stream_context_create([ |
11 | 21 | 'http' => [ |
12 | 22 | 'method' => 'PUT', |
13 | 23 | 'header' => [ |
14 | 24 | 'Content-Type: application/json', |
15 | 25 | 'X-Datadog-Test-Session-Token: client_side_stats_peer_tags', |
16 | 26 | ], |
17 | | - 'content' => json_encode(['version' => '7.65.0', 'client_drop_p0s' => true, 'peer_tags' => ['db.hostname']]), |
| 27 | + 'content' => json_encode(['version' => '7.65.0', 'client_drop_p0s' => true, 'peer_tags' => $peerTags]), |
18 | 28 | ] |
19 | 29 | ]); |
20 | 30 | file_get_contents('http://request-replayer/set-agent-info', false, $ctx); |
@@ -45,12 +55,15 @@ dd_trace_internal_fn('await_agent_info'); |
45 | 55 | // Now create the span whose stats we want to inspect. When this span is fed to the |
46 | 56 | // concentrator, ddog_apply_agent_info_concentrator_config() is called first, picks up |
47 | 57 | // the peer_tags update from the SHM, and the concentrator extracts db.hostname from meta. |
| 58 | +// db.hostname is the first key the agent sent and out.host the last one (index 41): both must end |
| 59 | +// up in the stats payload, no matter where they sit in the list. |
48 | 60 | $root = \DDTrace\start_trace_span(); |
49 | 61 | $root->name = "web.request"; |
50 | 62 | $root->resource = "GET /db"; |
51 | 63 | $root->service = "stats-test-service"; |
52 | 64 | $root->meta['span.kind'] = 'client'; |
53 | 65 | $root->meta['db.hostname'] = 'my-db-host'; |
| 66 | +$root->meta['out.host'] = 'my-remote-host'; |
54 | 67 | \DDTrace\close_span(); |
55 | 68 |
|
56 | 69 | dd_trace_internal_fn('synchronous_flush'); |
@@ -90,4 +103,4 @@ if (!$found) { |
90 | 103 |
|
91 | 104 | ?> |
92 | 105 | --EXPECT-- |
93 | | -peer_tags: ["db.hostname:my-db-host"] |
| 106 | +peer_tags: ["db.hostname:my-db-host","out.host:my-remote-host"] |
0 commit comments