chore: replace newrelic add_custom_parameter deprecated method
related issue: https://github.com/openedx/edx-platform/issues/33584 note: it has been replaced with add_custom_attribute. it is just a rename https://docs.newrelic.com/docs/release-notes/agent-release-notes/python-release-notes/python-agent-80300/
This commit is contained in:
@@ -100,17 +100,17 @@ class StaticContentServer(MiddlewareMixin):
|
||||
safe_course_key = safe_course_key.replace(run='only')
|
||||
|
||||
if newrelic:
|
||||
newrelic.agent.add_custom_parameter('course_id', safe_course_key)
|
||||
newrelic.agent.add_custom_parameter('org', loc.org)
|
||||
newrelic.agent.add_custom_parameter('contentserver.path', loc.path)
|
||||
newrelic.agent.add_custom_attribute('course_id', safe_course_key)
|
||||
newrelic.agent.add_custom_attribute('org', loc.org)
|
||||
newrelic.agent.add_custom_attribute('contentserver.path', loc.path)
|
||||
|
||||
# Figure out if this is a CDN using us as the origin.
|
||||
is_from_cdn = StaticContentServer.is_cdn_request(request)
|
||||
newrelic.agent.add_custom_parameter('contentserver.from_cdn', is_from_cdn)
|
||||
newrelic.agent.add_custom_attribute('contentserver.from_cdn', is_from_cdn)
|
||||
|
||||
# Check if this content is locked or not.
|
||||
locked = self.is_content_locked(content)
|
||||
newrelic.agent.add_custom_parameter('contentserver.locked', locked)
|
||||
newrelic.agent.add_custom_attribute('contentserver.locked', locked)
|
||||
|
||||
# Check that user has access to the content.
|
||||
if not self.is_user_authorized(request, content, loc):
|
||||
@@ -169,7 +169,7 @@ class StaticContentServer(MiddlewareMixin):
|
||||
response.status_code = 206 # Partial Content
|
||||
|
||||
if newrelic:
|
||||
newrelic.agent.add_custom_parameter('contentserver.ranged', True)
|
||||
newrelic.agent.add_custom_attribute('contentserver.ranged', True)
|
||||
else:
|
||||
log.warning(
|
||||
"Cannot satisfy ranges in Range header: %s for content: %s",
|
||||
@@ -183,8 +183,8 @@ class StaticContentServer(MiddlewareMixin):
|
||||
response['Content-Length'] = content.length
|
||||
|
||||
if newrelic:
|
||||
newrelic.agent.add_custom_parameter('contentserver.content_len', content.length)
|
||||
newrelic.agent.add_custom_parameter('contentserver.content_type', content.content_type)
|
||||
newrelic.agent.add_custom_attribute('contentserver.content_len', content.length)
|
||||
newrelic.agent.add_custom_attribute('contentserver.content_type', content.content_type)
|
||||
|
||||
# "Accept-Ranges: bytes" tells the user that only "bytes" ranges are allowed
|
||||
response['Accept-Ranges'] = 'bytes'
|
||||
@@ -214,13 +214,13 @@ class StaticContentServer(MiddlewareMixin):
|
||||
cache_ttl = CourseAssetCacheTtlConfig.get_cache_ttl()
|
||||
if cache_ttl > 0 and not is_locked:
|
||||
if newrelic:
|
||||
newrelic.agent.add_custom_parameter('contentserver.cacheable', True)
|
||||
newrelic.agent.add_custom_attribute('contentserver.cacheable', True)
|
||||
|
||||
response['Expires'] = StaticContentServer.get_expiration_value(datetime.datetime.utcnow(), cache_ttl)
|
||||
response['Cache-Control'] = "public, max-age={ttl}, s-maxage={ttl}".format(ttl=cache_ttl)
|
||||
elif is_locked:
|
||||
if newrelic:
|
||||
newrelic.agent.add_custom_parameter('contentserver.cacheable', False)
|
||||
newrelic.agent.add_custom_attribute('contentserver.cacheable', False)
|
||||
|
||||
response['Cache-Control'] = "private, no-cache, no-store"
|
||||
|
||||
|
||||
@@ -832,10 +832,10 @@ class SequenceBlock(
|
||||
"""
|
||||
if not newrelic:
|
||||
return
|
||||
newrelic.agent.add_custom_parameter('seq.block_id', str(self.location))
|
||||
newrelic.agent.add_custom_parameter('seq.display_name', self.display_name or '')
|
||||
newrelic.agent.add_custom_parameter('seq.position', self.position)
|
||||
newrelic.agent.add_custom_parameter('seq.is_time_limited', self.is_time_limited)
|
||||
newrelic.agent.add_custom_attribute('seq.block_id', str(self.location))
|
||||
newrelic.agent.add_custom_attribute('seq.display_name', self.display_name or '')
|
||||
newrelic.agent.add_custom_attribute('seq.position', self.position)
|
||||
newrelic.agent.add_custom_attribute('seq.is_time_limited', self.is_time_limited)
|
||||
|
||||
def _capture_full_seq_item_metrics(self, children):
|
||||
"""
|
||||
@@ -847,17 +847,17 @@ class SequenceBlock(
|
||||
return
|
||||
# Basic count of the number of Units (a.k.a. VerticalBlocks) we have in
|
||||
# this learning sequence
|
||||
newrelic.agent.add_custom_parameter('seq.num_units', len(children))
|
||||
newrelic.agent.add_custom_attribute('seq.num_units', len(children))
|
||||
|
||||
# Count of all modules (leaf nodes) in this sequence (e.g. videos,
|
||||
# problems, etc.) The units (verticals) themselves are not counted.
|
||||
all_item_keys = self._locations_in_subtree(self)
|
||||
newrelic.agent.add_custom_parameter('seq.num_items', len(all_item_keys))
|
||||
newrelic.agent.add_custom_attribute('seq.num_items', len(all_item_keys))
|
||||
|
||||
# Count of all modules by block_type (e.g. "video": 2, "discussion": 4)
|
||||
block_counts = collections.Counter(usage_key.block_type for usage_key in all_item_keys)
|
||||
for block_type, count in block_counts.items():
|
||||
newrelic.agent.add_custom_parameter(f'seq.block_counts.{block_type}', count)
|
||||
newrelic.agent.add_custom_attribute(f'seq.block_counts.{block_type}', count)
|
||||
|
||||
def _capture_current_unit_metrics(self, children):
|
||||
"""
|
||||
@@ -871,15 +871,15 @@ class SequenceBlock(
|
||||
if 1 <= self.position <= len(children):
|
||||
# Basic info about the Unit...
|
||||
current = children[self.position - 1]
|
||||
newrelic.agent.add_custom_parameter('seq.current.block_id', str(current.location))
|
||||
newrelic.agent.add_custom_parameter('seq.current.display_name', current.display_name or '')
|
||||
newrelic.agent.add_custom_attribute('seq.current.block_id', str(current.location))
|
||||
newrelic.agent.add_custom_attribute('seq.current.display_name', current.display_name or '')
|
||||
|
||||
# Examining all blocks inside the Unit (or split_test, conditional, etc.)
|
||||
child_locs = self._locations_in_subtree(current)
|
||||
newrelic.agent.add_custom_parameter('seq.current.num_items', len(child_locs))
|
||||
newrelic.agent.add_custom_attribute('seq.current.num_items', len(child_locs))
|
||||
curr_block_counts = collections.Counter(usage_key.block_type for usage_key in child_locs)
|
||||
for block_type, count in curr_block_counts.items():
|
||||
newrelic.agent.add_custom_parameter(f'seq.current.block_counts.{block_type}', count)
|
||||
newrelic.agent.add_custom_attribute(f'seq.current.block_counts.{block_type}', count)
|
||||
|
||||
def _time_limited_student_view(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user