Skip to content

Conversation

bentsku
Copy link
Contributor

@bentsku bentsku commented Mar 13, 2025

Motivation

This PR replaces the analytics Counter used for tracking usage of execute-api routes for API Gateway REST APIs.

Changes

  • replace the previous UsageSetCounter with the new Counter with labels

Testing

To test the changes:

  • run a LocalStack in host mode with this branch checked out
  • run the tests.aws.services.apigateway.test_apigateway_http.test_http_integration_method integration test with TEST_SKIP_LOCALSTACK_START=1 set, to avoid trying to start LocalStack with the test
    shutdown LocalStack
  • I've tried without sending the events but only printing the collected metrics and this is what I got:
{
  "metrics": [
    {
      "namespace": "apigateway",
      "name": "rest_api_execute",
      "value": 3,
      "type": "counter",
      "label_1_value": "HTTP",
      "label_1": "invocation_type"
    },
    {
      "namespace": "apigateway",
      "name": "rest_api_execute",
      "value": 3,
      "type": "counter",
      "label_1_value": "HTTP_PROXY",
      "label_1": "invocation_type"
    }
  ]
}

Now, with more tests:

  • apigateway.test_apigateway_eventbridge.test_apigateway_to_eventbridge
  • apigateway.test_apigateway_lambda.test_lambda_aws_proxy_integration
  • apigateway.test_apigateway_sqs.test_sqs_aws_integration
{
  "metrics": [
    {
      "namespace": "apigateway",
      "name": "rest_api_execute",
      "value": 11,
      "type": "counter",
      "label_1_value": "AWS_PROXY",
      "label_1": "invocation_type"
    },
    {
      "namespace": "apigateway",
      "name": "rest_api_execute",
      "value": 1,
      "type": "counter",
      "label_1_value": "AWS:sqs",
      "label_1": "invocation_type"
    },
    {
      "namespace": "apigateway",
      "name": "rest_api_execute",
      "value": 1,
      "type": "counter",
      "label_1_value": "AWS:events",
      "label_1": "invocation_type"
    }
  ]
}

@bentsku bentsku added aws:apigateway Amazon API Gateway semver: patch Non-breaking changes which can be included in patch releases labels Mar 13, 2025
@bentsku bentsku added this to the 4.3 milestone Mar 13, 2025
@bentsku bentsku self-assigned this Mar 13, 2025
Copy link

github-actions bot commented Mar 13, 2025

LocalStack Community integration with Pro

    2 files  ±    0      2 suites  ±0   31m 46s ⏱️ - 1h 19m 45s
1 087 tests  - 3 202  1 022 ✅  - 2 947  65 💤  - 255  0 ❌ ±0 
1 089 runs   - 3 202  1 022 ✅  - 2 947  67 💤  - 255  0 ❌ ±0 

Results for commit cdb5635. ± Comparison against base commit c4e88ef.

This pull request removes 3202 tests.
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_lambda_dynamodb
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_opensearch_crud
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_search_books
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_setup
tests.aws.scenario.kinesis_firehose.test_kinesis_firehose.TestKinesisFirehoseScenario ‑ test_kinesis_firehose_s3
tests.aws.scenario.lambda_destination.test_lambda_destination_scenario.TestLambdaDestinationScenario ‑ test_destination_sns
tests.aws.scenario.lambda_destination.test_lambda_destination_scenario.TestLambdaDestinationScenario ‑ test_infra
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_prefill_dynamodb_table
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_stepfunctions_input_recipient_list[step_function_input0-SUCCEEDED]
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_stepfunctions_input_recipient_list[step_function_input1-SUCCEEDED]
…

♻️ This comment has been updated with latest results.

@bentsku bentsku force-pushed the update-apigateway-counter branch from 75084f1 to e0ee15e Compare March 14, 2025 18:12
@bentsku bentsku marked this pull request as ready for review March 14, 2025 18:37
@bentsku bentsku requested a review from cloutierMat as a code owner March 14, 2025 18:37
Copy link
Member

@vittoriopolverino vittoriopolverino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🥳 I just added a non-blocking comment in case you’d like to consider separating execution type and target service. This would simplify filtering and aggregation of invocation types by service.

@bentsku bentsku merged commit fcc4de7 into master Mar 18, 2025
31 checks passed
@bentsku bentsku deleted the update-apigateway-counter branch March 18, 2025 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws:apigateway Amazon API Gateway semver: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants