|
1 | 1 | 'use strict' |
2 | 2 |
|
3 | 3 | const { fetchAgentInfo } = require('../agent/info') |
| 4 | +const log = require('../log') |
4 | 5 |
|
5 | 6 | const TRAILING_SLASHES = /\/+$/ |
6 | 7 |
|
| 8 | +/** |
| 9 | + * Receiver discovery contract |
| 10 | + * |
| 11 | + * The tracer sends `GET /info` to its configured local Agent URL. An |
| 12 | + * Agent-compatible trace receiver produces the response. The tracer does not. |
| 13 | + * |
| 14 | + * The full Agent and serverless-init embed the same trace receiver. A future |
| 15 | + * in-process receiver can expose the same contract. Callers can therefore |
| 16 | + * select capabilities without detecting the receiver implementation. |
| 17 | + * |
| 18 | + * For EVP discovery, `endpoints` advertises registered proxy paths. |
| 19 | + * `evp_proxy_allowed_headers` advertises headers that the proxy forwards to |
| 20 | + * intake. It does not include routing headers that the proxy consumes, such as |
| 21 | + * `X-Datadog-EVP-Subdomain`. |
| 22 | + * |
| 23 | + * An advertised route is not a health check. The receiver can register an EVP |
| 24 | + * route while configuration disables its handler. The request then returns |
| 25 | + * `405`. The `/info` version also identifies the embedded Agent code, not a |
| 26 | + * serverless-init image or deployment type. |
| 27 | + * |
| 28 | + * This module only discovers a candidate route. A missing or unresponsive |
| 29 | + * `/info` endpoint returns an error through the shared request timeout and |
| 30 | + * retry policy. A valid response without a compatible path returns no route. |
| 31 | + * Discovery sends no events, so the caller can safely select direct intake |
| 32 | + * after either result. The caller also owns later delivery failures. It can |
| 33 | + * switch future batches after an ambiguous timeout or reset, but it must not |
| 34 | + * replay the current batch because the first receiver might have accepted it. |
| 35 | + * |
| 36 | + * Reference implementations: |
| 37 | + * |
| 38 | + * Agent `/info` and EVP proxy: |
| 39 | + * https://github.com/DataDog/datadog-agent/tree/main/pkg/trace/api |
| 40 | + * |
| 41 | + * serverless-init entry point and embedded trace receiver: |
| 42 | + * https://github.com/DataDog/datadog-agent/blob/main/cmd/serverless-init/main.go |
| 43 | + * https://github.com/DataDog/datadog-agent/blob/main/pkg/serverless/trace/trace.go |
| 44 | + */ |
| 45 | + |
7 | 46 | /** |
8 | 47 | * Selects the first advertised EVP proxy path that the caller supports. |
9 | 48 | * |
@@ -82,6 +121,7 @@ function discoverEVPProxy (url, options, callback) { |
82 | 121 | return |
83 | 122 | } |
84 | 123 |
|
| 124 | + log.debug('EVP proxy route %s discovered through the configured local receiver', basePath) |
85 | 125 | callback(null, { url, basePath }) |
86 | 126 | }) |
87 | 127 | } |
|
0 commit comments