Skip to content

Commit 1986366

Browse files
authored
Revert "Synthetics Info Header Support (#896)" (#983)
This reverts commit 3980127.
1 parent fdaa4be commit 1986366

13 files changed

+54
-345
lines changed

newrelic/api/cat_header_mixin.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class CatHeaderMixin(object):
2222
cat_transaction_key = 'X-NewRelic-Transaction'
2323
cat_appdata_key = 'X-NewRelic-App-Data'
2424
cat_synthetics_key = 'X-NewRelic-Synthetics'
25-
cat_synthetics_info_key = 'X-NewRelic-Synthetics-Info'
2625
cat_metadata_key = 'x-newrelic-trace'
2726
cat_distributed_trace_key = 'newrelic'
2827
settings = None
@@ -106,9 +105,8 @@ def generate_request_headers(cls, transaction):
106105
(cls.cat_transaction_key, encoded_transaction))
107106

108107
if transaction.synthetics_header:
109-
nr_headers.append((cls.cat_synthetics_key, transaction.synthetics_header))
110-
if transaction.synthetics_info_header:
111-
nr_headers.append((cls.cat_synthetics_info_key, transaction.synthetics_info_header))
108+
nr_headers.append(
109+
(cls.cat_synthetics_key, transaction.synthetics_header))
112110

113111
return nr_headers
114112

newrelic/api/message_trace.py

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class MessageTrace(CatHeaderMixin, TimeTrace):
2727
cat_transaction_key = "NewRelicTransaction"
2828
cat_appdata_key = "NewRelicAppData"
2929
cat_synthetics_key = "NewRelicSynthetics"
30-
cat_synthetics_info_key = "NewRelicSyntheticsInfo"
3130

3231
def __init__(self, library, operation, destination_type, destination_name, params=None, terminal=True, **kwargs):
3332
parent = kwargs.pop("parent", None)

newrelic/api/transaction.py

-22
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
json_decode,
4545
json_encode,
4646
obfuscate,
47-
snake_case,
4847
)
4948
from newrelic.core.attribute import (
5049
MAX_ATTRIBUTE_LENGTH,
@@ -304,17 +303,10 @@ def __init__(self, application, enabled=None, source=None):
304303
self._alternate_path_hashes = {}
305304
self.is_part_of_cat = False
306305

307-
# Synthetics Header
308306
self.synthetics_resource_id = None
309307
self.synthetics_job_id = None
310308
self.synthetics_monitor_id = None
311309
self.synthetics_header = None
312-
313-
# Synthetics Info Header
314-
self.synthetics_type = None
315-
self.synthetics_initiator = None
316-
self.synthetics_attributes = None
317-
self.synthetics_info_header = None
318310

319311
self._custom_metrics = CustomMetrics()
320312
self._dimensional_metrics = DimensionalMetrics()
@@ -611,10 +603,6 @@ def __exit__(self, exc, value, tb):
611603
synthetics_job_id=self.synthetics_job_id,
612604
synthetics_monitor_id=self.synthetics_monitor_id,
613605
synthetics_header=self.synthetics_header,
614-
synthetics_type=self.synthetics_type,
615-
synthetics_initiator=self.synthetics_initiator,
616-
synthetics_attributes=self.synthetics_attributes,
617-
synthetics_info_header=self.synthetics_info_header,
618606
is_part_of_cat=self.is_part_of_cat,
619607
trip_id=self.trip_id,
620608
path_hash=self.path_hash,
@@ -852,16 +840,6 @@ def trace_intrinsics(self):
852840
i_attrs["synthetics_job_id"] = self.synthetics_job_id
853841
if self.synthetics_monitor_id:
854842
i_attrs["synthetics_monitor_id"] = self.synthetics_monitor_id
855-
if self.synthetics_type:
856-
i_attrs["synthetics_type"] = self.synthetics_type
857-
if self.synthetics_initiator:
858-
i_attrs["synthetics_initiator"] = self.synthetics_initiator
859-
if self.synthetics_attributes:
860-
# Add all synthetics attributes
861-
for k, v in self.synthetics_attributes.items():
862-
if k:
863-
i_attrs["synthetics_%s" % snake_case(k)] = v
864-
865843
if self.total_time:
866844
i_attrs["totalTime"] = self.total_time
867845
if self._loop_time:

newrelic/api/web_transaction.py

+1-38
Original file line numberDiff line numberDiff line change
@@ -125,27 +125,6 @@ def _parse_synthetics_header(header):
125125
return synthetics
126126

127127

128-
def _parse_synthetics_info_header(header):
129-
# Return a dictionary of values from SyntheticsInfo header
130-
# Returns empty dict, if version is not supported.
131-
132-
synthetics_info = {}
133-
version = None
134-
135-
try:
136-
version = int(header.get("version"))
137-
138-
if version == 1:
139-
synthetics_info['version'] = version
140-
synthetics_info['type'] = header.get("type")
141-
synthetics_info['initiator'] = header.get("initiator")
142-
synthetics_info['attributes'] = header.get("attributes")
143-
except Exception:
144-
return
145-
146-
return synthetics_info
147-
148-
149128
def _remove_query_string(url):
150129
url = ensure_str(url)
151130
out = urlparse.urlsplit(url)
@@ -252,7 +231,6 @@ def _process_synthetics_header(self):
252231
settings.trusted_account_ids and \
253232
settings.encoding_key:
254233

255-
# Synthetics Header
256234
encoded_header = self._request_headers.get('x-newrelic-synthetics')
257235
encoded_header = encoded_header and ensure_str(encoded_header)
258236
if not encoded_header:
@@ -263,33 +241,18 @@ def _process_synthetics_header(self):
263241
settings.encoding_key)
264242
synthetics = _parse_synthetics_header(decoded_header)
265243

266-
# Synthetics Info Header
267-
encoded_info_header = self._request_headers.get('x-newrelic-synthetics-info')
268-
encoded_info_header = encoded_info_header and ensure_str(encoded_info_header)
269-
270-
decoded_info_header = decode_newrelic_header(
271-
encoded_info_header,
272-
settings.encoding_key)
273-
synthetics_info = _parse_synthetics_info_header(decoded_info_header)
274-
275244
if synthetics and \
276245
synthetics['account_id'] in \
277246
settings.trusted_account_ids:
278247

279-
# Save obfuscated headers, because we will pass them along
248+
# Save obfuscated header, because we will pass it along
280249
# unchanged in all external requests.
281250

282251
self.synthetics_header = encoded_header
283252
self.synthetics_resource_id = synthetics['resource_id']
284253
self.synthetics_job_id = synthetics['job_id']
285254
self.synthetics_monitor_id = synthetics['monitor_id']
286255

287-
if synthetics_info:
288-
self.synthetics_info_header = encoded_info_header
289-
self.synthetics_type = synthetics_info['type']
290-
self.synthetics_initiator = synthetics_info['initiator']
291-
self.synthetics_attributes = synthetics_info['attributes']
292-
293256
def _process_context_headers(self):
294257
# Process the New Relic cross process ID header and extract
295258
# the relevant details.

newrelic/common/encoding_utils.py

-43
Original file line numberDiff line numberDiff line change
@@ -571,46 +571,3 @@ def decode(cls, payload, tk):
571571
data['pr'] = None
572572

573573
return data
574-
575-
576-
def capitalize(string):
577-
"""Capitalize the first letter of a string."""
578-
if not string:
579-
return string
580-
elif len(string) == 1:
581-
return string.capitalize()
582-
else:
583-
return "".join((string[0].upper(), string[1:]))
584-
585-
586-
def camel_case(string, upper=False):
587-
"""
588-
Convert a string of snake case to camel case.
589-
590-
Setting upper=True will capitalize the first letter. Defaults to False, where no change is made to the first letter.
591-
"""
592-
string = ensure_str(string)
593-
split_string = list(string.split("_"))
594-
595-
if len(split_string) < 2:
596-
if upper:
597-
return capitalize(string)
598-
else:
599-
return string
600-
else:
601-
if upper:
602-
camel_cased_string = "".join([capitalize(substr) for substr in split_string])
603-
else:
604-
camel_cased_string = split_string[0] + "".join([capitalize(substr) for substr in split_string[1:]])
605-
606-
return camel_cased_string
607-
608-
609-
_snake_case_re = re.compile(r"([A-Z]+[a-z]*)")
610-
def snake_case(string):
611-
"""Convert a string of camel case to snake case. Assumes no repeated runs of capital letters."""
612-
string = ensure_str(string)
613-
if "_" in string:
614-
return string # Don't touch strings that are already snake cased
615-
616-
return "_".join([s for s in _snake_case_re.split(string) if s]).lower()

newrelic/core/transaction_node.py

-14
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
import newrelic.core.error_collector
2424
import newrelic.core.trace_node
25-
from newrelic.common.encoding_utils import camel_case
2625
from newrelic.common.streaming_utils import SpanProtoAttrs
2726
from newrelic.core.attribute import create_agent_attributes, create_user_attributes
2827
from newrelic.core.attribute_filter import (
@@ -77,10 +76,6 @@
7776
"synthetics_job_id",
7877
"synthetics_monitor_id",
7978
"synthetics_header",
80-
"synthetics_type",
81-
"synthetics_initiator",
82-
"synthetics_attributes",
83-
"synthetics_info_header",
8479
"is_part_of_cat",
8580
"trip_id",
8681
"path_hash",
@@ -591,15 +586,6 @@ def _event_intrinsics(self, stats_table):
591586
intrinsics["nr.syntheticsJobId"] = self.synthetics_job_id
592587
intrinsics["nr.syntheticsMonitorId"] = self.synthetics_monitor_id
593588

594-
if self.synthetics_type:
595-
intrinsics["nr.syntheticsType"] = self.synthetics_type
596-
intrinsics["nr.syntheticsInitiator"] = self.synthetics_initiator
597-
if self.synthetics_attributes:
598-
# Add all synthetics attributes
599-
for k, v in self.synthetics_attributes.items():
600-
if k:
601-
intrinsics["nr.synthetics%s" % camel_case(k, upper=True)] = v
602-
603589
def _add_call_time(source, target):
604590
# include time for keys previously added to stats table via
605591
# stats_engine.record_transaction

tests/agent_features/test_error_events.py

+3-12
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from testing_support.fixtures import (
2121
cat_enabled,
2222
make_cross_agent_headers,
23-
make_synthetics_headers,
23+
make_synthetics_header,
2424
override_application_settings,
2525
reset_core_stats_engine,
2626
validate_error_event_sample_data,
@@ -43,9 +43,6 @@
4343
SYNTHETICS_RESOURCE_ID = "09845779-16ef-4fa7-b7f2-44da8e62931c"
4444
SYNTHETICS_JOB_ID = "8c7dd3ba-4933-4cbb-b1ed-b62f511782f4"
4545
SYNTHETICS_MONITOR_ID = "dc452ae9-1a93-4ab5-8a33-600521e9cd00"
46-
SYNTHETICS_TYPE = "scheduled"
47-
SYNTHETICS_INITIATOR = "graphql"
48-
SYNTHETICS_ATTRIBUTES = {"exampleAttribute": "1"}
4946

5047
ERR_MESSAGE = "Transaction had bad value"
5148
ERROR = ValueError(ERR_MESSAGE)
@@ -138,9 +135,6 @@ def test_transaction_error_cross_agent():
138135
"nr.syntheticsResourceId": SYNTHETICS_RESOURCE_ID,
139136
"nr.syntheticsJobId": SYNTHETICS_JOB_ID,
140137
"nr.syntheticsMonitorId": SYNTHETICS_MONITOR_ID,
141-
"nr.syntheticsType": SYNTHETICS_TYPE,
142-
"nr.syntheticsInitiator": SYNTHETICS_INITIATOR,
143-
"nr.syntheticsExampleAttribute": "1",
144138
}
145139

146140

@@ -150,15 +144,12 @@ def test_transaction_error_with_synthetics():
150144
"err_message": ERR_MESSAGE,
151145
}
152146
settings = application_settings()
153-
headers = make_synthetics_headers(
154-
settings.encoding_key,
147+
headers = make_synthetics_header(
155148
settings.trusted_account_ids[0],
156149
SYNTHETICS_RESOURCE_ID,
157150
SYNTHETICS_JOB_ID,
158151
SYNTHETICS_MONITOR_ID,
159-
SYNTHETICS_TYPE,
160-
SYNTHETICS_INITIATOR,
161-
SYNTHETICS_ATTRIBUTES,
152+
settings.encoding_key,
162153
)
163154
response = fully_featured_application.get("/", headers=headers, extra_environ=test_environ)
164155

0 commit comments

Comments
 (0)