-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
188 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/patches/test_botocore_sns.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
import botocore.session | ||
from moto import mock_aws | ||
|
||
from amazon.opentelemetry.distro.patches._instrumentation_patch import apply_instrumentation_patches | ||
from opentelemetry.instrumentation.botocore import BotocoreInstrumentor | ||
from opentelemetry.test.test_base import TestBase | ||
|
||
|
||
class TestSnsExtension(TestBase): | ||
def setUp(self): | ||
super().setUp() | ||
BotocoreInstrumentor().instrument() | ||
# Apply patches | ||
apply_instrumentation_patches() | ||
|
||
session = botocore.session.get_session() | ||
session.set_credentials(access_key="access-key", secret_key="secret-key") | ||
self.client = session.create_client("sns", region_name="us-west-2") | ||
self.topic_name = "my-topic" | ||
|
||
def tearDown(self): | ||
super().tearDown() | ||
BotocoreInstrumentor().uninstrument() | ||
|
||
@mock_aws | ||
def test_create_and_delete_topic(self): | ||
self.memory_exporter.clear() | ||
response = self.client.create_topic(Name=self.topic_name) | ||
topic_arn = response["TopicArn"] | ||
self.client.delete_topic(TopicArn=topic_arn) | ||
spans = self.memory_exporter.get_finished_spans() | ||
self.assertEqual(2, len(spans)) | ||
span = spans[1] | ||
self.assertEqual(topic_arn, span.attributes["aws.sns.topic_arn"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.