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

Improvements for Correlation Logs #3085

Open
wants to merge 11 commits into
base: 4.7.x
Choose a base branch
from
93 changes: 93 additions & 0 deletions core/org.wso2.carbon.logging.correlation/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) WSO2 Inc. (http://wso2.com) 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.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<parent>
<groupId>org.wso2.carbon</groupId>
<artifactId>carbon-kernel</artifactId>
<version>4.6.2</version>
<relativePath>../pom.xml</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.logging.correlation</artifactId>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Correlation Logging</name>
<description>Correlation logging component for Carbon</description>
<url>http://wso2.org</url>

<dependencies>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.osgi</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.annotation</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.metatype.annotations</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-stax-api_1.0_spec</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Export-Package>
!org.wso2.carbon.logging.correlation.internal.*,
org.wso2.carbon.logging.correlation.*,
</Export-Package>
<Import-Package>
*;resolution:=optional,
</Import-Package>
<DynamicImport-Package>*</DynamicImport-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>

</project>

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you 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.
*/

package org.wso2.carbon.logging.correlation;

import org.wso2.carbon.logging.correlation.bean.ImmutableCorrelationLogConfig;

/**
* The class definition of the correlation log service class which needs to be implemented in each component.
*/
public interface CorrelationLogConfigurable {

/**
* Returns name of the implementation.
*
* @return
*/
String getName();

/**
* Receives an instance of <code>ImmutableCorrelationLogConfig</code> class which holds the component-specific
* configuration.
*
* @param config
*/
void onConfigure(ImmutableCorrelationLogConfig config);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
*
* Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you 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.
*/

package org.wso2.carbon.logging.correlation;

import org.wso2.carbon.logging.correlation.bean.CorrelationLogConfig;

/**
* The class definition which needs to be implemented to override correlation log configurations dynamically in the
* runtime.
*/
public interface CorrelationLogConfigurator {

/**
* Returns an instance of the <code>CorrelationLogConfig</code> class which represents effective entire
* configuration related to correlation logs..
*
* @return
*/
CorrelationLogConfig getConfiguration();

/**
* Set the entire configuration related to correlation logs.
*
* @param correlationLogConfig
*/
void updateConfiguration(CorrelationLogConfig correlationLogConfig);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
*
* Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you 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.
*/

package org.wso2.carbon.logging.correlation.bean;

/**
* Component-specific configuration bean class.
*/
public class CorrelationLogComponentConfig {
private boolean logAllMethods;

public CorrelationLogComponentConfig() {
}

public CorrelationLogComponentConfig(boolean logAllMethods) {
this.logAllMethods = logAllMethods;
}

public boolean isLogAllMethods() {
return logAllMethods;
}

public void setLogAllMethods(boolean logAllMethods) {
this.logAllMethods = logAllMethods;
}

public CorrelationLogComponentConfig clone() {
return new CorrelationLogComponentConfig(this.logAllMethods);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
*
* Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you 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.
*/

package org.wso2.carbon.logging.correlation.bean;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
* Configuration bean class.
*/
public class CorrelationLogConfig {
private boolean enable;
private String[] components;
private String[] deniedThreads;
private Map<String, CorrelationLogComponentConfig> componentConfigs;

public CorrelationLogConfig() {
this(false, null, null);
}

public CorrelationLogConfig(boolean enable, String[] components, String[] deniedThreads) {
this(enable, components, deniedThreads, new HashMap<>());
}

public CorrelationLogConfig(boolean enable, String[] components, String[] deniedThreads,
Map<String, CorrelationLogComponentConfig> componentConfigs) {
this.enable = enable;
this.components = components;
this.deniedThreads = deniedThreads;
this.componentConfigs = componentConfigs;
}

public boolean isEnable() {
return enable;
}

public void setEnable(boolean enable) {
this.enable = enable;
}

public String[] getComponents() {
return components;
}

public void setComponents(String[] components) {
this.components = components;
}

public String[] getDeniedThreads() {
return deniedThreads;
}

public void setDeniedThreads(String[] deniedThreads) {
this.deniedThreads = deniedThreads;
}

public Map<String, CorrelationLogComponentConfig> getComponentConfigs() {
return componentConfigs;
}

public void setComponentConfigs(Map<String, CorrelationLogComponentConfig> componentConfigs) {
this.componentConfigs = componentConfigs;
}

/**
* Returns a clone of this instance.
*
* @return
*/
public CorrelationLogConfig clone() {
// Create a copy of the current instance.
CorrelationLogConfig clone = new CorrelationLogConfig(
this.enable,
Arrays.copyOf(this.components, this.components.length),
Arrays.copyOf(this.deniedThreads, this.deniedThreads.length));

// Copy component configurations.
Map<String, CorrelationLogComponentConfig> clonedComponentConfigs = new HashMap<>();
for (Map.Entry<String, CorrelationLogComponentConfig> entry : this.componentConfigs.entrySet()) {
clonedComponentConfigs.put(new String(entry.getKey()), entry.getValue().clone());
}
clone.setComponentConfigs(clonedComponentConfigs);
return clone;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you 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.
*/

package org.wso2.carbon.logging.correlation.bean;

import java.util.Arrays;

/**
* Immutable configuration bean class for correlation log.
* An object of this class is used to dispatch configuration changes to <code>CorrelationLogConfigurable</code>
* service implementations.
*/
public class ImmutableCorrelationLogConfig {
private boolean enable;
private String[] deniedThreads;
private boolean logAllMethods;

public ImmutableCorrelationLogConfig(boolean enable, String[] deniedThreads, boolean logAllMethods) {
this.enable = enable;
this.deniedThreads = deniedThreads;
this.logAllMethods = logAllMethods;
}

public boolean isEnable() {
return enable;
}

public String[] getDeniedThreads() {
return deniedThreads;
}

public boolean isLogAllMethods() {
return logAllMethods;
}
}
Loading