public class MeteringStats extends Object
Constructor and Description |
---|
MeteringStats(String serviceId,
Role meteringRole,
String meteringServiceDestinationName)
Initializes a new
MeteringStats with the given service id, role and metering service destination name. |
Modifier and Type | Method and Description |
---|---|
long |
getApiCountsFor(TenantMetricKeyPair key)
Getter for the current number of API accesses.
|
long |
getDistinctApiCounts()
Number of metric key stored.
|
long |
getSumOfApiCounts()
Aggregates the number of API accesses over all entries.
|
long |
record(TenantMetricKeyPair key)
Record a single access by the tenant to the API specified by the key.
|
long |
record(TenantMetricKeyPair key,
long increment)
Record a specified number accesses by a the tenant to the API specified by the key.
|
void |
sendToMeteringService()
Sends the stored data to the metering service.
|
public MeteringStats(String serviceId, Role meteringRole, String meteringServiceDestinationName)
MeteringStats
with the given service id, role and metering service destination name.serviceId
- The id needed for the metering service.meteringRole
- The role needed to obtain tenant information.meteringServiceDestinationName
- The name of the metering destination.public long record(TenantMetricKeyPair key)
key
- The metric key.public long record(TenantMetricKeyPair key, long increment)
key
- The metric key.increment
- The number of API accesses to record.public long getApiCountsFor(TenantMetricKeyPair key)
key
- The metric key to get the number of accesses for.public long getSumOfApiCounts()
public long getDistinctApiCounts()
public void sendToMeteringService() throws TenantNotAvailableException, TenantAccessException
TenantNotAvailableException
- If there is currently no Tenant available. This typically occurs when trying to access the tenant
within code that is running outside any tenant context, e.g., within a background task.TenantAccessException
- If there is an issue while accessing the Tenant.Copyright © 2018 SAP SE. All rights reserved.