Class: DatadogAPIClient::V2::APMTraceAPI

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog_api_client/v2/api/apm_trace_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = DatadogAPIClient::APIClient.default) ⇒ APMTraceAPI

Returns a new instance of APMTraceAPI.



22
23
24
# File 'lib/datadog_api_client/v2/api/apm_trace_api.rb', line 22

def initialize(api_client = DatadogAPIClient::APIClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



20
21
22
# File 'lib/datadog_api_client/v2/api/apm_trace_api.rb', line 20

def api_client
  @api_client
end

Instance Method Details

#get_pruned_trace_by_id(trace_id, opts = {}) ⇒ Object

Get a pruned trace by ID.



29
30
31
32
# File 'lib/datadog_api_client/v2/api/apm_trace_api.rb', line 29

def get_pruned_trace_by_id(trace_id, opts = {})
  data, _status_code, _headers = get_pruned_trace_by_id_with_http_info(trace_id, opts)
  data
end

#get_pruned_trace_by_id_with_http_info(trace_id, opts = {}) ⇒ Array<(PrunedTraceResponse, Integer, Hash)>

Get a pruned trace by ID.

Retrieve a pruned, hierarchical view of an APM trace by its trace ID. The trace is summarized as a tree of spans rooted at the trace root and reduced in size to keep rendering large traces in the UI practical. This endpoint is rate limited to 60 requests per minute per organization.

Parameters:

  • trace_id (String)

    The trace ID. Accepts either a 32-character hexadecimal string (128-bit trace ID) or a decimal string of up to 39 digits.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :expand_span_id (Integer)

    Span ID to expand and preserve in the pruned tree even when its branch would normally be summarized.

  • :time_hint (Integer)

    Optional Unix time hint, in seconds, used to optimize the lookup of the trace in long-term storage.

  • :force_source (String)

    Force the trace to be loaded from a specific source. When unset, the API picks the source automatically.

  • :include_path (Array<String>)

    Restrict the pruned tree to spans matching the given key:value pairs. Values may be passed as repeated query parameters.

  • :tag_include (Array<String>)

    Regex patterns of tag keys whose values must be included in the pruned spans. Values may be passed as repeated query parameters.

  • :tag_exclude (Array<String>)

    Regex patterns of tag keys whose values must be excluded from the pruned spans. Values may be passed as repeated query parameters.

  • :only_service_entry_spans (Boolean)

    When set to true, only service entry spans are included in the pruned tree.

Returns:

  • (Array<(PrunedTraceResponse, Integer, Hash)>)

    PrunedTraceResponse data, response status code and response headers



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/datadog_api_client/v2/api/apm_trace_api.rb', line 51

def get_pruned_trace_by_id_with_http_info(trace_id, opts = {})
  unstable_enabled = @api_client.config.unstable_operations["v2.get_pruned_trace_by_id".to_sym]
  if unstable_enabled
    @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.get_pruned_trace_by_id")
  else
    raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.get_pruned_trace_by_id"))
  end

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: APMTraceAPI.get_pruned_trace_by_id ...'
  end
  # verify the required parameter 'trace_id' is set
  if @api_client.config.client_side_validation && trace_id.nil?
    fail ArgumentError, "Missing the required parameter 'trace_id' when calling APMTraceAPI.get_pruned_trace_by_id"
  end
  if @api_client.config.client_side_validation && !opts[:'time_hint'].nil? && opts[:'time_hint'] > 2147483647
    fail ArgumentError, 'invalid value for "opts[:"time_hint"]" when calling APMTraceAPI.get_pruned_trace_by_id, must be smaller than or equal to 2147483647.'
  end
  # resource path
  local_var_path = '/api/v2/pruned_trace/{trace_id}'.sub('{trace_id}', CGI.escape(trace_id.to_s).gsub('%2F', '/'))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'expand_span_id'] = opts[:'expand_span_id'] if !opts[:'expand_span_id'].nil?
  query_params[:'time_hint'] = opts[:'time_hint'] if !opts[:'time_hint'].nil?
  query_params[:'force_source'] = opts[:'force_source'] if !opts[:'force_source'].nil?
  query_params[:'include_path'] = @api_client.build_collection_param(opts[:'include_path'], :multi) if !opts[:'include_path'].nil?
  query_params[:'tag_include'] = @api_client.build_collection_param(opts[:'tag_include'], :multi) if !opts[:'tag_include'].nil?
  query_params[:'tag_exclude'] = @api_client.build_collection_param(opts[:'tag_exclude'], :multi) if !opts[:'tag_exclude'].nil?
  query_params[:'only_service_entry_spans'] = opts[:'only_service_entry_spans'] if !opts[:'only_service_entry_spans'].nil?

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

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

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

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

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

  new_options = opts.merge(
    :operation => :get_pruned_trace_by_id,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type,
    :api_version => "V2"
  )
  new_options[:query_string_normalizer] = HTTParty::Request::NON_RAILS_QUERY_STRING_NORMALIZER

  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: APMTraceAPI#get_pruned_trace_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_trace_by_id(trace_id, opts = {}) ⇒ Object

Get a trace by ID.



121
122
123
124
# File 'lib/datadog_api_client/v2/api/apm_trace_api.rb', line 121

def get_trace_by_id(trace_id, opts = {})
  data, _status_code, _headers = get_trace_by_id_with_http_info(trace_id, opts)
  data
end

#get_trace_by_id_with_http_info(trace_id, opts = {}) ⇒ Array<(TraceResponse, Integer, Hash)>

Get a trace by ID.

Retrieve a full APM trace by its trace ID, including every span in the trace. Traces are returned from live storage when available and fall back to longer-term storage. This endpoint is rate limited to 60 requests per minute per organization.

Parameters:

  • trace_id (String)

    The trace ID. Accepts either a 32-character hexadecimal string (128-bit trace ID) or a decimal string of up to 39 digits.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :include_fields (Array<String>)

    List of span fields to include in the response. When omitted, every available field is returned. Values may be passed as repeated query parameters or as a single comma-separated value.

Returns:

  • (Array<(TraceResponse, Integer, Hash)>)

    TraceResponse data, response status code and response headers



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/datadog_api_client/v2/api/apm_trace_api.rb', line 136

def get_trace_by_id_with_http_info(trace_id, opts = {})
  unstable_enabled = @api_client.config.unstable_operations["v2.get_trace_by_id".to_sym]
  if unstable_enabled
    @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.get_trace_by_id")
  else
    raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.get_trace_by_id"))
  end

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: APMTraceAPI.get_trace_by_id ...'
  end
  # verify the required parameter 'trace_id' is set
  if @api_client.config.client_side_validation && trace_id.nil?
    fail ArgumentError, "Missing the required parameter 'trace_id' when calling APMTraceAPI.get_trace_by_id"
  end
  # resource path
  local_var_path = '/api/v2/trace/{trace_id}'.sub('{trace_id}', CGI.escape(trace_id.to_s).gsub('%2F', '/'))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'include_fields'] = @api_client.build_collection_param(opts[:'include_fields'], :multi) if !opts[:'include_fields'].nil?

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

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

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

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

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

  new_options = opts.merge(
    :operation => :get_trace_by_id,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type,
    :api_version => "V2"
  )
  new_options[:query_string_normalizer] = HTTParty::Request::NON_RAILS_QUERY_STRING_NORMALIZER

  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: APMTraceAPI#get_trace_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end