forked from pinpoint-apm/pinpoint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pinpoint-apm#8472] Support Kotlin Coroutines Plugin
- Loading branch information
1 parent
178c7b5
commit 0824ab4
Showing
14 changed files
with
713 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.navercorp.pinpoint</groupId> | ||
<artifactId>pinpoint-plugins</artifactId> | ||
<version>2.4.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>pinpoint-kotlin-coroutines-plugin</artifactId> | ||
<name>pinpoint-kotlin-coroutines-plugin</name> | ||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<jdk.version>1.8</jdk.version> | ||
<jdk.home>${env.JAVA_8_HOME}</jdk.home> | ||
<sniffer.artifactid>java18</sniffer.artifactid> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.navercorp.pinpoint</groupId> | ||
<artifactId>pinpoint-bootstrap-core</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.navercorp.pinpoint</groupId> | ||
<artifactId>pinpoint-annotations</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jetbrains.kotlinx</groupId> | ||
<artifactId>kotlinx-coroutines-core</artifactId> | ||
<version>1.5.2</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
</project> |
68 changes: 68 additions & 0 deletions
68
...ines/src/main/java/com/navercorp/pinpoint/plugin/kotlinx/coroutines/CoroutinesConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright 2021 NAVER Corp. | ||
* | ||
* 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. | ||
*/ | ||
|
||
package com.navercorp.pinpoint.plugin.kotlinx.coroutines; | ||
|
||
import com.navercorp.pinpoint.bootstrap.config.ProfilerConfig; | ||
import com.navercorp.pinpoint.common.util.StringUtils; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
/** | ||
* @author Taejin Koo | ||
*/ | ||
public class CoroutinesConfig { | ||
|
||
private final boolean traceCoroutines; | ||
private final List<String> nameIncludeList; | ||
|
||
public CoroutinesConfig(ProfilerConfig config) { | ||
this.traceCoroutines = config.readBoolean("profiler.kotlin.coroutines.enable", false); | ||
String nameIncludes = config.readString("profiler.kotlin.coroutines.name.include", ""); | ||
|
||
if (StringUtils.hasLength(nameIncludes)) { | ||
String[] nameIncludeArray = nameIncludes.split(","); | ||
List<String> result = new ArrayList<>(nameIncludeArray.length); | ||
for (String nameInclude : nameIncludeArray) { | ||
if (StringUtils.hasLength(nameInclude)) { | ||
result.add(nameInclude); | ||
} | ||
} | ||
nameIncludeList = Collections.unmodifiableList(result); | ||
} else { | ||
nameIncludeList = Collections.emptyList(); | ||
} | ||
} | ||
|
||
public boolean isTraceCoroutines() { | ||
return traceCoroutines; | ||
} | ||
|
||
public List<String> getIncludedNameList() { | ||
return nameIncludeList; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
final StringBuilder sb = new StringBuilder("CoroutinesConfig{"); | ||
sb.append("traceCoroutines=").append(traceCoroutines); | ||
sb.append(", nameIncludeList=").append(nameIncludeList); | ||
sb.append('}'); | ||
return sb.toString(); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...s/src/main/java/com/navercorp/pinpoint/plugin/kotlinx/coroutines/CoroutinesConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright 2021 NAVER Corp. | ||
* | ||
* 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. | ||
*/ | ||
|
||
package com.navercorp.pinpoint.plugin.kotlinx.coroutines; | ||
|
||
import com.navercorp.pinpoint.common.trace.ServiceType; | ||
import com.navercorp.pinpoint.common.trace.ServiceTypeFactory; | ||
|
||
/** | ||
* @author Taejin Koo | ||
*/ | ||
public final class CoroutinesConstants { | ||
|
||
private CoroutinesConstants() { | ||
} | ||
|
||
public static final ServiceType SERVICE_TYPE = ServiceTypeFactory.of(8901, "KT_COROUTINES"); | ||
|
||
public static final String SCOPE = "KT_COROUTINES_SCOPE"; | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
...ain/java/com/navercorp/pinpoint/plugin/kotlinx/coroutines/CoroutinesMetadataProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2021 NAVER Corp. | ||
* | ||
* 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. | ||
*/ | ||
|
||
package com.navercorp.pinpoint.plugin.kotlinx.coroutines; | ||
|
||
import com.navercorp.pinpoint.common.trace.TraceMetadataProvider; | ||
import com.navercorp.pinpoint.common.trace.TraceMetadataSetupContext; | ||
|
||
/** | ||
* @author Taejin Koo | ||
*/ | ||
public class CoroutinesMetadataProvider implements TraceMetadataProvider { | ||
|
||
@Override | ||
public void setup(TraceMetadataSetupContext context) { | ||
context.addServiceType(CoroutinesConstants.SERVICE_TYPE); | ||
} | ||
|
||
} |
Oops, something went wrong.