Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions solarwinds_apm/trace/response_time_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

from solarwinds_apm.apm_constants import (
INTL_SWO_TRANSACTION_ATTR_KEY,
INTL_SWO_TRANSACTION_ATTR_MAX,
)

if TYPE_CHECKING:
Expand Down Expand Up @@ -129,38 +128,6 @@ def calculate_span_time(
ms_end_time = int(end_time // time_conversion)
return ms_end_time - ms_start_time

def calculate_otlp_transaction_name(
self,
span_name: str,
) -> str:
"""
Calculate transaction name for OTLP metrics with fallback hierarchy.

Follows this order of decreasing precedence, truncated to 255 char:
1. SW_APM_TRANSACTION_NAME
2. AWS_LAMBDA_FUNCTION_NAME
3. automated naming from span name
4. "unknown" backup, to match core lib

See also _SwSampler.calculate_otlp_transaction_name

Parameters:
span_name (str): The name of the span to use as fallback.

Returns:
str: The calculated transaction name, truncated to 255 characters.
"""
if self.env_transaction_name:
return self.env_transaction_name[:INTL_SWO_TRANSACTION_ATTR_MAX]

if self.lambda_function_name:
return self.lambda_function_name[:INTL_SWO_TRANSACTION_ATTR_MAX]

if span_name:
return span_name[:INTL_SWO_TRANSACTION_ATTR_MAX]

return "unknown"

def enhance_meter_attrs_with_http_span_attrs(
self, span: "ReadableSpan", meter_attrs: dict
) -> dict:
Expand Down
68 changes: 0 additions & 68 deletions tests/unit/test_processors/test_response_time_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,74 +196,6 @@ def test_calculate_span_time_1e6(self, mocker):
1e6,
)

def test_calculate_otlp_transaction_name_env_trans(self, mocker):
mock_apm_config = self.get_mock_apm_config(
mocker,
"foo-env-trans-name",
)
assert "foo-env-trans-name" == ResponseTimeProcessor(
mock_apm_config,
).calculate_otlp_transaction_name("foo-span")

def test_calculate_otlp_transaction_name_env_trans_truncated(self, mocker):
mock_apm_config = self.get_mock_apm_config(
mocker,
"foo-txn-ffoooofofooooooofooofooooofofofofoooooofoooooooooffoffooooooffffofooooofffooooooofoooooffoofofoooooofffofooofoffoooofooofoooooooooooooofooffoooofofooofoooofoofooffooooofoofooooofoooooffoofffoffoooooofoooofoooffooffooofofooooooffffooofoooooofoooooofooofoooofoo",
)
assert "foo-txn-ffoooofofooooooofooofooooofofofofoooooofoooooooooffoffooooooffffofooooofffooooooofoooooffoofofoooooofffofooofoffoooofooofoooooooooooooofooffoooofofooofoooofoofooffooooofoofooooofoooooffoofffoffoooooofoooofoooffooffooofofooooooffffooofoooooofoooooo" == ResponseTimeProcessor(
mock_apm_config,
).calculate_otlp_transaction_name("foo-span")

def test_calculate_otlp_transaction_name_env_lambda(self, mocker):
mock_apm_config = self.get_mock_apm_config(
mocker,
outer_txn_retval=None,
lambda_function_name="foo-lambda-ffoooofofooooooofooofooooofofofofoooooofoooooooooffoffooooooffffofooooofffooooooofoooooffoofofoooooofffofooofoffoooofooofoooooooooooooofooffoooofofooofoooofoofooffooooofoofooooofoooooffoofffoffoooooofoooofoooffooffooofofooooooffffooofoooooofoooooofooofoooofoo",
)
assert "foo-lambda-ffoooofofooooooofooofooooofofofofoooooofoooooooooffoffooooooffffofooooofffooooooofoooooffoofofoooooofffofooofoffoooofooofoooooooooooooofooffoooofofooofoooofoofooffooooofoofooooofoooooffoofffoffoooooofoooofoooffooffooofofooooooffffooofoooooofooo" == ResponseTimeProcessor(
mock_apm_config,
).calculate_otlp_transaction_name("foo-span")

def test_calculate_otlp_transaction_name_env_lambda_truncated(self, mocker):
mock_apm_config = self.get_mock_apm_config(
mocker,
outer_txn_retval=None,
lambda_function_name="foo-lambda-name",
)
assert "foo-lambda-name" == ResponseTimeProcessor(
mock_apm_config,
).calculate_otlp_transaction_name("foo-span")

def test_calculate_otlp_transaction_name_span_name(self, mocker):
mock_apm_config = self.get_mock_apm_config(
mocker,
outer_txn_retval=None,
lambda_function_name=None,
)
assert "foo-span" == ResponseTimeProcessor(
mock_apm_config,
).calculate_otlp_transaction_name("foo-span")

def test_calculate_otlp_transaction_name_span_name_truncated(self, mocker):
mock_apm_config = self.get_mock_apm_config(
mocker,
outer_txn_retval=None,
lambda_function_name=None,
)
assert "foo-span-ffoooofofooooooofooofooooofofofofoooooofoooooooooffoffooooooffffofooooofffooooooofoooooffoofofoooooofffofooofoffoooofooofoooooooooooooofooffoooofofooofoooofoofooffooooofoofooooofoooooffoofffoffoooooofoooofoooffooffooofofooooooffffooofoooooofooooo" == ResponseTimeProcessor(
mock_apm_config,
).calculate_otlp_transaction_name("foo-span-ffoooofofooooooofooofooooofofofofoooooofoooooooooffoffooooooffffofooooofffooooooofoooooffoofofoooooofffofooofoffoooofooofoooooooooooooofooffoooofofooofoooofoofooffooooofoofooooofoooooffoofffoffoooooofoooofoooffooffooofofooooooffffooofoooooofoooooofooofoooofoo")

def test_calculate_otlp_transaction_name_empty(self, mocker):
mock_apm_config = self.get_mock_apm_config(
mocker,
outer_txn_retval=None,
lambda_function_name=None,
)
assert "unknown" == ResponseTimeProcessor(
mock_apm_config,
).calculate_otlp_transaction_name("")

def patch_for_on_end(
self,
mocker,
Expand Down
Loading