|
| 1 | +<?php |
| 2 | +/* |
| 3 | + * Copyright 2020 New Relic Corporation. All rights reserved. |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + */ |
| 6 | + |
| 7 | +/*DESCRIPTION |
| 8 | +Test that transaction globals are properly freed when using New Relic API |
| 9 | + */ |
| 10 | + |
| 11 | +/*SKIPIF |
| 12 | +<?php |
| 13 | +require("skipif.inc"); |
| 14 | +*/ |
| 15 | + |
| 16 | +/*INI |
| 17 | +*/ |
| 18 | + |
| 19 | +/*EXPECT |
| 20 | +traceparent=found tracestate=found newrelic=found X-NewRelic-ID=missing X-NewRelic-Transaction=missing tracing endpoint reached |
| 21 | +traceparent=found tracestate=found newrelic=found X-NewRelic-ID=missing X-NewRelic-Transaction=missing tracing endpoint reached |
| 22 | +traceparent=found tracestate=found newrelic=found X-NewRelic-ID=missing X-NewRelic-Transaction=missing Customer-Header=found tracing endpoint reached |
| 23 | +traceparent=found tracestate=found newrelic=found X-NewRelic-ID=missing X-NewRelic-Transaction=missing tracing endpoint reached |
| 24 | +traceparent=found tracestate=found newrelic=found X-NewRelic-ID=missing X-NewRelic-Transaction=missing tracing endpoint reached |
| 25 | +traceparent=found tracestate=found newrelic=found X-NewRelic-ID=missing X-NewRelic-Transaction=missing Customer-Header=found tracing endpoint reached |
| 26 | +*/ |
| 27 | + |
| 28 | +/*EXPECT_RESPONSE_HEADERS |
| 29 | +*/ |
| 30 | + |
| 31 | +/*EXPECT_METRICS |
| 32 | +[ |
| 33 | + "?? agent run id", |
| 34 | + "?? timeframe start", |
| 35 | + "?? timeframe stop", |
| 36 | + [ |
| 37 | + [{"name":"External/127.0.0.1/all"}, [3, "??", "??", "??", "??", "??"]], |
| 38 | + [{"name":"External/127.0.0.1/all", |
| 39 | + "scope":"OtherTransaction/php__FILE__"}, [3, "??", "??", "??", "??", "??"]], |
| 40 | + [{"name":"External/all"}, [3, "??", "??", "??", "??", "??"]], |
| 41 | + [{"name":"External/allOther"}, [3, "??", "??", "??", "??", "??"]], |
| 42 | + [{"name":"OtherTransaction/all"}, [1, "??", "??", "??", "??", "??"]], |
| 43 | + [{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], |
| 44 | + [{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], |
| 45 | + [{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], |
| 46 | + [{"name":"Supportability/api/start_transaction"}, [1, "??", "??", "??", "??", "??"]], |
| 47 | + [{"name":"Supportability/api/end_transaction"}, [1, "??", "??", "??", "??", "??"]], |
| 48 | + [{"name":"Supportability/PHP/package/guzzlehttp/guzzle/7/detected"}, [1, "??", "??", "??", "??", "??"]], |
| 49 | + [{"name":"Supportability/Unsupported/curl_setopt/CURLOPT_HEADERFUNCTION/closure"}, [3, 0, 0, 0, 0, 0]], |
| 50 | + [{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/all"}, [1, "??", "??", "??", "??", "??"]], |
| 51 | + [{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/allOther"}, [1, "??", "??", "??", "??", "??"]], |
| 52 | + [{"name":"Supportability/TraceContext/Create/Success"}, [3, "??", "??", "??", "??", "??"]], |
| 53 | + [{"name":"Supportability/DistributedTrace/CreatePayload/Success"}, [3, "??", "??", "??", "??", "??"]], |
| 54 | + [{"name":"Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], |
| 55 | + [{"name":"Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], |
| 56 | + [{"name":"Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]], |
| 57 | + [{"name":"Supportability/Logging/Labels/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]] |
| 58 | + ] |
| 59 | +] |
| 60 | +*/ |
| 61 | + |
| 62 | + |
| 63 | +?> |
| 64 | +<?php |
| 65 | +require_once(realpath(dirname(__FILE__)) . '/../../../include/config.php'); |
| 66 | +require_once(realpath(dirname(__FILE__)) . '/../../../include/unpack_guzzle.php'); |
| 67 | +require_guzzle(7); |
| 68 | + |
| 69 | +use GuzzleHttp\Client; |
| 70 | + |
| 71 | +function run_test() { |
| 72 | + /* Create URL. */ |
| 73 | + $url = "http://" . make_tracing_url(realpath(dirname(__FILE__)) . '/../../../include/tracing_endpoint.php'); |
| 74 | + |
| 75 | + $client = new Client(); |
| 76 | + $response = $client->get($url); |
| 77 | + echo $response->getBody(); |
| 78 | + |
| 79 | + $response = $client->get($url, [ |
| 80 | + 'headers' => [ |
| 81 | + 'zip' => 'zap']]); |
| 82 | + echo $response->getBody(); |
| 83 | + |
| 84 | + $response = $client->get($url, [ |
| 85 | + 'headers' => [ |
| 86 | + 'zip' => 'zap', |
| 87 | + CUSTOMER_HEADER => 'zap']]); |
| 88 | + echo $response->getBody(); |
| 89 | +} |
| 90 | + |
| 91 | +run_test(); |
| 92 | + |
| 93 | +newrelic_end_transaction(true); |
| 94 | +newrelic_start_transaction(ini_get("newrelic.appname")); |
| 95 | + |
| 96 | +run_test(); |
| 97 | + |
| 98 | +newrelic_end_transaction(); |
0 commit comments