Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow multiple log group names/arns to be set in environmental variables for xray exporter #218

Merged
merged 1 commit into from
Jun 24, 2024

Conversation

pxaws
Copy link

@pxaws pxaws commented Jun 18, 2024

Description:

This commit is to allow users to set multiple log group names or arns using environmental variable. We choose to use & to separate individual log group name or arn because & is not allowed in log group names (https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_CreateLogGroup.html) and & implicitly means 'AND'.

Link to tracking Issue:
N/A

Testing:

Unit tests.

Manual end 2 end test confirmed that we get 2 log groups in the raw trace with the change. Note the cloudwatch_logs field below:

{
    "Id": "1-667339a9-c872ab16dbc29a0c11b60c8d",
    "Duration": 0.001,
    "LimitExceeded": false,
    "Segments": [
        {
            "Id": "c1e85cd075339ff9",
            "Document": {
                "id": "c1e85cd075339ff9",
                "name": "vets-service-ec2-java",
                "start_time": 1718827433.377284,
                "trace_id": "1-667339a9-c872ab16dbc29a0c11b60c8d",
                "end_time": 1718827433.3779771,
                "fault": false,
                "error": false,
                "throttle": false,
                "http": {
                    "request": {
                        "url": "http://172.31.47.118:36131/actuator/health",
                        "method": "GET",
                        "user_agent": "ReactorNetty/1.0.18"
                    },
                    "response": {
                        "status": 200,
                        "content_length": 0
                    }
                },
                "aws": {
                    "account_id": "868155213681",
                    "ec2": {
                        "availability_zone": "us-east-1b",
                        "instance_id": "i-0f496fe9393def8f7",
                        "instance_size": "t3.medium",
                        "ami_id": "ami-03934437c323e0de2"
                    },
                    "xray": {
                        "auto_instrumentation": true,
                        "sdk_version": "1.34.1",
                        "sdk": "opentelemetry for java"
                    },
                    "cloudwatch_logs": [
                        {
                            "log_group": "/aws/application-signals/data"
                        },
                        {
                            "log_group": "/aws/appsignals/generic"
                        }
                    ]
                },
                "annotations": {
                    "aws.local.service": "vets-service-ec2-java",
                    "aws.local.operation": "GET /actuator/health",
                    "aws.local.environment": "ec2:default"
                },
                "metadata": {
                    "default": {
                        "net.sock.peer.addr": "172.31.39.3",
                        "otel.resource.process.command_args": [
                            "/usr/lib/jvm/java-17-amazon-corretto.x86_64/bin/java",
                            "-jar",
                            "spring-petclinic-vets-service-2.6.7.jar"
                        ],
                        "otel.resource.host.arch": "amd64",
                        "otel.resource.host.name": "ip-172-31-47-118.ec2.internal",
                        "otel.resource.aws.log.group.names": "/aws/application-signals/data&/aws/appsignals/generic",
                        "thread.name": "http-nio-auto-1-exec-4",
                        "otel.resource.service.name": "vets-service-ec2-java",
                        "otel.resource.telemetry.auto.version": "1.32.2-aws",
                        "aws.span.kind": "LOCAL_ROOT",
                        "net.sock.host.addr": "172.31.47.118",
                        "otel.resource.process.pid": 472258,
                        "otel.resource.os.description": "Linux 6.1.91-99.172.amzn2023.x86_64",
                        "net.protocol.name": "http",
                        "otel.resource.cloud.platform": "aws_ec2",
                        "otel.resource.os.type": "linux",
                        "net.sock.peer.port": 51588,
                        "otel.resource.cloud.region": "us-east-1",
                        "otel.resource.host.type": "t3.medium",
                        "thread.id": 43,
                        "otel.resource.telemetry.sdk.name": "opentelemetry",
                        "otel.resource.service.version": "2.6.7",
                        "otel.resource.cloud.availability_zone": "us-east-1b",
                        "otel.resource.host.image.id": "ami-03934437c323e0de2",
                        "otel.resource.process.runtime.description": "Amazon.com Inc. OpenJDK 64-Bit Server VM 17.0.11+9-LTS",
                        "otel.resource.process.runtime.version": "17.0.11+9-LTS",
                        "Host": "ip-172-31-47-118.ec2.internal",
                        "otel.resource.host.id": "i-0f496fe9393def8f7",
                        "otel.resource.cloud.account.id": "868155213681",
                        "otel.resource.process.executable.path": "/usr/lib/jvm/java-17-amazon-corretto.x86_64/bin/java",
                        "otel.resource.telemetry.sdk.version": "1.34.1",
                        "http.route": "/actuator/health",
                        "EC2.InstanceId": "i-0f496fe9393def8f7",
                        "PlatformType": "AWS::EC2",
                        "otel.resource.process.runtime.name": "OpenJDK Runtime Environment",
                        "otel.resource.telemetry.sdk.language": "java",
                        "otel.resource.cloud.provider": "aws",
                        "net.protocol.version": "1.1",
                        "net.sock.host.port": 36131
                    }
                },
                "service": {
                    "version": "2.6.7"
                },
                "origin": "AWS::EC2::Instance",
                "subsegments": [
                    {
                        "id": "51aaeb8354a93a73",
                        "name": "OperationHandler.handle",
                        "start_time": 1718827433.3773975,
                        "end_time": 1718827433.3779185,
                        "fault": false,
                        "error": false,
                        "throttle": false,
                        "aws": {
                            "account_id": "868155213681",
                            "ec2": {
                                "availability_zone": "us-east-1b",
                                "instance_id": "i-0f496fe9393def8f7",
                                "instance_size": "t3.medium",
                                "ami_id": "ami-03934437c323e0de2"
                            },
                            "xray": {
                                "auto_instrumentation": true,
                                "sdk_version": "1.34.1",
                                "sdk": "opentelemetry for java"
                            },
                            "cloudwatch_logs": [
                                {
                                    "log_group": "/aws/application-signals/data"
                                },
                                {
                                    "log_group": "/aws/appsignals/generic"
                                }
                            ]
                        },
                        "annotations": {
                            "aws.local.operation": "GET /actuator/health",
                            "aws.local.environment": "ec2:default"
                        },
                        "metadata": {
                            "default": {
                                "EC2.InstanceId": "i-0f496fe9393def8f7",
                                "Host": "ip-172-31-47-118.ec2.internal",
                                "PlatformType": "AWS::EC2",
                                "thread.name": "http-nio-auto-1-exec-4",
                                "thread.id": 43
                            }
                        }
                    }
                ]
            }
        }
    ]
}

Documentation:
An example in the readme for xray exporter

@pxaws pxaws requested a review from wangzlei as a code owner June 18, 2024 23:31
Copy link
Collaborator

@wangzlei wangzlei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@lisguo
Copy link

lisguo commented Jun 24, 2024

kubernetes-test is failing due to a unit test in receiver/kubeletstatsreceiver unrelated to the changes here.

linter is failing due to container insights:

Error: awscontainerinsightreceiver/internal/stores/kubeletutil/podresourcesclient.go:51:15: SA1019: grpc.DialContext is deprecated: use NewClient instead.  Will be supported throughout 1.x. (staticcheck)
	conn, err := grpc.DialContext(ctx,

@lisguo lisguo merged commit c75e449 into amazon-contributing:aws-cwa-dev Jun 24, 2024
83 of 122 checks passed
andrzej-stencel pushed a commit to open-telemetry/opentelemetry-collector-contrib that referenced this pull request Jul 3, 2024
…nvironmental variables (#33795)

**Description:** <Describe what has changed.>
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->

Cherry-picking from downstream:


[amazon-contributing#218](amazon-contributing#218)

* We allow users to set multiple log group names or arns using
environmental variable. We choose to use `&` to separate individual log
group name or arn because & is not allowed in log group names
(https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_CreateLogGroup.html)
and `&` implicitly means 'AND'.
* This PR adds the parsing logic in xray exporter to handle multiple log
group names/arns set in environmental variable.

**Link to tracking Issue:** <Issue number if applicable>
N/A

**Testing:** <Describe what testing was performed and which tests were
added.>
Unit Testing

**Documentation:** <Describe the documentation added.>
The readme for xray exporter is updated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants