@Test public void should_ignore_synthetic_signatures() { String syntheticSignature = "customer1.FooConfig..EnhancerBySpringCGLIB..96aac875.CGLIB$BIND_CALLBACKS(java.lang.Object)"; InvocationDataPublication2 publication = InvocationDataPublication2.builder() .commonData(CommonPublicationData2.sampleCommonPublicationData()) .recordingIntervalStartedAtMillis(NOW.toEpochMilli()) .invocations(new HashSet<>(asList("signature", syntheticSignature))) .build(); when(syntheticSignatureService.isSyntheticMethod(syntheticSignature)).thenReturn(true); invocationDataImporter.importPublication(publication); verify(metricsService) .recordImportedPublication(PublicationType.INVOCATIONS, 1, 1, Duration.ZERO); }
@Override @Transactional @Restartable public boolean importPublication(InvocationDataPublication2 publication) { logger.debug("Importing {}", publication); Instant startedAt = clock.instant(); CommonPublicationData2 data = publication.getCommonData(); Set<String> invocations = publication.getInvocations().stream() .filter(i -> !syntheticSignatureService.isSyntheticMethod(i)) .collect(Collectors.toSet()); int ignoredSyntheticSignatures = publication.getInvocations().size() - invocations.size(); lockTemplate.doWithLock( Lock.forCustomer(data.getCustomerId()), () -> { ImportContext importContext = commonImporter.importCommonData(data); Instant trialPeriodEndsAt = importDAO.importInvocations( importContext, publication.getRecordingIntervalStartedAtMillis(), invocations); eventService.send( InvocationDataReceivedEvent.builder() .customerId(data.getCustomerId()) .appName(data.getAppName()) .appVersion(data.getAppVersion()) .agentVersion(data.getAgentVersion()) .environment(data.getEnvironment()) .hostname(data.getHostname()) .size(invocations.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.INVOCATIONS, invocations.size(), ignoredSyntheticSignatures, duration); return true; }
InvocationDataImporterImpl implements InvocationDataImporter { @Override @Transactional @Restartable public boolean importPublication(InvocationDataPublication2 publication) { logger.debug("Importing {}", publication); Instant startedAt = clock.instant(); CommonPublicationData2 data = publication.getCommonData(); Set<String> invocations = publication.getInvocations().stream() .filter(i -> !syntheticSignatureService.isSyntheticMethod(i)) .collect(Collectors.toSet()); int ignoredSyntheticSignatures = publication.getInvocations().size() - invocations.size(); lockTemplate.doWithLock( Lock.forCustomer(data.getCustomerId()), () -> { ImportContext importContext = commonImporter.importCommonData(data); Instant trialPeriodEndsAt = importDAO.importInvocations( importContext, publication.getRecordingIntervalStartedAtMillis(), invocations); eventService.send( InvocationDataReceivedEvent.builder() .customerId(data.getCustomerId()) .appName(data.getAppName()) .appVersion(data.getAppVersion()) .agentVersion(data.getAgentVersion()) .environment(data.getEnvironment()) .hostname(data.getHostname()) .size(invocations.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.INVOCATIONS, invocations.size(), ignoredSyntheticSignatures, duration); return true; } }
InvocationDataImporterImpl implements InvocationDataImporter { @Override @Transactional @Restartable public boolean importPublication(InvocationDataPublication2 publication) { logger.debug("Importing {}", publication); Instant startedAt = clock.instant(); CommonPublicationData2 data = publication.getCommonData(); Set<String> invocations = publication.getInvocations().stream() .filter(i -> !syntheticSignatureService.isSyntheticMethod(i)) .collect(Collectors.toSet()); int ignoredSyntheticSignatures = publication.getInvocations().size() - invocations.size(); lockTemplate.doWithLock( Lock.forCustomer(data.getCustomerId()), () -> { ImportContext importContext = commonImporter.importCommonData(data); Instant trialPeriodEndsAt = importDAO.importInvocations( importContext, publication.getRecordingIntervalStartedAtMillis(), invocations); eventService.send( InvocationDataReceivedEvent.builder() .customerId(data.getCustomerId()) .appName(data.getAppName()) .appVersion(data.getAppVersion()) .agentVersion(data.getAgentVersion()) .environment(data.getEnvironment()) .hostname(data.getHostname()) .size(invocations.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.INVOCATIONS, invocations.size(), ignoredSyntheticSignatures, duration); return true; }  }
InvocationDataImporterImpl implements InvocationDataImporter { @Override @Transactional @Restartable public boolean importPublication(InvocationDataPublication2 publication) { logger.debug("Importing {}", publication); Instant startedAt = clock.instant(); CommonPublicationData2 data = publication.getCommonData(); Set<String> invocations = publication.getInvocations().stream() .filter(i -> !syntheticSignatureService.isSyntheticMethod(i)) .collect(Collectors.toSet()); int ignoredSyntheticSignatures = publication.getInvocations().size() - invocations.size(); lockTemplate.doWithLock( Lock.forCustomer(data.getCustomerId()), () -> { ImportContext importContext = commonImporter.importCommonData(data); Instant trialPeriodEndsAt = importDAO.importInvocations( importContext, publication.getRecordingIntervalStartedAtMillis(), invocations); eventService.send( InvocationDataReceivedEvent.builder() .customerId(data.getCustomerId()) .appName(data.getAppName()) .appVersion(data.getAppVersion()) .agentVersion(data.getAgentVersion()) .environment(data.getEnvironment()) .hostname(data.getHostname()) .size(invocations.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.INVOCATIONS, invocations.size(), ignoredSyntheticSignatures, duration); return true; }  @Override @Transactional @Restartable boolean importPublication(InvocationDataPublication2 publication); }
InvocationDataImporterImpl implements InvocationDataImporter { @Override @Transactional @Restartable public boolean importPublication(InvocationDataPublication2 publication) { logger.debug("Importing {}", publication); Instant startedAt = clock.instant(); CommonPublicationData2 data = publication.getCommonData(); Set<String> invocations = publication.getInvocations().stream() .filter(i -> !syntheticSignatureService.isSyntheticMethod(i)) .collect(Collectors.toSet()); int ignoredSyntheticSignatures = publication.getInvocations().size() - invocations.size(); lockTemplate.doWithLock( Lock.forCustomer(data.getCustomerId()), () -> { ImportContext importContext = commonImporter.importCommonData(data); Instant trialPeriodEndsAt = importDAO.importInvocations( importContext, publication.getRecordingIntervalStartedAtMillis(), invocations); eventService.send( InvocationDataReceivedEvent.builder() .customerId(data.getCustomerId()) .appName(data.getAppName()) .appVersion(data.getAppVersion()) .agentVersion(data.getAgentVersion()) .environment(data.getEnvironment()) .hostname(data.getHostname()) .size(invocations.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.INVOCATIONS, invocations.size(), ignoredSyntheticSignatures, duration); return true; }  @Override @Transactional @Restartable boolean importPublication(InvocationDataPublication2 publication);  }