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
2 changes: 0 additions & 2 deletions solarwinds_apm/apm_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ def calculate_collector(
@classmethod
def calculate_metrics_enabled(
cls,
is_legacy: bool = False,
cnf_dict: dict = None,
) -> bool:
"""Return if export of instrumentor metrics telemetry enabled.
Expand All @@ -197,7 +196,6 @@ def calculate_metrics_enabled(
to get_cnf_dict() is made for a fresh read.

Parameters:
is_legacy (bool): Legacy flag (currently unused). Defaults to False.
cnf_dict (dict): Optional configuration dictionary. Defaults to None.

Returns:
Expand Down
8 changes: 6 additions & 2 deletions tests/docker/install/windows/_helper_check_sdist.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ function Get-Sdist {
if (-not $env:SOLARWINDS_APM_VERSION) {
# no SOLARWINDS_APM_VERSION provided, thus test version of current source code
$version_file = Join-Path $env:APM_ROOT "solarwinds_apm\version.py"
$version_content = Get-Content $version_file
if ($version_content -match '__version__ = "(.*)"') {
$version_content = Get-Content $version_file -Raw
if ($version_content -match '__version__ = "([^"]+)"') {
$env:SOLARWINDS_APM_VERSION = $matches[1]
}
else {
Write-Error "FAILED: Could not extract version from $version_file. File content: $version_content"
exit 1
}
Write-Host "No SOLARWINDS_APM_VERSION provided, thus testing source code version ($env:SOLARWINDS_APM_VERSION)"
}

Expand Down
10 changes: 7 additions & 3 deletions tests/docker/install/windows/_helper_check_wheel.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ function Get-Wheel {
if (-not $env:SOLARWINDS_APM_VERSION) {
# no SOLARWINDS_APM_VERSION provided, thus test version of current source code
$version_file = Join-Path $env:APM_ROOT "solarwinds_apm\version.py"
$version_content = Get-Content $version_file
if ($version_content -match '__version__ = "(.*)"') {
$version_content = Get-Content $version_file -Raw
if ($version_content -match '__version__ = "([^"]+)"') {
$env:SOLARWINDS_APM_VERSION = $matches[1]
}
Write-Host "No SOLARWINDS_APM_VERSION provided, thus testing source code version"
else {
Write-Error "FAILED: Could not extract version from $version_file. File content: $version_content"
exit 1
}
Write-Host "No SOLARWINDS_APM_VERSION provided, thus testing source code version ($env:SOLARWINDS_APM_VERSION)"
}

$tested_wheel = Get-ChildItem -Path "$env:APM_ROOT\dist" -Filter "solarwinds_apm-$env:SOLARWINDS_APM_VERSION-py3-none-any.whl"
Expand Down
58 changes: 29 additions & 29 deletions tests/unit/test_oboe/test_oboe_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def check_counters(sampler, counter_names):
assert counters == set()


class TestSamplerOptions:
class MockSamplerOptions:
def __init__(self, settings: Settings | None = None, local_settings: LocalSettings | None = None,
request_headers: RequestHeaders | None = None):
self._settings = settings
Expand All @@ -110,8 +110,8 @@ def request_headers(self) -> RequestHeaders | None:
return self._request_headers


class TestSampler(OboeSampler):
def __init__(self, options: TestSamplerOptions):
class MockSampler(OboeSampler):
def __init__(self, options: MockSamplerOptions):
self._metric_reader = InMemoryMetricReader()
meter_provider = MeterProvider(
metric_readers=[self._metric_reader],
Expand Down Expand Up @@ -205,7 +205,7 @@ def __str__(self):

class TestInvalidXTraceOptionsSignature:
def test_rejects_missing_signature_key(self):
sampler = TestSampler(TestSamplerOptions(
sampler = MockSampler(MockSamplerOptions(
settings=Settings(
sample_rate=1_000_000,
sample_source=SampleSource.REMOTE,
Expand All @@ -229,7 +229,7 @@ def test_rejects_missing_signature_key(self):
check_counters(sampler, ["trace.service.request_count"])

def test_rejects_bad_timestamp(self):
sampler = TestSampler(TestSamplerOptions(
sampler = MockSampler(MockSamplerOptions(
settings=Settings(
sample_rate=1_000_000,
sample_source=SampleSource.REMOTE,
Expand All @@ -254,7 +254,7 @@ def test_rejects_bad_timestamp(self):
check_counters(sampler, ["trace.service.request_count"])

def test_rejects_bad_signature(self):
sampler = TestSampler(TestSamplerOptions(
sampler = MockSampler(MockSamplerOptions(
settings=Settings(
sample_rate=1_000_000,
sample_source=SampleSource.REMOTE,
Expand All @@ -281,7 +281,7 @@ def test_rejects_bad_signature(self):

class TestMissingSettings:
def test_does_not_sample(self):
sampler = TestSampler(TestSamplerOptions(
sampler = MockSampler(MockSamplerOptions(
settings=None,
local_settings=LocalSettings(trigger_mode=False, tracing_mode=None),
request_headers=make_request_headers(MakeRequestHeaders())
Expand All @@ -293,7 +293,7 @@ def test_does_not_sample(self):
check_counters(sampler, ["trace.service.request_count"])

def test_expires_after_ttl(self):
sampler = TestSampler(TestSamplerOptions(
sampler = MockSampler(MockSamplerOptions(
settings=Settings(
sample_rate=0,
sample_source=SampleSource.LOCAL_DEFAULT,
Expand All @@ -313,7 +313,7 @@ def test_expires_after_ttl(self):
check_counters(sampler, ["trace.service.request_count"])

def test_respects_x_trace_options_keys_and_values(self):
sampler = TestSampler(TestSamplerOptions(
sampler = MockSampler(MockSamplerOptions(
settings=None,
local_settings=LocalSettings(trigger_mode=False, tracing_mode=None),
request_headers=make_request_headers(
Expand All @@ -325,7 +325,7 @@ def test_respects_x_trace_options_keys_and_values(self):
assert "trigger-trace=not-requested" in sampler.response_headers.x_trace_options_response

def test_ignores_trigger_trace(self):
sampler = TestSampler(TestSamplerOptions(
sampler = MockSampler(MockSamplerOptions(
settings=None,
local_settings=LocalSettings(trigger_mode=True, tracing_mode=None),
request_headers=make_request_headers(
Expand All @@ -339,7 +339,7 @@ def test_ignores_trigger_trace(self):

class TestEntrySpan:
def test_sw_w3c_tracestate_with_x_trace_options_response(self):
sampler = TestSampler(TestSamplerOptions(
sampler = MockSampler(MockSamplerOptions(
settings=Settings(
sample_rate=0,
sample_source=SampleSource.LOCAL_DEFAULT,
Expand All @@ -360,7 +360,7 @@ def test_sw_w3c_tracestate_with_x_trace_options_response(self):
assert INTL_SWO_X_OPTIONS_RESPONSE_KEY not in sample.attributes.get(TRACESTATE_CAPTURE_ATTRIBUTE)

def test_sw_w3c_tracestate_without_x_trace_options_response(self):
sampler = TestSampler(TestSamplerOptions(
sampler = MockSampler(MockSamplerOptions(
settings=Settings(
sample_rate=0,
sample_source=SampleSource.LOCAL_DEFAULT,
Expand All @@ -383,7 +383,7 @@ def test_sw_w3c_tracestate_without_x_trace_options_response(self):

class TestEntrySpanWithValidSwContextXTraceOptions:
def test_respects_keys_and_values(self):
sampler = TestSampler(TestSamplerOptions(
sampler = MockSampler(MockSamplerOptions(
settings=Settings(
sample_rate=0,
sample_source=SampleSource.LOCAL_DEFAULT,
Expand All @@ -405,7 +405,7 @@ def test_respects_keys_and_values(self):
assert "trigger-trace=not-requested" in sampler.response_headers.x_trace_options_response

def test_ignores_trigger_trace(self):
sampler = TestSampler(TestSamplerOptions(
sampler = MockSampler(MockSamplerOptions(
settings=Settings(
sample_rate=0,
sample_source=SampleSource.LOCAL_DEFAULT,
Expand All @@ -430,7 +430,7 @@ def test_ignores_trigger_trace(self):
class TestEntrySpanWithValidSwContextSampleThroughAlwaysSet:
@pytest.fixture()
def sample_through_always_set(self):
return TestSampler(TestSamplerOptions(
return MockSampler(MockSamplerOptions(
settings=Settings(
sample_rate=0,
sample_source=SampleSource.LOCAL_DEFAULT,
Expand Down Expand Up @@ -489,7 +489,7 @@ def test_respects_sw_not_sampled_over_w3c_sampled(self, sample_through_always_se

class TestEntrySpanWithValidSwContextSampleThroughAlwaysUnset:
def test_records_but_does_not_sample_when_SAMPLE_START_set(self):
sampler = TestSampler(TestSamplerOptions(
sampler = MockSampler(MockSamplerOptions(
settings=Settings(
sample_rate=0,
sample_source=SampleSource.LOCAL_DEFAULT,
Expand All @@ -510,7 +510,7 @@ def test_records_but_does_not_sample_when_SAMPLE_START_set(self):
check_counters(sampler, ["trace.service.request_count"])

def test_does_not_record_or_sample_when_SAMPLE_START_unset(self):
sampler = TestSampler(TestSamplerOptions(
sampler = MockSampler(MockSamplerOptions(
settings=Settings(
sample_rate=0,
sample_source=SampleSource.LOCAL_DEFAULT,
Expand All @@ -533,7 +533,7 @@ def test_does_not_record_or_sample_when_SAMPLE_START_unset(self):

class TestTriggerTraceRequestedTriggeredTraceSetUnsigned:
def test_records_and_samples_when_there_is_capacity(self):
sampler = TestSampler(TestSamplerOptions(
sampler = MockSampler(MockSamplerOptions(
settings=Settings(
sample_rate=0,
sample_source=SampleSource.LOCAL_DEFAULT,
Expand Down Expand Up @@ -564,7 +564,7 @@ def test_records_and_samples_when_there_is_capacity(self):
"trace.service.triggered_trace_count"])

def test_records_but_does_not_sample_when_there_is_no_capacity(self):
sampler = TestSampler(TestSamplerOptions(
sampler = MockSampler(MockSamplerOptions(
settings=Settings(
sample_rate=0,
sample_source=SampleSource.LOCAL_DEFAULT,
Expand Down Expand Up @@ -596,7 +596,7 @@ def test_records_but_does_not_sample_when_there_is_no_capacity(self):

class TestTriggerTraceRequestedTriggeredTraceSetSigned:
def test_records_and_samples_when_there_is_capacity(self):
sampler = TestSampler(TestSamplerOptions(
sampler = MockSampler(MockSamplerOptions(
settings=Settings(
sample_rate=0,
sample_source=SampleSource.LOCAL_DEFAULT,
Expand Down Expand Up @@ -629,7 +629,7 @@ def test_records_and_samples_when_there_is_capacity(self):
"trace.service.triggered_trace_count"])

def test_records_but_does_not_sample_when_there_is_no_capacity(self):
sampler = TestSampler(TestSamplerOptions(
sampler = MockSampler(MockSamplerOptions(
settings=Settings(
sample_rate=0,
sample_source=SampleSource.LOCAL_DEFAULT,
Expand Down Expand Up @@ -662,7 +662,7 @@ def test_records_but_does_not_sample_when_there_is_no_capacity(self):

class TestTriggerTraceRequestedTriggeredTraceUnset:
def test_record_but_does_not_sample_when_TRIGGERED_TRACE_unset(self):
sampler = TestSampler(TestSamplerOptions(
sampler = MockSampler(MockSamplerOptions(
settings=Settings(
sample_rate=0,
sample_source=SampleSource.LOCAL_DEFAULT,
Expand All @@ -689,7 +689,7 @@ def test_record_but_does_not_sample_when_TRIGGERED_TRACE_unset(self):

class TestTriggerTraceRequestedDiceRoll:
def test_respects_x_trace_options_keys_and_values(self):
sampler = TestSampler(TestSamplerOptions(
sampler = MockSampler(MockSamplerOptions(
settings=Settings(
sample_rate=0,
sample_source=SampleSource.LOCAL_DEFAULT,
Expand All @@ -711,7 +711,7 @@ def test_respects_x_trace_options_keys_and_values(self):
assert "trigger-trace=not-requested" in sampler.response_headers.x_trace_options_response

def test_records_and_samples_when_dice_success_and_sufficient_capacity(self):
sampler = TestSampler(TestSamplerOptions(
sampler = MockSampler(MockSamplerOptions(
settings=Settings(
sample_rate=1_000_000,
sample_source=SampleSource.REMOTE,
Expand Down Expand Up @@ -739,7 +739,7 @@ def test_records_and_samples_when_dice_success_and_sufficient_capacity(self):
["trace.service.request_count", "trace.service.samplecount", "trace.service.tracecount"])

def test_records_but_does_not_sample_when_dice_success_but_insufficient_capacity(self):
sampler = TestSampler(TestSamplerOptions(
sampler = MockSampler(MockSamplerOptions(
settings=Settings(
sample_rate=1_000_000,
sample_source=SampleSource.REMOTE,
Expand Down Expand Up @@ -767,7 +767,7 @@ def test_records_but_does_not_sample_when_dice_success_but_insufficient_capacity
"trace.service.tokenbucket_exhaustion_count"])

def test_records_but_does_not_sample_when_dice_failure(self):
sampler = TestSampler(TestSamplerOptions(
sampler = MockSampler(MockSamplerOptions(
settings=Settings(
sample_rate=0,
sample_source=SampleSource.LOCAL_DEFAULT,
Expand Down Expand Up @@ -796,7 +796,7 @@ def test_records_but_does_not_sample_when_dice_failure(self):

class TestTriggerTraceRequestedSampleStartUnset:
def test_ignores_trigger_trace(self):
sampler = TestSampler(TestSamplerOptions(
sampler = MockSampler(MockSamplerOptions(
settings=Settings(
sample_rate=0,
sample_source=SampleSource.LOCAL_DEFAULT,
Expand All @@ -818,7 +818,7 @@ def test_ignores_trigger_trace(self):
assert "ignored=invalid-key" in sampler.response_headers.x_trace_options_response

def test_records_when_SAMPLE_THROUGH_ALWAYS_set(self):
sampler = TestSampler(TestSamplerOptions(
sampler = MockSampler(MockSamplerOptions(
settings=Settings(
sample_rate=0,
sample_source=SampleSource.LOCAL_DEFAULT,
Expand All @@ -839,7 +839,7 @@ def test_records_when_SAMPLE_THROUGH_ALWAYS_set(self):
check_counters(sampler, ["trace.service.request_count"])

def test_does_not_record_when_SAMPLE_THROUGH_ALWAYS_unset(self):
sampler = TestSampler(TestSamplerOptions(
sampler = MockSampler(MockSamplerOptions(
settings=Settings(
sample_rate=0,
sample_source=SampleSource.LOCAL_DEFAULT,
Expand Down
Loading