-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat(ingest-metrics): Ensure billing metrics consumer avoids outcome double-billing #117186
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,7 @@ class BillingTxCountMetricConsumerStrategy(ProcessingStrategy[KafkaPayload]): | |
|
|
||
| span_metric_id = SPAN_METRICS_NAMES["c:spans/usage@none"] | ||
| span_is_segment_tag = str(SHARED_TAG_STRINGS["is_segment"]) | ||
| billing_outcome_accepted_tag = str(SHARED_TAG_STRINGS["billing_outcome_emitted"]) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The variable Suggested FixVerify the exact tag name sent by the corresponding Relay change. If Relay sends Prompt for AI AgentAlso affects:
|
||
|
|
||
| def __init__(self, next_step: ProcessingStrategy[Any]) -> None: | ||
| self.__next_step = next_step | ||
|
|
@@ -79,6 +80,10 @@ def _count_processed_items(self, generic_metric: GenericMetric) -> Mapping[DataC | |
| if generic_metric["metric_id"] != self.span_metric_id: | ||
| return {} | ||
|
|
||
| # If relay already produced an outcome for this item, ignore it. | ||
| if generic_metric["tags"].get(self.billing_outcome_accepted_tag) == "true": | ||
| return {} | ||
|
|
||
|
sentry[bot] marked this conversation as resolved.
|
||
| value = generic_metric["value"] | ||
| try: | ||
| quantity = max(int(value), 0) # type: ignore[arg-type] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The feature flag also needs to be exposed to Relay, search for
EXPOSABLE_FEATURES