Skip to content

Fix platform usage metering for thread and message events #32

@casey-brooks

Description

@casey-brooks

Platform usage remains empty in Console for thread/message activity.

Root cause from end-to-end tracing:

  • Console queries MeteringGateway.QueryUsage with orgId, UNIT_COUNT, and labelFilters kind=thread/message.
  • Metering stores/query labels and UTC timestamps correctly for supported kind filters.
  • Threads service does invoke metering after CreateThread and SendMessage, but recordUsageAsync resolves org_id only from x-organization-id incoming metadata.
  • Gateway forwards identity metadata only; Console sends organizationId in CreateThread request body, and SendMessage has no organizationId field.
  • As a result, normal Console/Gateway thread and message creation skips metering emission before Metering receives any records.

Expected:

  • Thread creation should record kind=thread usage with the created thread's organization_id.
  • Message send should record kind=message usage with the message thread's organization_id.
  • E2E should cover creating an org, creating a thread, sending a message, then verifying platform usage is non-zero via Console cards and/or MeteringGateway.QueryUsage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions