Skip to content

Commit 7192017

Browse files
authored
Merge branch 'main' into zhaez/merge-releases
2 parents 0bc9c09 + 7e79092 commit 7192017

File tree

7 files changed

+432
-6
lines changed

7 files changed

+432
-6
lines changed

.github/workflows/daily-scan.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs:
9595
id: high_scan
9696
uses: ./.github/actions/image_scan
9797
with:
98-
image-ref: "public.ecr.aws/aws-observability/adot-autoinstrumentation-python:v0.11.0"
98+
image-ref: "public.ecr.aws/aws-observability/adot-autoinstrumentation-python:v0.12.0"
9999
severity: 'CRITICAL,HIGH'
100100
logout: 'false'
101101

@@ -104,7 +104,7 @@ jobs:
104104
id: low_scan
105105
uses: ./.github/actions/image_scan
106106
with:
107-
image-ref: "public.ecr.aws/aws-observability/adot-autoinstrumentation-python:v0.11.0"
107+
image-ref: "public.ecr.aws/aws-observability/adot-autoinstrumentation-python:v0.12.0"
108108
severity: 'MEDIUM,LOW,UNKNOWN'
109109
logout: 'false'
110110

.github/workflows/main-build.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,23 @@ jobs:
109109
with:
110110
staging-wheel-name: ${{ needs.build.outputs.staging_wheel_file }}
111111
adot-image-name: ${{ needs.build.outputs.staging_registry }}/aws-observability/adot-autoinstrumentation-python-staging:${{ needs.build.outputs.python_image_tag }}
112+
113+
publish-main-build-status:
114+
name: "Publish Main Build Status"
115+
needs: [ build, application-signals-e2e-test ]
116+
runs-on: ubuntu-latest
117+
if: always()
118+
steps:
119+
- name: Configure AWS Credentials for emitting metrics
120+
uses: aws-actions/configure-aws-credentials@v4
121+
with:
122+
role-to-assume: ${{ secrets.MONITORING_ROLE_ARN }}
123+
aws-region: ${{ env.AWS_DEFAULT_REGION }}
124+
125+
- name: Publish main build status
126+
run: |
127+
value="${{ needs.build.result == 'success' && needs.application-signals-e2e-test.result == 'success' && '0.0' || '1.0'}}"
128+
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
129+
--metric-name Failure \
130+
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=main_build \
131+
--value $value

.github/workflows/release-build.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,24 @@ jobs:
3535
- name: Checkout Repo @ SHA - ${{ github.sha }}
3636
uses: actions/checkout@v4
3737

38+
- name: Check main build status
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
run: |
42+
WORKFLOW_ID=$(gh api repos/${{ github.repository }}/actions/workflows --jq '.workflows[] | select(.name=="Python Instrumentation Main Build") | .id')
43+
LATEST_RUN=$(gh api repos/${{ github.repository }}/actions/workflows/$WORKFLOW_ID/runs --jq '[.workflow_runs[] | select(.head_branch=="${{ github.ref_name }}")] | sort_by(.created_at) | .[-1] | {conclusion, status}')
44+
STATUS=$(echo "$LATEST_RUN" | jq -r '.status')
45+
CONCLUSION=$(echo "$LATEST_RUN" | jq -r '.conclusion')
46+
47+
if [ "$STATUS" = "in_progress" ] || [ "$STATUS" = "queued" ]; then
48+
echo "Main build is still running (status: $STATUS). Cannot proceed with release."
49+
exit 1
50+
elif [ "$CONCLUSION" != "success" ]; then
51+
echo "Latest main build on branch ${{ github.ref_name }} conclusion: $CONCLUSION"
52+
exit 1
53+
fi
54+
echo "Main build succeeded, proceeding with release"
55+
3856
- name: Build Wheel and Image Files
3957
uses: ./.github/actions/artifacts_build
4058
with:

aws-opentelemetry-distro/src/amazon/opentelemetry/distro/llo_handler.py

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
ROLE_SYSTEM = "system"
1717
ROLE_USER = "user"
1818
ROLE_ASSISTANT = "assistant"
19+
ROLE_TOOL = "tool"
1920

2021
_logger = logging.getLogger(__name__)
2122

@@ -137,6 +138,35 @@ class PatternConfig(TypedDict, total=False):
137138
"role": ROLE_USER,
138139
"source": "prompt",
139140
},
141+
# OTel GenAI Semantic Convention used by the latest Strands SDK
142+
# References:
143+
# - OTel GenAI SemConv: https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-events/
144+
# - Strands SDK PR(introduced in v0.1.9): https://github.com/strands-agents/sdk-python/pull/319
145+
"gen_ai.user.message": {
146+
"type": PatternType.DIRECT,
147+
"role": ROLE_USER,
148+
"source": "prompt",
149+
},
150+
"gen_ai.assistant.message": {
151+
"type": PatternType.DIRECT,
152+
"role": ROLE_ASSISTANT,
153+
"source": "output",
154+
},
155+
"gen_ai.system.message": {
156+
"type": PatternType.DIRECT,
157+
"role": ROLE_SYSTEM,
158+
"source": "prompt",
159+
},
160+
"gen_ai.tool.message": {
161+
"type": PatternType.DIRECT,
162+
"role": ROLE_TOOL,
163+
"source": "prompt",
164+
},
165+
"gen_ai.choice": {
166+
"type": PatternType.DIRECT,
167+
"role": ROLE_ASSISTANT,
168+
"source": "output",
169+
},
140170
}
141171

142172

@@ -214,6 +244,7 @@ def _collect_all_llo_messages(self, span: ReadableSpan, attributes: types.Attrib
214244
for attr_key, value in attributes.items():
215245
if attr_key in self._exact_match_patterns:
216246
config = self._pattern_configs[attr_key]
247+
217248
messages.append(
218249
{"content": value, "role": config.get("role", "unknown"), "source": config.get("source", "unknown")}
219250
)
@@ -279,6 +310,12 @@ def _collect_llo_attributes_from_span(self, span: ReadableSpan) -> Dict[str, Any
279310
# Collect from span events
280311
if span.events:
281312
for event in span.events:
313+
# Check if event name itself is an LLO pattern (e.g., "gen_ai.user.message")
314+
if self._is_llo_attribute(event.name):
315+
# Put all event attributes as the content as LLO in log event
316+
all_llo_attributes[event.name] = dict(event.attributes) if event.attributes else {}
317+
318+
# Also check traditional pattern - LLO attributes within event attributes
282319
if event.attributes:
283320
for key, value in event.attributes.items():
284321
if self._is_llo_attribute(key):
@@ -372,6 +409,10 @@ def _filter_span_events(self, span: ReadableSpan) -> None:
372409
updated_events = []
373410

374411
for event in span.events:
412+
# Skip entire event if event name is an LLO pattern
413+
if self._is_llo_attribute(event.name):
414+
continue
415+
375416
if not event.attributes:
376417
updated_events.append(event)
377418
continue
@@ -417,7 +458,7 @@ def _group_messages_by_type(self, messages: List[Dict[str, Any]]) -> Dict[str, L
417458
elif role == ROLE_ASSISTANT:
418459
output_messages.append(formatted_message)
419460
else:
420-
# Route based on source for non-standard roles
461+
# Route based on source for non-standard roles including tool
421462
if any(key in message.get("source", "") for key in ["completion", "output", "result"]):
422463
output_messages.append(formatted_message)
423464
else:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
__version__ = "0.11.0.dev0"
4+
__version__ = "0.12.0.dev0"

0 commit comments

Comments
 (0)