@@ -0,0 +1,2550 @@
+//snippet-sourcedescription:%5BCreateGroup.java demonstrates how to create an AWS XRay group with a filter expression.%5D%0A//snippet-keyword:%5BSDK for Java 2.0%5D%0A//snippet-keyword:%5BCode Sample%5D%0A//snippet-service:%5BAWS X-Ray Service%5D%0A//snippet-sourcetype:%5Bfull-example%5D%0A//snippet-sourcedate:%5B09/29/2021%5D%0A//snippet-sourceauthor:%5Bscmacdon-aws%5D%0A%0A/*%0A   Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.%0A   SPDX-License-Identifier: Apache-2.0%0A*/%0A%0Apackage com.example.xray;%0A%0A// snippet-start:%5Bxray.java2_create_group.import%5D%0Aimport software.amazon.awssdk.regions.Region;%0Aimport software.amazon.awssdk.services.xray.XRayClient;%0Aimport software.amazon.awssdk.services.xray.model.CreateGroupRequest;%0Aimport software.amazon.awssdk.services.xray.model.CreateGroupResponse;%0Aimport software.amazon.awssdk.services.xray.model.XRayException;%0A// snippet-end:%5Bxray.java2_create_group.import%5D%0A%0A/**%0A * To run this Java V2 code example, ensure that you have setup your development environment, including your credentials.%0A *%0A * For information, see this documentation topic:%0A *%0A * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html%0A */%0Apublic class CreateGroup %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A%0A        final String USAGE = %22%5Cn%22 +%0A                %22Usage: %22 +%0A                %22   %3CgroupName%3E%5Cn%5Cn%22 +%0A                %22Where:%5Cn%22 +%0A                %22   groupName - the name of the group to create %5Cn%5Cn%22;%0A%0A        if (args.length != 1) %7B%0A            System.out.println(USAGE);%0A            System.exit(1);%0A        %7D%0A%0A        String groupName = args%5B0%5D;%0A        Region region = Region.US_EAST_1;%0A        XRayClient xRayClient = XRayClient.builder()%0A                .region(region)%0A                .build();%0A%0A        createNewGroup(xRayClient, groupName);%0A    %7D%0A%0A    // snippet-start:%5Bxray.java2_create_group.main%5D%0A    public static void createNewGroup(XRayClient xRayClient, String groupName) %7B%0A%0A        try %7B%0A            CreateGroupRequest groupRequest = CreateGroupRequest.builder()%0A                    .filterExpression(%22fault = true AND http.url CONTAINS %5C%22example/game%5C%22 AND responsetime %3E= 5%22)%0A                    .groupName(groupName)%0A                    .build();%0A%0A            CreateGroupResponse groupResponse = xRayClient.createGroup(groupRequest);%0A            System.out.println(%22The Group ARN is %22+groupResponse.group().groupARN());%0A%0A        %7D catch (XRayException e) %7B%0A            System.err.println(e.getMessage());%0A            System.exit(1);%0A        %7D%0A    %7D%0A    // snippet-end:%5Bxray.java2_create_group.main%5D%0A%7D%0A

Create CreateGroup.java