Skip to content

Commit 57b3776

Browse files
authored
Merge branch 'main' into python-e2e-test
2 parents 5d6c1b5 + cc72f68 commit 57b3776

File tree

7 files changed

+229
-94
lines changed

7 files changed

+229
-94
lines changed

.github/workflows/release_lambda.yml

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ on:
1010

1111
env:
1212
COMMERCIAL_REGIONS: us-east-1, us-east-2, us-west-1, us-west-2, ap-south-1, ap-northeast-3, ap-northeast-2, ap-southeast-1, ap-southeast-2, ap-northeast-1, ca-central-1, eu-central-1, eu-west-1, eu-west-2, eu-west-3, eu-north-1, sa-east-1
13-
# LAYER_NAME: AWSOpenTelemetryDistroPython
14-
LAYER_NAME: AWSOpenTelemetryDistroPythonBeta
13+
LAYER_NAME: AWSOpenTelemetryDistroPython
1514

1615
permissions:
1716
id-token: write
@@ -56,7 +55,6 @@ jobs:
5655
needs: build-layer
5756
strategy:
5857
matrix:
59-
# aws_region: ${{ fromJson(github.event.inputs.aws_region) }}
6058
aws_region: ${{ fromJson(needs.build-layer.outputs.aws_regions_json) }}
6159
steps:
6260
- name: role arn
@@ -112,7 +110,6 @@ jobs:
112110
mkdir ${{ env.LAYER_NAME }}
113111
echo $layerARN > ${{ env.LAYER_NAME }}/${{ matrix.aws_region }}
114112
cat ${{ env.LAYER_NAME }}/${{ matrix.aws_region }}
115-
pwd
116113
- name: public layer
117114
run: |
118115
layerVersion=$(
@@ -193,21 +190,39 @@ jobs:
193190
run: |
194191
git config user.name "github-actions[bot]"
195192
git config user.email "github-actions[bot]@users.noreply.github.com"
196-
git checkout -b "release-lambda-${{ github.run_id }}"
197193
mv layer.tf lambda-layer/terraform/lambda/
198194
git add lambda-layer/terraform/lambda/layer.tf
199195
git commit -m "Update Lambda layer ARNs for releasing" || echo "No changes to commit"
200-
git push --set-upstream origin "release-lambda-${{ github.run_id }}"
201-
- name: Create Pull Request
196+
git push
197+
create-release:
198+
runs-on: ubuntu-latest
199+
needs: generate-release-note
200+
steps:
201+
- name: Checkout Repo @ SHA - ${{ github.sha }}
202+
uses: actions/checkout@v4
203+
- name: Get latest commit SHA
204+
run: |
205+
echo "COMMIT_SHA=${GITHUB_SHA}" >> $GITHUB_ENV
206+
SHORT_SHA=$(echo $GITHUB_SHA | cut -c1-7)
207+
echo "SHORT_SHA=${SHORT_SHA}" >> $GITHUB_ENV
208+
- name: Create Tag
209+
run: |
210+
git config user.name "github-actions[bot]"
211+
git config user.email "github-actions[bot]@users.noreply.github.com"
212+
TAG_NAME="lambda-${SHORT_SHA}"
213+
git tag -a "$TAG_NAME" -m "Release Lambda layer based on commit $TAG_NAME"
214+
git push origin "$TAG_NAME"
215+
echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_ENV
216+
env:
217+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
218+
- name: Create Release
219+
id: create_release
220+
uses: actions/create-release@v1
202221
env:
203222
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
204-
uses: peter-evans/create-pull-request@v5
205223
with:
206-
token: ${{ secrets.GITHUB_TOKEN }}
207-
commit-message: "Update Lambda layer ARNs for releasing"
208-
title: "Update Layer layer ARNs for releasing"
209-
body: |
210-
This PR updates the layer.tf file for the AWS region `${{ matrix.aws_region }}`.
211-
branch: release-lambda-${{ github.run_id }}
212-
base: main
213-
224+
tag_name: ${{ env.TAG_NAME }}
225+
release_name: "Release AWSOpenTelemetryDistroPython Lambda Layer"
226+
body_path: lambda-layer/terraform/lambda/layer.tf
227+
draft: true
228+
prerelease: false

aws-opentelemetry-distro/src/amazon/opentelemetry/distro/sampler/_sampling_rule_applier.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from amazon.opentelemetry.distro.sampler._sampling_target import _SamplingTarget
1313
from opentelemetry.context import Context
1414
from opentelemetry.sdk.resources import Resource
15-
from opentelemetry.sdk.trace.sampling import Decision, ParentBased, Sampler, SamplingResult, TraceIdRatioBased
15+
from opentelemetry.sdk.trace.sampling import Decision, Sampler, SamplingResult, TraceIdRatioBased
1616
from opentelemetry.semconv.resource import CloudPlatformValues, ResourceAttributes
1717
from opentelemetry.semconv.trace import SpanAttributes
1818
from opentelemetry.trace import Link, SpanKind
@@ -42,7 +42,7 @@ def __init__(
4242
self.__borrowing = False
4343

4444
if target is None:
45-
self.__fixed_rate_sampler = ParentBased(TraceIdRatioBased(self.sampling_rule.FixedRate))
45+
self.__fixed_rate_sampler = TraceIdRatioBased(self.sampling_rule.FixedRate)
4646
# Until targets are fetched, initialize as borrowing=True if there will be a quota > 0
4747
if self.sampling_rule.ReservoirSize > 0:
4848
self.__reservoir_sampler = self.__create_reservoir_sampler(quota=1)
@@ -55,7 +55,7 @@ def __init__(
5555
new_quota = target.ReservoirQuota if target.ReservoirQuota is not None else 0
5656
new_fixed_rate = target.FixedRate if target.FixedRate is not None else 0
5757
self.__reservoir_sampler = self.__create_reservoir_sampler(quota=new_quota)
58-
self.__fixed_rate_sampler = ParentBased(TraceIdRatioBased(new_fixed_rate))
58+
self.__fixed_rate_sampler = TraceIdRatioBased(new_fixed_rate)
5959
if target.ReservoirQuotaTTL is not None:
6060
self.__reservoir_expiry = self._clock.from_timestamp(target.ReservoirQuotaTTL)
6161
else:
@@ -159,7 +159,7 @@ def matches(self, resource: Resource, attributes: Attributes) -> bool:
159159
)
160160

161161
def __create_reservoir_sampler(self, quota: int) -> Sampler:
162-
return ParentBased(_RateLimitingSampler(quota, self._clock))
162+
return _RateLimitingSampler(quota, self._clock)
163163

164164
# pylint: disable=no-self-use
165165
def __get_service_type(self, resource: Resource) -> str:

aws-opentelemetry-distro/src/amazon/opentelemetry/distro/sampler/aws_xray_remote_sampler.py

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,48 @@
2424
DEFAULT_SAMPLING_PROXY_ENDPOINT = "http://127.0.0.1:2000"
2525

2626

27+
# Wrapper class to ensure that all XRay Sampler Functionality in _AwsXRayRemoteSampler
28+
# uses ParentBased logic to respect the parent span's sampling decision
2729
class AwsXRayRemoteSampler(Sampler):
30+
def __init__(
31+
self,
32+
resource: Resource,
33+
endpoint: str = None,
34+
polling_interval: int = None,
35+
log_level=None,
36+
):
37+
self._root = ParentBased(
38+
_AwsXRayRemoteSampler(
39+
resource=resource, endpoint=endpoint, polling_interval=polling_interval, log_level=log_level
40+
)
41+
)
42+
43+
# pylint: disable=no-self-use
44+
@override
45+
def should_sample(
46+
self,
47+
parent_context: Optional[Context],
48+
trace_id: int,
49+
name: str,
50+
kind: SpanKind = None,
51+
attributes: Attributes = None,
52+
links: Sequence[Link] = None,
53+
trace_state: TraceState = None,
54+
) -> SamplingResult:
55+
return self._root.should_sample(
56+
parent_context, trace_id, name, kind=kind, attributes=attributes, links=links, trace_state=trace_state
57+
)
58+
59+
# pylint: disable=no-self-use
60+
@override
61+
def get_description(self) -> str:
62+
return f"AwsXRayRemoteSampler{{root:{self._root.get_description()}}}"
63+
64+
65+
# _AwsXRayRemoteSampler contains all core XRay Sampler Functionality,
66+
# however it is NOT Parent-based (e.g. Sample logic runs for each span)
67+
# Not intended for external use, use Parent-based `AwsXRayRemoteSampler` instead.
68+
class _AwsXRayRemoteSampler(Sampler):
2869
"""
2970
Remote Sampler for OpenTelemetry that gets sampling configurations from AWS X-Ray
3071
@@ -58,7 +99,7 @@ def __init__(
5899
self.__client_id = self.__generate_client_id()
59100
self._clock = _Clock()
60101
self.__xray_client = _AwsXRaySamplingClient(endpoint, log_level=log_level)
61-
self.__fallback_sampler = ParentBased(_FallbackSampler(self._clock))
102+
self.__fallback_sampler = _FallbackSampler(self._clock)
62103

63104
self.__polling_interval = polling_interval
64105
self.__target_polling_interval = DEFAULT_TARGET_POLLING_INTERVAL_SECONDS
@@ -114,7 +155,7 @@ def should_sample(
114155
# pylint: disable=no-self-use
115156
@override
116157
def get_description(self) -> str:
117-
description = "AwsXRayRemoteSampler{remote sampling with AWS X-Ray}"
158+
description = "_AwsXRayRemoteSampler{remote sampling with AWS X-Ray}"
118159
return description
119160

120161
def __get_and_update_sampling_rules(self) -> None:

0 commit comments

Comments
 (0)