├── .github └── workflows │ ├── build-with-maven.yml │ ├── release.yml │ └── snapshot.yml ├── .gitignore ├── LICENSE ├── README.md ├── pom.xml ├── sidekick-agent-all ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── runsidekick │ │ └── agent │ │ └── all │ │ ├── AgentSupport.java │ │ └── initialize │ │ └── AgentSupportInitializer.java │ └── resources │ └── META-INF │ └── services │ └── com.runsidekick.agent.core.initialize.EnvironmentInitializer ├── sidekick-agent-api-broker ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── runsidekick │ └── agent │ └── api │ └── broker │ └── publisher │ ├── EventPublisher.java │ └── RequestPublisher.java ├── sidekick-agent-api-data-redaction ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── runsidekick │ └── agent │ └── api │ └── dataredaction │ ├── DataRedactionContext.java │ └── SidekickDataRedactionAPI.java ├── sidekick-agent-api-logpoint ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── runsidekick │ └── agent │ └── api │ └── logpoint │ ├── LogPointAPI.java │ └── LogPointAPIService.java ├── sidekick-agent-api-tracepoint-integrations-junit4 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── runsidekick │ └── agent │ └── api │ └── tracepoint │ └── integrations │ └── junit4 │ └── TracePointSnapshotTestRule.java ├── sidekick-agent-api-tracepoint-integrations-junit5 ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── runsidekick │ └── agent │ └── api │ └── tracepoint │ └── integrations │ └── junit5 │ └── TracePointSnapshotExtension.java ├── sidekick-agent-api-tracepoint ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── runsidekick │ └── agent │ └── api │ └── tracepoint │ ├── TracePointAPI.java │ └── TracePointAPIService.java ├── sidekick-agent-bootstrap ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── runsidekick │ └── agent │ └── bootstrap │ ├── Agent.java │ └── Attach.java ├── sidekick-agent-broker ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── runsidekick │ │ └── agent │ │ └── broker │ │ ├── BrokerCredentials.java │ │ ├── BrokerManager.java │ │ ├── BrokerMessageCallback.java │ │ ├── application │ │ └── ApplicationStatusProvider.java │ │ ├── client │ │ ├── BrokerClient.java │ │ ├── BrokerClientFactory.java │ │ ├── BrokerClientHandshakeException.java │ │ └── impl │ │ │ └── OkHttpWebSocketBrokerClient.java │ │ ├── domain │ │ └── ApplicationStatus.java │ │ ├── error │ │ ├── CodedError.java │ │ ├── CodedException.java │ │ ├── CommonErrorCodes.java │ │ └── impl │ │ │ └── SimpleCodedError.java │ │ ├── event │ │ ├── Event.java │ │ ├── MutableEvent.java │ │ └── impl │ │ │ ├── ApplicationStatusEvent.java │ │ │ └── BaseEvent.java │ │ ├── handler │ │ ├── request │ │ │ ├── RequestHandler.java │ │ │ └── impl │ │ │ │ ├── AttachRequestHandler.java │ │ │ │ ├── BaseRequestHandler.java │ │ │ │ ├── DetachRequestHandler.java │ │ │ │ └── UpdateConfigRequestHandler.java │ │ └── response │ │ │ ├── ResponseHandler.java │ │ │ └── impl │ │ │ ├── BaseResponseHandler.java │ │ │ └── GetConfigResponseHandler.java │ │ ├── initialize │ │ └── BrokerSupportInitializer.java │ │ ├── request │ │ ├── Request.java │ │ └── impl │ │ │ ├── AttachRequest.java │ │ │ ├── BaseRequest.java │ │ │ ├── DetachRequest.java │ │ │ ├── FilterLogPointsRequest.java │ │ │ ├── FilterTracePointsRequest.java │ │ │ ├── GetConfigRequest.java │ │ │ └── UpdateConfigRequest.java │ │ ├── response │ │ ├── MutableResponse.java │ │ ├── Response.java │ │ └── impl │ │ │ ├── AttachResponse.java │ │ │ ├── BaseResponse.java │ │ │ ├── DetachResponse.java │ │ │ ├── ErrorResponse.java │ │ │ ├── GetConfigResponse.java │ │ │ └── UpdateConfigResponse.java │ │ └── support │ │ └── BaseProbeSupport.java │ └── resources │ └── META-INF │ └── services │ ├── com.runsidekick.agent.broker.handler.request.RequestHandler │ ├── com.runsidekick.agent.broker.handler.response.ResponseHandler │ └── com.runsidekick.agent.core.initialize.EnvironmentInitializer ├── sidekick-agent-core ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── runsidekick │ │ │ └── agent │ │ │ └── core │ │ │ ├── SidekickSupport.java │ │ │ ├── app │ │ │ ├── Application.java │ │ │ ├── ApplicationInfo.java │ │ │ ├── ApplicationInfoProvider.java │ │ │ └── impl │ │ │ │ ├── DelegatedApplicationInfoProvider.java │ │ │ │ ├── PropertyAwareApplicationInfoProvider.java │ │ │ │ ├── SimpleApplicationInfoProvider.java │ │ │ │ └── SuppliedApplicationInfoProvider.java │ │ │ ├── config │ │ │ └── ConfigProvider.java │ │ │ ├── entity │ │ │ ├── Activatable.java │ │ │ ├── Destroyable.java │ │ │ └── Ordered.java │ │ │ ├── factory │ │ │ ├── Factory.java │ │ │ ├── InstanceProviderAwareFactory.java │ │ │ └── PropertyAwareFactory.java │ │ │ ├── initialize │ │ │ ├── EnvironmentAsyncInitializer.java │ │ │ ├── EnvironmentInitializer.java │ │ │ └── EnvironmentInitializerManager.java │ │ │ ├── instance │ │ │ ├── InstanceAwareProxy.java │ │ │ ├── InstanceClassAwareProxy.java │ │ │ ├── InstanceCreator.java │ │ │ ├── InstanceDefinitionPathProvider.java │ │ │ ├── InstanceDiscovery.java │ │ │ ├── InstanceLoader.java │ │ │ ├── InstanceProvider.java │ │ │ ├── InstanceScope.java │ │ │ └── InstanceTypeAwareProxy.java │ │ │ ├── internal │ │ │ ├── FeatureChecker.java │ │ │ ├── LicenseKeyHelper.java │ │ │ └── LicenseKeyInfo.java │ │ │ ├── io │ │ │ └── TypeAwareJsonMapper.java │ │ │ ├── logger │ │ │ ├── LoggerFactory.java │ │ │ └── StdLogger.java │ │ │ ├── property │ │ │ ├── ClassPathAwarePropertyAccessor.java │ │ │ ├── CombinedPropertyAccessor.java │ │ │ ├── FileSystemAwarePropertyAccessor.java │ │ │ ├── FileUtils.java │ │ │ ├── MutablePropertyAccessor.java │ │ │ ├── ProfileProvider.java │ │ │ ├── PropertyAccessor.java │ │ │ ├── PropertyAccessorUtil.java │ │ │ ├── ProvidedPropertyAccessor.java │ │ │ ├── StandardPropertyAccessor.java │ │ │ ├── SystemEnvironmentAwarePropertyAccessor.java │ │ │ ├── SystemPropertyAwarePropertyAccessor.java │ │ │ ├── UserHomeAwarePropertyAccessor.java │ │ │ └── provider │ │ │ │ ├── PropertyProvider.java │ │ │ │ └── PropertyProviderManager.java │ │ │ ├── terminate │ │ │ ├── EnvironmentTerminator.java │ │ │ └── EnvironmentTerminatorManager.java │ │ │ └── util │ │ │ ├── ClassNameUtils.java │ │ │ ├── ClassUtils.java │ │ │ ├── EnvironmentUtils.java │ │ │ ├── EnvironmentVariableUtils.java │ │ │ ├── ExceptionUtils.java │ │ │ ├── ExecutorUtils.java │ │ │ ├── FileUtils.java │ │ │ ├── IOUtils.java │ │ │ ├── InstanceUtils.java │ │ │ ├── JsonUtils.java │ │ │ ├── PackageUtils.java │ │ │ ├── PropertyUtils.java │ │ │ ├── ReflectionUtils.java │ │ │ ├── StringUtils.java │ │ │ ├── ThreadUtils.java │ │ │ ├── executor │ │ │ ├── ManagedScheduledThreadPoolExecutor.java │ │ │ ├── ManagedThreadPoolExecutor.java │ │ │ └── SidekickExecutor.java │ │ │ ├── map │ │ │ ├── ConcurrentWeakMap.java │ │ │ └── WeakMap.java │ │ │ └── thread │ │ │ └── ManagedThread.java │ └── resources │ │ ├── sidekick.properties │ │ └── tinylog.properties │ └── test │ ├── java │ └── com │ │ └── runsidekick │ │ └── agent │ │ └── core │ │ ├── app │ │ ├── ApplicationInfoTest.java │ │ └── PropertyAwareApplicationInfoProviderTest.java │ │ ├── initialize │ │ ├── EnvironmentInitializerTest.java │ │ └── TestEnvironmentInitializer.java │ │ ├── instance │ │ ├── InstanceDiscoveryTest.java │ │ ├── InstanceProviderTest.java │ │ ├── TestDiscoveredInstance.java │ │ └── TestDiscoveredInstanceImpl.java │ │ ├── property │ │ ├── PropertyAccessorTest.java │ │ ├── PropertyAccessorTestUtil.java │ │ └── TestPropertyProvider.java │ │ └── test │ │ ├── BaseSidekickTest.java │ │ └── EnvironmentTestUtils.java │ └── resources │ ├── META-INF │ └── services │ │ ├── com.runsidekick.agent.core.initialize.EnvironmentInitializer │ │ ├── com.runsidekick.agent.core.instance.TestDiscoveredInstance │ │ └── com.runsidekick.agent.core.property.provider.PropertyProvider │ ├── test-testprofile.properties │ ├── test-testprofile.yml │ ├── test.properties │ └── test.yml ├── sidekick-agent-data-redaction ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── runsidekick │ └── agent │ └── dataredaction │ └── DataRedactionHelper.java ├── sidekick-agent-instrument ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── runsidekick │ │ └── agent │ │ └── instrument │ │ ├── Agent.java │ │ ├── AgentAware.java │ │ ├── Installer.java │ │ ├── InstrumentSupport.java │ │ └── internal │ │ └── InstrumentSupportInternal.java │ └── test │ └── java │ └── com │ └── runsidekick │ └── agent │ └── instrument │ └── InstrumentSupportTest.java ├── sidekick-agent-jdk-attach ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── runsidekick │ │ └── agent │ │ └── jdk │ │ └── attach │ │ └── JDKAttachSupport.java │ └── resources │ ├── com │ └── sun │ │ └── tools │ │ └── attach │ │ ├── AgentInitializationException.class │ │ ├── AgentLoadException.class │ │ ├── AttachNotSupportedException.class │ │ ├── AttachPermission.class │ │ ├── VirtualMachine.class │ │ ├── VirtualMachineDescriptor.class │ │ ├── package-info.class │ │ └── spi │ │ ├── AttachProvider.class │ │ └── package-info.class │ └── sun │ └── tools │ └── attach │ ├── BsdAttachProvider.class │ ├── BsdVirtualMachine$SocketInputStream.class │ ├── BsdVirtualMachine.class │ ├── HotSpotAttachProvider$HotSpotVirtualMachineDescriptor.class │ ├── HotSpotAttachProvider.class │ ├── HotSpotVirtualMachine.class │ ├── LinuxAttachProvider.class │ ├── LinuxVirtualMachine$SocketInputStream.class │ ├── LinuxVirtualMachine.class │ ├── MacosxAttachProvider.class │ ├── MacosxVirtualMachine$SocketInputStream.class │ ├── MacosxVirtualMachine.class │ ├── OperatingSystemAwareAttachProvider.class │ ├── SolarisAttachProvider.class │ ├── SolarisVirtualMachine$SocketInputStream.class │ ├── SolarisVirtualMachine.class │ ├── WindowsAttachProvider.class │ ├── WindowsVirtualMachine$PipedInputStream.class │ └── WindowsVirtualMachine.class ├── sidekick-agent-logpoint ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── runsidekick │ │ │ └── agent │ │ │ └── logpoint │ │ │ ├── LogPointSupport.java │ │ │ ├── api │ │ │ └── LogPointAPIServiceImpl.java │ │ │ ├── application │ │ │ └── ApplicationStatusLogPointProvider.java │ │ │ ├── domain │ │ │ └── LogPoint.java │ │ │ ├── error │ │ │ └── LogPointErrorCodes.java │ │ │ ├── event │ │ │ ├── LogPointEvent.java │ │ │ └── LogPointFailedEvent.java │ │ │ ├── expression │ │ │ └── execute │ │ │ │ ├── LogPointExpressionExecutor.java │ │ │ │ └── impl │ │ │ │ ├── MustacheExpressionExecutor.java │ │ │ │ └── SpelExpressionExecutor.java │ │ │ ├── handler │ │ │ ├── request │ │ │ │ ├── BaseLogPointRequestHandler.java │ │ │ │ ├── DisableLogPointRequestHandler.java │ │ │ │ ├── EnableLogPointRequestHandler.java │ │ │ │ ├── PutLogPointRequestHandler.java │ │ │ │ ├── RemoveBatchLogPointRequestHandler.java │ │ │ │ ├── RemoveLogPointRequestHandler.java │ │ │ │ └── UpdateLogPointRequestHandler.java │ │ │ └── response │ │ │ │ ├── BaseLogPointResponseHandler.java │ │ │ │ └── FilterLogPointsResponseHandler.java │ │ │ ├── initialize │ │ │ └── LogPointSupportInitializer.java │ │ │ ├── internal │ │ │ ├── LogPointAction.java │ │ │ ├── LogPointContext.java │ │ │ ├── LogPointExpireTask.java │ │ │ └── LogPointManager.java │ │ │ ├── request │ │ │ ├── DisableLogPointRequest.java │ │ │ ├── EnableLogPointRequest.java │ │ │ ├── PutLogPointRequest.java │ │ │ ├── RemoveBatchLogPointRequest.java │ │ │ ├── RemoveLogPointRequest.java │ │ │ └── UpdateLogPointRequest.java │ │ │ └── response │ │ │ ├── DisableLogPointResponse.java │ │ │ ├── EnableLogPointResponse.java │ │ │ ├── FilterLogPointsResponse.java │ │ │ ├── PutLogPointResponse.java │ │ │ ├── RemoveBatchLogPointResponse.java │ │ │ ├── RemoveLogPointResponse.java │ │ │ └── UpdateLogPointResponse.java │ └── resources │ │ └── META-INF │ │ └── services │ │ ├── com.runsidekick.agent.broker.application.ApplicationStatusProvider │ │ ├── com.runsidekick.agent.broker.handler.request.RequestHandler │ │ ├── com.runsidekick.agent.broker.handler.response.ResponseHandler │ │ └── com.runsidekick.agent.core.initialize.EnvironmentInitializer │ └── test │ └── java │ └── com │ └── runsidekick │ └── agent │ └── logpoint │ ├── App.java │ ├── CollectionTest.java │ ├── Hello.java │ ├── Item.java │ ├── MustacheTests.java │ ├── ObjectTest.java │ └── SpelTests.java ├── sidekick-agent-probe-tag ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── runsidekick │ │ │ └── agent │ │ │ └── probetag │ │ │ ├── handler │ │ │ └── request │ │ │ │ ├── DisableProbeTagRequestHandler.java │ │ │ │ ├── EnableProbeTagRequestHandler.java │ │ │ │ └── RemoveProbeTagRequestHandler.java │ │ │ ├── request │ │ │ ├── DisableProbeTagRequest.java │ │ │ ├── EnableProbeTagRequest.java │ │ │ └── RemoveProbeTagRequest.java │ │ │ └── response │ │ │ ├── DisableProbeTagResponse.java │ │ │ ├── EnableProbeTagResponse.java │ │ │ └── RemoveProbeTagResponse.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── com.runsidekick.agent.broker.handler.request.RequestHandler │ └── test │ └── java │ └── com │ └── runsidekick │ └── agent │ └── probetag │ ├── App.java │ └── Hello.java ├── sidekick-agent-probe ├── pom.xml └── src │ ├── main │ ├── antlr4 │ │ └── com │ │ │ └── runsidekick │ │ │ └── agent │ │ │ └── probe │ │ │ └── condition │ │ │ └── parser │ │ │ └── Condition.g4 │ ├── java │ │ └── com │ │ │ └── runsidekick │ │ │ └── agent │ │ │ └── probe │ │ │ ├── ProbeBridge.java │ │ │ ├── ProbeSupport.java │ │ │ ├── condition │ │ │ ├── BinaryOperator.java │ │ │ ├── ComparisonOperator.java │ │ │ ├── CompositeCondition.java │ │ │ ├── Condition.java │ │ │ ├── ConditionContext.java │ │ │ ├── ConditionFactory.java │ │ │ ├── ConditionUtils.java │ │ │ ├── SingleCondition.java │ │ │ ├── VariableInfo.java │ │ │ ├── VariableInfoProvider.java │ │ │ ├── operand │ │ │ │ ├── BooleanOperand.java │ │ │ │ ├── CharacterOperand.java │ │ │ │ ├── NullOperand.java │ │ │ │ ├── NumberOperand.java │ │ │ │ ├── ObjectOperand.java │ │ │ │ ├── Operand.java │ │ │ │ ├── PlaceholderOperand.java │ │ │ │ ├── StringOperand.java │ │ │ │ ├── TypedOperand.java │ │ │ │ └── VariableOperand.java │ │ │ └── value │ │ │ │ ├── BasePlaceholderValueProvider.java │ │ │ │ ├── ConstantValueProvider.java │ │ │ │ ├── PlaceholderValueProvider.java │ │ │ │ ├── TypeAwareValueProvider.java │ │ │ │ ├── ValueProvider.java │ │ │ │ └── VariableValueProvider.java │ │ │ ├── domain │ │ │ ├── ClassType.java │ │ │ ├── MutableProbe.java │ │ │ ├── Probe.java │ │ │ ├── ProbeAction.java │ │ │ ├── ProbeContext.java │ │ │ ├── ProbeMetadata.java │ │ │ ├── Variable.java │ │ │ └── impl │ │ │ │ ├── BaseProbe.java │ │ │ │ ├── ConditionAwareProbeAction.java │ │ │ │ ├── DelegatedProbeAction.java │ │ │ │ ├── ExpiringProbeAction.java │ │ │ │ └── RateLimitedProbeAction.java │ │ │ ├── error │ │ │ └── ProbeErrorCodes.java │ │ │ ├── event │ │ │ ├── ProbeActionFailedEvent.java │ │ │ └── ProbeRateLimitEvent.java │ │ │ ├── initialize │ │ │ └── ProbeSupportInitializer.java │ │ │ ├── internal │ │ │ ├── ClassProbes.java │ │ │ ├── ConditionHelper.java │ │ │ ├── InternalProbe.java │ │ │ ├── LocalVarMetadata.java │ │ │ ├── MethodProbes.java │ │ │ └── ProbeManager.java │ │ │ ├── ratelimit │ │ │ ├── RateLimitResult.java │ │ │ └── RateLimiter.java │ │ │ ├── serialization │ │ │ ├── DeserializationHelper.java │ │ │ ├── JsonWriter.java │ │ │ ├── ManagedJsonFactory.java │ │ │ ├── ManagedJsonGenerator.java │ │ │ ├── ManagedJsonWriteContext.java │ │ │ └── SerializationHelper.java │ │ │ ├── sourcecode │ │ │ ├── SourceCode.java │ │ │ ├── SourceCodeContent.java │ │ │ ├── SourceCodeSupport.java │ │ │ ├── SourceCodeType.java │ │ │ └── provider │ │ │ │ ├── ClassPathSourceCodeProvider.java │ │ │ │ ├── RootPathSourceCodeProvider.java │ │ │ │ └── SourceCodeProvider.java │ │ │ └── util │ │ │ ├── ClassUtils.java │ │ │ ├── GitHelper.java │ │ │ └── ProbeUtils.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── com.runsidekick.agent.core.initialize.EnvironmentInitializer │ └── test │ └── java │ └── com │ └── runsidekick │ └── agent │ └── probe │ ├── serialization │ └── DeserializationTest.java │ └── util │ └── ClassUtilsTest.java └── sidekick-agent-tracepoint ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── runsidekick │ │ └── agent │ │ └── tracepoint │ │ ├── TracePointSupport.java │ │ ├── api │ │ └── TracePointAPIServiceImpl.java │ │ ├── application │ │ └── ApplicationStatusTracePointProvider.java │ │ ├── domain │ │ ├── Frame.java │ │ ├── LineInfo.java │ │ ├── TracePoint.java │ │ └── Variables.java │ │ ├── error │ │ └── TracePointErrorCodes.java │ │ ├── event │ │ ├── TracePointSnapshotEvent.java │ │ └── TracePointSnapshotFailedEvent.java │ │ ├── handler │ │ ├── request │ │ │ ├── BaseTracePointRequestHandler.java │ │ │ ├── DisableTracePointRequestHandler.java │ │ │ ├── EnableTracePointRequestHandler.java │ │ │ ├── PutTracePointRequestHandler.java │ │ │ ├── RemoveBatchTracePointRequestHandler.java │ │ │ ├── RemoveTracePointRequestHandler.java │ │ │ └── UpdateTracePointRequestHandler.java │ │ └── response │ │ │ ├── BaseTracePointResponseHandler.java │ │ │ └── FilterTracePointsResponseHandler.java │ │ ├── initialize │ │ └── TracePointSupportInitializer.java │ │ ├── internal │ │ ├── StackTraceProvider.java │ │ ├── TracePointAction.java │ │ ├── TracePointContext.java │ │ ├── TracePointExpireTask.java │ │ └── TracePointManager.java │ │ ├── request │ │ ├── DisableTracePointRequest.java │ │ ├── EnableTracePointRequest.java │ │ ├── PutTracePointRequest.java │ │ ├── RemoveBatchTracePointRequest.java │ │ ├── RemoveTracePointRequest.java │ │ └── UpdateTracePointRequest.java │ │ ├── response │ │ ├── DisableTracePointResponse.java │ │ ├── EnableTracePointResponse.java │ │ ├── FilterTracePointsResponse.java │ │ ├── PutTracePointResponse.java │ │ ├── RemoveBatchTracePointResponse.java │ │ ├── RemoveTracePointResponse.java │ │ └── UpdateTracePointResponse.java │ │ └── trace │ │ ├── TraceContext.java │ │ └── TraceSupport.java └── resources │ └── META-INF │ └── services │ ├── com.runsidekick.agent.broker.application.ApplicationStatusProvider │ ├── com.runsidekick.agent.broker.handler.request.RequestHandler │ ├── com.runsidekick.agent.broker.handler.response.ResponseHandler │ └── com.runsidekick.agent.core.initialize.EnvironmentInitializer └── test └── java └── com └── runsidekick └── agent └── tracepoint ├── App.java ├── Hello.java └── condition └── ConditionTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | pom.xml.tag 3 | pom.xml.releaseBackup 4 | pom.xml.versionsBackup 5 | pom.xml.next 6 | release.properties 7 | dependency-reduced-pom.xml 8 | buildNumber.properties 9 | .mvn/timing.properties 10 | # https://github.com/takari/maven-wrapper#usage-without-binary-jar 11 | .mvn/wrapper/maven-wrapper.jar 12 | .idea 13 | -------------------------------------------------------------------------------- /sidekick-agent-all/src/main/java/com/runsidekick/agent/all/AgentSupport.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.all; 2 | 3 | import com.runsidekick.agent.core.logger.LoggerFactory; 4 | import com.runsidekick.agent.core.util.PropertyUtils; 5 | import com.runsidekick.agent.core.util.StringUtils; 6 | import org.slf4j.Logger; 7 | 8 | /** 9 | * Support class for agent related stuff. 10 | * 11 | * @author serkan 12 | */ 13 | public final class AgentSupport { 14 | 15 | private static final Logger LOGGER = LoggerFactory.getLogger(AgentSupport.class); 16 | 17 | private static boolean initialized = false; 18 | 19 | public synchronized static void ensureInitialized() { 20 | if (!initialized) { 21 | doInitialize(); 22 | initialized = true; 23 | } 24 | } 25 | 26 | private static void doInitialize() { 27 | String apiKey = PropertyUtils.getApiKey(); 28 | boolean hasApiKey = StringUtils.hasValue(apiKey); 29 | 30 | if (!hasApiKey) { 31 | LOGGER.warn("API key is not set, so no monitoring data will be reported"); 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /sidekick-agent-all/src/main/java/com/runsidekick/agent/all/initialize/AgentSupportInitializer.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.all.initialize; 2 | 3 | import com.runsidekick.agent.all.AgentSupport; 4 | import com.runsidekick.agent.core.initialize.EnvironmentInitializer; 5 | 6 | /** 7 | * {@link EnvironmentInitializer} implementation for initialization 8 | * of Sidekick agent. 9 | * 10 | * @author serkan 11 | */ 12 | public class AgentSupportInitializer implements EnvironmentInitializer { 13 | 14 | @Override 15 | public void initialize() { 16 | AgentSupport.ensureInitialized(); 17 | } 18 | 19 | @Override 20 | public int order() { 21 | return HIGHEST; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /sidekick-agent-all/src/main/resources/META-INF/services/com.runsidekick.agent.core.initialize.EnvironmentInitializer: -------------------------------------------------------------------------------- 1 | com.runsidekick.agent.all.initialize.AgentSupportInitializer -------------------------------------------------------------------------------- /sidekick-agent-api-broker/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | com.runsidekick.agent 7 | sidekick-agent-parent 8 | 0.0.19-SNAPSHOT 9 | 10 | 11 | com.runsidekick.agent 12 | sidekick-agent-api-broker 13 | sidekick-agent-trace-broker 14 | 15 | 16 | -------------------------------------------------------------------------------- /sidekick-agent-api-broker/src/main/java/com/runsidekick/agent/api/broker/publisher/EventPublisher.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.api.broker.publisher; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public interface EventPublisher { 7 | 8 | void publishEvent(String eventJson); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /sidekick-agent-api-broker/src/main/java/com/runsidekick/agent/api/broker/publisher/RequestPublisher.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.api.broker.publisher; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public interface RequestPublisher { 7 | 8 | void publishRequest(String requestJson); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /sidekick-agent-api-data-redaction/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | sidekick-agent-parent 5 | com.runsidekick.agent 6 | 0.0.19-SNAPSHOT 7 | 8 | 4.0.0 9 | 10 | com.runsidekick.agent 11 | sidekick-agent-api-data-redaction 12 | sidekick-agent-api-data-redaction 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /sidekick-agent-api-data-redaction/src/main/java/com/runsidekick/agent/api/dataredaction/DataRedactionContext.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.api.dataredaction; 2 | 3 | /** 4 | * @author yasin.kalafat 5 | */ 6 | public class DataRedactionContext { 7 | 8 | private final Class clazz; 9 | private final String fileName; 10 | private final String className; 11 | private final int lineNo; 12 | private final String methodName; 13 | 14 | public DataRedactionContext(Class clazz, String fileName, String className, int lineNo, String methodName) { 15 | this.clazz = clazz; 16 | this.className = className; 17 | this.fileName = fileName; 18 | this.lineNo = lineNo; 19 | this.methodName = methodName; 20 | } 21 | 22 | public Class getClazz() { 23 | return clazz; 24 | } 25 | 26 | public String getFileName() { 27 | return fileName; 28 | } 29 | 30 | public String getClassName() { 31 | return className; 32 | } 33 | 34 | public int getLineNo() { 35 | return lineNo; 36 | } 37 | 38 | public String getMethodName() { 39 | return methodName; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /sidekick-agent-api-data-redaction/src/main/java/com/runsidekick/agent/api/dataredaction/SidekickDataRedactionAPI.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.api.dataredaction; 2 | 3 | /** 4 | * @author yasin.kalafat 5 | */ 6 | public interface SidekickDataRedactionAPI { 7 | 8 | default String redactLogMessage(DataRedactionContext dataRedactionContext, 9 | String logExpression, String logMessage) { 10 | return logMessage; 11 | } 12 | 13 | boolean shouldRedactVariable(DataRedactionContext dataRedactionContext, String fieldName); 14 | } 15 | -------------------------------------------------------------------------------- /sidekick-agent-api-logpoint/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | com.runsidekick.agent 7 | sidekick-agent-parent 8 | 0.0.19-SNAPSHOT 9 | 10 | 11 | com.runsidekick.agent 12 | sidekick-agent-api-logpoint 13 | sidekick-agent-api-logpoint 14 | 15 | 16 | 17 | com.runsidekick.agent 18 | sidekick-agent-api-broker 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /sidekick-agent-api-logpoint/src/main/java/com/runsidekick/agent/api/logpoint/LogPointAPIService.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.api.logpoint; 2 | 3 | import com.runsidekick.agent.api.broker.publisher.EventPublisher; 4 | 5 | import java.util.Set; 6 | 7 | /** 8 | * @author yasin 9 | */ 10 | public interface LogPointAPIService { 11 | 12 | EventPublisher getEventPublisher(); 13 | 14 | void setEventPublisher(EventPublisher eventPublisher); 15 | 16 | String putLogPoint(String className, int lineNo, String client, String logExpression, 17 | String fileHash, String conditionExpression, int expireSecs, int expireCount, 18 | boolean stdoutEnabled, String logLevel, boolean disable, Set tags); 19 | 20 | void updateLogPoint(String id, String client, String logExpression, 21 | String conditionExpression, int expireSecs, int expireCount, boolean disable, 22 | boolean stdoutEnabled, String logLevel, Set tags); 23 | 24 | void removeLogPoint(String id, String client); 25 | 26 | void enableLogPoint(String id, String client); 27 | 28 | void disableLogPoint(String id, String client); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /sidekick-agent-api-tracepoint-integrations-junit4/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | com.runsidekick.agent 7 | sidekick-agent-parent 8 | 0.0.19-SNAPSHOT 9 | 10 | 11 | com.runsidekick.agent 12 | sidekick-agent-api-tracepoint-integrations-junit4 13 | sidekick-agent-trace-tracepoint-integrations-junit4 14 | 15 | 16 | 17 | com.runsidekick.agent 18 | sidekick-agent-api-tracepoint 19 | 20 | 21 | junit 22 | junit 23 | provided 24 | true 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /sidekick-agent-api-tracepoint-integrations-junit5/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | com.runsidekick.agent 7 | sidekick-agent-parent 8 | 0.0.19-SNAPSHOT 9 | 10 | 11 | com.runsidekick.agent 12 | sidekick-agent-api-tracepoint-integrations-junit5 13 | sidekick-agent-trace-tracepoint-integrations-junit5 14 | 15 | 16 | 5.7.1 17 | 18 | 19 | 20 | 21 | com.runsidekick.agent 22 | sidekick-agent-api-tracepoint 23 | 24 | 25 | org.junit.jupiter 26 | junit-jupiter 27 | ${junit5.jupiter.version} 28 | provided 29 | true 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /sidekick-agent-api-tracepoint/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | com.runsidekick.agent 7 | sidekick-agent-parent 8 | 0.0.19-SNAPSHOT 9 | 10 | 11 | com.runsidekick.agent 12 | sidekick-agent-api-tracepoint 13 | sidekick-agent-trace-tracepoint 14 | 15 | 16 | 17 | com.runsidekick.agent 18 | sidekick-agent-api-broker 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /sidekick-agent-api-tracepoint/src/main/java/com/runsidekick/agent/api/tracepoint/TracePointAPIService.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.api.tracepoint; 2 | 3 | import com.runsidekick.agent.api.broker.publisher.EventPublisher; 4 | 5 | import java.util.Set; 6 | 7 | /** 8 | * @author serkan 9 | */ 10 | public interface TracePointAPIService { 11 | 12 | EventPublisher getEventPublisher(); 13 | void setEventPublisher(EventPublisher eventPublisher); 14 | 15 | String putTracePoint(String className, int lineNo, String client, 16 | String fileHash, String conditionExpression, int expireSecs, int expireCount, 17 | boolean enableTracing, boolean disable, Set tags); 18 | void updateTracePoint(String id, String client, 19 | String conditionExpression, int expireSecs, int expireCount, 20 | boolean enableTracing, boolean disable, Set tags); 21 | void removeTracePoint(String id, String client); 22 | void enableTracePoint(String id, String client); 23 | void disableTracePoint(String id, String client); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /sidekick-agent-broker/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | com.runsidekick.agent 7 | sidekick-agent-parent 8 | 0.0.19-SNAPSHOT 9 | 10 | 11 | com.runsidekick.agent 12 | sidekick-agent-broker 13 | sidekick-agent-broker 14 | 15 | 16 | 17 | com.runsidekick.agent 18 | sidekick-agent-core 19 | 20 | 21 | com.runsidekick.agent 22 | sidekick-agent-api-broker 23 | 24 | 25 | com.fasterxml.jackson.module 26 | jackson-module-afterburner 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/BrokerMessageCallback.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker; 2 | 3 | import com.runsidekick.agent.broker.client.BrokerClient; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public interface BrokerMessageCallback { 9 | 10 | void onMessage(BrokerClient brokerClient, byte[] message); 11 | 12 | void onMessage(BrokerClient brokerClient, String message); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/application/ApplicationStatusProvider.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.application; 2 | 3 | import com.runsidekick.agent.broker.domain.ApplicationStatus; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public interface ApplicationStatusProvider { 9 | 10 | void provide(ApplicationStatus applicationStatus, String client); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/client/BrokerClient.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.client; 2 | 3 | import java.io.IOException; 4 | import java.util.concurrent.TimeUnit; 5 | 6 | /** 7 | * @author serkan 8 | */ 9 | public interface BrokerClient { 10 | 11 | void send(String msg) throws IOException; 12 | void send(byte[] msg) throws IOException; 13 | void send(byte[] msg, int off, int len) throws IOException; 14 | 15 | void sendCloseMessage(int code, String reason) throws IOException; 16 | 17 | void close(); 18 | 19 | boolean isClosed(); 20 | 21 | boolean waitUntilClosed(); 22 | boolean waitUntilClosed(long timeout, TimeUnit unit); 23 | 24 | void destroy(); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/client/BrokerClientFactory.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.client; 2 | 3 | import com.runsidekick.agent.broker.BrokerCredentials; 4 | import com.runsidekick.agent.broker.BrokerMessageCallback; 5 | import com.runsidekick.agent.broker.client.impl.OkHttpWebSocketBrokerClient; 6 | 7 | import java.util.concurrent.CompletableFuture; 8 | 9 | /** 10 | * @author serkan 11 | */ 12 | public final class BrokerClientFactory { 13 | 14 | private BrokerClientFactory() { 15 | } 16 | 17 | public static BrokerClient createWebSocketClient(String host, int port, 18 | BrokerCredentials brokerCredentials, 19 | BrokerMessageCallback brokerMessageCallback, 20 | CompletableFuture connectedFuture, 21 | CompletableFuture closedFuture) throws Exception { 22 | return new OkHttpWebSocketBrokerClient( 23 | host, port, brokerCredentials, 24 | brokerMessageCallback, null, connectedFuture, closedFuture); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/client/BrokerClientHandshakeException.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.client; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public class BrokerClientHandshakeException extends IOException { 9 | 10 | public BrokerClientHandshakeException() { 11 | super(); 12 | } 13 | 14 | public BrokerClientHandshakeException(String message) { 15 | super(message); 16 | } 17 | 18 | public BrokerClientHandshakeException(String message, Throwable cause) { 19 | super(message, cause); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/error/CodedError.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.error; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public interface CodedError { 7 | 8 | int getCode(); 9 | String getMessageTemplate(); 10 | String formatMessage(Object... args); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/error/CodedException.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.error; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public class CodedException extends RuntimeException { 7 | 8 | private final int code; 9 | 10 | public CodedException(int code, String message) { 11 | super(message); 12 | this.code = code; 13 | } 14 | 15 | public CodedException(int code, String message, Throwable cause) { 16 | super(message, cause); 17 | this.code = code; 18 | } 19 | 20 | public CodedException(CodedError codedError, Object... args) { 21 | super(codedError.formatMessage(args)); 22 | this.code = codedError.getCode(); 23 | } 24 | 25 | public CodedException(CodedError codedError, Throwable cause, Object... args) { 26 | super(codedError.formatMessage(args), cause); 27 | this.code = codedError.getCode(); 28 | } 29 | 30 | public int getCode() { 31 | return code; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/error/CommonErrorCodes.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.error; 2 | 3 | import com.runsidekick.agent.broker.error.impl.SimpleCodedError; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public interface CommonErrorCodes { 9 | 10 | CodedError UNKNOWN = new SimpleCodedError(0, "Unknown"); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/error/impl/SimpleCodedError.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.error.impl; 2 | 3 | import com.runsidekick.agent.broker.error.CodedError; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public class SimpleCodedError implements CodedError { 9 | 10 | protected final int code; 11 | protected final String messageTemplate; 12 | 13 | public SimpleCodedError(int code, String messageTemplate) { 14 | this.code = code; 15 | this.messageTemplate = messageTemplate; 16 | } 17 | 18 | public int getCode() { 19 | return code; 20 | } 21 | 22 | @Override 23 | public String getMessageTemplate() { 24 | return messageTemplate; 25 | } 26 | 27 | @Override 28 | public String formatMessage(Object... args) { 29 | return String.format(messageTemplate, args); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/event/Event.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.event; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public interface Event { 7 | 8 | default String getType() { 9 | return "Event"; 10 | } 11 | 12 | String getName(); 13 | 14 | String getId(); 15 | 16 | boolean isSendAck(); 17 | 18 | String getClient(); 19 | 20 | long getTime(); 21 | 22 | String getHostName(); 23 | 24 | String getApplicationName(); 25 | 26 | String getApplicationInstanceId(); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/event/MutableEvent.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.event; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public interface MutableEvent extends Event { 7 | 8 | void setId(String id); 9 | 10 | void setClient(String client); 11 | 12 | void setTime(long time); 13 | 14 | void setHostName(String hostName); 15 | 16 | void setApplicationName(String applicationName); 17 | 18 | void setApplicationInstanceId(String applicationInstanceId); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/event/impl/ApplicationStatusEvent.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.event.impl; 2 | 3 | import com.runsidekick.agent.broker.domain.ApplicationStatus; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public class ApplicationStatusEvent extends BaseEvent { 9 | 10 | private final ApplicationStatus application; 11 | 12 | public ApplicationStatusEvent(ApplicationStatus application) { 13 | this.application = application; 14 | } 15 | 16 | public ApplicationStatusEvent(ApplicationStatus application, String client) { 17 | this.application = application; 18 | this.client = client; 19 | } 20 | 21 | public ApplicationStatus getApplication() { 22 | return application; 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return "ApplicationStatusEvent{" + 28 | "application=" + application + 29 | ", id='" + id + '\'' + 30 | ", sendAck=" + sendAck + 31 | ", client='" + client + '\'' + 32 | ", time=" + time + 33 | ", hostName='" + hostName + '\'' + 34 | ", applicationName='" + applicationName + '\'' + 35 | ", applicationInstanceId='" + applicationInstanceId + '\'' + 36 | '}'; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/handler/request/RequestHandler.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.handler.request; 2 | 3 | import com.runsidekick.agent.broker.request.Request; 4 | import com.runsidekick.agent.broker.response.Response; 5 | 6 | /** 7 | * @author serkan 8 | */ 9 | public interface RequestHandler { 10 | 11 | String getRequestName(); 12 | Class getRequestClass(); 13 | Class getResponseClass(); 14 | 15 | Res handleRequest(Req request); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/handler/request/impl/AttachRequestHandler.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.handler.request.impl; 2 | 3 | import com.runsidekick.agent.broker.BrokerManager; 4 | import com.runsidekick.agent.broker.request.impl.AttachRequest; 5 | import com.runsidekick.agent.broker.response.impl.AttachResponse; 6 | 7 | /** 8 | * @author yasin.kalafat 9 | */ 10 | public class AttachRequestHandler extends BaseRequestHandler { 11 | 12 | public static final String REQUEST_NAME = "AttachRequest"; 13 | 14 | public AttachRequestHandler() { 15 | super(REQUEST_NAME, AttachRequest.class, AttachResponse.class); 16 | } 17 | 18 | @Override 19 | public AttachResponse handleRequest(AttachRequest request) { 20 | try { 21 | BrokerManager.attach(); 22 | 23 | BrokerManager.publishApplicationStatus(); 24 | if (request.getClient() != null) { 25 | BrokerManager.publishApplicationStatus(request.getClient()); 26 | } 27 | return new AttachResponse(). 28 | setRequestId(request.getId()). 29 | setClient(request.getClient()); 30 | } catch (Throwable error) { 31 | return new AttachResponse(). 32 | setRequestId(request.getId()). 33 | setClient(request.getClient()). 34 | setError(error); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/handler/request/impl/BaseRequestHandler.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.handler.request.impl; 2 | 3 | import com.runsidekick.agent.broker.request.Request; 4 | import com.runsidekick.agent.broker.response.Response; 5 | import com.runsidekick.agent.broker.handler.request.RequestHandler; 6 | import org.slf4j.Logger; 7 | import com.runsidekick.agent.core.logger.LoggerFactory; 8 | 9 | /** 10 | * @author serkan 11 | */ 12 | public abstract class BaseRequestHandler 13 | implements RequestHandler { 14 | 15 | protected final Logger logger = LoggerFactory.getLogger(getClass()); 16 | 17 | protected final String requestName; 18 | protected final Class requestClass; 19 | protected final Class responseClass; 20 | 21 | public BaseRequestHandler(String requestName, Class requestClass, Class responseClass) { 22 | this.requestName = requestName; 23 | this.requestClass = requestClass; 24 | this.responseClass = responseClass; 25 | } 26 | 27 | @Override 28 | public String getRequestName() { 29 | return requestName; 30 | } 31 | 32 | @Override 33 | public Class getRequestClass() { 34 | return requestClass; 35 | } 36 | 37 | @Override 38 | public Class getResponseClass() { 39 | return responseClass; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/handler/request/impl/DetachRequestHandler.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.handler.request.impl; 2 | 3 | import com.runsidekick.agent.broker.BrokerManager; 4 | import com.runsidekick.agent.broker.request.impl.DetachRequest; 5 | import com.runsidekick.agent.broker.response.impl.DetachResponse; 6 | 7 | /** 8 | * @author yasin.kalafat 9 | */ 10 | public class DetachRequestHandler extends BaseRequestHandler { 11 | 12 | public static final String REQUEST_NAME = "DetachRequest"; 13 | 14 | public DetachRequestHandler() { 15 | super(REQUEST_NAME, DetachRequest.class, DetachResponse.class); 16 | } 17 | 18 | @Override 19 | public DetachResponse handleRequest(DetachRequest request) { 20 | try { 21 | BrokerManager.detach(); 22 | return new DetachResponse(). 23 | setRequestId(request.getId()). 24 | setClient(request.getClient()); 25 | } catch (Throwable error) { 26 | return new DetachResponse(). 27 | setRequestId(request.getId()). 28 | setClient(request.getClient()). 29 | setError(error); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/handler/request/impl/UpdateConfigRequestHandler.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.handler.request.impl; 2 | 3 | import com.runsidekick.agent.broker.request.impl.UpdateConfigRequest; 4 | import com.runsidekick.agent.broker.response.impl.UpdateConfigResponse; 5 | 6 | /** 7 | * @author yasin.kalafat 8 | */ 9 | public class UpdateConfigRequestHandler extends BaseRequestHandler { 10 | 11 | public static final String REQUEST_NAME = "UpdateConfigRequest"; 12 | 13 | public UpdateConfigRequestHandler() { 14 | super(REQUEST_NAME, UpdateConfigRequest.class, UpdateConfigResponse.class); 15 | } 16 | 17 | @Override 18 | public UpdateConfigResponse handleRequest(UpdateConfigRequest request) { 19 | return null; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/handler/response/ResponseHandler.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.handler.response; 2 | 3 | import com.runsidekick.agent.broker.response.Response; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public interface ResponseHandler { 9 | 10 | String getResponseName(); 11 | 12 | Class getResponseClass(); 13 | 14 | void handleResponse(Res response); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/handler/response/impl/BaseResponseHandler.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.handler.response.impl; 2 | 3 | import com.runsidekick.agent.broker.handler.response.ResponseHandler; 4 | import com.runsidekick.agent.broker.response.Response; 5 | import org.slf4j.Logger; 6 | import com.runsidekick.agent.core.logger.LoggerFactory; 7 | 8 | /** 9 | * @author serkan 10 | */ 11 | public abstract class BaseResponseHandler 12 | implements ResponseHandler { 13 | 14 | protected final Logger logger = LoggerFactory.getLogger(getClass()); 15 | 16 | protected final String responseName; 17 | protected final Class responseClass; 18 | 19 | public BaseResponseHandler(String responseName, Class responseClass) { 20 | this.responseName = responseName; 21 | this.responseClass = responseClass; 22 | } 23 | 24 | @Override 25 | public String getResponseName() { 26 | return responseName; 27 | } 28 | 29 | 30 | @Override 31 | public Class getResponseClass() { 32 | return responseClass; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/handler/response/impl/GetConfigResponseHandler.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.handler.response.impl; 2 | 3 | import com.runsidekick.agent.broker.response.impl.GetConfigResponse; 4 | import com.runsidekick.agent.core.config.ConfigProvider; 5 | 6 | /** 7 | * @author yasin.kalafat 8 | */ 9 | public class GetConfigResponseHandler extends BaseResponseHandler { 10 | 11 | public static final String RESPONSE_NAME = "GetConfigResponse"; 12 | 13 | public GetConfigResponseHandler() { 14 | super(RESPONSE_NAME, GetConfigResponse.class); 15 | } 16 | 17 | @Override 18 | public void handleResponse(GetConfigResponse response) { 19 | ConfigProvider.setConfig(response.getConfig()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/initialize/BrokerSupportInitializer.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.initialize; 2 | 3 | import com.runsidekick.agent.broker.BrokerManager; 4 | import com.runsidekick.agent.core.initialize.EnvironmentInitializer; 5 | 6 | /** 7 | * @author serkan 8 | */ 9 | public class BrokerSupportInitializer implements EnvironmentInitializer { 10 | 11 | @Override 12 | public void initialize() { 13 | BrokerManager.ensureInitialized(); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/request/Request.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.request; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public interface Request { 7 | 8 | default String getType() { 9 | return "Request"; 10 | } 11 | 12 | String getName(); 13 | 14 | String getId(); 15 | 16 | String getClient(); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/request/impl/AttachRequest.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.request.impl; 2 | 3 | /** 4 | * @author yasin.kalafat 5 | */ 6 | public class AttachRequest extends BaseRequest { 7 | } 8 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/request/impl/BaseRequest.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.request.impl; 2 | 3 | import com.runsidekick.agent.broker.request.Request; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public abstract class BaseRequest implements Request { 9 | 10 | protected String id; 11 | protected String client; 12 | 13 | @Override 14 | public String getName() { 15 | return getClass().getSimpleName(); 16 | } 17 | 18 | @Override 19 | public String getId() { 20 | return id; 21 | } 22 | 23 | public void setId(String id) { 24 | this.id = id; 25 | } 26 | 27 | @Override 28 | public String getClient() { 29 | return client; 30 | } 31 | 32 | public void setClient(String client) { 33 | this.client = client; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/request/impl/DetachRequest.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.request.impl; 2 | 3 | /** 4 | * @author yasin.kalafat 5 | */ 6 | public class DetachRequest extends BaseRequest { 7 | } 8 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/request/impl/GetConfigRequest.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.request.impl; 2 | 3 | /** 4 | * @author yasin.kalafat 5 | */ 6 | public class GetConfigRequest extends BaseRequest { 7 | } 8 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/request/impl/UpdateConfigRequest.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.request.impl; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * @author yasin.kalafat 7 | */ 8 | public class UpdateConfigRequest extends BaseRequest { 9 | 10 | private Map config; 11 | 12 | public Map getConfig() { 13 | return config; 14 | } 15 | 16 | public void setConfig(Map config) { 17 | this.config = config; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/response/MutableResponse.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.response; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public interface MutableResponse extends Response { 7 | 8 | R setRequestId(String requestId); 9 | 10 | R setClient(String client); 11 | 12 | R setApplicationName(String applicationName); 13 | R setApplicationInstanceId(String applicationInstanceId); 14 | 15 | R setErroneous(boolean erroneous); 16 | R setErrorCode(int errorCode); 17 | R setErrorMessage(String errorMessage); 18 | R setError(Throwable error); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/response/Response.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.response; 2 | 3 | import com.runsidekick.agent.core.util.EnvironmentUtils; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public interface Response { 9 | 10 | default String getType() { 11 | return "Response"; 12 | } 13 | 14 | default String getSource(){return "Agent";} 15 | 16 | default String getRuntime(){return "JVM-" + EnvironmentUtils.JVM_VERSION;} 17 | 18 | default String getAgentVersion(){return EnvironmentUtils.AGENT_VERSION;} 19 | 20 | String getName(); 21 | 22 | String getRequestId(); 23 | 24 | String getClient(); 25 | 26 | String getApplicationName(); 27 | String getApplicationInstanceId(); 28 | 29 | boolean isErroneous(); 30 | int getErrorCode(); 31 | String getErrorMessage(); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/response/impl/AttachResponse.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.response.impl; 2 | 3 | public class AttachResponse extends BaseResponse { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/response/impl/DetachResponse.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.response.impl; 2 | 3 | public class DetachResponse extends BaseResponse { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/response/impl/ErrorResponse.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.response.impl; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public class ErrorResponse extends BaseResponse { 7 | 8 | public ErrorResponse() { 9 | } 10 | 11 | public ErrorResponse(String requestId, String client, int errorCode, String errorMessage) { 12 | this.requestId = requestId; 13 | this.client = client; 14 | this.erroneous = true; 15 | this.errorCode = errorCode; 16 | this.errorMessage = errorMessage; 17 | } 18 | 19 | public ErrorResponse(String requestId, String client, Throwable error) { 20 | this.requestId = requestId; 21 | this.client = client; 22 | setError(error); 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return "ErrorResponse{" + 28 | "requestId='" + requestId + '\'' + 29 | ", client='" + client + '\'' + 30 | ", erroneous=" + erroneous + 31 | ", errorCode=" + errorCode + 32 | ", errorMessage='" + errorMessage + '\'' + 33 | '}'; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/response/impl/GetConfigResponse.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.response.impl; 2 | 3 | import java.util.Map; 4 | 5 | public class GetConfigResponse extends BaseResponse { 6 | 7 | private Map config; 8 | 9 | public Map getConfig() { 10 | return config; 11 | } 12 | 13 | public void setConfig(Map config) { 14 | this.config = config; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/response/impl/UpdateConfigResponse.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.response.impl; 2 | 3 | public class UpdateConfigResponse extends BaseResponse { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/java/com/runsidekick/agent/broker/support/BaseProbeSupport.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.broker.support; 2 | 3 | /** 4 | * @author yasin.kalafat 5 | */ 6 | public interface BaseProbeSupport { 7 | 8 | void detach(); 9 | } 10 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/resources/META-INF/services/com.runsidekick.agent.broker.handler.request.RequestHandler: -------------------------------------------------------------------------------- 1 | com.runsidekick.agent.broker.handler.request.impl.AttachRequestHandler 2 | com.runsidekick.agent.broker.handler.request.impl.DetachRequestHandler 3 | com.runsidekick.agent.broker.handler.request.impl.UpdateConfigRequestHandler 4 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/resources/META-INF/services/com.runsidekick.agent.broker.handler.response.ResponseHandler: -------------------------------------------------------------------------------- 1 | com.runsidekick.agent.broker.handler.response.impl.GetConfigResponseHandler 2 | -------------------------------------------------------------------------------- /sidekick-agent-broker/src/main/resources/META-INF/services/com.runsidekick.agent.core.initialize.EnvironmentInitializer: -------------------------------------------------------------------------------- 1 | com.runsidekick.agent.broker.initialize.BrokerSupportInitializer -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/app/Application.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.app; 2 | 3 | import com.runsidekick.agent.core.util.InstanceUtils; 4 | import com.runsidekick.agent.core.instance.InstanceScope; 5 | import com.runsidekick.agent.core.app.impl.DelegatedApplicationInfoProvider; 6 | import com.runsidekick.agent.core.app.impl.PropertyAwareApplicationInfoProvider; 7 | 8 | /** 9 | * Mediator class for common application related stuff. 10 | * 11 | * @author serkan 12 | */ 13 | public final class Application { 14 | 15 | private static final DelegatedApplicationInfoProvider delegatedApplicationInfoProvider = 16 | new DelegatedApplicationInfoProvider( 17 | InstanceUtils.getInstanceFromProperties( 18 | "sidekick.agent.application.application-info-provider-factory", 19 | "sidekick.agent.application.application-info-provider", 20 | InstanceScope.GLOBAL, 21 | new PropertyAwareApplicationInfoProvider())); 22 | 23 | private Application() { 24 | } 25 | 26 | public static ApplicationInfoProvider getApplicationInfoProvider() { 27 | return delegatedApplicationInfoProvider.getDelegatedApplicationInfoProvider(); 28 | } 29 | 30 | public static void setApplicationInfoProvider(ApplicationInfoProvider applicationInfoProvider) { 31 | delegatedApplicationInfoProvider.setDelegatedApplicationInfoProvider(applicationInfoProvider); 32 | } 33 | 34 | public static ApplicationInfo getApplicationInfo() { 35 | return delegatedApplicationInfoProvider.getApplicationInfo(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/app/ApplicationInfoProvider.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.app; 2 | 3 | import com.runsidekick.agent.core.util.EnvironmentUtils; 4 | 5 | /** 6 | * Interface to provide {@link ApplicationInfo} 7 | * which contains application specific information 8 | * such as application name, type, id, etc ... 9 | * 10 | * @author serkan 11 | */ 12 | public interface ApplicationInfoProvider { 13 | 14 | /** 15 | * Runtime of the application which represents JAVA runtime. 16 | */ 17 | String APPLICATION_RUNTIME = "java"; 18 | 19 | /** 20 | * Runtime version of the application which represents JVM version. 21 | */ 22 | String APPLICATION_RUNTIME_VERSION = EnvironmentUtils.JVM_VERSION; 23 | 24 | /** 25 | * Provides {@link ApplicationInfo}. 26 | * 27 | * @return the provided {@link ApplicationInfo} 28 | */ 29 | ApplicationInfo getApplicationInfo(); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/app/impl/DelegatedApplicationInfoProvider.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.app.impl; 2 | 3 | import com.runsidekick.agent.core.app.ApplicationInfo; 4 | import com.runsidekick.agent.core.app.ApplicationInfoProvider; 5 | 6 | /** 7 | * {@link ApplicationInfoProvider} implementation which delegates to 8 | * specified {@link ApplicationInfoProvider} instance. 9 | * 10 | * @author serkan 11 | */ 12 | public class DelegatedApplicationInfoProvider implements ApplicationInfoProvider { 13 | 14 | private volatile ApplicationInfoProvider delegatedApplicationInfoProvider; 15 | 16 | public DelegatedApplicationInfoProvider(ApplicationInfoProvider delegatedApplicationInfoProvider) { 17 | this.delegatedApplicationInfoProvider = delegatedApplicationInfoProvider; 18 | } 19 | 20 | public ApplicationInfoProvider getDelegatedApplicationInfoProvider() { 21 | return delegatedApplicationInfoProvider; 22 | } 23 | 24 | public void setDelegatedApplicationInfoProvider(ApplicationInfoProvider delegatedApplicationInfoProvider) { 25 | this.delegatedApplicationInfoProvider = delegatedApplicationInfoProvider; 26 | } 27 | 28 | @Override 29 | public ApplicationInfo getApplicationInfo() { 30 | ApplicationInfoProvider applicationInfoProvider = delegatedApplicationInfoProvider; 31 | if (applicationInfoProvider != null) { 32 | return applicationInfoProvider.getApplicationInfo(); 33 | } else { 34 | return null; 35 | } 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/app/impl/SuppliedApplicationInfoProvider.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.app.impl; 2 | 3 | import com.runsidekick.agent.core.app.ApplicationInfo; 4 | import com.runsidekick.agent.core.app.ApplicationInfoProvider; 5 | import com.runsidekick.agent.core.util.ExceptionUtils; 6 | 7 | import java.util.function.Supplier; 8 | 9 | /** 10 | * {@link ApplicationInfoProvider} implementation which provides 11 | * {@link ApplicationInfo application information} 12 | * by delegating to supplied {@link ApplicationInfoProvider}. 13 | * 14 | * @author serkan 15 | */ 16 | public class SuppliedApplicationInfoProvider implements ApplicationInfoProvider { 17 | 18 | private final Supplier appInfoProviderSupplier; 19 | 20 | public SuppliedApplicationInfoProvider(Supplier appInfoProviderSupplier) { 21 | this.appInfoProviderSupplier = appInfoProviderSupplier; 22 | } 23 | 24 | @Override 25 | public ApplicationInfo getApplicationInfo() { 26 | try { 27 | ApplicationInfoProvider applicationInfoProvider = appInfoProviderSupplier.get(); 28 | if (applicationInfoProvider != null) { 29 | return applicationInfoProvider.getApplicationInfo(); 30 | } 31 | } catch (Exception e) { 32 | ExceptionUtils.sneakyThrow(e); 33 | } 34 | return null; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/config/ConfigProvider.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.config; 2 | 3 | import com.runsidekick.agent.core.util.PropertyUtils; 4 | import com.runsidekick.agent.core.util.StringUtils; 5 | 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | import java.util.concurrent.ConcurrentHashMap; 9 | 10 | /** 11 | * @author yasin.kalafat 12 | */ 13 | public final class ConfigProvider { 14 | 15 | private static Map configMap = new ConcurrentHashMap<>(); 16 | 17 | private static Map configPropertyMapping = new HashMap() {{ 18 | put("sidekick.agent.tracepoint.stacktrace.maxdepth", "maxFrames"); 19 | put("sidekick.agent.tracepoint.serialization.array.length.max", "maxProperties"); 20 | put("sidekick.agent.tracepoint.serialization.depth.max", "maxParseDepth"); 21 | put("-", "maxExpandFrames"); 22 | put("errorCollectionEnable", "errorCollectionEnable"); 23 | put("errorCollectionEnableCaptureFrame", "errorCollectionEnableCaptureFrame"); 24 | }}; 25 | 26 | private ConfigProvider() { 27 | 28 | } 29 | 30 | public static Integer getIntegerProperty(String propName, int defaultPropValue) { 31 | if (configPropertyMapping.containsKey(propName)) { 32 | String key = configPropertyMapping.get(propName); 33 | if (configMap.containsKey(key)) { 34 | return Integer.valueOf(configMap.get(key).toString()); 35 | } 36 | } 37 | return defaultPropValue; 38 | } 39 | 40 | 41 | public static void setConfig(Map config) { 42 | configMap.clear(); 43 | if (config != null && config.size() > 0) { 44 | for (Map.Entry entry : config.entrySet()) { 45 | configMap.put(entry.getKey(), entry.getValue()); 46 | } 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/entity/Activatable.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.entity; 2 | 3 | /** 4 | * Interface for implementations which can be activated/deactivated. 5 | * 6 | * @author serkan 7 | */ 8 | public interface Activatable { 9 | 10 | /** 11 | * Returns activation status whether it is active. 12 | * 13 | * @return true if active, false otherwise 14 | */ 15 | boolean isActive(); 16 | 17 | /** 18 | * Activates. 19 | */ 20 | void activate(); 21 | 22 | /** 23 | * Deactivates. 24 | */ 25 | void deactivate(); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/entity/Destroyable.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.entity; 2 | 3 | /** 4 | * Interface to represent types which can be able to destroyed. 5 | * 6 | * @author serkan 7 | */ 8 | public interface Destroyable { 9 | 10 | /** 11 | * Triggers destroy. 12 | */ 13 | void destroy(); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/entity/Ordered.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.entity; 2 | 3 | /** 4 | * Interface to specify order. 5 | * 6 | * @author serkan 7 | */ 8 | public interface Ordered { 9 | 10 | /** 11 | * Represents lowest order. 12 | */ 13 | int LOWEST = Integer.MIN_VALUE; 14 | 15 | /** 16 | * Represents low order. 17 | */ 18 | int LOW = Integer.MIN_VALUE / 2; 19 | 20 | /** 21 | * Represents normal order. 22 | */ 23 | int NORMAL = 0; 24 | 25 | /** 26 | * Represents high order. 27 | */ 28 | int HIGH = Integer.MAX_VALUE / 2; 29 | 30 | /** 31 | * Represents highest order. 32 | */ 33 | int HIGHEST = Integer.MAX_VALUE; 34 | 35 | /** 36 | * Returns the order. 37 | * 38 | * @return the order 39 | */ 40 | default int order() { 41 | return NORMAL; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/factory/Factory.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.factory; 2 | 3 | /** 4 | * Interface for implementations which create instances. 5 | * 6 | * @param type of the created instances 7 | * 8 | * @author serkan 9 | */ 10 | public interface Factory { 11 | 12 | /** 13 | * Creates (or provides) and returns the requested instance. 14 | * 15 | * @return the requested instance 16 | */ 17 | T create(); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/factory/InstanceProviderAwareFactory.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.factory; 2 | 3 | import com.runsidekick.agent.core.instance.InstanceProvider; 4 | import com.runsidekick.agent.core.instance.InstanceScope; 5 | 6 | /** 7 | * {@link Factory} implementation which creates instances 8 | * through {@link InstanceProvider} by their {@link InstanceScope scope}s. 9 | * 10 | * @author serkan 11 | */ 12 | public class InstanceProviderAwareFactory implements Factory { 13 | 14 | private final Class type; 15 | private final InstanceScope scope; 16 | 17 | public InstanceProviderAwareFactory(Class type) { 18 | this(type, InstanceScope.GLOBAL); 19 | } 20 | 21 | public InstanceProviderAwareFactory(Class type, InstanceScope scope) { 22 | this.type = type; 23 | this.scope = scope; 24 | } 25 | 26 | @Override 27 | public T create() { 28 | return InstanceProvider.getInstance(type, scope); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/initialize/EnvironmentAsyncInitializer.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.initialize; 2 | 3 | import java.util.concurrent.CompletableFuture; 4 | 5 | /** 6 | * Interface for sub-types of {@link EnvironmentInitializer} which can be initialized asynchronously. 7 | * 8 | * @author serkan 9 | */ 10 | public interface EnvironmentAsyncInitializer extends EnvironmentInitializer { 11 | 12 | /** 13 | * Called before initialization. 14 | */ 15 | default void preInitializeAsync() { 16 | } 17 | 18 | /** 19 | * Executes initialization logic in async way. 20 | * 21 | * @return {@link CompletableFuture} future to check whether or not initialization has completed 22 | */ 23 | CompletableFuture initializeAsync(); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/initialize/EnvironmentInitializer.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.initialize; 2 | 3 | import com.runsidekick.agent.core.entity.Ordered; 4 | 5 | /** 6 | * Interface for types to be initialized on startup. 7 | * 8 | * @author serkan 9 | */ 10 | public interface EnvironmentInitializer extends Ordered { 11 | 12 | /** 13 | * Executes pre-initialization logic. 14 | */ 15 | default void preInitialize() { 16 | } 17 | 18 | /** 19 | * Executes initialization logic. 20 | */ 21 | void initialize(); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/instance/InstanceAwareProxy.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.instance; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public interface InstanceAwareProxy { 7 | 8 | Object getInstance(); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/instance/InstanceClassAwareProxy.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.instance; 2 | 3 | /** 4 | * Interface to represent proxies which are aware of 5 | * implementation {@link Class}es of the underlying proxied instances. 6 | * 7 | * @author serkan 8 | */ 9 | public interface InstanceClassAwareProxy { 10 | 11 | /** 12 | * Gets the implementation {@link Class} of the proxied instance. 13 | * 14 | * @return the implementation {@link Class} of the proxied instance 15 | */ 16 | Class getInstanceClass(); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/instance/InstanceCreator.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.instance; 2 | 3 | /** 4 | * Creates instances for given type. 5 | * 6 | * @author serkan 7 | */ 8 | public interface InstanceCreator { 9 | 10 | /** 11 | * Creates instances for given type. 12 | * 13 | * @param clazz {@link Class} of the instance to be created 14 | * @param generic type of the instance 15 | * @return the created instance 16 | */ 17 | T create(Class clazz); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/instance/InstanceDefinitionPathProvider.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.instance; 2 | 3 | import com.runsidekick.agent.core.entity.Ordered; 4 | 5 | /** 6 | * Interface for implementations which provide base path 7 | * for service definition files. 8 | * 9 | * @author serkan 10 | */ 11 | public interface InstanceDefinitionPathProvider extends Ordered { 12 | 13 | /** 14 | * Gets the path contains instance definition files. 15 | * 16 | * @return the path contains instance definition files 17 | * null if default path (META-INF/services/) 18 | * should be used 19 | */ 20 | String getPath(); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/instance/InstanceLoader.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.instance; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public interface InstanceLoader { 7 | 8 | T load(); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/instance/InstanceScope.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.instance; 2 | 3 | /** 4 | * Represents scope of provided instances. 5 | * 6 | * @author serkan 7 | */ 8 | public enum InstanceScope { 9 | 10 | /** 11 | * Gives singleton instance across all application (in fact classloader) 12 | */ 13 | GLOBAL, 14 | 15 | /** 16 | * Gives thread specific instance for each thread 17 | */ 18 | THREAD_LOCAL, 19 | 20 | /** 21 | * Gives thread specific instance for hierarchically connected threads (parent/child) 22 | */ 23 | INHERITABLE_THREAD_LOCAL, 24 | 25 | /** 26 | * Gives new fresh instance for every request 27 | */ 28 | PROTOTYPE; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/instance/InstanceTypeAwareProxy.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.instance; 2 | 3 | /** 4 | * Interface to represent proxies which are aware of 5 | * interface {@link Class}es of the underlying proxied instances. 6 | * 7 | * @author serkan 8 | */ 9 | public interface InstanceTypeAwareProxy { 10 | 11 | /** 12 | * Gets the interface {@link Class} of the proxied instance. 13 | * 14 | * @return the interface {@link Class} of the proxied instance 15 | */ 16 | Class getInstanceType(); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/internal/FeatureChecker.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.internal; 2 | 3 | import com.runsidekick.agent.core.logger.LoggerFactory; 4 | import com.runsidekick.agent.core.util.PropertyUtils; 5 | import org.slf4j.Logger; 6 | 7 | /** 8 | * Utility class for checking features. 9 | * 10 | * @author serkan 11 | */ 12 | public final class FeatureChecker { 13 | 14 | private static final Logger LOGGER = LoggerFactory.getLogger("FeatureChecker"); 15 | 16 | private FeatureChecker() { 17 | } 18 | 19 | public static boolean isFeatureEnabled(String featureName, int level) { 20 | boolean enabled = false; 21 | try { 22 | // For preventing reflection hacks, 23 | // fields are not neither defined as member and nor cached 24 | 25 | LicenseKeyInfo licenseKeyInfo = LicenseKeyHelper.decodeLicenseKeyInfo(PropertyUtils.getLicenseKey()); 26 | LicenseKeyHelper.checkLicenseKeyInfo(licenseKeyInfo); 27 | Integer featureLevel = licenseKeyInfo.getProperty("featureLevel"); 28 | if (featureLevel != null) { 29 | enabled = featureLevel >= level; 30 | } 31 | } catch (Throwable t) { 32 | LOGGER.error( 33 | String.format( 34 | "Error occurred while checking feature '%s' " + 35 | "whether or not it is enabled at level %d", 36 | featureName, level), 37 | t); 38 | } 39 | if (!enabled) { 40 | LOGGER.info(String.format( 41 | "Feature '%s' has been checked whether or not it is enabled at level %d, but it is not", 42 | featureName, level)); 43 | } 44 | return enabled; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/property/FileUtils.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.property; 2 | 3 | /** 4 | * Utility class for providing File related stuff. 5 | * 6 | * @author serkan 7 | */ 8 | final class FileUtils { 9 | 10 | private FileUtils() { 11 | } 12 | 13 | static String getProfiledFileName(String fileName, String profileName) { 14 | int extIds = fileName.lastIndexOf("."); 15 | if (extIds > 0) { 16 | return fileName.substring(0, extIds) + "-" + profileName + "." + fileName.substring(extIds + 1); 17 | } else { 18 | return fileName + "-" + profileName; 19 | } 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/property/MutablePropertyAccessor.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.property; 2 | 3 | /** 4 | * Interface for mutable {@link PropertyAccessor} implementations. 5 | * 6 | * @author serkan 7 | */ 8 | public interface MutablePropertyAccessor 9 | extends PropertyAccessor { 10 | 11 | /** 12 | * Puts the property associated with given property name. 13 | * 14 | * @param propName the name of property to be put 15 | * @param propValue the value of property to be put 16 | * @return the old value of the property if it is exist, 17 | * null otherwise 18 | */ 19 | String putProperty(String propName, String propValue); 20 | 21 | /** 22 | * Puts the property associated with given property name 23 | * if and only if it is not exist. 24 | * 25 | * @param propName the name of property to be put 26 | * @param propValue the value of property to be put 27 | * @return null if the property is no exist and 28 | * put is succeeded, the existing value of the property otherwise 29 | */ 30 | String putPropertyIfAbsent(String propName, String propValue); 31 | 32 | /** 33 | * Removes the property associated with given property name. 34 | * 35 | * @param propName the name of property to be removed 36 | * @return the old value of the property if it is exist and 37 | * remove is succeeded, null otherwise 38 | */ 39 | String removeProperty(String propName); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/property/ProfileProvider.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.property; 2 | 3 | /** 4 | * Provider which services profile name. 5 | * 6 | * @author serkan 7 | */ 8 | public final class ProfileProvider { 9 | 10 | private ProfileProvider() { 11 | } 12 | 13 | public static String getProfile() { 14 | String profile = System.getProperty("sidekick.agent.property.profile"); 15 | if (profile == null) { 16 | profile = System.getenv("SIDEKICK_AGENT_PROPERTY_PROFILE"); 17 | } 18 | return profile; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/property/ProvidedPropertyAccessor.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.property; 2 | 3 | import com.runsidekick.agent.core.property.provider.PropertyProviderManager; 4 | import com.runsidekick.agent.core.property.provider.PropertyProvider; 5 | 6 | import java.util.Map; 7 | 8 | /** 9 | * {@link PropertyAccessor} implementation which provides properties 10 | * over registered {@link PropertyProvider}s. 11 | * 12 | * @author serkan 13 | */ 14 | public final class ProvidedPropertyAccessor implements PropertyAccessor { 15 | 16 | public static final ProvidedPropertyAccessor INSTANCE = new ProvidedPropertyAccessor(); 17 | 18 | private ProvidedPropertyAccessor() { 19 | } 20 | 21 | @Override 22 | public String getProperty(String propName) { 23 | return PropertyProviderManager.lookupProperty(propName); 24 | } 25 | 26 | @Override 27 | public Map getProperties() { 28 | return PropertyProviderManager.getAllProvidedProperties(); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/property/SystemEnvironmentAwarePropertyAccessor.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.property; 2 | 3 | import com.runsidekick.agent.core.util.StringUtils; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | /** 9 | * Environment variable based {@link PropertyAccessor} implementation 10 | * which searches/loads properties from environment variables. 11 | * 12 | * @author serkan 13 | */ 14 | public class SystemEnvironmentAwarePropertyAccessor implements PropertyAccessor { 15 | 16 | private final Map envVars = getLowerCaseEnvVars(); 17 | 18 | private static Map getLowerCaseEnvVars() { 19 | Map envVars = new HashMap<>(); 20 | for (Map.Entry e : System.getenv().entrySet()) { 21 | String envVarName = e.getKey().trim(); 22 | String envVarValue = e.getValue().trim(); 23 | String normalizedEnvVarName = StringUtils.toLowerCase(envVarName).replace("_", "."); 24 | envVars.put(normalizedEnvVarName, envVarValue); 25 | } 26 | return envVars; 27 | } 28 | 29 | @Override 30 | public String getProperty(String propName) { 31 | return envVars.get(propName); 32 | } 33 | 34 | @Override 35 | public Map getProperties() { 36 | return envVars; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/property/SystemPropertyAwarePropertyAccessor.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.property; 2 | 3 | import com.runsidekick.agent.core.util.StringUtils; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | import java.util.Properties; 8 | import java.util.Set; 9 | 10 | /** 11 | * System property based {@link PropertyAccessor} implementation 12 | * which searches/loads properties from system properties. 13 | * 14 | * @author serkan 15 | */ 16 | public class SystemPropertyAwarePropertyAccessor implements PropertyAccessor { 17 | 18 | @Override 19 | public String getProperty(String propName) { 20 | return System.getProperty(propName); 21 | } 22 | 23 | @Override 24 | public Map getProperties() { 25 | Properties properties = System.getProperties(); 26 | Set propNames = properties.stringPropertyNames(); 27 | Map propMap = new HashMap<>(propNames.size()); 28 | for (String propName : properties.stringPropertyNames()) { 29 | propMap.put(StringUtils.toLowerCase(propName), properties.getProperty(propName)); 30 | } 31 | return propMap; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/property/UserHomeAwarePropertyAccessor.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.property; 2 | 3 | /** 4 | * User home directory based {@link PropertyAccessor} implementation 5 | * which searches/loads properties from user home directory. 6 | * 7 | * @author serkan 8 | */ 9 | public class UserHomeAwarePropertyAccessor extends FileSystemAwarePropertyAccessor { 10 | 11 | public UserHomeAwarePropertyAccessor(String fileName) { 12 | this(fileName, ProfileProvider.getProfile()); 13 | } 14 | 15 | public UserHomeAwarePropertyAccessor(String fileName, String profileName) { 16 | super(getUserHomeDirectory(), fileName, profileName); 17 | } 18 | 19 | private static String getUserHomeDirectory() { 20 | return System.getProperty("user.home"); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/property/provider/PropertyProvider.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.property.provider; 2 | 3 | import com.runsidekick.agent.core.entity.Ordered; 4 | import com.runsidekick.agent.core.property.PropertyAccessor; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Sub-type of {@link PropertyProvider} which provides custom properties. 10 | * 11 | * @author serkan 12 | */ 13 | public interface PropertyProvider 14 | extends PropertyAccessor, Ordered { 15 | 16 | /** 17 | * Gets names of the provided property names. 18 | * 19 | * @return names of the provided property names 20 | */ 21 | List getProvidedPropertyNames(); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/terminate/EnvironmentTerminator.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.terminate; 2 | 3 | import com.runsidekick.agent.core.entity.Ordered; 4 | 5 | /** 6 | * Interface for types to be terminated on shutdown. 7 | * 8 | * @author serkan 9 | */ 10 | public interface EnvironmentTerminator extends Ordered { 11 | 12 | /** 13 | * Executes termination logic. 14 | */ 15 | void terminate(); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/util/JsonUtils.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.util; 2 | 3 | import org.json.JSONObject; 4 | 5 | import java.util.Map; 6 | 7 | /** 8 | * Utility class for JSON related stuff. 9 | * 10 | * @author serkan 11 | */ 12 | public final class JsonUtils { 13 | 14 | private JsonUtils() { 15 | } 16 | 17 | public static Map jsonToMap(String json) { 18 | return new JSONObject(json).toMap(); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/util/PackageUtils.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.util; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | 5 | import java.io.BufferedReader; 6 | import java.io.FileReader; 7 | import java.io.IOException; 8 | 9 | /** 10 | * Utility class for package related stuffs. 11 | * 12 | * @author serkan 13 | */ 14 | public final class PackageUtils { 15 | 16 | public PackageUtils() { 17 | } 18 | 19 | public static String extractPackageFromSource(String filepath) throws IOException { 20 | String packageName = ""; 21 | BufferedReader buff = new BufferedReader(new FileReader(filepath)); 22 | Throwable error = null; 23 | try { 24 | String currentLine = ""; 25 | while((currentLine = buff.readLine()) != null && StringUtils.isEmpty(packageName)) { 26 | if (StringUtils.isNotEmpty(currentLine) && StringUtils.isEmpty(packageName)) { 27 | packageName = currentLine.startsWith("package") ? resolvePackage(currentLine) : ""; 28 | } 29 | } 30 | } catch (Throwable t) { 31 | error = t; 32 | throw t; 33 | } finally { 34 | if (buff != null) { 35 | if (error != null) { 36 | try { 37 | buff.close(); 38 | } catch (Throwable t) { 39 | error.addSuppressed(t); 40 | } 41 | } else { 42 | buff.close(); 43 | } 44 | } 45 | } 46 | return packageName; 47 | } 48 | 49 | private static String resolvePackage(String packageLine) { 50 | return packageLine.replace("package", "").replace(";", "").trim(); 51 | } 52 | 53 | } 54 | 55 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/util/executor/ManagedScheduledThreadPoolExecutor.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.util.executor; 2 | 3 | import java.util.concurrent.RejectedExecutionHandler; 4 | import java.util.concurrent.ScheduledThreadPoolExecutor; 5 | import java.util.concurrent.ThreadFactory; 6 | 7 | /** 8 | * @author serkan 9 | */ 10 | public class ManagedScheduledThreadPoolExecutor 11 | extends ScheduledThreadPoolExecutor 12 | implements SidekickExecutor { 13 | 14 | public ManagedScheduledThreadPoolExecutor(int corePoolSize) { 15 | super(corePoolSize); 16 | } 17 | 18 | public ManagedScheduledThreadPoolExecutor(int corePoolSize, ThreadFactory threadFactory) { 19 | super(corePoolSize, threadFactory); 20 | } 21 | 22 | public ManagedScheduledThreadPoolExecutor(int corePoolSize, RejectedExecutionHandler handler) { 23 | super(corePoolSize, handler); 24 | } 25 | 26 | public ManagedScheduledThreadPoolExecutor(int corePoolSize, ThreadFactory threadFactory, 27 | RejectedExecutionHandler handler) { 28 | super(corePoolSize, threadFactory, handler); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/util/executor/SidekickExecutor.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.util.executor; 2 | 3 | import java.util.concurrent.Executor; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public interface SidekickExecutor extends Executor { 9 | } 10 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/util/map/ConcurrentWeakMap.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.util.map; 2 | 3 | import com.blogspot.mydailyjava.weaklockfree.WeakConcurrentMap; 4 | import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap; 5 | 6 | import java.util.concurrent.ConcurrentMap; 7 | 8 | /** 9 | * Thread-safe weak {@link ConcurrentMap} implementation. 10 | * 11 | * @author serkan 12 | */ 13 | public class ConcurrentWeakMap extends WeakConcurrentMap { 14 | 15 | private static final int CACHE_CONCURRENCY = 16 | Math.max(8, Runtime.getRuntime().availableProcessors()); 17 | 18 | public ConcurrentWeakMap() { 19 | this(false); 20 | } 21 | 22 | public ConcurrentWeakMap(boolean cleanerThread) { 23 | super(cleanerThread); 24 | } 25 | 26 | public ConcurrentWeakMap(boolean cleanerThread, boolean reuseKeys) { 27 | super(cleanerThread, reuseKeys); 28 | } 29 | 30 | public ConcurrentWeakMap(boolean cleanerThread, boolean reuseKeys, ConcurrentMap, V> target) { 31 | super(cleanerThread, reuseKeys, target); 32 | } 33 | 34 | public ConcurrentWeakMap(int maxSize) { 35 | super(false, true, createMaxSizeMap(maxSize)); 36 | } 37 | 38 | private static ConcurrentMap createMaxSizeMap(int maxSize) { 39 | return new ConcurrentLinkedHashMap.Builder(). 40 | maximumWeightedCapacity(maxSize). 41 | concurrencyLevel(CACHE_CONCURRENCY). 42 | build(); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/util/map/WeakMap.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.util.map; 2 | 3 | import java.util.WeakHashMap; 4 | 5 | /** 6 | * Non-thread-safe weak {@link java.util.Map} implementation. 7 | * 8 | * @author serkan 9 | */ 10 | public class WeakMap extends WeakHashMap { 11 | 12 | public WeakMap() { 13 | } 14 | 15 | public WeakMap(int initialCapacity, float loadFactor) { 16 | super(initialCapacity, loadFactor); 17 | } 18 | 19 | public WeakMap(int initialCapacity) { 20 | super(initialCapacity); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/java/com/runsidekick/agent/core/util/thread/ManagedThread.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.util.thread; 2 | 3 | import org.jetbrains.annotations.NotNull; 4 | import org.jetbrains.annotations.Nullable; 5 | 6 | /** 7 | * @author serkan 8 | */ 9 | public class ManagedThread extends Thread { 10 | 11 | public ManagedThread() { 12 | } 13 | 14 | public ManagedThread(Runnable target) { 15 | super(target); 16 | } 17 | 18 | public ManagedThread(@Nullable ThreadGroup group, Runnable target) { 19 | super(group, target); 20 | } 21 | 22 | public ManagedThread(@NotNull String name) { 23 | super(name); 24 | } 25 | 26 | public ManagedThread(@Nullable ThreadGroup group, @NotNull String name) { 27 | super(group, name); 28 | } 29 | 30 | public ManagedThread(Runnable target, String name) { 31 | super(target, name); 32 | } 33 | 34 | public ManagedThread(@Nullable ThreadGroup group, Runnable target, @NotNull String name) { 35 | super(group, target, name); 36 | } 37 | 38 | public ManagedThread(@Nullable ThreadGroup group, Runnable target, @NotNull String name, long stackSize) { 39 | super(group, target, name, stackSize); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/resources/sidekick.properties: -------------------------------------------------------------------------------- 1 | version=${project.version} -------------------------------------------------------------------------------- /sidekick-agent-core/src/main/resources/tinylog.properties: -------------------------------------------------------------------------------- 1 | tinylog.format = [SIDEKICK] {level|min-size=5} {date:yyyy-MM-dd HH:mm:ss.SSS} [{thread}] {class}.{method}(): {message} -------------------------------------------------------------------------------- /sidekick-agent-core/src/test/java/com/runsidekick/agent/core/initialize/EnvironmentInitializerTest.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.initialize; 2 | 3 | import com.runsidekick.agent.core.instance.InstanceProvider; 4 | import com.runsidekick.agent.core.instance.InstanceScope; 5 | import org.junit.Test; 6 | 7 | import java.util.Collection; 8 | 9 | import static org.junit.Assert.assertEquals; 10 | import static org.junit.Assert.assertTrue; 11 | 12 | /** 13 | * @author serkan 14 | */ 15 | public class EnvironmentInitializerTest { 16 | 17 | @Test 18 | public void environmentInitializersShouldBeAbleToDiscoveredAndInitialized() { 19 | InstanceProvider.clearScope(InstanceScope.GLOBAL); 20 | EnvironmentInitializerManager.reset(); 21 | 22 | Collection environmentInitializers = 23 | EnvironmentInitializerManager.getEnvironmentInitializers(); 24 | assertEquals(1, environmentInitializers.size()); 25 | 26 | EnvironmentInitializer environmentInitializer = 27 | environmentInitializers.iterator().next(); 28 | assertTrue(environmentInitializer instanceof TestEnvironmentInitializer); 29 | 30 | TestEnvironmentInitializer testEnvironmentInitializer = 31 | (TestEnvironmentInitializer) environmentInitializer; 32 | assertEquals(0, testEnvironmentInitializer.getInitializeCounter()); 33 | 34 | EnvironmentInitializerManager.ensureInitialized(); 35 | assertEquals(1, testEnvironmentInitializer.getInitializeCounter()); 36 | 37 | EnvironmentInitializerManager.ensureInitialized(); 38 | assertEquals(1, testEnvironmentInitializer.getInitializeCounter()); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/test/java/com/runsidekick/agent/core/initialize/TestEnvironmentInitializer.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.initialize; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public class TestEnvironmentInitializer implements EnvironmentInitializer { 7 | 8 | private int initializeCounter; 9 | 10 | @Override 11 | public void initialize() { 12 | initializeCounter++; 13 | } 14 | 15 | public int getInitializeCounter() { 16 | return initializeCounter; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/test/java/com/runsidekick/agent/core/instance/InstanceDiscoveryTest.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.instance; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.assertNotNull; 6 | import static org.junit.Assert.assertTrue; 7 | 8 | /** 9 | * @author serkan 10 | */ 11 | public class InstanceDiscoveryTest { 12 | 13 | @Test 14 | public void instanceShouldBeAbleToDiscovered() { 15 | TestDiscoveredInstance testDiscoveredInstance = 16 | InstanceDiscovery.instanceOf(TestDiscoveredInstance.class); 17 | assertNotNull(testDiscoveredInstance); 18 | assertTrue(testDiscoveredInstance instanceof TestDiscoveredInstanceImpl); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/test/java/com/runsidekick/agent/core/instance/TestDiscoveredInstance.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.instance; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public interface TestDiscoveredInstance { 7 | } 8 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/test/java/com/runsidekick/agent/core/instance/TestDiscoveredInstanceImpl.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.instance; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public class TestDiscoveredInstanceImpl implements TestDiscoveredInstance { 7 | } 8 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/test/java/com/runsidekick/agent/core/property/TestPropertyProvider.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.core.property; 2 | 3 | import com.runsidekick.agent.core.property.provider.PropertyProvider; 4 | 5 | import java.util.Arrays; 6 | import java.util.HashMap; 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | /** 11 | * @author serkan 12 | */ 13 | public class TestPropertyProvider implements PropertyProvider { 14 | 15 | private final Map props = new HashMap(); 16 | 17 | public TestPropertyProvider() { 18 | props.put("key1", "value1"); 19 | } 20 | 21 | @Override 22 | public String getProperty(String propName) { 23 | return props.get(propName); 24 | } 25 | 26 | @Override 27 | public Map getProperties() { 28 | return props; 29 | } 30 | 31 | @Override 32 | public List getProvidedPropertyNames() { 33 | return Arrays.asList("key1"); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /sidekick-agent-core/src/test/resources/META-INF/services/com.runsidekick.agent.core.initialize.EnvironmentInitializer: -------------------------------------------------------------------------------- 1 | com.runsidekick.agent.core.initialize.TestEnvironmentInitializer -------------------------------------------------------------------------------- /sidekick-agent-core/src/test/resources/META-INF/services/com.runsidekick.agent.core.instance.TestDiscoveredInstance: -------------------------------------------------------------------------------- 1 | com.runsidekick.agent.core.instance.TestDiscoveredInstanceImpl -------------------------------------------------------------------------------- /sidekick-agent-core/src/test/resources/META-INF/services/com.runsidekick.agent.core.property.provider.PropertyProvider: -------------------------------------------------------------------------------- 1 | com.runsidekick.agent.core.property.TestPropertyProvider -------------------------------------------------------------------------------- /sidekick-agent-core/src/test/resources/test-testprofile.properties: -------------------------------------------------------------------------------- 1 | test.key1=value11 -------------------------------------------------------------------------------- /sidekick-agent-core/src/test/resources/test-testprofile.yml: -------------------------------------------------------------------------------- 1 | test: 2 | key1: value11 -------------------------------------------------------------------------------- /sidekick-agent-core/src/test/resources/test.properties: -------------------------------------------------------------------------------- 1 | test.key1=value1 -------------------------------------------------------------------------------- /sidekick-agent-core/src/test/resources/test.yml: -------------------------------------------------------------------------------- 1 | test: 2 | key1: value1 -------------------------------------------------------------------------------- /sidekick-agent-data-redaction/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | sidekick-agent-parent 5 | com.runsidekick.agent 6 | 0.0.19-SNAPSHOT 7 | 8 | 4.0.0 9 | 10 | com.runsidekick.agent 11 | sidekick-agent-data-redaction 12 | sidekick-agent-data-redaction 13 | 14 | 15 | 16 | com.runsidekick.agent 17 | sidekick-agent-api-data-redaction 18 | 19 | 20 | com.runsidekick.agent 21 | sidekick-agent-core 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /sidekick-agent-instrument/src/main/java/com/runsidekick/agent/instrument/AgentAware.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.instrument; 2 | 3 | import com.runsidekick.agent.core.entity.Ordered; 4 | 5 | import java.lang.instrument.Instrumentation; 6 | 7 | /** 8 | * Interface for implementations to be notified when Sidekick agent is started 9 | * from command line as JVM argument. 10 | * 11 | * @author serkan 12 | */ 13 | public interface AgentAware extends Ordered { 14 | 15 | /** 16 | * Called when agent is started 17 | * 18 | * @param arguments the passed arguments to the agent 19 | * @param instrumentation the {@link Instrumentation} instance 20 | */ 21 | void onAgentStart(String arguments, Instrumentation instrumentation); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /sidekick-agent-instrument/src/main/java/com/runsidekick/agent/instrument/Installer.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.instrument; 2 | 3 | import java.lang.instrument.Instrumentation; 4 | 5 | /** 6 | * Main class of dynamically created java agent class to be invoked and 7 | * passed {@link Instrumentation} instance. 8 | * 9 | * @author serkan 10 | */ 11 | public class Installer { 12 | 13 | public static volatile Instrumentation INSTRUMENTATION; 14 | 15 | public static void agentmain(String agentArgs, Instrumentation inst) { 16 | INSTRUMENTATION = inst; 17 | } 18 | 19 | public static void premain(String arguments, Instrumentation inst) { 20 | INSTRUMENTATION = inst; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /sidekick-agent-instrument/src/test/java/com/runsidekick/agent/instrument/InstrumentSupportTest.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.instrument; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.assertNotNull; 6 | 7 | /** 8 | * @author serkan 9 | */ 10 | public class InstrumentSupportTest { 11 | 12 | @Test 13 | public void instrumentationSupportShouldBeAbleToActivated() { 14 | InstrumentSupport.ensureActivated(); 15 | assertNotNull(InstrumentSupport.getInstrumentation()); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | com.runsidekick.agent 7 | sidekick-agent-parent 8 | 0.0.19-SNAPSHOT 9 | 10 | 11 | com.runsidekick.agent 12 | sidekick-agent-jdk-attach 13 | sidekick-agent-jdk-attach 14 | 15 | -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/java/com/runsidekick/agent/jdk/attach/JDKAttachSupport.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.jdk.attach; 2 | 3 | import java.io.File; 4 | 5 | /** 6 | * Support class for providing JDK's Attach API related stuff. 7 | * 8 | * @author serkan 9 | */ 10 | public final class JDKAttachSupport { 11 | 12 | private JDKAttachSupport() { 13 | } 14 | 15 | /** 16 | * Checks whether JDK's Attach API related classes are provided 17 | * by JDK (if it is JDK instead of JRE). 18 | * 19 | * @return true if Attach API related classes are provided 20 | * false otherwise 21 | */ 22 | public static boolean areAttachAPIRelatedClassesProvidedByJDK() { 23 | String name = "com.sun.tools.attach.VirtualMachine"; 24 | try { 25 | Class.forName(name); 26 | return true; 27 | } catch (Exception e) { 28 | String toolsPath = System.getProperty("java.home").replace('\\', '/') + "/../lib/tools.jar"; 29 | return new File(toolsPath).exists(); 30 | } 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/com/sun/tools/attach/AgentInitializationException.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/com/sun/tools/attach/AgentInitializationException.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/com/sun/tools/attach/AgentLoadException.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/com/sun/tools/attach/AgentLoadException.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/com/sun/tools/attach/AttachNotSupportedException.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/com/sun/tools/attach/AttachNotSupportedException.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/com/sun/tools/attach/AttachPermission.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/com/sun/tools/attach/AttachPermission.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/com/sun/tools/attach/VirtualMachine.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/com/sun/tools/attach/VirtualMachine.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/com/sun/tools/attach/VirtualMachineDescriptor.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/com/sun/tools/attach/VirtualMachineDescriptor.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/com/sun/tools/attach/package-info.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/com/sun/tools/attach/package-info.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/com/sun/tools/attach/spi/AttachProvider.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/com/sun/tools/attach/spi/AttachProvider.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/com/sun/tools/attach/spi/package-info.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/com/sun/tools/attach/spi/package-info.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/BsdAttachProvider.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/BsdAttachProvider.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/BsdVirtualMachine$SocketInputStream.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/BsdVirtualMachine$SocketInputStream.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/BsdVirtualMachine.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/BsdVirtualMachine.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/HotSpotAttachProvider$HotSpotVirtualMachineDescriptor.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/HotSpotAttachProvider$HotSpotVirtualMachineDescriptor.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/HotSpotAttachProvider.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/HotSpotAttachProvider.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/HotSpotVirtualMachine.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/HotSpotVirtualMachine.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/LinuxAttachProvider.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/LinuxAttachProvider.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/LinuxVirtualMachine$SocketInputStream.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/LinuxVirtualMachine$SocketInputStream.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/LinuxVirtualMachine.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/LinuxVirtualMachine.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/MacosxAttachProvider.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/MacosxAttachProvider.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/MacosxVirtualMachine$SocketInputStream.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/MacosxVirtualMachine$SocketInputStream.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/MacosxVirtualMachine.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/MacosxVirtualMachine.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/OperatingSystemAwareAttachProvider.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/OperatingSystemAwareAttachProvider.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/SolarisAttachProvider.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/SolarisAttachProvider.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/SolarisVirtualMachine$SocketInputStream.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/SolarisVirtualMachine$SocketInputStream.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/SolarisVirtualMachine.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/SolarisVirtualMachine.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/WindowsAttachProvider.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/WindowsAttachProvider.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/WindowsVirtualMachine$PipedInputStream.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/WindowsVirtualMachine$PipedInputStream.class -------------------------------------------------------------------------------- /sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/WindowsVirtualMachine.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/runsidekick/sidekick-agent-java/4da7189fe71dfca30a63b5207acdaecb6a854600/sidekick-agent-jdk-attach/src/main/resources/sun/tools/attach/WindowsVirtualMachine.class -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/main/java/com/runsidekick/agent/logpoint/application/ApplicationStatusLogPointProvider.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.logpoint.application; 2 | 3 | import com.runsidekick.agent.logpoint.LogPointSupport; 4 | import com.runsidekick.agent.broker.application.ApplicationStatusProvider; 5 | import com.runsidekick.agent.broker.domain.ApplicationStatus; 6 | 7 | /** 8 | * @author yasin 9 | */ 10 | public class ApplicationStatusLogPointProvider implements ApplicationStatusProvider { 11 | 12 | @Override 13 | public void provide(ApplicationStatus applicationStatus, String client) { 14 | applicationStatus.addAttribute("logPoints", LogPointSupport.listLogPoints(client)); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/main/java/com/runsidekick/agent/logpoint/event/LogPointFailedEvent.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.logpoint.event; 2 | 3 | import com.runsidekick.agent.broker.event.impl.BaseEvent; 4 | 5 | /** 6 | * @author yasin 7 | */ 8 | public class LogPointFailedEvent extends BaseEvent { 9 | 10 | private final String className; 11 | private final int lineNo; 12 | private final int errorCode; 13 | private final String errorMessage; 14 | 15 | public LogPointFailedEvent(String className, int lineNo, 16 | int errorCode, String errorMessage) { 17 | this.className = className; 18 | this.lineNo = lineNo; 19 | this.errorCode = errorCode; 20 | this.errorMessage = errorMessage; 21 | } 22 | 23 | public String getClassName() { 24 | return className; 25 | } 26 | 27 | public int getLineNo() { 28 | return lineNo; 29 | } 30 | 31 | public int getErrorCode() { 32 | return errorCode; 33 | } 34 | 35 | public String getErrorMessage() { 36 | return errorMessage; 37 | } 38 | 39 | @Override 40 | public String toString() { 41 | return "LogPointFailedEvent{" + 42 | "className='" + className + '\'' + 43 | ", lineNo=" + lineNo + 44 | ", errorCode=" + errorCode + 45 | ", errorMessage='" + errorMessage + '\'' + 46 | ", id='" + id + '\'' + 47 | ", sendAck=" + sendAck + 48 | ", client='" + client + '\'' + 49 | ", time=" + time + 50 | ", hostName='" + hostName + '\'' + 51 | ", applicationName='" + applicationName + '\'' + 52 | ", applicationInstanceId='" + applicationInstanceId + '\'' + 53 | '}'; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/main/java/com/runsidekick/agent/logpoint/expression/execute/LogPointExpressionExecutor.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.logpoint.expression.execute; 2 | 3 | import com.runsidekick.agent.api.dataredaction.DataRedactionContext; 4 | 5 | import java.util.Map; 6 | 7 | /** 8 | * @author yasin 9 | */ 10 | public interface LogPointExpressionExecutor { 11 | 12 | String execute(DataRedactionContext dataRedactionContext, String expression, Map variables); 13 | } 14 | -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/main/java/com/runsidekick/agent/logpoint/expression/execute/impl/SpelExpressionExecutor.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.logpoint.expression.execute.impl; 2 | 3 | import com.runsidekick.agent.api.dataredaction.DataRedactionContext; 4 | import com.runsidekick.agent.core.util.map.ConcurrentWeakMap; 5 | import com.runsidekick.agent.logpoint.expression.execute.LogPointExpressionExecutor; 6 | import org.springframework.context.expression.MapAccessor; 7 | import org.springframework.expression.Expression; 8 | import org.springframework.expression.spel.standard.SpelExpressionParser; 9 | import org.springframework.expression.spel.support.StandardEvaluationContext; 10 | 11 | import java.util.Map; 12 | 13 | /** 14 | * @author yasin 15 | */ 16 | public class SpelExpressionExecutor implements LogPointExpressionExecutor { 17 | 18 | private final SpelExpressionParser parser = new SpelExpressionParser(); 19 | private static final ConcurrentWeakMap expressionMap = new ConcurrentWeakMap(); 20 | 21 | @Override 22 | public String execute(DataRedactionContext dataRedactionContext, String expression, Map variables) { 23 | // TODO data redaction implementation 24 | StandardEvaluationContext context = new StandardEvaluationContext(variables); 25 | context.addPropertyAccessor(new MapAccessor()); 26 | 27 | Expression exp = expressionMap.get(expression); 28 | if (exp == null) { 29 | exp = parser.parseRaw(expression); 30 | Expression existingExp = expressionMap.putIfAbsent(expression, exp); 31 | if (existingExp != null) { 32 | exp = existingExp; 33 | } 34 | } 35 | return exp.getValue(context, String.class); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/main/java/com/runsidekick/agent/logpoint/handler/request/DisableLogPointRequestHandler.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.logpoint.handler.request; 2 | 3 | import com.runsidekick.agent.broker.BrokerManager; 4 | import com.runsidekick.agent.logpoint.LogPointSupport; 5 | import com.runsidekick.agent.logpoint.request.DisableLogPointRequest; 6 | import com.runsidekick.agent.logpoint.response.DisableLogPointResponse; 7 | 8 | /** 9 | * @author yasin 10 | */ 11 | public class DisableLogPointRequestHandler 12 | extends BaseLogPointRequestHandler { 13 | 14 | public static final String REQUEST_NAME = "DisableLogPointRequest"; 15 | 16 | public DisableLogPointRequestHandler() { 17 | super(REQUEST_NAME, DisableLogPointRequest.class, DisableLogPointResponse.class); 18 | } 19 | 20 | @Override 21 | public DisableLogPointResponse handleRequest(DisableLogPointRequest request) { 22 | try { 23 | LogPointSupport.disableLogPoint(request.getLogPointId(), request.getClient()); 24 | BrokerManager.publishApplicationStatus(); 25 | if (request.getClient() != null) { 26 | BrokerManager.publishApplicationStatus(request.getClient()); 27 | } 28 | return new DisableLogPointResponse(). 29 | setRequestId(request.getId()). 30 | setClient(request.getClient()); 31 | } catch (Throwable error) { 32 | return new DisableLogPointResponse(). 33 | setRequestId(request.getId()). 34 | setClient(request.getClient()). 35 | setError(error); 36 | } 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/main/java/com/runsidekick/agent/logpoint/handler/request/EnableLogPointRequestHandler.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.logpoint.handler.request; 2 | 3 | import com.runsidekick.agent.broker.BrokerManager; 4 | import com.runsidekick.agent.logpoint.LogPointSupport; 5 | import com.runsidekick.agent.logpoint.request.EnableLogPointRequest; 6 | import com.runsidekick.agent.logpoint.response.EnableLogPointResponse; 7 | 8 | /** 9 | * @author yasin 10 | */ 11 | public class EnableLogPointRequestHandler 12 | extends BaseLogPointRequestHandler { 13 | 14 | public static final String REQUEST_NAME = "EnableLogPointRequest"; 15 | 16 | public EnableLogPointRequestHandler() { 17 | super(REQUEST_NAME, EnableLogPointRequest.class, EnableLogPointResponse.class); 18 | } 19 | 20 | @Override 21 | public EnableLogPointResponse handleRequest(EnableLogPointRequest request) { 22 | try { 23 | LogPointSupport.enableLogPoint(request.getLogPointId(), request.getClient()); 24 | BrokerManager.publishApplicationStatus(); 25 | if (request.getClient() != null) { 26 | BrokerManager.publishApplicationStatus(request.getClient()); 27 | } 28 | return new EnableLogPointResponse(). 29 | setRequestId(request.getId()). 30 | setClient(request.getClient()); 31 | } catch (Throwable error) { 32 | return new EnableLogPointResponse(). 33 | setRequestId(request.getId()). 34 | setClient(request.getClient()). 35 | setError(error); 36 | } 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/main/java/com/runsidekick/agent/logpoint/handler/request/RemoveLogPointRequestHandler.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.logpoint.handler.request; 2 | 3 | import com.runsidekick.agent.broker.BrokerManager; 4 | import com.runsidekick.agent.logpoint.LogPointSupport; 5 | import com.runsidekick.agent.logpoint.request.RemoveLogPointRequest; 6 | import com.runsidekick.agent.logpoint.response.RemoveLogPointResponse; 7 | 8 | /** 9 | * @author yasin 10 | */ 11 | public class RemoveLogPointRequestHandler 12 | extends BaseLogPointRequestHandler { 13 | 14 | public static final String REQUEST_NAME = "RemoveLogPointRequest"; 15 | 16 | public RemoveLogPointRequestHandler() { 17 | super(REQUEST_NAME, RemoveLogPointRequest.class, RemoveLogPointResponse.class); 18 | } 19 | 20 | @Override 21 | public RemoveLogPointResponse handleRequest(RemoveLogPointRequest request) { 22 | try { 23 | LogPointSupport.removeLogPoint(request.getLogPointId(), request.getClient()); 24 | BrokerManager.publishApplicationStatus(); 25 | if (request.getClient() != null) { 26 | BrokerManager.publishApplicationStatus(request.getClient()); 27 | } 28 | return new RemoveLogPointResponse(). 29 | setRequestId(request.getId()). 30 | setClient(request.getClient()); 31 | } catch (Throwable error) { 32 | return new RemoveLogPointResponse(). 33 | setRequestId(request.getId()). 34 | setClient(request.getClient()). 35 | setError(error); 36 | } 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/main/java/com/runsidekick/agent/logpoint/initialize/LogPointSupportInitializer.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.logpoint.initialize; 2 | 3 | import com.runsidekick.agent.logpoint.LogPointSupport; 4 | import com.runsidekick.agent.core.initialize.EnvironmentInitializer; 5 | 6 | /** 7 | * @author yasin 8 | */ 9 | public class LogPointSupportInitializer implements EnvironmentInitializer { 10 | 11 | @Override 12 | public void initialize() { 13 | LogPointSupport.ensureInitialized(); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/main/java/com/runsidekick/agent/logpoint/internal/LogPointExpireTask.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.logpoint.internal; 2 | 3 | /** 4 | * @author yasin 5 | */ 6 | class LogPointExpireTask implements Runnable { 7 | 8 | private final LogPointContext context; 9 | 10 | LogPointExpireTask(LogPointContext context) { 11 | this.context = context; 12 | } 13 | 14 | @Override 15 | public void run() { 16 | context.expireFuture = null; 17 | LogPointManager.expireLogPoint(context); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/main/java/com/runsidekick/agent/logpoint/request/DisableLogPointRequest.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.logpoint.request; 2 | 3 | import com.runsidekick.agent.broker.request.impl.BaseRequest; 4 | 5 | /** 6 | * @author yasin 7 | */ 8 | public class DisableLogPointRequest extends BaseRequest { 9 | 10 | private String logPointId; 11 | private String fileName; 12 | private String className; 13 | private int lineNo; 14 | 15 | public String getLogPointId() { 16 | return logPointId; 17 | } 18 | 19 | public void setLogPointId(String logPointId) { 20 | this.logPointId = logPointId; 21 | } 22 | 23 | public String getFileName() { 24 | return fileName; 25 | } 26 | 27 | public void setFileName(String fileName) { 28 | this.fileName = fileName; 29 | } 30 | 31 | public String getClassName() { 32 | return className; 33 | } 34 | 35 | public void setClassName(String className) { 36 | this.className = className; 37 | } 38 | 39 | public int getLineNo() { 40 | return lineNo; 41 | } 42 | 43 | public void setLineNo(int lineNo) { 44 | this.lineNo = lineNo; 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "DisableLogPointRequest{" + 50 | "logPointId='" + logPointId + '\'' + 51 | ", fileName='" + fileName + '\'' + 52 | ", className='" + className + '\'' + 53 | ", lineNo=" + lineNo + 54 | ", id='" + id + '\'' + 55 | ", client='" + client + '\'' + 56 | '}'; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/main/java/com/runsidekick/agent/logpoint/request/EnableLogPointRequest.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.logpoint.request; 2 | 3 | import com.runsidekick.agent.broker.request.impl.BaseRequest; 4 | 5 | /** 6 | * @author yasin 7 | */ 8 | public class EnableLogPointRequest extends BaseRequest { 9 | 10 | private String logPointId; 11 | private String fileName; 12 | private String className; 13 | private int lineNo; 14 | 15 | public String getLogPointId() { 16 | return logPointId; 17 | } 18 | 19 | public void setLogPointId(String logPointId) { 20 | this.logPointId = logPointId; 21 | } 22 | 23 | public String getFileName() { 24 | return fileName; 25 | } 26 | 27 | public void setFileName(String fileName) { 28 | this.fileName = fileName; 29 | } 30 | 31 | public String getClassName() { 32 | return className; 33 | } 34 | 35 | public void setClassName(String className) { 36 | this.className = className; 37 | } 38 | 39 | public int getLineNo() { 40 | return lineNo; 41 | } 42 | 43 | public void setLineNo(int lineNo) { 44 | this.lineNo = lineNo; 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "EnableLogPointRequest{" + 50 | "logPointId='" + logPointId + '\'' + 51 | ", fileName='" + fileName + '\'' + 52 | ", className='" + className + '\'' + 53 | ", lineNo=" + lineNo + 54 | ", id='" + id + '\'' + 55 | ", client='" + client + '\'' + 56 | '}'; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/main/java/com/runsidekick/agent/logpoint/request/RemoveBatchLogPointRequest.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.logpoint.request; 2 | 3 | import com.runsidekick.agent.broker.request.impl.BaseRequest; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author yasin 9 | */ 10 | public class RemoveBatchLogPointRequest extends BaseRequest { 11 | 12 | private List logPointIds; 13 | 14 | public List getLogPointIds() { 15 | return logPointIds; 16 | } 17 | 18 | public void setLogPointIds(List logPointIds) { 19 | this.logPointIds = logPointIds; 20 | } 21 | 22 | @Override 23 | public String toString() { 24 | return "RemoveLogPointRequest{" + 25 | "logPointIds='" + logPointIds + '\'' + 26 | ", client='" + client + '\'' + 27 | ", id='" + id + '\'' + 28 | '}'; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/main/java/com/runsidekick/agent/logpoint/request/RemoveLogPointRequest.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.logpoint.request; 2 | 3 | import com.runsidekick.agent.broker.request.impl.BaseRequest; 4 | 5 | /** 6 | * @author yasin 7 | */ 8 | public class RemoveLogPointRequest extends BaseRequest { 9 | 10 | private String logPointId; 11 | private String fileName; 12 | private String className; 13 | private int lineNo; 14 | 15 | public String getLogPointId() { 16 | return logPointId; 17 | } 18 | 19 | public void setLogPointId(String logPointId) { 20 | this.logPointId = logPointId; 21 | } 22 | 23 | public String getFileName() { 24 | return fileName; 25 | } 26 | 27 | public void setFileName(String fileName) { 28 | this.fileName = fileName; 29 | } 30 | 31 | public String getClassName() { 32 | return className; 33 | } 34 | 35 | public void setClassName(String className) { 36 | this.className = className; 37 | } 38 | 39 | public int getLineNo() { 40 | return lineNo; 41 | } 42 | 43 | public void setLineNo(int lineNo) { 44 | this.lineNo = lineNo; 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "RemoveLogPointRequest{" + 50 | "logPointId='" + logPointId + '\'' + 51 | ", fileName='" + fileName + '\'' + 52 | ", className='" + className + '\'' + 53 | ", lineNo=" + lineNo + 54 | ", id='" + id + '\'' + 55 | ", client='" + client + '\'' + 56 | '}'; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/main/java/com/runsidekick/agent/logpoint/response/DisableLogPointResponse.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.logpoint.response; 2 | 3 | import com.runsidekick.agent.broker.response.impl.BaseResponse; 4 | 5 | /** 6 | * @author yasin 7 | */ 8 | public class DisableLogPointResponse extends BaseResponse { 9 | 10 | @Override 11 | public String toString() { 12 | return "DisableLogPointResponse{" + 13 | "requestId='" + requestId + '\'' + 14 | ", applicationInstanceId='" + applicationInstanceId + '\'' + 15 | ", client='" + client + '\'' + 16 | ", erroneous=" + erroneous + 17 | ", errorCode=" + errorCode + 18 | ", errorMessage='" + errorMessage + '\'' + 19 | '}'; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/main/java/com/runsidekick/agent/logpoint/response/EnableLogPointResponse.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.logpoint.response; 2 | 3 | import com.runsidekick.agent.broker.response.impl.BaseResponse; 4 | 5 | /** 6 | * @author yasin 7 | */ 8 | public class EnableLogPointResponse extends BaseResponse { 9 | 10 | @Override 11 | public String toString() { 12 | return "EnableLogPointResponse{" + 13 | "requestId='" + requestId + '\'' + 14 | ", applicationInstanceId='" + applicationInstanceId + '\'' + 15 | ", client='" + client + '\'' + 16 | ", erroneous=" + erroneous + 17 | ", errorCode=" + errorCode + 18 | ", errorMessage='" + errorMessage + '\'' + 19 | '}'; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/main/java/com/runsidekick/agent/logpoint/response/FilterLogPointsResponse.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.logpoint.response; 2 | 3 | import com.runsidekick.agent.broker.response.impl.BaseResponse; 4 | import com.runsidekick.agent.logpoint.domain.LogPoint; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author yasin 10 | */ 11 | public class FilterLogPointsResponse extends BaseResponse { 12 | 13 | protected List logPoints; 14 | 15 | public FilterLogPointsResponse() { 16 | } 17 | 18 | public List getLogPoints() { 19 | return logPoints; 20 | } 21 | 22 | public void setLogPoints(List logPoints) { 23 | this.logPoints = logPoints; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return "FilterLogPointsResponse{" + 29 | "requestId='" + requestId + '\'' + 30 | ", applicationInstanceId='" + applicationInstanceId + '\'' + 31 | ", logPoints=" + logPoints + 32 | ", erroneous=" + erroneous + 33 | ", errorCode=" + errorCode + 34 | ", errorMessage='" + errorMessage + '\'' + 35 | '}'; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/main/java/com/runsidekick/agent/logpoint/response/PutLogPointResponse.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.logpoint.response; 2 | 3 | import com.runsidekick.agent.broker.response.impl.BaseResponse; 4 | 5 | /** 6 | * @author yasin 7 | */ 8 | public class PutLogPointResponse extends BaseResponse { 9 | 10 | @Override 11 | public String toString() { 12 | return "PutLogPointResponse{" + 13 | "requestId='" + requestId + '\'' + 14 | ", applicationInstanceId='" + applicationInstanceId + '\'' + 15 | ", client='" + client + '\'' + 16 | ", erroneous=" + erroneous + 17 | ", errorCode=" + errorCode + 18 | ", errorMessage='" + errorMessage + '\'' + 19 | '}'; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/main/java/com/runsidekick/agent/logpoint/response/RemoveLogPointResponse.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.logpoint.response; 2 | 3 | import com.runsidekick.agent.broker.response.impl.BaseResponse; 4 | 5 | /** 6 | * @author yasin 7 | */ 8 | public class RemoveLogPointResponse extends BaseResponse { 9 | 10 | @Override 11 | public String toString() { 12 | return "RemoveLogPointResponse{" + 13 | "requestId='" + requestId + '\'' + 14 | ", applicationInstanceId='" + applicationInstanceId + '\'' + 15 | ", client='" + client + '\'' + 16 | ", erroneous=" + erroneous + 17 | ", errorCode=" + errorCode + 18 | ", errorMessage='" + errorMessage + '\'' + 19 | '}'; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/main/java/com/runsidekick/agent/logpoint/response/UpdateLogPointResponse.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.logpoint.response; 2 | 3 | import com.runsidekick.agent.broker.response.impl.BaseResponse; 4 | 5 | /** 6 | * @author yasin 7 | */ 8 | public class UpdateLogPointResponse extends BaseResponse { 9 | 10 | @Override 11 | public String toString() { 12 | return "UpdateLogPointResponse{" + 13 | "requestId='" + requestId + '\'' + 14 | ", applicationInstanceId='" + applicationInstanceId + '\'' + 15 | ", client='" + client + '\'' + 16 | ", erroneous=" + erroneous + 17 | ", errorCode=" + errorCode + 18 | ", errorMessage='" + errorMessage + '\'' + 19 | '}'; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/main/resources/META-INF/services/com.runsidekick.agent.broker.application.ApplicationStatusProvider: -------------------------------------------------------------------------------- 1 | com.runsidekick.agent.logpoint.application.ApplicationStatusLogPointProvider -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/main/resources/META-INF/services/com.runsidekick.agent.broker.handler.request.RequestHandler: -------------------------------------------------------------------------------- 1 | com.runsidekick.agent.logpoint.handler.request.PutLogPointRequestHandler 2 | com.runsidekick.agent.logpoint.handler.request.UpdateLogPointRequestHandler 3 | com.runsidekick.agent.logpoint.handler.request.RemoveBatchLogPointRequestHandler 4 | com.runsidekick.agent.logpoint.handler.request.RemoveLogPointRequestHandler 5 | com.runsidekick.agent.logpoint.handler.request.EnableLogPointRequestHandler 6 | com.runsidekick.agent.logpoint.handler.request.DisableLogPointRequestHandler 7 | -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/main/resources/META-INF/services/com.runsidekick.agent.broker.handler.response.ResponseHandler: -------------------------------------------------------------------------------- 1 | com.runsidekick.agent.logpoint.handler.response.FilterLogPointsResponseHandler 2 | -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/main/resources/META-INF/services/com.runsidekick.agent.core.initialize.EnvironmentInitializer: -------------------------------------------------------------------------------- 1 | com.runsidekick.agent.logpoint.initialize.LogPointSupportInitializer -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/test/java/com/runsidekick/agent/logpoint/CollectionTest.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.logpoint; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class CollectionTest { 7 | 8 | public static void listTest() { 9 | List testList = new ArrayList<>(); 10 | for (int i = 0; i < 10; i++) { 11 | Item t = new Item(); 12 | testList.add(t); 13 | } 14 | System.out.println(testList.size()); 15 | } 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/test/java/com/runsidekick/agent/logpoint/Hello.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.logpoint; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | public class Hello { 7 | 8 | private final List helloMessages = Arrays.asList("merhaba", "hi", "hola"); 9 | private final HelloMessageProvider helloMessageProvider = new HelloMessageProvider(); 10 | 11 | public String sayHello(String name) { 12 | StringBuilder sb = new StringBuilder(); 13 | int[] ia = new int[] {1, 2, 3}; 14 | for (int i = 0; i < helloMessages.size(); i++) { 15 | String helloMsg = helloMessageProvider.getHelloMessage(i); 16 | if (i > 0) { 17 | sb.append(", "); 18 | } 19 | sb.append(helloMsg).append(" ").append(name); 20 | } 21 | return sb.toString(); 22 | } 23 | 24 | public class HelloMessageProvider { 25 | 26 | private String getHelloMessage(int idx) { 27 | return helloMessages.get(idx); 28 | } 29 | 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/test/java/com/runsidekick/agent/logpoint/Item.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.logpoint; 2 | 3 | import java.util.UUID; 4 | 5 | public class Item { 6 | 7 | private Double doubleVal; 8 | private String strVal; 9 | private Boolean boolVal; 10 | private Item item; 11 | 12 | public Item() { 13 | doubleVal = Math.random() * 100; 14 | strVal = UUID.randomUUID().toString(); 15 | boolVal = doubleVal.intValue() % 3 == 0; 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | return "Item{" + "doubleVal=" + doubleVal + ", strVal='" + strVal + '\'' + ", boolVal=" + boolVal + '}'; 21 | } 22 | 23 | public Double getDoubleVal() { 24 | return doubleVal; 25 | } 26 | 27 | public String getStrVal() { 28 | return strVal; 29 | } 30 | 31 | public Boolean getBoolVal() { 32 | return boolVal; 33 | } 34 | 35 | public Item getItem() { 36 | return item; 37 | } 38 | 39 | public void setItem(Item item) { 40 | this.item = item; 41 | } 42 | } -------------------------------------------------------------------------------- /sidekick-agent-logpoint/src/test/java/com/runsidekick/agent/logpoint/ObjectTest.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.logpoint; 2 | 3 | public class ObjectTest { 4 | 5 | public static void test() { 6 | Item item = new Item(); 7 | boolean result = item.getBoolVal() && true; 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /sidekick-agent-probe-tag/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | sidekick-agent-parent 5 | com.runsidekick.agent 6 | 0.0.19-SNAPSHOT 7 | 8 | 4.0.0 9 | 10 | sidekick-agent-probe-tag 11 | 12 | 13 | 14 | com.runsidekick.agent 15 | sidekick-agent-broker 16 | 17 | 18 | com.runsidekick.agent 19 | sidekick-agent-tracepoint 20 | 21 | 22 | com.runsidekick.agent 23 | sidekick-agent-logpoint 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /sidekick-agent-probe-tag/src/main/java/com/runsidekick/agent/probetag/handler/request/DisableProbeTagRequestHandler.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probetag.handler.request; 2 | 3 | 4 | import com.runsidekick.agent.broker.BrokerManager; 5 | import com.runsidekick.agent.broker.handler.request.impl.BaseRequestHandler; 6 | import com.runsidekick.agent.logpoint.LogPointSupport; 7 | import com.runsidekick.agent.probetag.request.DisableProbeTagRequest; 8 | import com.runsidekick.agent.probetag.response.DisableProbeTagResponse; 9 | import com.runsidekick.agent.tracepoint.TracePointSupport; 10 | 11 | /** 12 | * @author yasin.kalafat 13 | */ 14 | public class DisableProbeTagRequestHandler extends BaseRequestHandler { 15 | 16 | public static final String REQUEST_NAME = "DisableProbeTagRequest"; 17 | 18 | public DisableProbeTagRequestHandler() { 19 | super(REQUEST_NAME, DisableProbeTagRequest.class, DisableProbeTagResponse.class); 20 | } 21 | 22 | @Override 23 | public DisableProbeTagResponse handleRequest(DisableProbeTagRequest request) { 24 | try { 25 | TracePointSupport.disableTag(request.getTag(), request.getClient()); 26 | LogPointSupport.disableTag(request.getTag(), request.getClient()); 27 | BrokerManager.publishApplicationStatus(); 28 | if (request.getClient() != null) { 29 | BrokerManager.publishApplicationStatus(request.getClient()); 30 | } 31 | return new DisableProbeTagResponse(). 32 | setRequestId(request.getId()). 33 | setClient(request.getClient()); 34 | } catch (Throwable error) { 35 | return new DisableProbeTagResponse(). 36 | setRequestId(request.getId()). 37 | setClient(request.getClient()). 38 | setError(error); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /sidekick-agent-probe-tag/src/main/java/com/runsidekick/agent/probetag/handler/request/RemoveProbeTagRequestHandler.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probetag.handler.request; 2 | 3 | 4 | import com.runsidekick.agent.broker.BrokerManager; 5 | import com.runsidekick.agent.broker.handler.request.impl.BaseRequestHandler; 6 | import com.runsidekick.agent.logpoint.LogPointSupport; 7 | import com.runsidekick.agent.probetag.request.RemoveProbeTagRequest; 8 | import com.runsidekick.agent.probetag.response.RemoveProbeTagResponse; 9 | import com.runsidekick.agent.tracepoint.TracePointSupport; 10 | 11 | /** 12 | * @author yasin.kalafat 13 | */ 14 | public class RemoveProbeTagRequestHandler extends BaseRequestHandler { 15 | 16 | public static final String REQUEST_NAME = "RemoveProbeTagRequest"; 17 | 18 | public RemoveProbeTagRequestHandler() { 19 | super(REQUEST_NAME, RemoveProbeTagRequest.class, RemoveProbeTagResponse.class); 20 | } 21 | 22 | @Override 23 | public RemoveProbeTagResponse handleRequest(RemoveProbeTagRequest request) { 24 | try { 25 | TracePointSupport.removeTag(request.getTag(), request.getClient()); 26 | LogPointSupport.removeTag(request.getTag(), request.getClient()); 27 | BrokerManager.publishApplicationStatus(); 28 | if (request.getClient() != null) { 29 | BrokerManager.publishApplicationStatus(request.getClient()); 30 | } 31 | return new RemoveProbeTagResponse(). 32 | setRequestId(request.getId()). 33 | setClient(request.getClient()); 34 | } catch (Throwable error) { 35 | return new RemoveProbeTagResponse(). 36 | setRequestId(request.getId()). 37 | setClient(request.getClient()). 38 | setError(error); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /sidekick-agent-probe-tag/src/main/java/com/runsidekick/agent/probetag/request/DisableProbeTagRequest.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probetag.request; 2 | 3 | import com.runsidekick.agent.broker.request.impl.BaseRequest; 4 | 5 | /** 6 | * @author yasin.kalafat 7 | */ 8 | public class DisableProbeTagRequest extends BaseRequest { 9 | 10 | private String tag; 11 | 12 | public String getTag() { 13 | return tag; 14 | } 15 | 16 | public void setTag(String tag) { 17 | this.tag = tag; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /sidekick-agent-probe-tag/src/main/java/com/runsidekick/agent/probetag/request/EnableProbeTagRequest.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probetag.request; 2 | 3 | import com.runsidekick.agent.broker.request.impl.BaseRequest; 4 | 5 | /** 6 | * @author yasin.kalafat 7 | */ 8 | public class EnableProbeTagRequest extends BaseRequest { 9 | 10 | private String tag; 11 | 12 | public String getTag() { 13 | return tag; 14 | } 15 | 16 | public void setTag(String tag) { 17 | this.tag = tag; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /sidekick-agent-probe-tag/src/main/java/com/runsidekick/agent/probetag/request/RemoveProbeTagRequest.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probetag.request; 2 | 3 | import com.runsidekick.agent.broker.request.impl.BaseRequest; 4 | 5 | /** 6 | * @author yasin.kalafat 7 | */ 8 | public class RemoveProbeTagRequest extends BaseRequest { 9 | 10 | private String tag; 11 | 12 | public String getTag() { 13 | return tag; 14 | } 15 | 16 | public void setTag(String tag) { 17 | this.tag = tag; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /sidekick-agent-probe-tag/src/main/java/com/runsidekick/agent/probetag/response/DisableProbeTagResponse.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probetag.response; 2 | 3 | import com.runsidekick.agent.broker.response.impl.BaseResponse; 4 | 5 | /** 6 | * @author yasin.kalafat 7 | */ 8 | public class DisableProbeTagResponse extends BaseResponse { 9 | 10 | @Override 11 | public String toString() { 12 | return "DisableProbeTagResponse{" + 13 | "requestId='" + requestId + '\'' + 14 | ", applicationInstanceId='" + applicationInstanceId + '\'' + 15 | ", client='" + client + '\'' + 16 | ", erroneous=" + erroneous + 17 | ", errorCode=" + errorCode + 18 | ", errorMessage='" + errorMessage + '\'' + 19 | '}'; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /sidekick-agent-probe-tag/src/main/java/com/runsidekick/agent/probetag/response/EnableProbeTagResponse.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probetag.response; 2 | 3 | import com.runsidekick.agent.broker.response.impl.BaseResponse; 4 | 5 | /** 6 | * @author yasin.kalafat 7 | */ 8 | public class EnableProbeTagResponse extends BaseResponse { 9 | 10 | @Override 11 | public String toString() { 12 | return "EnableProbeTagResponse{" + 13 | "requestId='" + requestId + '\'' + 14 | ", applicationInstanceId='" + applicationInstanceId + '\'' + 15 | ", client='" + client + '\'' + 16 | ", erroneous=" + erroneous + 17 | ", errorCode=" + errorCode + 18 | ", errorMessage='" + errorMessage + '\'' + 19 | '}'; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /sidekick-agent-probe-tag/src/main/java/com/runsidekick/agent/probetag/response/RemoveProbeTagResponse.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probetag.response; 2 | 3 | import com.runsidekick.agent.broker.response.impl.BaseResponse; 4 | 5 | /** 6 | * @author yasin.kalafat 7 | */ 8 | public class RemoveProbeTagResponse extends BaseResponse { 9 | 10 | @Override 11 | public String toString() { 12 | return "RemoveProbeTagResponse{" + 13 | "requestId='" + requestId + '\'' + 14 | ", applicationInstanceId='" + applicationInstanceId + '\'' + 15 | ", client='" + client + '\'' + 16 | ", erroneous=" + erroneous + 17 | ", errorCode=" + errorCode + 18 | ", errorMessage='" + errorMessage + '\'' + 19 | '}'; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /sidekick-agent-probe-tag/src/main/resources/META-INF/services/com.runsidekick.agent.broker.handler.request.RequestHandler: -------------------------------------------------------------------------------- 1 | com.runsidekick.agent.probetag.handler.request.DisableProbeTagRequestHandler 2 | com.runsidekick.agent.probetag.handler.request.EnableProbeTagRequestHandler 3 | com.runsidekick.agent.probetag.handler.request.RemoveProbeTagRequestHandler 4 | -------------------------------------------------------------------------------- /sidekick-agent-probe-tag/src/test/java/com/runsidekick/agent/probetag/Hello.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probetag; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | public class Hello { 7 | 8 | private final List helloMessages = Arrays.asList("merhaba", "hi", "hola"); 9 | private final HelloMessageProvider helloMessageProvider = new HelloMessageProvider(); 10 | 11 | public String sayHello(String name) { 12 | StringBuilder sb = new StringBuilder(); 13 | int[] ia = new int[] {1, 2, 3}; 14 | for (int i = 0; i < helloMessages.size(); i++) { 15 | String helloMsg = helloMessageProvider.getHelloMessage(i); 16 | if (i > 0) { 17 | sb.append(", "); 18 | } 19 | sb.append(helloMsg).append(" ").append(name); 20 | } 21 | return sb.toString(); 22 | } 23 | 24 | public class HelloMessageProvider { 25 | 26 | private String getHelloMessage(int idx) { 27 | return helloMessages.get(idx); 28 | } 29 | 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/antlr4/com/runsidekick/agent/probe/condition/parser/Condition.g4: -------------------------------------------------------------------------------- 1 | grammar Condition; 2 | 3 | parse 4 | : expression EOF 5 | ; 6 | 7 | expression 8 | : LPAREN expression RPAREN #parenExpression 9 | | left=expression op=binary right=expression #binaryExpression 10 | | left=operand op=comparator right=operand #comparatorExpression 11 | ; 12 | 13 | comparator 14 | : GT | GE | LT | LE | EQ | NE 15 | ; 16 | 17 | binary 18 | : AND | OR 19 | ; 20 | 21 | BOOLEAN 22 | : TRUE | FALSE 23 | ; 24 | 25 | operand 26 | : BOOLEAN | CHARACTER | NUMBER | STRING | NULL | VARIABLE | PLACEHOLDER 27 | ; 28 | 29 | AND : 'AND' | '&&'; 30 | OR : 'OR' | '||'; 31 | NOT : 'NOT' ; 32 | TRUE : 'true' ; 33 | FALSE : 'false' ; 34 | NULL : 'null' ; 35 | GT : '>' ; 36 | GE : '>=' ; 37 | LT : '<' ; 38 | LE : '<=' ; 39 | EQ : '==' ; 40 | NE : '!=' ; 41 | LPAREN : '(' ; 42 | RPAREN : ')' ; 43 | CHARACTER : '\'' . '\'' ; 44 | NUMBER : '-'? [0-9]+ ( '.' [0-9]+ )? ; 45 | STRING : '"' (~('"' | '\\' | '\r' | '\n') | '\\' ('"' | '\\'))* '"' ; 46 | VARIABLE : [a-zA-Z_][a-zA-Z0-9_.]* ; 47 | PLACEHOLDER : '$' '{' [a-zA-Z0-9_.]+ '}' ; 48 | WS : [ \r\t\u000C\n]+ -> skip ; 49 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/condition/BinaryOperator.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.condition; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public enum BinaryOperator { 7 | 8 | AND, 9 | OR, 10 | 11 | } 12 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/condition/ComparisonOperator.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.condition; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public enum ComparisonOperator { 7 | 8 | EQ("=="), 9 | NE("!="), 10 | LT("<"), 11 | LE("<="), 12 | GT(">"), 13 | GE(">="); 14 | 15 | private final String expression; 16 | 17 | private ComparisonOperator(String expression) { 18 | this.expression = expression; 19 | } 20 | 21 | public static ComparisonOperator fromExpression(String expression) { 22 | for (ComparisonOperator comparisonOperator : ComparisonOperator.values()) { 23 | if (comparisonOperator.expression.equals(expression)) { 24 | return comparisonOperator; 25 | } 26 | } 27 | return null; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/condition/CompositeCondition.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.condition; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public class CompositeCondition implements Condition { 9 | 10 | private final List conditions; 11 | private final List binaryOperators; 12 | 13 | public CompositeCondition(List conditions, List binaryOperators) { 14 | this.conditions = conditions; 15 | this.binaryOperators = binaryOperators; 16 | } 17 | 18 | @Override 19 | public boolean evaluate(ConditionContext conditionContext) { 20 | Boolean result = null; 21 | for (int i = 0; i < conditions.size(); i++) { 22 | Condition condition = conditions.get(i); 23 | boolean evaluationResult = condition.evaluate(conditionContext); 24 | if (result == null) { 25 | result = evaluationResult; 26 | } else { 27 | BinaryOperator binaryOperator = binaryOperators.get(i - 1); 28 | switch (binaryOperator) { 29 | case AND: 30 | result = result && evaluationResult; 31 | break; 32 | case OR: 33 | result = result || evaluationResult; 34 | break; 35 | } 36 | } 37 | } 38 | if (result != null) { 39 | return result; 40 | } else { 41 | return false; 42 | } 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/condition/Condition.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.condition; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public interface Condition { 7 | 8 | boolean evaluate(ConditionContext conditionContext); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/condition/ConditionContext.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.condition; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public class ConditionContext { 7 | 8 | private final Class clazz; 9 | private final Object obj; 10 | private final Object[] variables; 11 | 12 | public ConditionContext(Object[] variables) { 13 | this.clazz = null; 14 | this.obj = null; 15 | this.variables = variables; 16 | } 17 | 18 | public ConditionContext(Class clazz, Object obj, 19 | Object[] variables) { 20 | this.clazz = clazz; 21 | this.obj = obj; 22 | this.variables = variables; 23 | } 24 | 25 | public Class getClazz() { 26 | return clazz; 27 | } 28 | 29 | public Object getObj() { 30 | return obj; 31 | } 32 | 33 | public ClassLoader getClassLoader() { 34 | if (clazz != null) { 35 | return clazz.getClassLoader(); 36 | } 37 | return null; 38 | } 39 | 40 | public V getVariableValue(int varIdx) { 41 | if (variables != null && variables.length > varIdx) { 42 | return (V) variables[varIdx]; 43 | } 44 | return null; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/condition/ConditionUtils.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.condition; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public final class ConditionUtils { 7 | 8 | private ConditionUtils() { 9 | } 10 | 11 | public static boolean isBooleanType(Class type) { 12 | return boolean.class.equals(type) || Boolean.class.equals(type); 13 | } 14 | 15 | public static boolean isCharacterType(Class type) { 16 | return char.class.equals(type) || Character.class.equals(type); 17 | } 18 | 19 | public static boolean isNumberType(Class type) { 20 | return byte.class.equals(type) || Byte.class.equals(type) 21 | || short.class.equals(type) || Short.class.equals(type) 22 | || int.class.equals(type) || Integer.class.equals(type) 23 | || float.class.equals(type) || Float.class.equals(type) 24 | || long.class.equals(type) || Long.class.equals(type) 25 | || double.class.equals(type) || Double.class.equals(type); 26 | } 27 | 28 | public static boolean isStringType(Class type) { 29 | return String.class.equals(type); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/condition/SingleCondition.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.condition; 2 | 3 | import com.runsidekick.agent.probe.condition.operand.Operand; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public class SingleCondition implements Condition { 9 | 10 | private final Operand leftOperand; 11 | private final Operand rightOperand; 12 | private final ComparisonOperator comparisonOperator; 13 | 14 | public SingleCondition(Operand leftOperand, Operand rightOperand, ComparisonOperator comparisonOperator) { 15 | this.leftOperand = leftOperand; 16 | this.rightOperand = rightOperand; 17 | this.comparisonOperator = comparisonOperator; 18 | } 19 | 20 | @Override 21 | public boolean evaluate(ConditionContext conditionContext) { 22 | switch(comparisonOperator) { 23 | case EQ: 24 | return leftOperand.eq(rightOperand, conditionContext); 25 | case NE: 26 | return leftOperand.ne(rightOperand, conditionContext); 27 | case LT: 28 | return leftOperand.lt(rightOperand, conditionContext); 29 | case LE: 30 | return leftOperand.le(rightOperand, conditionContext); 31 | case GT: 32 | return leftOperand.gt(rightOperand, conditionContext); 33 | case GE: 34 | return leftOperand.ge(rightOperand, conditionContext); 35 | default: 36 | return false; 37 | } 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/condition/VariableInfo.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.condition; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public class VariableInfo { 7 | 8 | private final Class type; 9 | private final int idx; 10 | 11 | public VariableInfo(Class type, int idx) { 12 | this.type = type; 13 | this.idx = idx; 14 | } 15 | 16 | public Class getType() { 17 | return type; 18 | } 19 | 20 | public int getIndex() { 21 | return idx; 22 | } 23 | 24 | @Override 25 | public String toString() { 26 | return "VariableInfo{" + 27 | "type=" + type + 28 | ", index=" + idx + 29 | '}'; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/condition/VariableInfoProvider.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.condition; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public interface VariableInfoProvider { 7 | 8 | VariableInfo getVariableInfo(String variableName); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/condition/operand/BooleanOperand.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.condition.operand; 2 | 3 | import com.runsidekick.agent.probe.condition.value.ValueProvider; 4 | import com.runsidekick.agent.probe.condition.ConditionContext; 5 | 6 | import java.util.Objects; 7 | 8 | /** 9 | * @author serkan 10 | */ 11 | public class BooleanOperand extends TypedOperand { 12 | 13 | public BooleanOperand(ValueProvider valueProvider) { 14 | super(BooleanOperand.class, Boolean.class, valueProvider); 15 | } 16 | 17 | @Override 18 | protected boolean isEQ(Boolean value, ConditionContext conditionContext) { 19 | Boolean curValue = getValue(conditionContext); 20 | return Objects.equals(curValue, value); 21 | } 22 | 23 | @Override 24 | protected boolean isNE(Boolean value, ConditionContext conditionContext) { 25 | Boolean curValue = getValue(conditionContext); 26 | return !Objects.equals(curValue, value); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/condition/operand/CharacterOperand.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.condition.operand; 2 | 3 | import com.runsidekick.agent.probe.condition.value.ValueProvider; 4 | import com.runsidekick.agent.probe.condition.ConditionContext; 5 | 6 | import java.util.Objects; 7 | 8 | /** 9 | * @author serkan 10 | */ 11 | public class CharacterOperand extends TypedOperand { 12 | 13 | public CharacterOperand(ValueProvider valueProvider) { 14 | super(CharacterOperand.class, Character.class, valueProvider); 15 | } 16 | 17 | @Override 18 | protected boolean isEQ(Character value, ConditionContext conditionContext) { 19 | Character curValue = getValue(conditionContext); 20 | return Objects.equals(curValue, value); 21 | } 22 | 23 | @Override 24 | protected boolean isNE(Character value, ConditionContext conditionContext) { 25 | Character curValue = getValue(conditionContext); 26 | return !Objects.equals(curValue, value); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/condition/operand/NullOperand.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.condition.operand; 2 | 3 | import com.runsidekick.agent.probe.condition.ConditionContext; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public class NullOperand implements Operand { 9 | 10 | @Override 11 | public Object getValue(ConditionContext conditionContext) { 12 | return null; 13 | } 14 | 15 | @Override 16 | public boolean eq(Operand operand, ConditionContext conditionContext) { 17 | return operand.getValue(conditionContext) == null; 18 | } 19 | 20 | @Override 21 | public boolean ne(Operand operand, ConditionContext conditionContext) { 22 | return operand.getValue(conditionContext) != null; 23 | } 24 | 25 | @Override 26 | public boolean lt(Operand operand, ConditionContext conditionContext) { 27 | return false; 28 | } 29 | 30 | @Override 31 | public boolean le(Operand operand, ConditionContext conditionContext) { 32 | return false; 33 | } 34 | 35 | @Override 36 | public boolean gt(Operand operand, ConditionContext conditionContext) { 37 | return false; 38 | } 39 | 40 | @Override 41 | public boolean ge(Operand operand, ConditionContext conditionContext) { 42 | return false; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/condition/operand/ObjectOperand.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.condition.operand; 2 | 3 | import com.runsidekick.agent.probe.condition.value.ValueProvider; 4 | import com.runsidekick.agent.probe.condition.ConditionContext; 5 | 6 | import java.util.Objects; 7 | 8 | /** 9 | * @author serkan 10 | */ 11 | public class ObjectOperand implements Operand { 12 | 13 | private final ValueProvider valueProvider; 14 | 15 | public ObjectOperand(ValueProvider valueProvider) { 16 | this.valueProvider = valueProvider; 17 | } 18 | 19 | @Override 20 | public V getValue(ConditionContext conditionContext) { 21 | return valueProvider.getValue(conditionContext); 22 | } 23 | 24 | @Override 25 | public boolean eq(Operand operand, ConditionContext conditionContext) { 26 | Object value1 = getValue(conditionContext); 27 | Object value2 = operand.getValue(conditionContext); 28 | return Objects.equals(value1, value2); 29 | } 30 | 31 | @Override 32 | public boolean ne(Operand operand, ConditionContext conditionContext) { 33 | Object value1 = getValue(conditionContext); 34 | Object value2 = operand.getValue(conditionContext); 35 | return !Objects.equals(value1, value2); 36 | } 37 | 38 | @Override 39 | public boolean lt(Operand operand, ConditionContext conditionContext) { 40 | return false; 41 | } 42 | 43 | @Override 44 | public boolean le(Operand operand, ConditionContext conditionContext) { 45 | return false; 46 | } 47 | 48 | @Override 49 | public boolean gt(Operand operand, ConditionContext conditionContext) { 50 | return false; 51 | } 52 | 53 | @Override 54 | public boolean ge(Operand operand, ConditionContext conditionContext) { 55 | return false; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/condition/operand/Operand.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.condition.operand; 2 | 3 | import com.runsidekick.agent.probe.condition.ConditionContext; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public interface Operand { 9 | 10 | V getValue(ConditionContext conditionContext); 11 | 12 | default boolean eq(Operand operand, ConditionContext conditionContext) { 13 | return false; 14 | } 15 | 16 | default boolean ne(Operand operand, ConditionContext conditionContext) { 17 | return false; 18 | } 19 | 20 | default boolean lt(Operand operand, ConditionContext conditionContext) { 21 | return false; 22 | } 23 | 24 | default boolean le(Operand operand, ConditionContext conditionContext) { 25 | return false; 26 | } 27 | 28 | default boolean gt(Operand operand, ConditionContext conditionContext) { 29 | return false; 30 | } 31 | 32 | default boolean ge(Operand operand, ConditionContext conditionContext) { 33 | return false; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/condition/operand/StringOperand.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.condition.operand; 2 | 3 | import com.runsidekick.agent.probe.condition.value.ValueProvider; 4 | import com.runsidekick.agent.probe.condition.ConditionContext; 5 | 6 | import java.util.Objects; 7 | 8 | /** 9 | * @author serkan 10 | */ 11 | public class StringOperand extends TypedOperand { 12 | 13 | public StringOperand(ValueProvider valueProvider) { 14 | super(StringOperand.class, String.class, valueProvider); 15 | } 16 | 17 | @Override 18 | protected boolean isEQ(String value, ConditionContext conditionContext) { 19 | String curValue = getValue(conditionContext); 20 | return Objects.equals(curValue, value); 21 | } 22 | 23 | @Override 24 | protected boolean isNE(String value, ConditionContext conditionContext) { 25 | String curValue = getValue(conditionContext); 26 | return !Objects.equals(curValue, value); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/condition/value/BasePlaceholderValueProvider.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.condition.value; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public abstract class BasePlaceholderValueProvider implements PlaceholderValueProvider { 7 | 8 | protected final String placeholderName; 9 | protected final Class valueType; 10 | 11 | public BasePlaceholderValueProvider(String placeholderName, Class valueType) { 12 | this.placeholderName = placeholderName; 13 | this.valueType = valueType; 14 | } 15 | 16 | @Override 17 | public String getPlaceholderName() { 18 | return placeholderName; 19 | } 20 | 21 | @Override 22 | public Class getValueType() { 23 | return valueType; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/condition/value/ConstantValueProvider.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.condition.value; 2 | 3 | import com.runsidekick.agent.probe.condition.ConditionContext; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public class ConstantValueProvider implements ValueProvider { 9 | 10 | private final V value; 11 | 12 | public ConstantValueProvider(V value) { 13 | this.value = value; 14 | } 15 | 16 | @Override 17 | public V getValue(ConditionContext conditionContext) { 18 | return value; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/condition/value/PlaceholderValueProvider.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.condition.value; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public interface PlaceholderValueProvider extends TypeAwareValueProvider { 7 | 8 | default boolean isEnabled() { 9 | return true; 10 | } 11 | 12 | String getPlaceholderName(); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/condition/value/TypeAwareValueProvider.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.condition.value; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public interface TypeAwareValueProvider extends ValueProvider { 7 | 8 | Class getValueType(); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/condition/value/ValueProvider.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.condition.value; 2 | 3 | import com.runsidekick.agent.probe.condition.ConditionContext; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public interface ValueProvider { 9 | 10 | V getValue(ConditionContext conditionContext); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/domain/ClassType.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.domain; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public enum ClassType { 7 | 8 | JAVA("java"), 9 | KOTLIN("kt"), 10 | SCALA("scala"); 11 | 12 | private final String extension; 13 | 14 | ClassType(String extension) { 15 | this.extension = extension; 16 | } 17 | 18 | public String getExtension() { 19 | return extension; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/domain/MutableProbe.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.domain; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public interface MutableProbe extends Probe { 7 | 8 | void setRemoved(boolean removed); 9 | 10 | A addAction(A action); 11 | 12 | A replaceAction(A action); 13 | 14 | A removeAction(String id); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/domain/Probe.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.domain; 2 | 3 | import java.util.Collection; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public interface Probe { 9 | 10 | String getId(); 11 | 12 | String getFileName(); 13 | 14 | String getClassName(); 15 | 16 | int getLineNo(); 17 | 18 | String getClient(); 19 | 20 | String getMethodName(); 21 | 22 | A getAction(String id); 23 | 24 | Collection actions(); 25 | 26 | boolean hasAnyAction(); 27 | 28 | boolean isRemoved(); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/domain/ProbeAction.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.domain; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public interface ProbeAction { 7 | 8 | String id(); 9 | 10 | C getContext(); 11 | 12 | boolean isDisabled(); 13 | 14 | void onProbe(Probe probe, 15 | Class clazz, Object obj, String methodName, 16 | String[] localVarNames, Object[] localVarValues); 17 | 18 | default C unwrap(Class clazz) { 19 | if (clazz.isAssignableFrom(getClass())) { 20 | return clazz.cast(this); 21 | } else { 22 | return null; 23 | } 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/domain/ProbeContext.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.domain; 2 | 3 | import com.runsidekick.agent.probe.condition.Condition; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public interface ProbeContext { 9 | 10 | default Condition getCondition() { 11 | return null; 12 | } 13 | 14 | default int getExpireCount() { 15 | return -1; 16 | } 17 | 18 | default void expire() { 19 | } 20 | 21 | default boolean hasTag() { 22 | return false; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/domain/ProbeMetadata.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.domain; 2 | 3 | import javassist.CtClass; 4 | import javassist.CtMethod; 5 | 6 | /** 7 | * @author serkan 8 | */ 9 | public class ProbeMetadata { 10 | 11 | private final ClassLoader classLoader; 12 | private final CtClass clazz; 13 | private final CtMethod method; 14 | private final ClassType classType; 15 | 16 | public ProbeMetadata(ClassLoader classLoader, CtClass clazz, CtMethod method, ClassType classType) { 17 | this.classLoader = classLoader; 18 | this.clazz = clazz; 19 | this.method = method; 20 | this.classType = classType; 21 | } 22 | 23 | public ClassLoader classLoader() { 24 | return classLoader; 25 | } 26 | 27 | public CtClass clazz() { 28 | return clazz; 29 | } 30 | 31 | public CtMethod method() { 32 | return method; 33 | } 34 | 35 | public ClassType classType() { 36 | return classType; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/domain/impl/ConditionAwareProbeAction.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.domain.impl; 2 | 3 | import com.runsidekick.agent.core.logger.LoggerFactory; 4 | import com.runsidekick.agent.probe.condition.Condition; 5 | import com.runsidekick.agent.probe.condition.ConditionContext; 6 | import com.runsidekick.agent.probe.domain.Probe; 7 | import com.runsidekick.agent.probe.domain.ProbeAction; 8 | import com.runsidekick.agent.probe.domain.ProbeContext; 9 | import org.slf4j.Logger; 10 | 11 | /** 12 | * @author serkan 13 | */ 14 | public class ConditionAwareProbeAction extends DelegatedProbeAction { 15 | 16 | private static final Logger LOGGER = LoggerFactory.getLogger(ConditionAwareProbeAction.class); 17 | 18 | public ConditionAwareProbeAction(ProbeAction action) { 19 | super(action); 20 | } 21 | 22 | protected boolean checkWhetherConditionOk(Probe probe, Class clazz, Object obj, Object[] localVarValues) { 23 | C context = getContext(); 24 | if (context != null) { 25 | Condition condition = context.getCondition(); 26 | if (condition != null) { 27 | ConditionContext conditionContext = new ConditionContext(clazz, obj, localVarValues); 28 | return condition.evaluate(conditionContext); 29 | } 30 | } 31 | return true; 32 | } 33 | 34 | @Override 35 | public void onProbe(Probe probe, Class clazz, Object obj, String methodName, 36 | String[] localVarNames, Object[] localVarValues) { 37 | if (!checkWhetherConditionOk(probe, clazz, obj, localVarValues)) { 38 | return; 39 | } 40 | super.onProbe(probe, clazz, obj, methodName, localVarNames, localVarValues); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/domain/impl/DelegatedProbeAction.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.domain.impl; 2 | 3 | import com.runsidekick.agent.probe.domain.Probe; 4 | import com.runsidekick.agent.probe.domain.ProbeAction; 5 | import com.runsidekick.agent.probe.domain.ProbeContext; 6 | 7 | /** 8 | * @author serkan 9 | */ 10 | public abstract class DelegatedProbeAction implements ProbeAction { 11 | 12 | private final ProbeAction action; 13 | 14 | public DelegatedProbeAction(ProbeAction action) { 15 | this.action = action; 16 | } 17 | 18 | @Override 19 | public String id() { 20 | return action.id(); 21 | } 22 | 23 | @Override 24 | public C getContext() { 25 | return action.getContext(); 26 | } 27 | 28 | @Override 29 | public boolean isDisabled() { 30 | return action.isDisabled(); 31 | } 32 | 33 | @Override 34 | public void onProbe(Probe probe, Class clazz, Object obj, String methodName, 35 | String[] localVarNames, Object[] localVarValues) { 36 | action.onProbe(probe, clazz, obj, methodName, localVarNames, localVarValues); 37 | } 38 | 39 | @Override 40 | public C unwrap(Class clazz) { 41 | if (action != null) { 42 | return action.unwrap(clazz); 43 | } else { 44 | return ProbeAction.super.unwrap(clazz); 45 | } 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/event/ProbeActionFailedEvent.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.event; 2 | 3 | import com.runsidekick.agent.broker.event.impl.BaseEvent; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public class ProbeActionFailedEvent extends BaseEvent { 9 | 10 | private final String className; 11 | private final int lineNo; 12 | private final int errorCode; 13 | private final String errorMessage; 14 | 15 | public ProbeActionFailedEvent(String className, int lineNo, String client, 16 | int errorCode, String errorMessage) { 17 | this.className = className; 18 | this.lineNo = lineNo; 19 | this.client = client; 20 | this.errorCode = errorCode; 21 | this.errorMessage = errorMessage; 22 | } 23 | 24 | public String getClassName() { 25 | return className; 26 | } 27 | 28 | public int getLineNo() { 29 | return lineNo; 30 | } 31 | 32 | public int getErrorCode() { 33 | return errorCode; 34 | } 35 | 36 | public String getErrorMessage() { 37 | return errorMessage; 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return "ProbeActionFailedEvent{" + 43 | "className='" + className + '\'' + 44 | ", lineNo=" + lineNo + 45 | ", errorCode=" + errorCode + 46 | ", errorMessage='" + errorMessage + '\'' + 47 | ", id='" + id + '\'' + 48 | ", sendAck=" + sendAck + 49 | ", client='" + client + '\'' + 50 | ", time=" + time + 51 | ", hostName='" + hostName + '\'' + 52 | ", applicationName='" + applicationName + '\'' + 53 | ", applicationInstanceId='" + applicationInstanceId + '\'' + 54 | '}'; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/event/ProbeRateLimitEvent.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.event; 2 | 3 | import com.runsidekick.agent.broker.event.impl.BaseEvent; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public class ProbeRateLimitEvent extends BaseEvent { 9 | 10 | private final String className; 11 | private final int lineNo; 12 | 13 | public ProbeRateLimitEvent(String className, int lineNo, String client) { 14 | this.className = className; 15 | this.lineNo = lineNo; 16 | this.client = client; 17 | } 18 | 19 | public String getClassName() { 20 | return className; 21 | } 22 | 23 | public int getLineNo() { 24 | return lineNo; 25 | } 26 | 27 | @Override 28 | public String toString() { 29 | return "ProbeRateLimitEvent{" + 30 | "className='" + className + '\'' + 31 | ", lineNo=" + lineNo + 32 | ", id='" + id + '\'' + 33 | ", sendAck=" + sendAck + 34 | ", client='" + client + '\'' + 35 | ", time=" + time + 36 | ", hostName='" + hostName + '\'' + 37 | ", applicationName='" + applicationName + '\'' + 38 | ", applicationInstanceId='" + applicationInstanceId + '\'' + 39 | '}'; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/initialize/ProbeSupportInitializer.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.initialize; 2 | 3 | import com.runsidekick.agent.core.initialize.EnvironmentInitializer; 4 | import com.runsidekick.agent.probe.ProbeSupport; 5 | 6 | /** 7 | * @author serkan 8 | */ 9 | public class ProbeSupportInitializer implements EnvironmentInitializer { 10 | 11 | @Override 12 | public void initialize() { 13 | ProbeSupport.ensureInitialized(); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/internal/ClassProbes.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.internal; 2 | 3 | import java.util.Map; 4 | import java.util.concurrent.ConcurrentHashMap; 5 | 6 | /** 7 | * @author serkan 8 | */ 9 | class ClassProbes { 10 | 11 | final Map methodProbesMap = new ConcurrentHashMap<>(); 12 | 13 | ClassProbes() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/internal/LocalVarMetadata.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.internal; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | class LocalVarMetadata implements Comparable { 7 | 8 | private final int startPc; 9 | private final int idx; 10 | private final String name; 11 | private final String originalName; 12 | private final String typeSignature; 13 | 14 | LocalVarMetadata(int startPc, int idx, String name, String typeSignature) { 15 | this.startPc = startPc; 16 | this.idx = idx; 17 | this.name = name; 18 | this.originalName = name; 19 | this.typeSignature = typeSignature; 20 | } 21 | 22 | LocalVarMetadata(int startPc, int idx, String name, String originalName, String typeSignature) { 23 | this.startPc = startPc; 24 | this.idx = idx; 25 | this.name = name; 26 | this.originalName = originalName; 27 | this.typeSignature = typeSignature; 28 | } 29 | 30 | public String getName() { 31 | return name; 32 | } 33 | 34 | public String getOriginalName() { 35 | return originalName; 36 | } 37 | 38 | public String getTypeSignature() { 39 | return typeSignature; 40 | } 41 | 42 | @Override 43 | public int compareTo(LocalVarMetadata o) { 44 | int c1 = Integer.compare(startPc, o.startPc); 45 | if (c1 == 0) { 46 | return Integer.compare(idx, o.idx); 47 | } else { 48 | return c1; 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/internal/MethodProbes.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.internal; 2 | 3 | import java.util.Map; 4 | import java.util.concurrent.ConcurrentHashMap; 5 | 6 | /** 7 | * @author serkan 8 | */ 9 | class MethodProbes { 10 | 11 | final Map probes = new ConcurrentHashMap<>(); 12 | final ClassProbes ownerClassProbes; 13 | final String methodId; 14 | 15 | MethodProbes(ClassProbes ownerClassProbes, String methodId) { 16 | this.ownerClassProbes = ownerClassProbes; 17 | this.methodId = methodId; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/ratelimit/RateLimitResult.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.ratelimit; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public enum RateLimitResult { 7 | 8 | OK, 9 | HIT, 10 | EXCEEDED; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/serialization/ManagedJsonFactory.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.serialization; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.core.SerializableString; 5 | import com.fasterxml.jackson.core.io.IOContext; 6 | import com.fasterxml.jackson.core.util.DefaultPrettyPrinter; 7 | import com.fasterxml.jackson.databind.MappingJsonFactory; 8 | 9 | import java.io.IOException; 10 | import java.io.Writer; 11 | 12 | /** 13 | * @author serkan 14 | */ 15 | public class ManagedJsonFactory extends MappingJsonFactory { 16 | 17 | @Override 18 | protected JsonGenerator _createGenerator(Writer out, IOContext ctxt) throws IOException { 19 | ManagedJsonGenerator gen = 20 | new ManagedJsonGenerator(ctxt, _generatorFeatures, _objectCodec, out); 21 | if (_characterEscapes != null) { 22 | gen.setCharacterEscapes(_characterEscapes); 23 | } 24 | SerializableString rootSep = _rootValueSeparator; 25 | if (rootSep != DefaultPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR) { 26 | gen.setRootValueSeparator(rootSep); 27 | } 28 | return gen; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/sourcecode/SourceCode.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.sourcecode; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public class SourceCode { 9 | 10 | private final String className; 11 | private final String sourceFileName; 12 | private final String sourceFilePath; 13 | private final SourceCodeType sourceCodeType; 14 | 15 | public SourceCode(String className, String sourceFileName, 16 | String sourceFilePath, SourceCodeType sourceCodeType) { 17 | this.className = className; 18 | this.sourceFileName = sourceFileName; 19 | this.sourceFilePath = sourceFilePath; 20 | this.sourceCodeType = sourceCodeType; 21 | } 22 | 23 | public String getClassName() { 24 | return className; 25 | } 26 | 27 | public String getSourceFileName() { 28 | return sourceFileName; 29 | } 30 | 31 | public String getSourceFilePath() { 32 | return sourceFilePath; 33 | } 34 | 35 | public SourceCodeType getSourceCodeType() { 36 | return sourceCodeType; 37 | } 38 | 39 | public boolean hasSourceCodeFilePath() { 40 | return StringUtils.isNotEmpty(this.sourceFilePath); 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return "SourceCode{" + 46 | "className='" + className + '\'' + 47 | ", sourceFileName='" + sourceFileName + '\'' + 48 | ", sourceFilePath='" + sourceFilePath + '\'' + 49 | ", sourceCodeType=" + sourceCodeType + 50 | '}'; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/sourcecode/SourceCodeContent.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.sourcecode; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public class SourceCodeContent { 7 | 8 | public static final SourceCodeContent EMPTY = new SourceCodeContent(null, null); 9 | 10 | private final SourceCode sourceCode; 11 | private final String source; 12 | private final boolean original; 13 | 14 | public SourceCodeContent(SourceCode sourceCode, String source) { 15 | this.sourceCode = sourceCode; 16 | this.source = source; 17 | this.original = true; 18 | } 19 | 20 | public SourceCodeContent(SourceCode sourceCode, String source, boolean original) { 21 | this.sourceCode = sourceCode; 22 | this.source = source; 23 | this.original = original; 24 | } 25 | 26 | public SourceCode getSourceCode() { 27 | return sourceCode; 28 | } 29 | 30 | public String getSource() { 31 | return source; 32 | } 33 | 34 | public boolean isOriginal() { 35 | return original; 36 | } 37 | 38 | public String[] getLines() { 39 | if (source == null) { 40 | return null; 41 | } 42 | return source.split("\\r?\\n"); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/sourcecode/SourceCodeType.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.sourcecode; 2 | 3 | import com.runsidekick.agent.probe.domain.ClassType; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public enum SourceCodeType { 9 | 10 | JAVA("java"), 11 | KOTLIN("kt"), 12 | SCALA("scala"); 13 | 14 | private final String extension; 15 | 16 | SourceCodeType(String extension) { 17 | this.extension = extension; 18 | } 19 | 20 | public String getExtension() { 21 | return extension; 22 | } 23 | 24 | public static SourceCodeType fromExtension(String extension) { 25 | if (extension.startsWith(".")) { 26 | extension = extension.substring(1); 27 | } 28 | for (SourceCodeType sourceCodeType : SourceCodeType.values()) { 29 | if (sourceCodeType.extension.equals(extension)) { 30 | return sourceCodeType; 31 | } 32 | } 33 | return null; 34 | } 35 | 36 | public static SourceCodeType fromFileName(String fileName) { 37 | int lastDot = fileName.lastIndexOf("."); 38 | if (lastDot < 0) { 39 | return null; 40 | } 41 | String extension = fileName.substring(lastDot + 1); 42 | return fromExtension(extension); 43 | } 44 | 45 | public static SourceCodeType fromClassType(ClassType classType) { 46 | return fromExtension(classType.getExtension()); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/sourcecode/provider/SourceCodeProvider.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.sourcecode.provider; 2 | 3 | import com.runsidekick.agent.core.entity.Ordered; 4 | import com.runsidekick.agent.probe.sourcecode.SourceCodeContent; 5 | import com.runsidekick.agent.probe.sourcecode.SourceCodeType; 6 | 7 | /** 8 | * @author serkan 9 | */ 10 | public interface SourceCodeProvider extends Ordered { 11 | 12 | SourceCodeContent getSourceCodeContent( 13 | ClassLoader classLoader, 14 | String className, 15 | SourceCodeType sourceCodeType); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/java/com/runsidekick/agent/probe/util/GitHelper.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.probe.util; 2 | 3 | import java.util.Arrays; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | import java.util.regex.Matcher; 8 | import java.util.regex.Pattern; 9 | 10 | /** 11 | * 12 | * @author yasin.kalafat 13 | */ 14 | public final class GitHelper { 15 | 16 | private static final List FILE_NAME_URL_PATTERNS = 17 | Arrays.asList( 18 | Pattern.compile(".*api\\.github\\.com\\/repos\\/[^\\/]+\\/[^\\/]+\\/contents/(?[^\\?]+).*"), 19 | Pattern.compile("gitlab\\.com\\/repos\\/[^\\/]+\\/[^\\/]+\\/contents/(?[^\\?]+).*") 20 | ); 21 | private static final Map REPO_API_URL_MAPPING = new HashMap() {{ 22 | put("github.com", "api.github.com/repos"); 23 | put("gitlab.com", "gitlab.com/repos"); 24 | }}; 25 | 26 | public static String normalizeFileName(String fileNameURL) { 27 | String fileName = fileNameURL; 28 | for (Pattern pattern : FILE_NAME_URL_PATTERNS) { 29 | Matcher matcher = pattern.matcher(fileName); 30 | if (matcher.matches()) { 31 | fileName = matcher.group("fileName"); 32 | break; 33 | } 34 | } 35 | return fileName; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /sidekick-agent-probe/src/main/resources/META-INF/services/com.runsidekick.agent.core.initialize.EnvironmentInitializer: -------------------------------------------------------------------------------- 1 | com.runsidekick.agent.probe.initialize.ProbeSupportInitializer -------------------------------------------------------------------------------- /sidekick-agent-tracepoint/src/main/java/com/runsidekick/agent/tracepoint/application/ApplicationStatusTracePointProvider.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.tracepoint.application; 2 | 3 | import com.runsidekick.agent.tracepoint.TracePointSupport; 4 | import com.runsidekick.agent.broker.application.ApplicationStatusProvider; 5 | import com.runsidekick.agent.broker.domain.ApplicationStatus; 6 | 7 | /** 8 | * @author serkan 9 | */ 10 | public class ApplicationStatusTracePointProvider implements ApplicationStatusProvider { 11 | 12 | @Override 13 | public void provide(ApplicationStatus applicationStatus, String client) { 14 | applicationStatus.addAttribute("tracePoints", TracePointSupport.listTracePoints(client)); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /sidekick-agent-tracepoint/src/main/java/com/runsidekick/agent/tracepoint/domain/LineInfo.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.tracepoint.domain; 2 | 3 | import com.runsidekick.agent.probe.domain.Variable; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Holds line information with the associated line number, 9 | * source code and active local variable informations 10 | * where information is collected. 11 | * 12 | * @author serkan 13 | */ 14 | public class LineInfo { 15 | 16 | private int line; 17 | private String source; 18 | private List localVars; 19 | 20 | public LineInfo(int line) { 21 | this.line = line; 22 | } 23 | 24 | public LineInfo(int line, String source, List localVars) { 25 | this.line = line; 26 | this.source = source; 27 | this.localVars = localVars; 28 | } 29 | 30 | public int getLine() { 31 | return line; 32 | } 33 | 34 | public String getSource() { 35 | return source; 36 | } 37 | 38 | public void setSource(String source) { 39 | this.source = source; 40 | } 41 | 42 | public List getLocalVars() { 43 | return localVars; 44 | } 45 | 46 | public void setLocalVars(List localVars) { 47 | this.localVars = localVars; 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "LineInfo{" + 53 | "line=" + line + 54 | ", source='" + source + '\'' + 55 | ", localVars=" + localVars.toString() + 56 | '}'; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /sidekick-agent-tracepoint/src/main/java/com/runsidekick/agent/tracepoint/event/TracePointSnapshotFailedEvent.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.tracepoint.event; 2 | 3 | import com.runsidekick.agent.broker.event.impl.BaseEvent; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public class TracePointSnapshotFailedEvent extends BaseEvent { 9 | 10 | private final String className; 11 | private final int lineNo; 12 | private final int errorCode; 13 | private final String errorMessage; 14 | 15 | public TracePointSnapshotFailedEvent(String className, int lineNo, 16 | int errorCode, String errorMessage) { 17 | this.className = className; 18 | this.lineNo = lineNo; 19 | this.errorCode = errorCode; 20 | this.errorMessage = errorMessage; 21 | } 22 | 23 | public String getClassName() { 24 | return className; 25 | } 26 | 27 | public int getLineNo() { 28 | return lineNo; 29 | } 30 | 31 | public int getErrorCode() { 32 | return errorCode; 33 | } 34 | 35 | public String getErrorMessage() { 36 | return errorMessage; 37 | } 38 | 39 | @Override 40 | public String toString() { 41 | return "TracePointSnapshotFailedEvent{" + 42 | "className='" + className + '\'' + 43 | ", lineNo=" + lineNo + 44 | ", errorCode=" + errorCode + 45 | ", errorMessage='" + errorMessage + '\'' + 46 | ", id='" + id + '\'' + 47 | ", sendAck=" + sendAck + 48 | ", client='" + client + '\'' + 49 | ", time=" + time + 50 | ", hostName='" + hostName + '\'' + 51 | ", applicationName='" + applicationName + '\'' + 52 | ", applicationInstanceId='" + applicationInstanceId + '\'' + 53 | '}'; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /sidekick-agent-tracepoint/src/main/java/com/runsidekick/agent/tracepoint/handler/request/DisableTracePointRequestHandler.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.tracepoint.handler.request; 2 | 3 | import com.runsidekick.agent.tracepoint.TracePointSupport; 4 | import com.runsidekick.agent.tracepoint.request.DisableTracePointRequest; 5 | import com.runsidekick.agent.tracepoint.response.DisableTracePointResponse; 6 | import com.runsidekick.agent.broker.BrokerManager; 7 | import com.runsidekick.agent.core.util.StringUtils; 8 | 9 | /** 10 | * @author serkan 11 | */ 12 | public class DisableTracePointRequestHandler 13 | extends BaseTracePointRequestHandler { 14 | 15 | public static final String REQUEST_NAME = "DisableTracePointRequest"; 16 | 17 | public DisableTracePointRequestHandler() { 18 | super(REQUEST_NAME, DisableTracePointRequest.class, DisableTracePointResponse.class); 19 | } 20 | 21 | @Override 22 | public DisableTracePointResponse handleRequest(DisableTracePointRequest request) { 23 | try { 24 | TracePointSupport.disableTracePoint(request.getTracePointId(), request.getClient()); 25 | BrokerManager.publishApplicationStatus(); 26 | if (request.getClient() != null) { 27 | BrokerManager.publishApplicationStatus(request.getClient()); 28 | } 29 | return new DisableTracePointResponse(). 30 | setRequestId(request.getId()). 31 | setClient(request.getClient()); 32 | } catch (Throwable error) { 33 | return new DisableTracePointResponse(). 34 | setRequestId(request.getId()). 35 | setClient(request.getClient()). 36 | setError(error); 37 | } 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /sidekick-agent-tracepoint/src/main/java/com/runsidekick/agent/tracepoint/handler/request/EnableTracePointRequestHandler.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.tracepoint.handler.request; 2 | 3 | import com.runsidekick.agent.tracepoint.TracePointSupport; 4 | import com.runsidekick.agent.tracepoint.request.EnableTracePointRequest; 5 | import com.runsidekick.agent.tracepoint.response.EnableTracePointResponse; 6 | import com.runsidekick.agent.broker.BrokerManager; 7 | import com.runsidekick.agent.core.util.StringUtils; 8 | 9 | /** 10 | * @author serkan 11 | */ 12 | public class EnableTracePointRequestHandler 13 | extends BaseTracePointRequestHandler { 14 | 15 | public static final String REQUEST_NAME = "EnableTracePointRequest"; 16 | 17 | public EnableTracePointRequestHandler() { 18 | super(REQUEST_NAME, EnableTracePointRequest.class, EnableTracePointResponse.class); 19 | } 20 | 21 | @Override 22 | public EnableTracePointResponse handleRequest(EnableTracePointRequest request) { 23 | try { 24 | TracePointSupport.enableTracePoint(request.getTracePointId(), request.getClient()); 25 | BrokerManager.publishApplicationStatus(); 26 | if (request.getClient() != null) { 27 | BrokerManager.publishApplicationStatus(request.getClient()); 28 | } 29 | return new EnableTracePointResponse(). 30 | setRequestId(request.getId()). 31 | setClient(request.getClient()); 32 | } catch (Throwable error) { 33 | return new EnableTracePointResponse(). 34 | setRequestId(request.getId()). 35 | setClient(request.getClient()). 36 | setError(error); 37 | } 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /sidekick-agent-tracepoint/src/main/java/com/runsidekick/agent/tracepoint/handler/request/RemoveTracePointRequestHandler.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.tracepoint.handler.request; 2 | 3 | import com.runsidekick.agent.tracepoint.TracePointSupport; 4 | import com.runsidekick.agent.tracepoint.request.RemoveTracePointRequest; 5 | import com.runsidekick.agent.tracepoint.response.RemoveTracePointResponse; 6 | import com.runsidekick.agent.broker.BrokerManager; 7 | import com.runsidekick.agent.core.util.StringUtils; 8 | 9 | /** 10 | * @author serkan 11 | */ 12 | public class RemoveTracePointRequestHandler 13 | extends BaseTracePointRequestHandler { 14 | 15 | public static final String REQUEST_NAME = "RemoveTracePointRequest"; 16 | 17 | public RemoveTracePointRequestHandler() { 18 | super(REQUEST_NAME, RemoveTracePointRequest.class, RemoveTracePointResponse.class); 19 | } 20 | 21 | @Override 22 | public RemoveTracePointResponse handleRequest(RemoveTracePointRequest request) { 23 | try { 24 | TracePointSupport.removeTracePoint(request.getTracePointId(), request.getClient()); 25 | BrokerManager.publishApplicationStatus(); 26 | if (request.getClient() != null) { 27 | BrokerManager.publishApplicationStatus(request.getClient()); 28 | } 29 | return new RemoveTracePointResponse(). 30 | setRequestId(request.getId()). 31 | setClient(request.getClient()); 32 | } catch (Throwable error) { 33 | return new RemoveTracePointResponse(). 34 | setRequestId(request.getId()). 35 | setClient(request.getClient()). 36 | setError(error); 37 | } 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /sidekick-agent-tracepoint/src/main/java/com/runsidekick/agent/tracepoint/initialize/TracePointSupportInitializer.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.tracepoint.initialize; 2 | 3 | import com.runsidekick.agent.tracepoint.TracePointSupport; 4 | import com.runsidekick.agent.core.initialize.EnvironmentInitializer; 5 | 6 | /** 7 | * @author serkan 8 | */ 9 | public class TracePointSupportInitializer implements EnvironmentInitializer { 10 | 11 | @Override 12 | public void initialize() { 13 | TracePointSupport.ensureInitialized(); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /sidekick-agent-tracepoint/src/main/java/com/runsidekick/agent/tracepoint/internal/TracePointExpireTask.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.tracepoint.internal; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | class TracePointExpireTask implements Runnable { 7 | 8 | private final TracePointContext context; 9 | 10 | TracePointExpireTask(TracePointContext context) { 11 | this.context = context; 12 | } 13 | 14 | @Override 15 | public void run() { 16 | context.expireFuture = null; 17 | TracePointManager.expireTracePoint(context); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /sidekick-agent-tracepoint/src/main/java/com/runsidekick/agent/tracepoint/request/DisableTracePointRequest.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.tracepoint.request; 2 | 3 | import com.runsidekick.agent.broker.request.impl.BaseRequest; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public class DisableTracePointRequest extends BaseRequest { 9 | 10 | private String tracePointId; 11 | private String fileName; 12 | private String className; 13 | private int lineNo; 14 | 15 | public String getTracePointId() { 16 | return tracePointId; 17 | } 18 | 19 | public void setTracePointId(String tracePointId) { 20 | this.tracePointId = tracePointId; 21 | } 22 | 23 | public String getFileName() { 24 | return fileName; 25 | } 26 | 27 | public void setFileName(String fileName) { 28 | this.fileName = fileName; 29 | } 30 | 31 | public String getClassName() { 32 | return className; 33 | } 34 | 35 | public void setClassName(String className) { 36 | this.className = className; 37 | } 38 | 39 | public int getLineNo() { 40 | return lineNo; 41 | } 42 | 43 | public void setLineNo(int lineNo) { 44 | this.lineNo = lineNo; 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "DisableTracePointRequest{" + 50 | "tracePointId='" + tracePointId + '\'' + 51 | ", fileName='" + fileName + '\'' + 52 | ", className='" + className + '\'' + 53 | ", lineNo=" + lineNo + 54 | ", id='" + id + '\'' + 55 | ", client='" + client + '\'' + 56 | '}'; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /sidekick-agent-tracepoint/src/main/java/com/runsidekick/agent/tracepoint/request/EnableTracePointRequest.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.tracepoint.request; 2 | 3 | import com.runsidekick.agent.broker.request.impl.BaseRequest; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public class EnableTracePointRequest extends BaseRequest { 9 | 10 | private String tracePointId; 11 | private String fileName; 12 | private String className; 13 | private int lineNo; 14 | 15 | public String getTracePointId() { 16 | return tracePointId; 17 | } 18 | 19 | public void setTracePointId(String tracePointId) { 20 | this.tracePointId = tracePointId; 21 | } 22 | 23 | public String getFileName() { 24 | return fileName; 25 | } 26 | 27 | public void setFileName(String fileName) { 28 | this.fileName = fileName; 29 | } 30 | 31 | public String getClassName() { 32 | return className; 33 | } 34 | 35 | public void setClassName(String className) { 36 | this.className = className; 37 | } 38 | 39 | public int getLineNo() { 40 | return lineNo; 41 | } 42 | 43 | public void setLineNo(int lineNo) { 44 | this.lineNo = lineNo; 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "EnableTracePointRequest{" + 50 | "tracePointId='" + tracePointId + '\'' + 51 | ", fileName='" + fileName + '\'' + 52 | ", className='" + className + '\'' + 53 | ", lineNo=" + lineNo + 54 | ", id='" + id + '\'' + 55 | ", client='" + client + '\'' + 56 | '}'; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /sidekick-agent-tracepoint/src/main/java/com/runsidekick/agent/tracepoint/request/RemoveBatchTracePointRequest.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.tracepoint.request; 2 | 3 | import com.runsidekick.agent.broker.request.impl.BaseRequest; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author oguzhan 9 | */ 10 | public class RemoveBatchTracePointRequest extends BaseRequest { 11 | 12 | private List tracePointIds; 13 | 14 | public List getTracePointIds() { 15 | return tracePointIds; 16 | } 17 | 18 | public void setTracePointIds(List tracePointIds) { 19 | this.tracePointIds = tracePointIds; 20 | } 21 | 22 | @Override 23 | public String toString() { 24 | return "RemoveTracePointRequest{" + 25 | "tracePointIds='" + tracePointIds + '\'' + 26 | ", client='" + client + '\'' + 27 | ", id='" + id + '\'' + 28 | '}'; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /sidekick-agent-tracepoint/src/main/java/com/runsidekick/agent/tracepoint/request/RemoveTracePointRequest.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.tracepoint.request; 2 | 3 | import com.runsidekick.agent.broker.request.impl.BaseRequest; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public class RemoveTracePointRequest extends BaseRequest { 9 | 10 | private String tracePointId; 11 | private String fileName; 12 | private String className; 13 | private int lineNo; 14 | 15 | public String getTracePointId() { 16 | return tracePointId; 17 | } 18 | 19 | public void setTracePointId(String tracePointId) { 20 | this.tracePointId = tracePointId; 21 | } 22 | 23 | public String getFileName() { 24 | return fileName; 25 | } 26 | 27 | public void setFileName(String fileName) { 28 | this.fileName = fileName; 29 | } 30 | 31 | public String getClassName() { 32 | return className; 33 | } 34 | 35 | public void setClassName(String className) { 36 | this.className = className; 37 | } 38 | 39 | public int getLineNo() { 40 | return lineNo; 41 | } 42 | 43 | public void setLineNo(int lineNo) { 44 | this.lineNo = lineNo; 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "RemoveTracePointRequest{" + 50 | "tracePointId='" + tracePointId + '\'' + 51 | ", fileName='" + fileName + '\'' + 52 | ", className='" + className + '\'' + 53 | ", lineNo=" + lineNo + 54 | ", id='" + id + '\'' + 55 | ", client='" + client + '\'' + 56 | '}'; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /sidekick-agent-tracepoint/src/main/java/com/runsidekick/agent/tracepoint/response/DisableTracePointResponse.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.tracepoint.response; 2 | 3 | import com.runsidekick.agent.broker.response.impl.BaseResponse; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public class DisableTracePointResponse extends BaseResponse { 9 | 10 | @Override 11 | public String toString() { 12 | return "DisableTracePointResponse{" + 13 | "requestId='" + requestId + '\'' + 14 | ", applicationInstanceId='" + applicationInstanceId + '\'' + 15 | ", client='" + client + '\'' + 16 | ", erroneous=" + erroneous + 17 | ", errorCode=" + errorCode + 18 | ", errorMessage='" + errorMessage + '\'' + 19 | '}'; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /sidekick-agent-tracepoint/src/main/java/com/runsidekick/agent/tracepoint/response/EnableTracePointResponse.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.tracepoint.response; 2 | 3 | import com.runsidekick.agent.broker.response.impl.BaseResponse; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public class EnableTracePointResponse extends BaseResponse { 9 | 10 | @Override 11 | public String toString() { 12 | return "EnableTracePointResponse{" + 13 | "requestId='" + requestId + '\'' + 14 | ", applicationInstanceId='" + applicationInstanceId + '\'' + 15 | ", client='" + client + '\'' + 16 | ", erroneous=" + erroneous + 17 | ", errorCode=" + errorCode + 18 | ", errorMessage='" + errorMessage + '\'' + 19 | '}'; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /sidekick-agent-tracepoint/src/main/java/com/runsidekick/agent/tracepoint/response/FilterTracePointsResponse.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.tracepoint.response; 2 | 3 | import com.runsidekick.agent.tracepoint.domain.TracePoint; 4 | import com.runsidekick.agent.broker.response.impl.BaseResponse; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author serkan 10 | */ 11 | public class FilterTracePointsResponse extends BaseResponse { 12 | 13 | protected List tracePoints; 14 | 15 | public FilterTracePointsResponse() { 16 | } 17 | 18 | public List getTracePoints() { 19 | return tracePoints; 20 | } 21 | 22 | public void setTracePoints(List tracePoints) { 23 | this.tracePoints = tracePoints; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return "FilterTracePointsResponse{" + 29 | "requestId='" + requestId + '\'' + 30 | ", applicationInstanceId='" + applicationInstanceId + '\'' + 31 | ", tracePoints=" + tracePoints + 32 | ", erroneous=" + erroneous + 33 | ", errorCode=" + errorCode + 34 | ", errorMessage='" + errorMessage + '\'' + 35 | '}'; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /sidekick-agent-tracepoint/src/main/java/com/runsidekick/agent/tracepoint/response/PutTracePointResponse.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.tracepoint.response; 2 | 3 | import com.runsidekick.agent.broker.response.impl.BaseResponse; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public class PutTracePointResponse extends BaseResponse { 9 | 10 | @Override 11 | public String toString() { 12 | return "PutTracePointResponse{" + 13 | "requestId='" + requestId + '\'' + 14 | ", applicationInstanceId='" + applicationInstanceId + '\'' + 15 | ", client='" + client + '\'' + 16 | ", erroneous=" + erroneous + 17 | ", errorCode=" + errorCode + 18 | ", errorMessage='" + errorMessage + '\'' + 19 | '}'; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /sidekick-agent-tracepoint/src/main/java/com/runsidekick/agent/tracepoint/response/RemoveTracePointResponse.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.tracepoint.response; 2 | 3 | import com.runsidekick.agent.broker.response.impl.BaseResponse; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public class RemoveTracePointResponse extends BaseResponse { 9 | 10 | @Override 11 | public String toString() { 12 | return "RemoveTracePointResponse{" + 13 | "requestId='" + requestId + '\'' + 14 | ", applicationInstanceId='" + applicationInstanceId + '\'' + 15 | ", client='" + client + '\'' + 16 | ", erroneous=" + erroneous + 17 | ", errorCode=" + errorCode + 18 | ", errorMessage='" + errorMessage + '\'' + 19 | '}'; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /sidekick-agent-tracepoint/src/main/java/com/runsidekick/agent/tracepoint/response/UpdateTracePointResponse.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.tracepoint.response; 2 | 3 | import com.runsidekick.agent.broker.response.impl.BaseResponse; 4 | 5 | /** 6 | * @author serkan 7 | */ 8 | public class UpdateTracePointResponse extends BaseResponse { 9 | 10 | @Override 11 | public String toString() { 12 | return "UpdateTracePointResponse{" + 13 | "requestId='" + requestId + '\'' + 14 | ", applicationInstanceId='" + applicationInstanceId + '\'' + 15 | ", client='" + client + '\'' + 16 | ", erroneous=" + erroneous + 17 | ", errorCode=" + errorCode + 18 | ", errorMessage='" + errorMessage + '\'' + 19 | '}'; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /sidekick-agent-tracepoint/src/main/java/com/runsidekick/agent/tracepoint/trace/TraceContext.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.tracepoint.trace; 2 | 3 | /** 4 | * @author serkan 5 | */ 6 | public class TraceContext { 7 | 8 | private final String traceId; 9 | private final String transactionId; 10 | private final String spanId; 11 | 12 | public TraceContext(String traceId, String transactionId, String spanId) { 13 | this.traceId = traceId; 14 | this.transactionId = transactionId; 15 | this.spanId = spanId; 16 | } 17 | 18 | public String getTraceId() { 19 | return traceId; 20 | } 21 | 22 | public String getTransactionId() { 23 | return transactionId; 24 | } 25 | 26 | public String getSpanId() { 27 | return spanId; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /sidekick-agent-tracepoint/src/main/resources/META-INF/services/com.runsidekick.agent.broker.application.ApplicationStatusProvider: -------------------------------------------------------------------------------- 1 | com.runsidekick.agent.tracepoint.application.ApplicationStatusTracePointProvider -------------------------------------------------------------------------------- /sidekick-agent-tracepoint/src/main/resources/META-INF/services/com.runsidekick.agent.broker.handler.request.RequestHandler: -------------------------------------------------------------------------------- 1 | com.runsidekick.agent.tracepoint.handler.request.PutTracePointRequestHandler 2 | com.runsidekick.agent.tracepoint.handler.request.UpdateTracePointRequestHandler 3 | com.runsidekick.agent.tracepoint.handler.request.RemoveBatchTracePointRequestHandler 4 | com.runsidekick.agent.tracepoint.handler.request.RemoveTracePointRequestHandler 5 | com.runsidekick.agent.tracepoint.handler.request.EnableTracePointRequestHandler 6 | com.runsidekick.agent.tracepoint.handler.request.DisableTracePointRequestHandler 7 | -------------------------------------------------------------------------------- /sidekick-agent-tracepoint/src/main/resources/META-INF/services/com.runsidekick.agent.broker.handler.response.ResponseHandler: -------------------------------------------------------------------------------- 1 | com.runsidekick.agent.tracepoint.handler.response.FilterTracePointsResponseHandler 2 | -------------------------------------------------------------------------------- /sidekick-agent-tracepoint/src/main/resources/META-INF/services/com.runsidekick.agent.core.initialize.EnvironmentInitializer: -------------------------------------------------------------------------------- 1 | com.runsidekick.agent.tracepoint.initialize.TracePointSupportInitializer -------------------------------------------------------------------------------- /sidekick-agent-tracepoint/src/test/java/com/runsidekick/agent/tracepoint/App.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.tracepoint; 2 | 3 | import com.runsidekick.agent.core.initialize.EnvironmentInitializerManager; 4 | 5 | import java.util.Arrays; 6 | import java.util.List; 7 | import java.util.UUID; 8 | 9 | /* 10 | -Dsidekick.agent.broker.host=wss://broker.service.runsidekick.me 11 | -Dsidekick.agent.broker.port=443 12 | -Dsidekick.agent.broker.host2=ws://localhost 13 | -Dsidekick.agent.broker.port2=7777 14 | -Dsidekick.apikey= 15 | -Dsidekick.agent.application.name=hello 16 | */ 17 | public class App { 18 | 19 | public static void main(String[] args) throws Exception { 20 | EnvironmentInitializerManager.ensureInitialized(); 21 | 22 | Hello hello = new Hello(); 23 | 24 | String tracePointId1 = UUID.randomUUID().toString(); 25 | String tracePointId2 = UUID.randomUUID().toString(); 26 | 27 | TracePointSupport.putTracePoint(tracePointId1, Hello.class.getName(), 19, "serkan@thundra.io", null, "name==\"kaan\" AND i > 0", -1, -1, true, false, null); 28 | TracePointSupport.putTracePoint(tracePointId2, Hello.class.getName(), 27, "serkan@thundra.io", null, "idx > 0", -1, -1, true, false, null); 29 | 30 | List names = Arrays.asList("serkan", "seyda", "kaan"); 31 | int i = 0; 32 | while (true) { 33 | Thread.sleep(5000); 34 | System.out.println(hello.sayHello(names.get(i++ % names.size()))); 35 | } 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /sidekick-agent-tracepoint/src/test/java/com/runsidekick/agent/tracepoint/Hello.java: -------------------------------------------------------------------------------- 1 | package com.runsidekick.agent.tracepoint; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | public class Hello { 7 | 8 | private final List helloMessages = Arrays.asList("merhaba", "hi", "hola"); 9 | private final HelloMessageProvider helloMessageProvider = new HelloMessageProvider(); 10 | 11 | public String sayHello(String name) { 12 | StringBuilder sb = new StringBuilder(); 13 | int[] ia = new int[] {1, 2, 3}; 14 | for (int i = 0; i < helloMessages.size(); i++) { 15 | String helloMsg = helloMessageProvider.getHelloMessage(i); 16 | if (i > 0) { 17 | sb.append(", "); 18 | } 19 | sb.append(helloMsg).append(" ").append(name); 20 | } 21 | return sb.toString(); 22 | } 23 | 24 | public class HelloMessageProvider { 25 | 26 | private String getHelloMessage(int idx) { 27 | return helloMessages.get(idx); 28 | } 29 | 30 | } 31 | 32 | } 33 | --------------------------------------------------------------------------------