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

Closes #1383 - Method configuration editor: preserve Trace and Measure settings when editing existing scope #1391

Merged
merged 3 commits into from
Apr 12, 2022
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
Expand Up @@ -138,16 +138,27 @@ const MethodConfigurationEditor = ({ yamlConfiguration }) => {
*/
const addScope = (typeMatcher, methodMatcher) => {
const cloneConfiguration = _.cloneDeep(configuration);
const scopeName = currentScopeName ? currentScopeName : ('s_gen_scope_' + uuid()).replaceAll('-', '_');
let scopeName;
// Check whether an existing scope was modified or a new scope created
if (currentScopeName) {
// If currentScopeName is set, an existing scope is being modified
scopeName = currentScopeName;
} else {
// If currentScopeName is undefined, a new scope is being created
// Generate random name for new scope
scopeName = ('s_gen_scope_' + uuid()).replaceAll('-', '_');
// Enable Trace and Measure by default for new scope
_.set(cloneConfiguration, ['inspectit', 'instrumentation', 'rules', 'r_method_configuration_trace', 'scopes', scopeName], true);
_.set(cloneConfiguration, ['inspectit', 'instrumentation', 'rules', 'r_method_configuration_duration', 'scopes', scopeName], true);
}

const preparedScope = prepareScope(typeMatcher, methodMatcher);

try {
_.set(cloneConfiguration, ['inspectit', 'instrumentation', 'scopes', scopeName], preparedScope);
_.set(cloneConfiguration, ['inspectit', 'instrumentation', 'rules', 'r_method_configuration_trace', 'scopes', scopeName], true);
_.set(cloneConfiguration, ['inspectit', 'instrumentation', 'rules', 'r_method_configuration_duration', 'scopes', scopeName], true);

updateConfiguration(cloneConfiguration);
} catch (error) {
// todo: proper error handling
throw new Error(error);
}
};
Expand Down