Search in sources :

Example 1 with ECSPlugin

use of com.amazonaws.xray.plugins.ECSPlugin in project aws-xray-sdk-java by aws.

the class AWSXRayRecorderTest method testPluginEquality.

@Test
public void testPluginEquality() {
    Collection<Plugin> plugins = new HashSet<>();
    plugins.add(new EC2Plugin());
    // should be deduped
    plugins.add(new EC2Plugin());
    plugins.add(new ECSPlugin());
    plugins.add(new EKSPlugin());
    plugins.add(new ElasticBeanstalkPlugin());
    Assert.assertEquals(4, plugins.size());
}
Also used : EC2Plugin(com.amazonaws.xray.plugins.EC2Plugin) ECSPlugin(com.amazonaws.xray.plugins.ECSPlugin) EKSPlugin(com.amazonaws.xray.plugins.EKSPlugin) ECSPlugin(com.amazonaws.xray.plugins.ECSPlugin) EKSPlugin(com.amazonaws.xray.plugins.EKSPlugin) ElasticBeanstalkPlugin(com.amazonaws.xray.plugins.ElasticBeanstalkPlugin) EC2Plugin(com.amazonaws.xray.plugins.EC2Plugin) Plugin(com.amazonaws.xray.plugins.Plugin) HashSet(java.util.HashSet) ElasticBeanstalkPlugin(com.amazonaws.xray.plugins.ElasticBeanstalkPlugin) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with ECSPlugin

use of com.amazonaws.xray.plugins.ECSPlugin in project aws-xray-sdk-java by aws.

the class AWSXRayRecorderBuilder method withDefaultPlugins.

/**
 * Adds all implemented plugins to the builder instance rather than requiring them to be individually added. The recorder will
 * only reflect metadata from plugins that are enabled, which is checked in the build method below.
 *
 * @return
 * The builder instance, for chaining
 */
public AWSXRayRecorderBuilder withDefaultPlugins() {
    plugins.add(new EC2Plugin());
    plugins.add(new ECSPlugin());
    plugins.add(new EKSPlugin());
    plugins.add(new ElasticBeanstalkPlugin());
    return this;
}
Also used : EC2Plugin(com.amazonaws.xray.plugins.EC2Plugin) ECSPlugin(com.amazonaws.xray.plugins.ECSPlugin) EKSPlugin(com.amazonaws.xray.plugins.EKSPlugin) ElasticBeanstalkPlugin(com.amazonaws.xray.plugins.ElasticBeanstalkPlugin)

Example 3 with ECSPlugin

use of com.amazonaws.xray.plugins.ECSPlugin in project aws-xray-sdk-java by aws.

the class AWSXRayRecorderTest method testEKSOriginResolvesOverECSOrigin.

@Test
public void testEKSOriginResolvesOverECSOrigin() {
    // given
    ECSPlugin ecsPlugin = Mockito.mock(ECSPlugin.class);
    EKSPlugin eksPlugin = Mockito.mock(EKSPlugin.class);
    Map<String, Object> runtimeContext = new HashMap<>();
    runtimeContext.put("key", "value");
    Mockito.doReturn(true).when(ecsPlugin).isEnabled();
    Mockito.doReturn(runtimeContext).when(ecsPlugin).getRuntimeContext();
    Mockito.doReturn("ecs").when(ecsPlugin).getServiceName();
    Mockito.doReturn(ECSPlugin.ORIGIN).when(ecsPlugin).getOrigin();
    Mockito.doReturn(true).when(eksPlugin).isEnabled();
    Mockito.doReturn(runtimeContext).when(eksPlugin).getRuntimeContext();
    Mockito.doReturn("eks").when(eksPlugin).getServiceName();
    Mockito.doReturn(EKSPlugin.ORIGIN).when(eksPlugin).getOrigin();
    AWSXRayRecorder recorder = AWSXRayRecorderBuilder.standard().withPlugin(eksPlugin).withPlugin(ecsPlugin).build();
    // when
    Assert.assertEquals(EKSPlugin.ORIGIN, recorder.getOrigin());
}
Also used : HashMap(java.util.HashMap) ECSPlugin(com.amazonaws.xray.plugins.ECSPlugin) EKSPlugin(com.amazonaws.xray.plugins.EKSPlugin) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with ECSPlugin

use of com.amazonaws.xray.plugins.ECSPlugin in project aws-xray-sdk-java by aws.

the class AWSXRayRecorderTest method testOriginResolutionWithAllPlugins.

@Test
public void testOriginResolutionWithAllPlugins() {
    // given
    EC2Plugin ec2Plugin = Mockito.mock(EC2Plugin.class);
    ECSPlugin ecsPlugin = Mockito.mock(ECSPlugin.class);
    ElasticBeanstalkPlugin ebPlugin = Mockito.mock(ElasticBeanstalkPlugin.class);
    EKSPlugin eksPlugin = Mockito.mock(EKSPlugin.class);
    List<Plugin> plugins = new ArrayList<>();
    plugins.add(ec2Plugin);
    plugins.add(ecsPlugin);
    plugins.add(ebPlugin);
    plugins.add(eksPlugin);
    List<String> origins = new ArrayList<>();
    origins.add(EC2Plugin.ORIGIN);
    origins.add(ECSPlugin.ORIGIN);
    origins.add(ElasticBeanstalkPlugin.ORIGIN);
    origins.add(EKSPlugin.ORIGIN);
    Map<String, Object> runtimeContext = new HashMap<>();
    runtimeContext.put("key", "value");
    for (int i = 0; i < 4; i++) {
        Mockito.doReturn(true).when(plugins.get(i)).isEnabled();
        Mockito.doReturn(runtimeContext).when(plugins.get(i)).getRuntimeContext();
        Mockito.doReturn("serviceName").when(plugins.get(i)).getServiceName();
        Mockito.doReturn(origins.get(i)).when(plugins.get(i)).getOrigin();
    }
    AWSXRayRecorder recorder = AWSXRayRecorderBuilder.standard().withPlugin(ec2Plugin).withPlugin(ecsPlugin).withPlugin(ebPlugin).withPlugin(eksPlugin).build();
    // when
    Assert.assertEquals(ElasticBeanstalkPlugin.ORIGIN, recorder.getOrigin());
}
Also used : EC2Plugin(com.amazonaws.xray.plugins.EC2Plugin) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ElasticBeanstalkPlugin(com.amazonaws.xray.plugins.ElasticBeanstalkPlugin) ECSPlugin(com.amazonaws.xray.plugins.ECSPlugin) EKSPlugin(com.amazonaws.xray.plugins.EKSPlugin) ECSPlugin(com.amazonaws.xray.plugins.ECSPlugin) EKSPlugin(com.amazonaws.xray.plugins.EKSPlugin) ElasticBeanstalkPlugin(com.amazonaws.xray.plugins.ElasticBeanstalkPlugin) EC2Plugin(com.amazonaws.xray.plugins.EC2Plugin) Plugin(com.amazonaws.xray.plugins.Plugin) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

ECSPlugin (com.amazonaws.xray.plugins.ECSPlugin)4 EKSPlugin (com.amazonaws.xray.plugins.EKSPlugin)4 EC2Plugin (com.amazonaws.xray.plugins.EC2Plugin)3 ElasticBeanstalkPlugin (com.amazonaws.xray.plugins.ElasticBeanstalkPlugin)3 Test (org.junit.Test)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 Plugin (com.amazonaws.xray.plugins.Plugin)2 HashMap (java.util.HashMap)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1