You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SigV4 Authentication Support for OTLP HTTP Logs Exporter (#358)
**Background**
Supporting ADOT auto instrumentation to automatically inject SigV4
authentication headers for outgoing export log requests to the allow
exporting to the AWS Logs OTLP endpoint. Users will need to configure
the following environment variables in order to enable and properly run
this exporter:
`OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=https://logs.[AWS-REGION].amazonaws.com/v1/logs`;
**required**
`OTEL_EXPORTER_OTLP_LOGS_HEADERS`=`x-aws-log-group=[CW-LOG-GROUP-NAME],x-aws-log-stream=[CW-LOG-STREAM-NAME]`
**required**
`OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED`=`true` **required**
`OTEL_LOGS_EXPORTER=otlp` **required or do not set env variable**
`OTEL_EXPORTER_OTLP_LOGS_PROTOCOL=http/protobuf` **required or do not
set env variable**
`OTEL_METRICS_EXPORTER=none`
**Description of changes:**
1. Add new AwsAuthSession class to inject Sigv4 headers directly into
the sessions object used by the upstream exporter.
https://github.com/srprash/aws-otel-sigv4-auth/tree/main
2. In order to ensure we don't override any user configurations from
environment variables, the `OTLPAwsLogExporter` constructor copies all
existing `LogsExporter` configurations create by upstream's
instrumentation.
3. The ADOT auto instrumentation is now configured to automatically
detect if a user is exporting to CW Logs OTLP Logs endpoint by checking
if the environment variable `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT` is
configured to match this url pattern:
`https://logs.[AWS-REGION].amazonaws.com/v1/logs`
**Testing:**
1. E2E test done in an empty EC2 environment without configuring .aws
credentials config file or setting AWS credentials in the environment
variable
2. Manual testing was done by configuring the above environment
variables and setting up the sample app locally with ADOT auto
instrumentation and verified the spans in CW Logs.
3. The sample app was run and rerun 30 times and confirmed no issues
with exporting the logs to the endpoint
4. Unit tests were added to verify functionality of OtlpAwsLogsExporter
Further testing will be done with the Release tests.
Example of a log exported using this exporter:
```
{
"resource": {
"attributes": {
"aws.local.service": "test",
"service.name": "test",
"cloud.region": "us-west-2",
"host.type": "c5.4xlarge",
"cloud.availability_zone": "us-west-2c",
"telemetry.sdk.name": "opentelemetry",
"telemetry.sdk.language": "python",
"cloud.provider": "aws",
"cloud.account.id": "571600841604",
"telemetry.sdk.version": "1.27.0",
"host.name": "ip-172-31-7-29.us-west-2.compute.internal",
"cloud.platform": "aws_ec2",
"host.id": "i-0b04d6affbae7d629",
"telemetry.auto.version": "0.9.0.dev0-aws"
}
},
"scope": {
"name": "opentelemetry.sdk._logs._internal"
},
"timeUnixNano": 1746221090210187520,
"observedTimeUnixNano": 1746221090210645309,
"severityNumber": 9,
"severityText": "INFO",
"body": "\u001b[31m\u001b[1mWARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.\u001b[0m\n * Running on http://127.0.0.1:8082",
"attributes": {
"code.filepath": "/home/ec2-user/aws-otel-python-instrumentation/auto_instrumentation/lib64/python3.11/site-packages/werkzeug/_internal.py",
"otelTraceSampled": false,
"code.function": "_log",
"code.lineno": 97,
"otelTraceID": "0",
"otelSpanID": "0",
"otelServiceName": "test"
},
"traceId": "",
"spanId": ""
}
```
0 commit comments