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

Revert #34 because the agent and collector have different signatures #43

Merged
merged 1 commit into from
Mar 6, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@
import lombok.Getter;

import com.navercorp.scavenger.util.HashGenerator;
import com.navercorp.scavenger.util.Signatures;

public class MethodRegistry {
public static final String SYNTHETIC_SIGNATURE_HASH = "";

@Getter
private final Map<String, String> byteBuddySignatureToHash = new ConcurrentHashMap<>();

private static final Pattern SYNTHETIC_SIGNATURE_PATTERN = Pattern.compile(".*\\$\\$(Enhancer|FastClass)BySpringCGLIB\\$\\$.*");

public String getHash(String byteBuddySignature, boolean legacyCompatibilityMode) {
String hash = this.byteBuddySignatureToHash.get(byteBuddySignature);

if (hash == null) {
if (Signatures.containsSyntheticPattern(byteBuddySignature)) {
if (SYNTHETIC_SIGNATURE_PATTERN.matcher(byteBuddySignature).matches()) {
hash = SYNTHETIC_SIGNATURE_HASH;
} else {
String signature = extractSignature(byteBuddySignature);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import com.navercorp.scavenger.dto.CommonImportResultDto
import com.navercorp.scavenger.dto.InvocationImportDto
import com.navercorp.scavenger.exception.UnknownPublicationException
import com.navercorp.scavenger.util.HashGenerator
import com.navercorp.scavenger.util.Signatures
import io.codekvast.javaagent.model.v4.CodeBasePublication4
import io.codekvast.javaagent.model.v4.CommonPublicationData4
import io.codekvast.javaagent.model.v4.InvocationDataPublication4
import java.io.InputStream
import java.io.ObjectInputStream
import java.util.regex.Pattern

sealed interface Publication {
fun getCommonImportDto(customerId: Long): CommonImportDto
Expand Down Expand Up @@ -107,7 +107,7 @@ sealed class LegacyPublication private constructor(val commonData: CommonPublica
override fun getCodeBaseImportDto(commonImportResultDto: CommonImportResultDto): CodeBaseImportDto =
with(commonImportResultDto) {
val entries = pub.entries
.filterNot { Signatures.containsSyntheticPattern(it.signature) }
.filterNot { syntheticSignaturePattern.matcher(it.signature).matches() }
.map {
CodeBaseImportDto.CodeBaseEntry(
declaringType = it.methodSignature.declaringType,
Expand Down Expand Up @@ -140,13 +140,17 @@ sealed class LegacyPublication private constructor(val commonData: CommonPublica
applicationId = applicationId,
environmentId = environmentId,
invocations = pub.invocations
.filterNot { Signatures.containsSyntheticPattern(it) }
.filterNot { syntheticSignaturePattern.matcher(it).matches() }
.map { HashGenerator.Md5.from(it) }
.sorted(),
invokedAtMillis = pub.recordingIntervalStartedAtMillis,
)
}
}

companion object {
val syntheticSignaturePattern: Pattern = Pattern.compile(".*\\.\\.(Enhancer|FastClass)BySpringCGLIB\\.\\..*")
}
}

fun InputStream.toLegacyPublication(): LegacyPublication {
Expand Down
4 changes: 0 additions & 4 deletions scavenger-model/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ dependencies {
implementation("io.grpc:grpc-kotlin-stub:${property("grpcKotlinVersion")}")
implementation("io.grpc:grpc-protobuf:${property("grpcVersion")}")
implementation("javax.annotation:javax.annotation-api:1.3.2")

testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.2")
testImplementation("org.assertj:assertj-core:3.22.0")
}

tasks.withType<JavaCompile> {
Expand Down

This file was deleted.

This file was deleted.