Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NH-67051 Add span processor config tests #233

Merged
merged 1 commit into from
Nov 23, 2023
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# © 2023 SolarWinds Worldwide, LLC. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at:http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

from solarwinds_apm import configurator

# otel fixtures
from .fixtures.trace import get_trace_mocks

# apm python fixtures
from .fixtures.apm_config import (
mock_apmconfig_enabled,
mock_apmconfig_enabled_expt,
)
Comment on lines +13 to +16

Check notice

Code scanning / CodeQL

Unused import Note test

Import of 'mock_apmconfig_enabled' is not used.
Import of 'mock_apmconfig_enabled_expt' is not used.
from .fixtures.meter_manager import mock_meter_manager

Check notice

Code scanning / CodeQL

Unused import Note test

Import of 'mock_meter_manager' is not used.
from .fixtures.txn_name_manager import mock_txn_name_manager

Check notice

Code scanning / CodeQL

Unused import Note test

Import of 'mock_txn_name_manager' is not used.

class TestConfiguratorSpanProcessors:
def test_configure_inbound_metrics_span_processor(
self,
mocker,
mock_apmconfig_enabled,
mock_txn_name_manager,
):
mock_trace, mock_get_tracer_provider, mock_add_span_processor, _ = get_trace_mocks(mocker)
mock_processor = mocker.patch(
"solarwinds_apm.configurator.SolarWindsInboundMetricsSpanProcessor"
)

test_configurator = configurator.SolarWindsConfigurator()
test_configurator._configure_inbound_metrics_span_processor(
mock_txn_name_manager,
mock_apmconfig_enabled,
)
mock_get_tracer_provider.assert_called_once()
mock_add_span_processor.assert_called_once()
mock_processor.assert_called_once_with(
mock_txn_name_manager,
mock_apmconfig_enabled,
)

def test_configure_otlp_metrics_span_processor_missing_flag(
self,
mocker,
mock_apmconfig_enabled,
mock_txn_name_manager,
mock_meter_manager,
):
mock_trace, mock_get_tracer_provider, mock_add_span_processor, _ = get_trace_mocks(mocker)
mock_processor = mocker.patch(
"solarwinds_apm.configurator.SolarWindsOTLPMetricsSpanProcessor"
)

test_configurator = configurator.SolarWindsConfigurator()
test_configurator._configure_otlp_metrics_span_processor(
mock_txn_name_manager,
mock_apmconfig_enabled,
mock_meter_manager,
)
mock_get_tracer_provider.assert_not_called()
mock_add_span_processor.assert_not_called()
mock_processor.assert_not_called()

def test_configure_otlp_metrics_span_processor(
self,
mocker,
mock_apmconfig_enabled_expt,
mock_txn_name_manager,
mock_meter_manager,
):
mock_trace, mock_get_tracer_provider, mock_add_span_processor, _ = get_trace_mocks(mocker)
mock_processor = mocker.patch(
"solarwinds_apm.configurator.SolarWindsOTLPMetricsSpanProcessor"
)

test_configurator = configurator.SolarWindsConfigurator()
test_configurator._configure_otlp_metrics_span_processor(
mock_txn_name_manager,
mock_apmconfig_enabled_expt,
mock_meter_manager,
)
mock_get_tracer_provider.assert_called_once()
mock_add_span_processor.assert_called_once()
mock_processor.assert_called_once_with(
mock_txn_name_manager,
mock_apmconfig_enabled_expt,
mock_meter_manager,
)
Loading