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

Add lambda traced invocations usage endpoint #889

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.2",
"regenerated": "2022-05-09 16:43:07.537568",
"spec_repo_commit": "a3819bf3"
"regenerated": "2022-05-10 15:39:28.303775",
"spec_repo_commit": "f1e731d3"
},
"v2": {
"apigentools_version": "1.6.2",
"regenerated": "2022-05-09 16:43:07.557285",
"spec_repo_commit": "a3819bf3"
"regenerated": "2022-05-10 15:39:28.323191",
"spec_repo_commit": "f1e731d3"
}
}
}
70 changes: 70 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1668,11 +1668,13 @@ components:
enum:
- app_sec_host_count
- observability_pipelines_bytes_processed
- lambda_traced_invocations_count
example: observability_pipelines_bytes_processed
type: string
x-enum-varnames:
- APP_SEC_HOST_COUNT
- OBSERVABILITY_PIPELINES_BYTES_PROCESSSED
- LAMBDA_TRACED_INVOCATIONS_COUNT
IdPMetadataFormData:
description: The form data submitted to upload IdP metadata
properties:
Expand Down Expand Up @@ -6585,6 +6587,15 @@ components:
type:
$ref: '#/components/schemas/UsageTimeSeriesType'
type: object
UsageLambdaTracedInvocationsResponse:
description: Lambda Traced Invocations usage response.
properties:
data:
description: Response containing Lambda Traced Invocations usage.
items:
$ref: '#/components/schemas/UsageDataObject'
type: array
type: object
UsageObservabilityPipelinesResponse:
description: Observability Pipelines usage response.
properties:
Expand Down Expand Up @@ -12209,6 +12220,65 @@ paths:
x-menu-order: 39
x-undo:
type: safe
/api/v2/usage/lambda_traced_invocations:
get:
description: Get hourly usage for Lambda Traced Invocations.
operationId: GetUsageLambdaTracedInvocations
parameters:
- description: 'Datetime in ISO-8601 format, UTC, precise to hour: `[YYYY-MM-DDThh]`
for usage beginning at this hour.'
in: query
name: start_hr
required: true
schema:
format: date-time
type: string
- description: 'Datetime in ISO-8601 format, UTC, precise to hour: `[YYYY-MM-DDThh]`
for usage ending

**before** this hour.'
in: query
name: end_hr
required: false
schema:
format: date-time
type: string
responses:
'200':
content:
application/json;datetime-format=rfc3339:
schema:
$ref: '#/components/schemas/UsageLambdaTracedInvocationsResponse'
description: OK
'400':
content:
application/json;datetime-format=rfc3339:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: Bad Request
'403':
content:
application/json;datetime-format=rfc3339:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: Forbidden - User is not authorized
'429':
content:
application/json;datetime-format=rfc3339:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: Too many requests
security:
- apiKeyAuth: []
appKeyAuth: []
- AuthZ:
- usage_read
summary: Get hourly usage for Lambda Traced Invocations
tags:
- Usage Metering
x-menu-order: 38
x-undo:
type: safe
/api/v2/usage/observability_pipelines:
get:
description: Get hourly usage for Observability Pipelines.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2022-05-06T18:07:36.174Z

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2022-05-06T18:07:36.459Z

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Get hourly usage for Lambda Traced Invocations returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::UsageMeteringAPI.new
opts = {
end_hr: (Time.now + -3 * 86400),
}
p api_instance.get_usage_lambda_traced_invocations((Time.now + -5 * 86400), opts)
6 changes: 6 additions & 0 deletions features/v2/undo.json
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,12 @@
"type": "safe"
}
},
"GetUsageLambdaTracedInvocations": {
"tag": "Usage Metering",
"undo": {
"type": "safe"
}
},
"GetUsageObservabilityPipelines": {
"tag": "Usage Metering",
"undo": {
Expand Down
16 changes: 16 additions & 0 deletions features/v2/usage_metering.feature
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@ Feature: Usage Metering
When the request is sent
Then the response status is 200 OK

@team:DataDog/red-zone-revenue-query
Scenario: Get hourly usage for Lambda Traced Invocations returns "Bad Request" response
Given new "GetUsageLambdaTracedInvocations" request
And request contains "start_hr" parameter with value "{{ timeISO('now - 3d') }}"
And request contains "end_hr" parameter with value "{{ timeISO('now - 5d') }}"
When the request is sent
Then the response status is 400 Bad Request

@team:DataDog/red-zone-revenue-query
Scenario: Get hourly usage for Lambda Traced Invocations returns "OK" response
Given new "GetUsageLambdaTracedInvocations" request
And request contains "start_hr" parameter with value "{{ timeISO('now - 5d') }}"
And request contains "end_hr" parameter with value "{{ timeISO('now - 3d') }}"
When the request is sent
Then the response status is 200 OK

@team:DataDog/red-zone-revenue-query
Scenario: Get hourly usage for Observability Pipelines returns "Bad Request" response
Given new "GetUsageObservabilityPipelines" request
Expand Down
1 change: 1 addition & 0 deletions lib/datadog_api_client/v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@
require 'datadog_api_client/v2/models/usage_application_security_monitoring_response'
require 'datadog_api_client/v2/models/usage_attributes_object'
require 'datadog_api_client/v2/models/usage_data_object'
require 'datadog_api_client/v2/models/usage_lambda_traced_invocations_response'
require 'datadog_api_client/v2/models/usage_observability_pipelines_response'
require 'datadog_api_client/v2/models/usage_time_series_object'
require 'datadog_api_client/v2/models/usage_time_series_type'
Expand Down
76 changes: 76 additions & 0 deletions lib/datadog_api_client/v2/api/usage_metering_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,82 @@ def get_usage_application_security_monitoring_with_http_info(start_hr, opts = {}
return data, status_code, headers
end

# Get hourly usage for Lambda Traced Invocations.
#
# @see #get_usage_lambda_traced_invocations_with_http_info
def get_usage_lambda_traced_invocations(start_hr, opts = {})
data, _status_code, _headers = get_usage_lambda_traced_invocations_with_http_info(start_hr, opts)
data
end

# Get hourly usage for Lambda Traced Invocations.
#
# Get hourly usage for Lambda Traced Invocations.
#
# @param start_hr [Time] Datetime in ISO-8601 format, UTC, precise to hour: `[YYYY-MM-DDThh]` for usage beginning at this hour.
# @param opts [Hash] the optional parameters
# @option opts [Time] :end_hr Datetime in ISO-8601 format, UTC, precise to hour: `[YYYY-MM-DDThh]` for usage ending **before** this hour.
# @return [Array<(UsageLambdaTracedInvocationsResponse, Integer, Hash)>] UsageLambdaTracedInvocationsResponse data, response status code and response headers
def get_usage_lambda_traced_invocations_with_http_info(start_hr, opts = {})

if @api_client.config.unstable_operations.has_key?(:get_usage_lambda_traced_invocations)
unstable_enabled = @api_client.config.unstable_operations[:get_usage_lambda_traced_invocations]
if unstable_enabled
@api_client.config.logger.warn format("Using unstable operation '%s'", "get_usage_lambda_traced_invocations")
else
raise APIError.new(message: format("Unstable operation '%s' is disabled", "get_usage_lambda_traced_invocations"))
end
end

if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: UsageMeteringAPI.get_usage_lambda_traced_invocations ...'
end
# verify the required parameter 'start_hr' is set
if @api_client.config.client_side_validation && start_hr.nil?
fail ArgumentError, "Missing the required parameter 'start_hr' when calling UsageMeteringAPI.get_usage_lambda_traced_invocations"
end
# resource path
local_var_path = '/api/v2/usage/lambda_traced_invocations'

# query parameters
query_params = opts[:query_params] || {}
query_params[:'start_hr'] = start_hr
query_params[:'end_hr'] = opts[:'end_hr'] if !opts[:'end_hr'].nil?

# header parameters
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json;datetime-format=rfc3339'])

# form parameters
form_params = opts[:form_params] || {}

# http body (model)
post_body = opts[:debug_body]

# return_type
return_type = opts[:debug_return_type] || 'UsageLambdaTracedInvocationsResponse'

# auth_names
auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ]

new_options = opts.merge(
:operation => :get_usage_lambda_traced_invocations,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)

data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: UsageMeteringAPI#get_usage_lambda_traced_invocations\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end

# Get hourly usage for Observability Pipelines.
#
# @see #get_usage_observability_pipelines_with_http_info
Expand Down
1 change: 1 addition & 0 deletions lib/datadog_api_client/v2/models/hourly_usage_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ class HourlyUsageType

APP_SEC_HOST_COUNT = "app_sec_host_count".freeze
OBSERVABILITY_PIPELINES_BYTES_PROCESSSED = "observability_pipelines_bytes_processed".freeze
LAMBDA_TRACED_INVOCATIONS_COUNT = "lambda_traced_invocations_count".freeze
end
end
Loading