Skip to content

[SigV4] README for using SigV4 Exporter #172

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
],
"exclude": [
"src/third-party/**/*.ts",
"src/otlp-aws-span-exporter.ts"
"src/aws-span-exporter/otlp-aws-span-exporter.ts"
]
},
"bugs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import { AttributePropagatingSpanProcessorBuilder } from './attribute-propagatin
import { AwsBatchUnsampledSpanProcessor } from './aws-batch-unsampled-span-processor';
import { AwsMetricAttributesSpanExporterBuilder } from './aws-metric-attributes-span-exporter-builder';
import { AwsSpanMetricsProcessorBuilder } from './aws-span-metrics-processor-builder';
import { OTLPAwsSpanExporter } from './otlp-aws-span-exporter';
import { OTLPAwsSpanExporter } from './aws-span-exporter/otlp-aws-span-exporter';
import { OTLPUdpSpanExporter } from './otlp-udp-exporter';
import { AwsXRayRemoteSampler } from './sampler/aws-xray-remote-sampler';
// This file is generated via `npm run compile`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# ADOT X-Ray OTLP Trace Export Configuration

This guide explains how to automatically configure ADOT environment variables for exporting traces to [AWS X-Ray OTLP endpoint](https://docs.aws.amazon.com/xray/latest/devguide/xray-opentelemetry.html)

## Pre-requisites

1. Transaction Search must be enabled in order to send spans to the Xray OTLP endpoint. See [this doc](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Transaction-Search-getting-started.html) on how to enable Transaction Search.

2. Ensure the AWS role in your application environment has [AWSXRayWriteOnlyAccess](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AWSXrayWriteOnlyAccess.html) managed policy attached.

## Environment Variables

Set the following environment variables to **PROPERLY** configure trace export with SigV4 authentication:

```shell
# Set X-Ray endpoint (replace AWS_REGION with your region)
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://xray.<AWS_REGION>.amazonaws.com/v1/traces

# Configure OTLP export protocol
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf

OTEL_TRACES_EXPORTER=otlp
OTEL_METRICS_EXPORTER=none
OTEL_LOGS_EXPORTER=none
OTEL_RESOURCE_ATTRIBUTES="service.name=<YOUR_SERVICE_NAME>"

# Disable application signals (they will be generated in CloudWatch backend)
OTEL_AWS_APPLICATION_SIGNALS_ENABLED=false
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { OTLPExporterNodeConfigBase } from '@opentelemetry/otlp-exporter-base';
import { ProtobufTraceSerializer } from '@opentelemetry/otlp-transformer';
import { ReadableSpan } from '@opentelemetry/sdk-trace-base';
import { ExportResult } from '@opentelemetry/core';
import { getNodeVersion } from './utils';
import { getNodeVersion } from '../utils';

/**
* This exporter extends the functionality of the OTLPProtoTraceExporter to allow spans to be exported
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import expect from 'expect';
import { OTLPAwsSpanExporter } from '../src/otlp-aws-span-exporter';
import * as sinon from 'sinon';
import { OTLPAwsSpanExporter } from '../src/aws-span-exporter/otlp-aws-span-exporter';
import * as proxyquire from 'proxyquire';
import * as nock from 'nock';
import { getNodeVersion } from '../src/utils';
Expand Down Expand Up @@ -36,7 +36,7 @@ if (nodeVersion >= 16) {
return [200, ''];
});

mockModule = proxyquire('../src/otlp-aws-span-exporter', {
mockModule = proxyquire('../src/aws-span-exporter/otlp-aws-span-exporter', {
'@smithy/signature-v4': {
SignatureV4: class MockSignatureV4 {
sign(req: any) {
Expand Down Expand Up @@ -127,7 +127,7 @@ if (nodeVersion >= 16) {
});

it('should not inject SigV4 headers if failure to sign headers', done => {
const stubbedModule = proxyquire('../src/otlp-aws-span-exporter', {
const stubbedModule = proxyquire('../src/aws-span-exporter/otlp-aws-span-exporter', {
'@smithy/signature-v4': {
SignatureV4: class MockSignatureV4 {
sign() {
Expand Down Expand Up @@ -156,7 +156,7 @@ if (nodeVersion >= 16) {
});

it('should not inject SigV4 headers if failure to retrieve credentials', done => {
const stubbedModule = proxyquire('../src/otlp-aws-span-exporter', {
const stubbedModule = proxyquire('../src/aws-span-exporter/otlp-aws-span-exporter', {
'@aws-sdk/credential-provider-node': {
defaultProvider: () => async () => {
throw new Error('credentials error');
Expand Down
Loading