Skip to content

Publish service provider mapping on startup #12740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

silv-io
Copy link
Member

@silv-io silv-io commented Jun 11, 2025

Motivation

We have the need to track which providers are used for different AWS services. We can do this by a startup hook which basically sends the service config on startup.

/cc @mmaureenliu

Changes

  • add a hook which takes the service config and creates a mapping from service to provider plugin name and publishes it to the analytics backend

@silv-io silv-io added the semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases label Jun 11, 2025
Copy link

github-actions bot commented Jun 11, 2025

Test Results - Preflight, Unit

22 063 tests  +83   20 329 ✅ +83   6m 18s ⏱️ -36s
     1 suites ± 0    1 734 💤 ± 0 
     1 files   ± 0        0 ❌ ± 0 

Results for commit 41d7a49. ± Comparison against base commit f459293.

♻️ This comment has been updated with latest results.

@@ -42,13 +42,15 @@ def __call__(self, chain: HandlerChain, context: RequestContext, response: Respo
err_type = self._get_err_type(context, response) if response.status_code >= 400 else None
service_name = context.operation.service_model.service_name
operation_name = context.operation.name
provider = config.SERVICE_PROVIDER_CONFIG.get_provider(service_name)

Choose a reason for hiding this comment

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

this line seems to suggest that there's a 1:1 relationship of service_name to provider, which I think is not true - did I misread the function or the 1:1 relationship actually is true in the community version?

Copy link
Member Author

Choose a reason for hiding this comment

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

In a running instance the relation is 1:1. Only one provider can be active at once. The active provider is defined in the config

Copy link

github-actions bot commented Jun 11, 2025

LocalStack Community integration with Pro

    2 files      2 suites   1h 43m 22s ⏱️
4 586 tests 4 176 ✅ 410 💤 0 ❌
4 588 runs  4 176 ✅ 412 💤 0 ❌

Results for commit 41d7a49.

♻️ This comment has been updated with latest results.

Copy link
Member

@thrau thrau left a comment

Choose a reason for hiding this comment

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

Thanks for taking a stab at this! My high-level feedback is: if we include the service provider in each service request, we'll also need to adapt the analytics backend, specifically the materialized view that stores the AWS service request. We can do that, but this creates additional work, is quite a substantial change. Also, since the set of providers doesn't (because it currently cannot) change during the runtime of LocalStack, we'll be sending redundant data for each request.

It might be more efficient to capture the configured providers once at startup, similar to how we log environment variables. This would avoid redundancy and keep the data leaner. Happy to provide more guidance if needed, but suggest to sync up with @vittoriopolverino on this

@mmaureenliu
Copy link

Thanks for taking a stab at this! My high-level feedback is: if we include the service provider in each service request, we'll also need to adapt the analytics backend, specifically the materialized view that stores the AWS service request. We can do that, but this creates additional work, is quite a substantial change. Also, since the set of providers doesn't (because it currently cannot) change during the runtime of LocalStack, we'll be sending redundant data for each request.

It might be more efficient to capture the configured providers once at startup, similar to how we log environment variables. This would avoid redundancy and keep the data leaner. Happy to provide more guidance if needed, but suggest to sync up with @vittoriopolverino on this

Just want some clarification on the "capture the configured providers once at startup" suggestion - do you mean at each session start, send a map of provider to service to the data backend, and let the data backend figure out the provider for each service within the session?

@vittoriopolverino
Copy link
Member

suggest to sync up with @vittoriopolverino on this

Happy to support on this. +1 to what Thomas already pointed out

@silv-io silv-io force-pushed the service-provider-analytics branch from b6d93f4 to b881564 Compare July 16, 2025 07:45
@alexrashed alexrashed added this to the Playground milestone Jul 23, 2025
@silv-io silv-io force-pushed the service-provider-analytics branch from b881564 to f1db54e Compare July 30, 2025 15:54
@localstack-bot
Copy link
Contributor

Currently, only patch changes are allowed on main. Your PR labels (semver: minor) indicate that it cannot be merged into the main at this time.

@silv-io silv-io changed the title Add provider info to service request counter Publish service provider mapping on startup Jul 30, 2025
Copy link

github-actions bot commented Jul 30, 2025

Test Results (amd64) - Acceptance

7 tests  ±0   5 ✅ ±0   3m 10s ⏱️ -11s
1 suites ±0   2 💤 ±0 
1 files   ±0   0 ❌ ±0 

Results for commit 41d7a49. ± Comparison against base commit f459293.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Jul 30, 2025

Test Results (amd64) - Integration, Bootstrap

    5 files      5 suites   2h 22m 34s ⏱️
4 945 tests 4 383 ✅ 562 💤 0 ❌
4 951 runs  4 383 ✅ 568 💤 0 ❌

Results for commit 41d7a49.

♻️ This comment has been updated with latest results.

@coveralls
Copy link

Coverage Status

coverage: 83.179% (+31.8%) from 51.395%
when pulling f1db54e on service-provider-analytics
into 476e7f3 on main.

@silv-io silv-io force-pushed the service-provider-analytics branch from f1db54e to 13c54d3 Compare July 31, 2025 13:02
Copy link
Member

@thrau thrau left a comment

Choose a reason for hiding this comment

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

Hey @silv-io , sorry for not reviewing sooner!

We should be using the global analytics logger because it implicitly does the session handshake. The way the hook is implemented now will cause the analytics event not be associated with the session data.

Comment on lines 26 to 30
event = Event(
name="ls_service_provider_assignment", metadata=metadata, payload=provider_assignment
)

AnalyticsClientPublisher().publish([event])
Copy link
Member

Choose a reason for hiding this comment

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

we should use analytics.log.event event here:

from localstack.utils import analytics

@hooks.on_runtime_ready()
def publish_provider_assignment():
    ...
    analytics.log.event("ls_service_provider_assignment", provider_assignment)

Copy link
Member

@vittoriopolverino vittoriopolverino Aug 1, 2025

Choose a reason for hiding this comment

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

note: just to add more context, this way we should receive the event only after the session event. This is important for us due to some payload enrichment logic in the analytics-backend.
I hadn’t realized Thomas had already explained it above

Copy link
Member Author

Choose a reason for hiding this comment

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

Awesome, thanks. This was very confusing to me at first. Will fix it when I'm back next week

@vittoriopolverino
Copy link
Member

FYI @silv-io I’ve opened a PR so that we’re ready to receive and materialize this new event.

@silv-io silv-io requested a review from thrau August 4, 2025 11:58
@silv-io silv-io marked this pull request as ready for review August 4, 2025 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants