Skip to content

Commit 5ed034d

Browse files
authored
use non-private attributes for service name and endpoint URL (#1079)
1 parent 3f4eddc commit 5ed034d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

elasticapm/instrumentation/packages/botocore.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636

3737
HandlerInfo = namedtuple("HandlerInfo", ("signature", "span_type", "span_subtype", "span_action", "context"))
3838

39+
# Used for boto3 < 1.7
40+
endpoint_to_service_id = {"SNS": "SNS", "S3": "S3", "DYNAMODB": "DynamoDB", "SQS": "SQS"}
41+
3942

4043
class BotocoreInstrumentation(AbstractInstrumentedModule):
4144
name = "botocore"
@@ -48,9 +51,14 @@ def call(self, module, method, wrapped, instance, args, kwargs):
4851
else:
4952
operation_name = args[0]
5053

51-
service = instance._service_model.service_id
54+
service_model = instance.meta.service_model
55+
if hasattr(service_model, "service_id"): # added in boto3 1.7
56+
service = service_model.service_id
57+
else:
58+
service = service_model.service_name.upper()
59+
service = endpoint_to_service_id.get(service, service)
5260

53-
parsed_url = urlparse.urlparse(instance._endpoint.host)
61+
parsed_url = urlparse.urlparse(instance.meta.endpoint_url)
5462
context = {
5563
"destination": {
5664
"address": parsed_url.hostname,

0 commit comments

Comments
 (0)