Adds back retry_attempts to botocore (#275)

This commit is contained in:
Thomas Desrosiers
2021-01-05 20:27:18 -05:00
committed by GitHub
parent 5a6c4f6fd2
commit 21a5c164fa
3 changed files with 23 additions and 0 deletions

View File

@ -35,6 +35,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#236](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/236))
- Add README and example app for Prometheus Remote Write Exporter
([#227](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/227]))
- `opentelemetry-instrumentation-botocore` Adds a field to report the number of retries it take to complete an API call
([#275](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/275))
### Changed
- `opentelemetry-instrumentation-asgi`, `opentelemetry-instrumentation-wsgi` Return `None` for `CarrierGetter` if key not found

View File

@ -153,6 +153,11 @@ class BotocoreInstrumentor(BaseInstrumentor):
"aws.request_id", req_id,
)
if "RetryAttempts" in metadata:
span.set_attribute(
"retry_attempts", metadata["RetryAttempts"],
)
if "HTTPStatusCode" in metadata:
span.set_attribute(
"http.status_code", metadata["HTTPStatusCode"],

View File

@ -69,6 +69,7 @@ class TestBotocoreInstrumentor(TestBase):
"aws.region": "us-west-2",
"aws.request_id": "fdcdcab1-ae5c-489e-9c33-4637c5dda355",
"aws.service": "ec2",
"retry_attempts": 0,
"http.status_code": 200,
},
)
@ -116,6 +117,7 @@ class TestBotocoreInstrumentor(TestBase):
"aws.operation": "ListBuckets",
"aws.region": "us-west-2",
"aws.service": "s3",
"retry_attempts": 0,
"http.status_code": 200,
},
)
@ -159,6 +161,7 @@ class TestBotocoreInstrumentor(TestBase):
"aws.operation": "CreateBucket",
"aws.region": "us-west-2",
"aws.service": "s3",
"retry_attempts": 0,
"http.status_code": 200,
},
)
@ -169,6 +172,7 @@ class TestBotocoreInstrumentor(TestBase):
"aws.operation": "PutObject",
"aws.region": "us-west-2",
"aws.service": "s3",
"retry_attempts": 0,
"http.status_code": 200,
},
)
@ -180,6 +184,7 @@ class TestBotocoreInstrumentor(TestBase):
"aws.operation": "GetObject",
"aws.region": "us-west-2",
"aws.service": "s3",
"retry_attempts": 0,
"http.status_code": 200,
},
)
@ -203,6 +208,7 @@ class TestBotocoreInstrumentor(TestBase):
"aws.operation": "ListQueues",
"aws.region": "us-east-1",
"aws.service": "sqs",
"retry_attempts": 0,
"http.status_code": 200,
},
)
@ -233,6 +239,7 @@ class TestBotocoreInstrumentor(TestBase):
"aws.operation": "CreateQueue",
"aws.region": "us-east-1",
"aws.service": "sqs",
"retry_attempts": 0,
"http.status_code": 200,
},
)
@ -248,6 +255,7 @@ class TestBotocoreInstrumentor(TestBase):
"aws.queue_url": response["QueueUrl"],
"aws.region": "us-east-1",
"aws.service": "sqs",
"retry_attempts": 0,
"http.status_code": 200,
},
)
@ -270,6 +278,7 @@ class TestBotocoreInstrumentor(TestBase):
"aws.operation": "ListStreams",
"aws.region": "us-east-1",
"aws.service": "kinesis",
"retry_attempts": 0,
"http.status_code": 200,
},
)
@ -315,6 +324,7 @@ class TestBotocoreInstrumentor(TestBase):
"aws.operation": "ListFunctions",
"aws.region": "us-east-1",
"aws.service": "lambda",
"retry_attempts": 0,
"http.status_code": 200,
},
)
@ -335,6 +345,7 @@ class TestBotocoreInstrumentor(TestBase):
"aws.operation": "ListKeys",
"aws.region": "us-east-1",
"aws.service": "kms",
"retry_attempts": 0,
"http.status_code": 200,
},
)
@ -359,6 +370,7 @@ class TestBotocoreInstrumentor(TestBase):
"aws.region": "us-east-1",
"aws.request_id": "c6104cbe-af31-11e0-8154-cbc7ccf896c7",
"aws.service": "sts",
"retry_attempts": 0,
"http.status_code": 200,
},
)
@ -395,6 +407,7 @@ class TestBotocoreInstrumentor(TestBase):
"aws.region": "us-west-2",
"aws.request_id": "fdcdcab1-ae5c-489e-9c33-4637c5dda355",
"aws.service": "ec2",
"retry_attempts": 0,
"http.status_code": 200,
},
)
@ -463,6 +476,7 @@ class TestBotocoreInstrumentor(TestBase):
"aws.region": "us-west-2",
"aws.service": "dynamodb",
"aws.table_name": "test_table_name",
"retry_attempts": 0,
"http.status_code": 200,
},
)
@ -478,6 +492,7 @@ class TestBotocoreInstrumentor(TestBase):
"aws.region": "us-west-2",
"aws.service": "dynamodb",
"aws.table_name": "test_table_name",
"retry_attempts": 0,
"http.status_code": 200,
},
)
@ -493,6 +508,7 @@ class TestBotocoreInstrumentor(TestBase):
"aws.region": "us-west-2",
"aws.service": "dynamodb",
"aws.table_name": "test_table_name",
"retry_attempts": 0,
"http.status_code": 200,
},
)