|
| 1 | +package datadog.trace.agent.test.base |
| 2 | + |
| 3 | +import datadog.trace.core.datastreams.StatsGroup |
| 4 | + |
| 5 | +// This class tests multiline multivalue headers for those classes that support it. |
| 6 | +abstract class HttpClientTest2 extends HttpClientTest{ |
| 7 | + |
| 8 | + def "test request header #header tag mapping"() { |
| 9 | + when: |
| 10 | + def url = server.address.resolve("/success") |
| 11 | + def status = (value2 == null) ? doRequest(method, url, [[header, value]]) : doRequest(method, url, [[header, value], [header, value2]]) |
| 12 | + if (isDataStreamsEnabled()) { |
| 13 | + TEST_DATA_STREAMS_WRITER.waitForGroups(1) |
| 14 | + } |
| 15 | + |
| 16 | + then: |
| 17 | + status == 200 |
| 18 | + assertTraces(2) { |
| 19 | + trace(size(1)) { |
| 20 | + clientSpan(it, null, method, false, false, url, status, false, null, false, tags) |
| 21 | + } |
| 22 | + server.distributedRequestTrace(it, trace(0).last(), tags) |
| 23 | + } |
| 24 | + and: |
| 25 | + if (isDataStreamsEnabled()) { |
| 26 | + StatsGroup first = TEST_DATA_STREAMS_WRITER.groups.find { it.parentHash == 0 } |
| 27 | + verifyAll(first) { |
| 28 | + edgeTags.containsAll(DSM_EDGE_TAGS) |
| 29 | + edgeTags.size() == DSM_EDGE_TAGS.size() |
| 30 | + } |
| 31 | + } |
| 32 | + |
| 33 | + where: |
| 34 | + method | header | value | value2 | tags |
| 35 | + 'GET' | 'X-Datadog-Test-Both-Header' | 'foo' | null | [ 'both_header_tag': 'foo' ] |
| 36 | + 'GET' | 'X-Datadog-Test-Request-Header' | 'bar' | null | [ 'request_header_tag': 'bar' ] |
| 37 | + 'GET' | 'X-Datadog-Test-Both-Header' | 'bar,baz' | null | [ 'both_header_tag': 'bar,baz' ] |
| 38 | + 'GET' | 'X-Datadog-Test-Request-Header' | 'foo,bar' | null | [ 'request_header_tag': 'foo,bar' ] |
| 39 | + 'GET' | 'X-Datadog-Test-Both-Header' | 'bar,baz' | 'foo' | [ 'both_header_tag': 'bar,baz,foo' ] |
| 40 | + 'GET' | 'X-Datadog-Test-Request-Header' | 'foo,bar' | 'baz' | [ 'request_header_tag': 'foo,bar,baz' ] |
| 41 | + } |
| 42 | +} |
0 commit comments