@Test public void should_ignore_synthetic_signatures() { String syntheticSignature = "customer1.FooConfig..EnhancerBySpringCGLIB..96aac875.CGLIB$BIND_CALLBACKS(java.lang.Object)"; CodeBasePublication3 publication = CodeBasePublication3.builder() .commonData(CommonPublicationData2.sampleCommonPublicationData()) .entries( asList( CodeBaseEntry3.sampleCodeBaseEntry(), CodeBaseEntry3.sampleCodeBaseEntry().toBuilder() .signature(syntheticSignature) .build())) .build(); when(syntheticSignatureService.isSyntheticMethod(syntheticSignature)).thenReturn(true); codeBaseImporter.importPublication(publication); verify(metricsService).recordImportedPublication(PublicationType.CODEBASE, 1, 1, Duration.ZERO); }
@Override @Transactional @Restartable public boolean importPublication(CodeBasePublication3 publication) { logger.debug("Importing {}", publication); Instant startedAt = clock.instant(); CommonPublicationData2 data = publication.getCommonData(); Collection<CodeBaseEntry3> entries = publication.getEntries().stream() .filter(e -> !syntheticSignatureService.isSyntheticMethod(e.getSignature())) .collect(Collectors.toList()); int ignoredSyntheticSignatures = publication.getEntries().size() - entries.size(); lockTemplate.doWithLock( Lock.forCustomer(data.getCustomerId()), () -> { CommonImporter.ImportContext importContext = commonImporter.importCommonData(data); Instant trialPeriodEndsAt = importDAO.importMethods(data, importContext, entries); eventService.send( CodeBaseReceivedEvent.builder() .customerId(data.getCustomerId()) .appName(data.getAppName()) .appVersion(data.getAppVersion()) .agentVersion(data.getAgentVersion()) .environment(data.getEnvironment()) .hostname(data.getHostname()) .size(entries.size()) .receivedAt(Instant.ofEpochMilli(data.getPublishedAtMillis())) .trialPeriodEndsAt(trialPeriodEndsAt) .build()); }); Duration duration = Duration.between(startedAt, clock.instant()); logger.info( "Imported {} in {} (ignoring {} synthetic signatures)", publication, humanReadableDuration(duration), ignoredSyntheticSignatures); metricsService.recordImportedPublication( PublicationType.CODEBASE, entries.size(), ignoredSyntheticSignatures, duration); return true; }
CodeBaseImporterImpl implements CodeBaseImporter { @Override @Transactional @Restartable public boolean importPublication(CodeBasePublication3 publication) { logger.debug("Importing {}", publication); Instant startedAt = clock.instant(); CommonPublicationData2 data = publication.getCommonData(); Collection<CodeBaseEntry3> entries = publication.getEntries().stream() .filter(e -> !syntheticSignatureService.isSyntheticMethod(e.getSignature())) .collect(Collectors.toList()); int ignoredSyntheticSignatures = publication.getEntries().size() - entries.size(); lockTemplate.doWithLock( Lock.forCustomer(data.getCustomerId()), () -> { CommonImporter.ImportContext importContext = commonImporter.importCommonData(data); Instant trialPeriodEndsAt = importDAO.importMethods(data, importContext, entries); eventService.send( CodeBaseReceivedEvent.builder() .customerId(data.getCustomerId()) .appName(data.getAppName()) .appVersion(data.getAppVersion()) .agentVersion(data.getAgentVersion()) .environment(data.getEnvironment()) .hostname(data.getHostname()) .size(entries.size()) .receivedAt(Instant.ofEpochMilli(data.getPublishedAtMillis())) .trialPeriodEndsAt(trialPeriodEndsAt) .build()); }); Duration duration = Duration.between(startedAt, clock.instant()); logger.info( "Imported {} in {} (ignoring {} synthetic signatures)", publication, humanReadableDuration(duration), ignoredSyntheticSignatures); metricsService.recordImportedPublication( PublicationType.CODEBASE, entries.size(), ignoredSyntheticSignatures, duration); return true; } }
CodeBaseImporterImpl implements CodeBaseImporter { @Override @Transactional @Restartable public boolean importPublication(CodeBasePublication3 publication) { logger.debug("Importing {}", publication); Instant startedAt = clock.instant(); CommonPublicationData2 data = publication.getCommonData(); Collection<CodeBaseEntry3> entries = publication.getEntries().stream() .filter(e -> !syntheticSignatureService.isSyntheticMethod(e.getSignature())) .collect(Collectors.toList()); int ignoredSyntheticSignatures = publication.getEntries().size() - entries.size(); lockTemplate.doWithLock( Lock.forCustomer(data.getCustomerId()), () -> { CommonImporter.ImportContext importContext = commonImporter.importCommonData(data); Instant trialPeriodEndsAt = importDAO.importMethods(data, importContext, entries); eventService.send( CodeBaseReceivedEvent.builder() .customerId(data.getCustomerId()) .appName(data.getAppName()) .appVersion(data.getAppVersion()) .agentVersion(data.getAgentVersion()) .environment(data.getEnvironment()) .hostname(data.getHostname()) .size(entries.size()) .receivedAt(Instant.ofEpochMilli(data.getPublishedAtMillis())) .trialPeriodEndsAt(trialPeriodEndsAt) .build()); }); Duration duration = Duration.between(startedAt, clock.instant()); logger.info( "Imported {} in {} (ignoring {} synthetic signatures)", publication, humanReadableDuration(duration), ignoredSyntheticSignatures); metricsService.recordImportedPublication( PublicationType.CODEBASE, entries.size(), ignoredSyntheticSignatures, duration); return true; }  }
CodeBaseImporterImpl implements CodeBaseImporter { @Override @Transactional @Restartable public boolean importPublication(CodeBasePublication3 publication) { logger.debug("Importing {}", publication); Instant startedAt = clock.instant(); CommonPublicationData2 data = publication.getCommonData(); Collection<CodeBaseEntry3> entries = publication.getEntries().stream() .filter(e -> !syntheticSignatureService.isSyntheticMethod(e.getSignature())) .collect(Collectors.toList()); int ignoredSyntheticSignatures = publication.getEntries().size() - entries.size(); lockTemplate.doWithLock( Lock.forCustomer(data.getCustomerId()), () -> { CommonImporter.ImportContext importContext = commonImporter.importCommonData(data); Instant trialPeriodEndsAt = importDAO.importMethods(data, importContext, entries); eventService.send( CodeBaseReceivedEvent.builder() .customerId(data.getCustomerId()) .appName(data.getAppName()) .appVersion(data.getAppVersion()) .agentVersion(data.getAgentVersion()) .environment(data.getEnvironment()) .hostname(data.getHostname()) .size(entries.size()) .receivedAt(Instant.ofEpochMilli(data.getPublishedAtMillis())) .trialPeriodEndsAt(trialPeriodEndsAt) .build()); }); Duration duration = Duration.between(startedAt, clock.instant()); logger.info( "Imported {} in {} (ignoring {} synthetic signatures)", publication, humanReadableDuration(duration), ignoredSyntheticSignatures); metricsService.recordImportedPublication( PublicationType.CODEBASE, entries.size(), ignoredSyntheticSignatures, duration); return true; }  @Override @Transactional @Restartable boolean importPublication(CodeBasePublication3 publication); }
CodeBaseImporterImpl implements CodeBaseImporter { @Override @Transactional @Restartable public boolean importPublication(CodeBasePublication3 publication) { logger.debug("Importing {}", publication); Instant startedAt = clock.instant(); CommonPublicationData2 data = publication.getCommonData(); Collection<CodeBaseEntry3> entries = publication.getEntries().stream() .filter(e -> !syntheticSignatureService.isSyntheticMethod(e.getSignature())) .collect(Collectors.toList()); int ignoredSyntheticSignatures = publication.getEntries().size() - entries.size(); lockTemplate.doWithLock( Lock.forCustomer(data.getCustomerId()), () -> { CommonImporter.ImportContext importContext = commonImporter.importCommonData(data); Instant trialPeriodEndsAt = importDAO.importMethods(data, importContext, entries); eventService.send( CodeBaseReceivedEvent.builder() .customerId(data.getCustomerId()) .appName(data.getAppName()) .appVersion(data.getAppVersion()) .agentVersion(data.getAgentVersion()) .environment(data.getEnvironment()) .hostname(data.getHostname()) .size(entries.size()) .receivedAt(Instant.ofEpochMilli(data.getPublishedAtMillis())) .trialPeriodEndsAt(trialPeriodEndsAt) .build()); }); Duration duration = Duration.between(startedAt, clock.instant()); logger.info( "Imported {} in {} (ignoring {} synthetic signatures)", publication, humanReadableDuration(duration), ignoredSyntheticSignatures); metricsService.recordImportedPublication( PublicationType.CODEBASE, entries.size(), ignoredSyntheticSignatures, duration); return true; }  @Override @Transactional @Restartable boolean importPublication(CodeBasePublication3 publication);  }