Skip to content
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

SWATCH-2303: Add a metric to swatch-producer-azure for metered usage #3949

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Sgitario
Copy link
Contributor

Jira issue: SWATCH-2303

Description

When usage is processed by swatch-producer-azure, it should increment a counter named "swatch_producer_metered_total" with the amount in metric units, having labels:

product (swatch product tag)
metric_id (metric ID)
billing_provider
status (failed or succeeded)
What about retry: we only care about the final state after Azure returns

Testing

Added junit test to ensure the metric is populated.

Manual verification

  1. podman-compose up
  2. start azure service:
SERVER_PORT=8001 QUARKUS_MANAGEMENT_PORT=9001 ./gradlew :swatch-producer-azure:quarkusDev
  1. send message to topic "platform.rhsm-subscriptions.billable-usage-hourly-aggregate":
{"windowTimestamp":"2023-12-21T01:10:28Z","aggregateId": "e81bc918-6434-4a58-9192-8a8dd73ec8fb","aggregateKey": {"orgId": "org123","billingProvider": "azure","metricId": "Cores","productId": "rosa"}}

Note that this message is expected to fail at usage context lookup

  1. verification:
    The metrics from the swatch producer azure service should contain the new metric:
curl http://localhost:9001/metrics  | grep swatch_
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0# TYPE swatch_producer_metered counter
# HELP swatch_producer_metered  
swatch_producer_metered_total{billing_provider="azure",error_code="usage_context_lookup",metric_id="Cores",product="rosa",status="failed"} 0.0
# TYPE swatch_azure_marketplace_batch_rejected counter
# HELP swatch_azure_marketplace_batch_rejected  
swatch_azure_marketplace_batch_rejected_total 0.0
# TYPE swatch_azure_marketplace_batch_accepted counter
# HELP swatch_azure_marketplace_batch_accepted  
swatch_azure_marketplace_batch_accepted_total 0.0

Note that the new metric is "swatch_producer_metered_total".

@Sgitario Sgitario added QE Pull request should be approved by QE before merge Dev Pull requests that need developer review labels Nov 14, 2024
@kartikshahc kartikshahc self-assigned this Nov 18, 2024
@kartikshahc kartikshahc self-requested a review November 18, 2024 12:39
When usage is processed by swatch-producer-azure, it should increment a counter named "swatch_producer_metered_total" with the amount in metric units, having labels:

product (swatch product tag)
metric_id (metric ID)
billing_provider
status (failed or succeeded)
What about retry: we only care about the final state after Azure returns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dev Pull requests that need developer review QE Pull request should be approved by QE before merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants