You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

961 lines
33 KiB

  1. // Package cloudtrace provides access to the Stackdriver Trace API.
  2. //
  3. // See https://cloud.google.com/trace
  4. //
  5. // Usage example:
  6. //
  7. // import "google.golang.org/api/cloudtrace/v1"
  8. // ...
  9. // cloudtraceService, err := cloudtrace.New(oauthHttpClient)
  10. package cloudtrace // import "google.golang.org/api/cloudtrace/v1"
  11. import (
  12. "bytes"
  13. "encoding/json"
  14. "errors"
  15. "fmt"
  16. context "golang.org/x/net/context"
  17. ctxhttp "golang.org/x/net/context/ctxhttp"
  18. gensupport "google.golang.org/api/gensupport"
  19. googleapi "google.golang.org/api/googleapi"
  20. "io"
  21. "net/http"
  22. "net/url"
  23. "strconv"
  24. "strings"
  25. )
  26. // Always reference these packages, just in case the auto-generated code
  27. // below doesn't.
  28. var _ = bytes.NewBuffer
  29. var _ = strconv.Itoa
  30. var _ = fmt.Sprintf
  31. var _ = json.NewDecoder
  32. var _ = io.Copy
  33. var _ = url.Parse
  34. var _ = gensupport.MarshalJSON
  35. var _ = googleapi.Version
  36. var _ = errors.New
  37. var _ = strings.Replace
  38. var _ = context.Canceled
  39. var _ = ctxhttp.Do
  40. const apiId = "cloudtrace:v1"
  41. const apiName = "cloudtrace"
  42. const apiVersion = "v1"
  43. const basePath = "https://cloudtrace.googleapis.com/"
  44. // OAuth2 scopes used by this API.
  45. const (
  46. // View and manage your data across Google Cloud Platform services
  47. CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
  48. // Write Trace data for a project or application
  49. TraceAppendScope = "https://www.googleapis.com/auth/trace.append"
  50. // Read Trace data for a project or application
  51. TraceReadonlyScope = "https://www.googleapis.com/auth/trace.readonly"
  52. )
  53. func New(client *http.Client) (*Service, error) {
  54. if client == nil {
  55. return nil, errors.New("client is nil")
  56. }
  57. s := &Service{client: client, BasePath: basePath}
  58. s.Projects = NewProjectsService(s)
  59. return s, nil
  60. }
  61. type Service struct {
  62. client *http.Client
  63. BasePath string // API endpoint base URL
  64. UserAgent string // optional additional User-Agent fragment
  65. Projects *ProjectsService
  66. }
  67. func (s *Service) userAgent() string {
  68. if s.UserAgent == "" {
  69. return googleapi.UserAgent
  70. }
  71. return googleapi.UserAgent + " " + s.UserAgent
  72. }
  73. func NewProjectsService(s *Service) *ProjectsService {
  74. rs := &ProjectsService{s: s}
  75. rs.Traces = NewProjectsTracesService(s)
  76. return rs
  77. }
  78. type ProjectsService struct {
  79. s *Service
  80. Traces *ProjectsTracesService
  81. }
  82. func NewProjectsTracesService(s *Service) *ProjectsTracesService {
  83. rs := &ProjectsTracesService{s: s}
  84. return rs
  85. }
  86. type ProjectsTracesService struct {
  87. s *Service
  88. }
  89. // Empty: A generic empty message that you can re-use to avoid defining
  90. // duplicated
  91. // empty messages in your APIs. A typical example is to use it as the
  92. // request
  93. // or the response type of an API method. For instance:
  94. //
  95. // service Foo {
  96. // rpc Bar(google.protobuf.Empty) returns
  97. // (google.protobuf.Empty);
  98. // }
  99. //
  100. // The JSON representation for `Empty` is empty JSON object `{}`.
  101. type Empty struct {
  102. // ServerResponse contains the HTTP response code and headers from the
  103. // server.
  104. googleapi.ServerResponse `json:"-"`
  105. }
  106. // ListTracesResponse: The response message for the `ListTraces` method.
  107. type ListTracesResponse struct {
  108. // NextPageToken: If defined, indicates that there are more traces that
  109. // match the request
  110. // and that this value should be passed to the next request to
  111. // continue
  112. // retrieving additional traces.
  113. NextPageToken string `json:"nextPageToken,omitempty"`
  114. // Traces: List of trace records as specified by the view parameter.
  115. Traces []*Trace `json:"traces,omitempty"`
  116. // ServerResponse contains the HTTP response code and headers from the
  117. // server.
  118. googleapi.ServerResponse `json:"-"`
  119. // ForceSendFields is a list of field names (e.g. "NextPageToken") to
  120. // unconditionally include in API requests. By default, fields with
  121. // empty values are omitted from API requests. However, any non-pointer,
  122. // non-interface field appearing in ForceSendFields will be sent to the
  123. // server regardless of whether the field is empty or not. This may be
  124. // used to include empty fields in Patch requests.
  125. ForceSendFields []string `json:"-"`
  126. // NullFields is a list of field names (e.g. "NextPageToken") to include
  127. // in API requests with the JSON null value. By default, fields with
  128. // empty values are omitted from API requests. However, any field with
  129. // an empty value appearing in NullFields will be sent to the server as
  130. // null. It is an error if a field in this list has a non-empty value.
  131. // This may be used to include null fields in Patch requests.
  132. NullFields []string `json:"-"`
  133. }
  134. func (s *ListTracesResponse) MarshalJSON() ([]byte, error) {
  135. type NoMethod ListTracesResponse
  136. raw := NoMethod(*s)
  137. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  138. }
  139. // Trace: A trace describes how long it takes for an application to
  140. // perform an
  141. // operation. It consists of a set of spans, each of which represent a
  142. // single
  143. // timed event within the operation.
  144. type Trace struct {
  145. // ProjectId: Project ID of the Cloud project where the trace data is
  146. // stored.
  147. ProjectId string `json:"projectId,omitempty"`
  148. // Spans: Collection of spans in the trace.
  149. Spans []*TraceSpan `json:"spans,omitempty"`
  150. // TraceId: Globally unique identifier for the trace. This identifier is
  151. // a 128-bit
  152. // numeric value formatted as a 32-byte hex string.
  153. TraceId string `json:"traceId,omitempty"`
  154. // ServerResponse contains the HTTP response code and headers from the
  155. // server.
  156. googleapi.ServerResponse `json:"-"`
  157. // ForceSendFields is a list of field names (e.g. "ProjectId") to
  158. // unconditionally include in API requests. By default, fields with
  159. // empty values are omitted from API requests. However, any non-pointer,
  160. // non-interface field appearing in ForceSendFields will be sent to the
  161. // server regardless of whether the field is empty or not. This may be
  162. // used to include empty fields in Patch requests.
  163. ForceSendFields []string `json:"-"`
  164. // NullFields is a list of field names (e.g. "ProjectId") to include in
  165. // API requests with the JSON null value. By default, fields with empty
  166. // values are omitted from API requests. However, any field with an
  167. // empty value appearing in NullFields will be sent to the server as
  168. // null. It is an error if a field in this list has a non-empty value.
  169. // This may be used to include null fields in Patch requests.
  170. NullFields []string `json:"-"`
  171. }
  172. func (s *Trace) MarshalJSON() ([]byte, error) {
  173. type NoMethod Trace
  174. raw := NoMethod(*s)
  175. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  176. }
  177. // TraceSpan: A span represents a single timed event within a trace.
  178. // Spans can be nested
  179. // and form a trace tree. Often, a trace contains a root span that
  180. // describes the
  181. // end-to-end latency of an operation and, optionally, one or more
  182. // subspans for
  183. // its suboperations. Spans do not need to be contiguous. There may be
  184. // gaps
  185. // between spans in a trace.
  186. type TraceSpan struct {
  187. // EndTime: End time of the span in nanoseconds from the UNIX epoch.
  188. EndTime string `json:"endTime,omitempty"`
  189. // Kind: Distinguishes between spans generated in a particular context.
  190. // For example,
  191. // two spans with the same name may be distinguished using
  192. // `RPC_CLIENT`
  193. // and `RPC_SERVER` to identify queueing latency associated with the
  194. // span.
  195. //
  196. // Possible values:
  197. // "SPAN_KIND_UNSPECIFIED" - Unspecified.
  198. // "RPC_SERVER" - Indicates that the span covers server-side handling
  199. // of an RPC or other
  200. // remote network request.
  201. // "RPC_CLIENT" - Indicates that the span covers the client-side
  202. // wrapper around an RPC or
  203. // other remote request.
  204. Kind string `json:"kind,omitempty"`
  205. // Labels: Collection of labels associated with the span. Label keys
  206. // must be less than
  207. // 128 bytes. Label values must be less than 16 kilobytes (10MB
  208. // for
  209. // `/stacktrace` values).
  210. //
  211. // Some predefined label keys exist, or you may create your own. When
  212. // creating
  213. // your own, we recommend the following formats:
  214. //
  215. // * `/category/product/key` for agents of well-known products (e.g.
  216. // `/db/mongodb/read_size`).
  217. // * `short_host/path/key` for domain-specific keys (e.g.
  218. // `foo.com/myproduct/bar`)
  219. //
  220. // Predefined labels include:
  221. //
  222. // * `/agent`
  223. // * `/component`
  224. // * `/error/message`
  225. // * `/error/name`
  226. // * `/http/client_city`
  227. // * `/http/client_country`
  228. // * `/http/client_protocol`
  229. // * `/http/client_region`
  230. // * `/http/host`
  231. // * `/http/method`
  232. // * `/http/path`
  233. // * `/http/redirected_url`
  234. // * `/http/request/size`
  235. // * `/http/response/size`
  236. // * `/http/route`
  237. // * `/http/status_code`
  238. // * `/http/url`
  239. // * `/http/user_agent`
  240. // * `/pid`
  241. // * `/stacktrace`
  242. // * `/tid`
  243. Labels map[string]string `json:"labels,omitempty"`
  244. // Name: Name of the span. Must be less than 128 bytes. The span name is
  245. // sanitized
  246. // and displayed in the Stackdriver Trace tool in the
  247. // {% dynamic print site_values.console_name %}.
  248. // The name may be a method name or some other per-call site name.
  249. // For the same executable and the same call point, a best practice
  250. // is
  251. // to use a consistent name, which makes it easier to
  252. // correlate
  253. // cross-trace spans.
  254. Name string `json:"name,omitempty"`
  255. // ParentSpanId: ID of the parent span, if any. Optional.
  256. ParentSpanId uint64 `json:"parentSpanId,omitempty,string"`
  257. // SpanId: Identifier for the span. Must be a 64-bit integer other than
  258. // 0 and
  259. // unique within a trace.
  260. SpanId uint64 `json:"spanId,omitempty,string"`
  261. // StartTime: Start time of the span in nanoseconds from the UNIX epoch.
  262. StartTime string `json:"startTime,omitempty"`
  263. // ForceSendFields is a list of field names (e.g. "EndTime") to
  264. // unconditionally include in API requests. By default, fields with
  265. // empty values are omitted from API requests. However, any non-pointer,
  266. // non-interface field appearing in ForceSendFields will be sent to the
  267. // server regardless of whether the field is empty or not. This may be
  268. // used to include empty fields in Patch requests.
  269. ForceSendFields []string `json:"-"`
  270. // NullFields is a list of field names (e.g. "EndTime") to include in
  271. // API requests with the JSON null value. By default, fields with empty
  272. // values are omitted from API requests. However, any field with an
  273. // empty value appearing in NullFields will be sent to the server as
  274. // null. It is an error if a field in this list has a non-empty value.
  275. // This may be used to include null fields in Patch requests.
  276. NullFields []string `json:"-"`
  277. }
  278. func (s *TraceSpan) MarshalJSON() ([]byte, error) {
  279. type NoMethod TraceSpan
  280. raw := NoMethod(*s)
  281. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  282. }
  283. // Traces: List of new or updated traces.
  284. type Traces struct {
  285. // Traces: List of traces.
  286. Traces []*Trace `json:"traces,omitempty"`
  287. // ForceSendFields is a list of field names (e.g. "Traces") to
  288. // unconditionally include in API requests. By default, fields with
  289. // empty values are omitted from API requests. However, any non-pointer,
  290. // non-interface field appearing in ForceSendFields will be sent to the
  291. // server regardless of whether the field is empty or not. This may be
  292. // used to include empty fields in Patch requests.
  293. ForceSendFields []string `json:"-"`
  294. // NullFields is a list of field names (e.g. "Traces") to include in API
  295. // requests with the JSON null value. By default, fields with empty
  296. // values are omitted from API requests. However, any field with an
  297. // empty value appearing in NullFields will be sent to the server as
  298. // null. It is an error if a field in this list has a non-empty value.
  299. // This may be used to include null fields in Patch requests.
  300. NullFields []string `json:"-"`
  301. }
  302. func (s *Traces) MarshalJSON() ([]byte, error) {
  303. type NoMethod Traces
  304. raw := NoMethod(*s)
  305. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  306. }
  307. // method id "cloudtrace.projects.patchTraces":
  308. type ProjectsPatchTracesCall struct {
  309. s *Service
  310. projectId string
  311. traces *Traces
  312. urlParams_ gensupport.URLParams
  313. ctx_ context.Context
  314. header_ http.Header
  315. }
  316. // PatchTraces: Sends new traces to Stackdriver Trace or updates
  317. // existing traces. If the ID
  318. // of a trace that you send matches that of an existing trace, any
  319. // fields
  320. // in the existing trace and its spans are overwritten by the provided
  321. // values,
  322. // and any new fields provided are merged with the existing trace data.
  323. // If the
  324. // ID does not match, a new trace is created.
  325. func (r *ProjectsService) PatchTraces(projectId string, traces *Traces) *ProjectsPatchTracesCall {
  326. c := &ProjectsPatchTracesCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  327. c.projectId = projectId
  328. c.traces = traces
  329. return c
  330. }
  331. // Fields allows partial responses to be retrieved. See
  332. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  333. // for more information.
  334. func (c *ProjectsPatchTracesCall) Fields(s ...googleapi.Field) *ProjectsPatchTracesCall {
  335. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  336. return c
  337. }
  338. // Context sets the context to be used in this call's Do method. Any
  339. // pending HTTP request will be aborted if the provided context is
  340. // canceled.
  341. func (c *ProjectsPatchTracesCall) Context(ctx context.Context) *ProjectsPatchTracesCall {
  342. c.ctx_ = ctx
  343. return c
  344. }
  345. // Header returns an http.Header that can be modified by the caller to
  346. // add HTTP headers to the request.
  347. func (c *ProjectsPatchTracesCall) Header() http.Header {
  348. if c.header_ == nil {
  349. c.header_ = make(http.Header)
  350. }
  351. return c.header_
  352. }
  353. func (c *ProjectsPatchTracesCall) doRequest(alt string) (*http.Response, error) {
  354. reqHeaders := make(http.Header)
  355. for k, v := range c.header_ {
  356. reqHeaders[k] = v
  357. }
  358. reqHeaders.Set("User-Agent", c.s.userAgent())
  359. var body io.Reader = nil
  360. body, err := googleapi.WithoutDataWrapper.JSONReader(c.traces)
  361. if err != nil {
  362. return nil, err
  363. }
  364. reqHeaders.Set("Content-Type", "application/json")
  365. c.urlParams_.Set("alt", alt)
  366. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/projects/{projectId}/traces")
  367. urls += "?" + c.urlParams_.Encode()
  368. req, _ := http.NewRequest("PATCH", urls, body)
  369. req.Header = reqHeaders
  370. googleapi.Expand(req.URL, map[string]string{
  371. "projectId": c.projectId,
  372. })
  373. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  374. }
  375. // Do executes the "cloudtrace.projects.patchTraces" call.
  376. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  377. // code is an error. Response headers are in either
  378. // *Empty.ServerResponse.Header or (if a response was returned at all)
  379. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  380. // check whether the returned error was because http.StatusNotModified
  381. // was returned.
  382. func (c *ProjectsPatchTracesCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  383. gensupport.SetOptions(c.urlParams_, opts...)
  384. res, err := c.doRequest("json")
  385. if res != nil && res.StatusCode == http.StatusNotModified {
  386. if res.Body != nil {
  387. res.Body.Close()
  388. }
  389. return nil, &googleapi.Error{
  390. Code: res.StatusCode,
  391. Header: res.Header,
  392. }
  393. }
  394. if err != nil {
  395. return nil, err
  396. }
  397. defer googleapi.CloseBody(res)
  398. if err := googleapi.CheckResponse(res); err != nil {
  399. return nil, err
  400. }
  401. ret := &Empty{
  402. ServerResponse: googleapi.ServerResponse{
  403. Header: res.Header,
  404. HTTPStatusCode: res.StatusCode,
  405. },
  406. }
  407. target := &ret
  408. if err := gensupport.DecodeResponse(target, res); err != nil {
  409. return nil, err
  410. }
  411. return ret, nil
  412. // {
  413. // "description": "Sends new traces to Stackdriver Trace or updates existing traces. If the ID\nof a trace that you send matches that of an existing trace, any fields\nin the existing trace and its spans are overwritten by the provided values,\nand any new fields provided are merged with the existing trace data. If the\nID does not match, a new trace is created.",
  414. // "flatPath": "v1/projects/{projectId}/traces",
  415. // "httpMethod": "PATCH",
  416. // "id": "cloudtrace.projects.patchTraces",
  417. // "parameterOrder": [
  418. // "projectId"
  419. // ],
  420. // "parameters": {
  421. // "projectId": {
  422. // "description": "ID of the Cloud project where the trace data is stored.",
  423. // "location": "path",
  424. // "required": true,
  425. // "type": "string"
  426. // }
  427. // },
  428. // "path": "v1/projects/{projectId}/traces",
  429. // "request": {
  430. // "$ref": "Traces"
  431. // },
  432. // "response": {
  433. // "$ref": "Empty"
  434. // },
  435. // "scopes": [
  436. // "https://www.googleapis.com/auth/cloud-platform",
  437. // "https://www.googleapis.com/auth/trace.append"
  438. // ]
  439. // }
  440. }
  441. // method id "cloudtrace.projects.traces.get":
  442. type ProjectsTracesGetCall struct {
  443. s *Service
  444. projectId string
  445. traceId string
  446. urlParams_ gensupport.URLParams
  447. ifNoneMatch_ string
  448. ctx_ context.Context
  449. header_ http.Header
  450. }
  451. // Get: Gets a single trace by its ID.
  452. func (r *ProjectsTracesService) Get(projectId string, traceId string) *ProjectsTracesGetCall {
  453. c := &ProjectsTracesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  454. c.projectId = projectId
  455. c.traceId = traceId
  456. return c
  457. }
  458. // Fields allows partial responses to be retrieved. See
  459. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  460. // for more information.
  461. func (c *ProjectsTracesGetCall) Fields(s ...googleapi.Field) *ProjectsTracesGetCall {
  462. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  463. return c
  464. }
  465. // IfNoneMatch sets the optional parameter which makes the operation
  466. // fail if the object's ETag matches the given value. This is useful for
  467. // getting updates only after the object has changed since the last
  468. // request. Use googleapi.IsNotModified to check whether the response
  469. // error from Do is the result of In-None-Match.
  470. func (c *ProjectsTracesGetCall) IfNoneMatch(entityTag string) *ProjectsTracesGetCall {
  471. c.ifNoneMatch_ = entityTag
  472. return c
  473. }
  474. // Context sets the context to be used in this call's Do method. Any
  475. // pending HTTP request will be aborted if the provided context is
  476. // canceled.
  477. func (c *ProjectsTracesGetCall) Context(ctx context.Context) *ProjectsTracesGetCall {
  478. c.ctx_ = ctx
  479. return c
  480. }
  481. // Header returns an http.Header that can be modified by the caller to
  482. // add HTTP headers to the request.
  483. func (c *ProjectsTracesGetCall) Header() http.Header {
  484. if c.header_ == nil {
  485. c.header_ = make(http.Header)
  486. }
  487. return c.header_
  488. }
  489. func (c *ProjectsTracesGetCall) doRequest(alt string) (*http.Response, error) {
  490. reqHeaders := make(http.Header)
  491. for k, v := range c.header_ {
  492. reqHeaders[k] = v
  493. }
  494. reqHeaders.Set("User-Agent", c.s.userAgent())
  495. if c.ifNoneMatch_ != "" {
  496. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  497. }
  498. var body io.Reader = nil
  499. c.urlParams_.Set("alt", alt)
  500. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/projects/{projectId}/traces/{traceId}")
  501. urls += "?" + c.urlParams_.Encode()
  502. req, _ := http.NewRequest("GET", urls, body)
  503. req.Header = reqHeaders
  504. googleapi.Expand(req.URL, map[string]string{
  505. "projectId": c.projectId,
  506. "traceId": c.traceId,
  507. })
  508. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  509. }
  510. // Do executes the "cloudtrace.projects.traces.get" call.
  511. // Exactly one of *Trace or error will be non-nil. Any non-2xx status
  512. // code is an error. Response headers are in either
  513. // *Trace.ServerResponse.Header or (if a response was returned at all)
  514. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  515. // check whether the returned error was because http.StatusNotModified
  516. // was returned.
  517. func (c *ProjectsTracesGetCall) Do(opts ...googleapi.CallOption) (*Trace, error) {
  518. gensupport.SetOptions(c.urlParams_, opts...)
  519. res, err := c.doRequest("json")
  520. if res != nil && res.StatusCode == http.StatusNotModified {
  521. if res.Body != nil {
  522. res.Body.Close()
  523. }
  524. return nil, &googleapi.Error{
  525. Code: res.StatusCode,
  526. Header: res.Header,
  527. }
  528. }
  529. if err != nil {
  530. return nil, err
  531. }
  532. defer googleapi.CloseBody(res)
  533. if err := googleapi.CheckResponse(res); err != nil {
  534. return nil, err
  535. }
  536. ret := &Trace{
  537. ServerResponse: googleapi.ServerResponse{
  538. Header: res.Header,
  539. HTTPStatusCode: res.StatusCode,
  540. },
  541. }
  542. target := &ret
  543. if err := gensupport.DecodeResponse(target, res); err != nil {
  544. return nil, err
  545. }
  546. return ret, nil
  547. // {
  548. // "description": "Gets a single trace by its ID.",
  549. // "flatPath": "v1/projects/{projectId}/traces/{traceId}",
  550. // "httpMethod": "GET",
  551. // "id": "cloudtrace.projects.traces.get",
  552. // "parameterOrder": [
  553. // "projectId",
  554. // "traceId"
  555. // ],
  556. // "parameters": {
  557. // "projectId": {
  558. // "description": "ID of the Cloud project where the trace data is stored.",
  559. // "location": "path",
  560. // "required": true,
  561. // "type": "string"
  562. // },
  563. // "traceId": {
  564. // "description": "ID of the trace to return.",
  565. // "location": "path",
  566. // "required": true,
  567. // "type": "string"
  568. // }
  569. // },
  570. // "path": "v1/projects/{projectId}/traces/{traceId}",
  571. // "response": {
  572. // "$ref": "Trace"
  573. // },
  574. // "scopes": [
  575. // "https://www.googleapis.com/auth/cloud-platform",
  576. // "https://www.googleapis.com/auth/trace.readonly"
  577. // ]
  578. // }
  579. }
  580. // method id "cloudtrace.projects.traces.list":
  581. type ProjectsTracesListCall struct {
  582. s *Service
  583. projectId string
  584. urlParams_ gensupport.URLParams
  585. ifNoneMatch_ string
  586. ctx_ context.Context
  587. header_ http.Header
  588. }
  589. // List: Returns of a list of traces that match the specified filter
  590. // conditions.
  591. func (r *ProjectsTracesService) List(projectId string) *ProjectsTracesListCall {
  592. c := &ProjectsTracesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  593. c.projectId = projectId
  594. return c
  595. }
  596. // EndTime sets the optional parameter "endTime": End of the time
  597. // interval (inclusive) during which the trace data was
  598. // collected from the application.
  599. func (c *ProjectsTracesListCall) EndTime(endTime string) *ProjectsTracesListCall {
  600. c.urlParams_.Set("endTime", endTime)
  601. return c
  602. }
  603. // Filter sets the optional parameter "filter": An optional filter
  604. // against labels for the request.
  605. //
  606. // By default, searches use prefix matching. To specify exact match,
  607. // prepend
  608. // a plus symbol (`+`) to the search term.
  609. // Multiple terms are ANDed. Syntax:
  610. //
  611. // * `root:NAME_PREFIX` or `NAME_PREFIX`: Return traces where any
  612. // root
  613. // span starts with `NAME_PREFIX`.
  614. // * `+root:NAME` or `+NAME`: Return traces where any root span's name
  615. // is
  616. // exactly `NAME`.
  617. // * `span:NAME_PREFIX`: Return traces where any span starts with
  618. // `NAME_PREFIX`.
  619. // * `+span:NAME`: Return traces where any span's name is exactly
  620. // `NAME`.
  621. // * `latency:DURATION`: Return traces whose overall latency is
  622. // greater or equal to than `DURATION`. Accepted units are
  623. // nanoseconds
  624. // (`ns`), milliseconds (`ms`), and seconds (`s`). Default is `ms`.
  625. // For
  626. // example, `latency:24ms` returns traces whose overall latency
  627. // is greater than or equal to 24 milliseconds.
  628. // * `label:LABEL_KEY`: Return all traces containing the specified
  629. // label key (exact match, case-sensitive) regardless of the
  630. // key:value
  631. // pair's value (including empty values).
  632. // * `LABEL_KEY:VALUE_PREFIX`: Return all traces containing the
  633. // specified
  634. // label key (exact match, case-sensitive) whose value starts with
  635. // `VALUE_PREFIX`. Both a key and a value must be specified.
  636. // * `+LABEL_KEY:VALUE`: Return all traces containing a key:value
  637. // pair
  638. // exactly matching the specified text. Both a key and a value must
  639. // be
  640. // specified.
  641. // * `method:VALUE`: Equivalent to `/http/method:VALUE`.
  642. // * `url:VALUE`: Equivalent to `/http/url:VALUE`.
  643. func (c *ProjectsTracesListCall) Filter(filter string) *ProjectsTracesListCall {
  644. c.urlParams_.Set("filter", filter)
  645. return c
  646. }
  647. // OrderBy sets the optional parameter "orderBy": Field used to sort the
  648. // returned traces.
  649. // Can be one of the following:
  650. //
  651. // * `trace_id`
  652. // * `name` (`name` field of root span in the trace)
  653. // * `duration` (difference between `end_time` and `start_time` fields
  654. // of
  655. // the root span)
  656. // * `start` (`start_time` field of the root span)
  657. //
  658. // Descending order can be specified by appending `desc` to the sort
  659. // field
  660. // (for example, `name desc`).
  661. //
  662. // Only one sort field is permitted.
  663. func (c *ProjectsTracesListCall) OrderBy(orderBy string) *ProjectsTracesListCall {
  664. c.urlParams_.Set("orderBy", orderBy)
  665. return c
  666. }
  667. // PageSize sets the optional parameter "pageSize": Maximum number of
  668. // traces to return. If not specified or <= 0, the
  669. // implementation selects a reasonable value. The implementation
  670. // may
  671. // return fewer traces than the requested page size.
  672. func (c *ProjectsTracesListCall) PageSize(pageSize int64) *ProjectsTracesListCall {
  673. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  674. return c
  675. }
  676. // PageToken sets the optional parameter "pageToken": Token identifying
  677. // the page of results to return. If provided, use the
  678. // value of the `next_page_token` field from a previous request.
  679. func (c *ProjectsTracesListCall) PageToken(pageToken string) *ProjectsTracesListCall {
  680. c.urlParams_.Set("pageToken", pageToken)
  681. return c
  682. }
  683. // StartTime sets the optional parameter "startTime": Start of the time
  684. // interval (inclusive) during which the trace data was
  685. // collected from the application.
  686. func (c *ProjectsTracesListCall) StartTime(startTime string) *ProjectsTracesListCall {
  687. c.urlParams_.Set("startTime", startTime)
  688. return c
  689. }
  690. // View sets the optional parameter "view": Type of data returned for
  691. // traces in the list. Default is
  692. // `MINIMAL`.
  693. //
  694. // Possible values:
  695. // "VIEW_TYPE_UNSPECIFIED"
  696. // "MINIMAL"
  697. // "ROOTSPAN"
  698. // "COMPLETE"
  699. func (c *ProjectsTracesListCall) View(view string) *ProjectsTracesListCall {
  700. c.urlParams_.Set("view", view)
  701. return c
  702. }
  703. // Fields allows partial responses to be retrieved. See
  704. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  705. // for more information.
  706. func (c *ProjectsTracesListCall) Fields(s ...googleapi.Field) *ProjectsTracesListCall {
  707. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  708. return c
  709. }
  710. // IfNoneMatch sets the optional parameter which makes the operation
  711. // fail if the object's ETag matches the given value. This is useful for
  712. // getting updates only after the object has changed since the last
  713. // request. Use googleapi.IsNotModified to check whether the response
  714. // error from Do is the result of In-None-Match.
  715. func (c *ProjectsTracesListCall) IfNoneMatch(entityTag string) *ProjectsTracesListCall {
  716. c.ifNoneMatch_ = entityTag
  717. return c
  718. }
  719. // Context sets the context to be used in this call's Do method. Any
  720. // pending HTTP request will be aborted if the provided context is
  721. // canceled.
  722. func (c *ProjectsTracesListCall) Context(ctx context.Context) *ProjectsTracesListCall {
  723. c.ctx_ = ctx
  724. return c
  725. }
  726. // Header returns an http.Header that can be modified by the caller to
  727. // add HTTP headers to the request.
  728. func (c *ProjectsTracesListCall) Header() http.Header {
  729. if c.header_ == nil {
  730. c.header_ = make(http.Header)
  731. }
  732. return c.header_
  733. }
  734. func (c *ProjectsTracesListCall) doRequest(alt string) (*http.Response, error) {
  735. reqHeaders := make(http.Header)
  736. for k, v := range c.header_ {
  737. reqHeaders[k] = v
  738. }
  739. reqHeaders.Set("User-Agent", c.s.userAgent())
  740. if c.ifNoneMatch_ != "" {
  741. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  742. }
  743. var body io.Reader = nil
  744. c.urlParams_.Set("alt", alt)
  745. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/projects/{projectId}/traces")
  746. urls += "?" + c.urlParams_.Encode()
  747. req, _ := http.NewRequest("GET", urls, body)
  748. req.Header = reqHeaders
  749. googleapi.Expand(req.URL, map[string]string{
  750. "projectId": c.projectId,
  751. })
  752. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  753. }
  754. // Do executes the "cloudtrace.projects.traces.list" call.
  755. // Exactly one of *ListTracesResponse or error will be non-nil. Any
  756. // non-2xx status code is an error. Response headers are in either
  757. // *ListTracesResponse.ServerResponse.Header or (if a response was
  758. // returned at all) in error.(*googleapi.Error).Header. Use
  759. // googleapi.IsNotModified to check whether the returned error was
  760. // because http.StatusNotModified was returned.
  761. func (c *ProjectsTracesListCall) Do(opts ...googleapi.CallOption) (*ListTracesResponse, error) {
  762. gensupport.SetOptions(c.urlParams_, opts...)
  763. res, err := c.doRequest("json")
  764. if res != nil && res.StatusCode == http.StatusNotModified {
  765. if res.Body != nil {
  766. res.Body.Close()
  767. }
  768. return nil, &googleapi.Error{
  769. Code: res.StatusCode,
  770. Header: res.Header,
  771. }
  772. }
  773. if err != nil {
  774. return nil, err
  775. }
  776. defer googleapi.CloseBody(res)
  777. if err := googleapi.CheckResponse(res); err != nil {
  778. return nil, err
  779. }
  780. ret := &ListTracesResponse{
  781. ServerResponse: googleapi.ServerResponse{
  782. Header: res.Header,
  783. HTTPStatusCode: res.StatusCode,
  784. },
  785. }
  786. target := &ret
  787. if err := gensupport.DecodeResponse(target, res); err != nil {
  788. return nil, err
  789. }
  790. return ret, nil
  791. // {
  792. // "description": "Returns of a list of traces that match the specified filter conditions.",
  793. // "flatPath": "v1/projects/{projectId}/traces",
  794. // "httpMethod": "GET",
  795. // "id": "cloudtrace.projects.traces.list",
  796. // "parameterOrder": [
  797. // "projectId"
  798. // ],
  799. // "parameters": {
  800. // "endTime": {
  801. // "description": "End of the time interval (inclusive) during which the trace data was\ncollected from the application.",
  802. // "format": "google-datetime",
  803. // "location": "query",
  804. // "type": "string"
  805. // },
  806. // "filter": {
  807. // "description": "An optional filter against labels for the request.\n\nBy default, searches use prefix matching. To specify exact match, prepend\na plus symbol (`+`) to the search term.\nMultiple terms are ANDed. Syntax:\n\n* `root:NAME_PREFIX` or `NAME_PREFIX`: Return traces where any root\n span starts with `NAME_PREFIX`.\n* `+root:NAME` or `+NAME`: Return traces where any root span's name is\n exactly `NAME`.\n* `span:NAME_PREFIX`: Return traces where any span starts with\n `NAME_PREFIX`.\n* `+span:NAME`: Return traces where any span's name is exactly\n `NAME`.\n* `latency:DURATION`: Return traces whose overall latency is\n greater or equal to than `DURATION`. Accepted units are nanoseconds\n (`ns`), milliseconds (`ms`), and seconds (`s`). Default is `ms`. For\n example, `latency:24ms` returns traces whose overall latency\n is greater than or equal to 24 milliseconds.\n* `label:LABEL_KEY`: Return all traces containing the specified\n label key (exact match, case-sensitive) regardless of the key:value\n pair's value (including empty values).\n* `LABEL_KEY:VALUE_PREFIX`: Return all traces containing the specified\n label key (exact match, case-sensitive) whose value starts with\n `VALUE_PREFIX`. Both a key and a value must be specified.\n* `+LABEL_KEY:VALUE`: Return all traces containing a key:value pair\n exactly matching the specified text. Both a key and a value must be\n specified.\n* `method:VALUE`: Equivalent to `/http/method:VALUE`.\n* `url:VALUE`: Equivalent to `/http/url:VALUE`.",
  808. // "location": "query",
  809. // "type": "string"
  810. // },
  811. // "orderBy": {
  812. // "description": "Field used to sort the returned traces. Optional.\nCan be one of the following:\n\n* `trace_id`\n* `name` (`name` field of root span in the trace)\n* `duration` (difference between `end_time` and `start_time` fields of\n the root span)\n* `start` (`start_time` field of the root span)\n\nDescending order can be specified by appending `desc` to the sort field\n(for example, `name desc`).\n\nOnly one sort field is permitted.",
  813. // "location": "query",
  814. // "type": "string"
  815. // },
  816. // "pageSize": {
  817. // "description": "Maximum number of traces to return. If not specified or \u003c= 0, the\nimplementation selects a reasonable value. The implementation may\nreturn fewer traces than the requested page size. Optional.",
  818. // "format": "int32",
  819. // "location": "query",
  820. // "type": "integer"
  821. // },
  822. // "pageToken": {
  823. // "description": "Token identifying the page of results to return. If provided, use the\nvalue of the `next_page_token` field from a previous request. Optional.",
  824. // "location": "query",
  825. // "type": "string"
  826. // },
  827. // "projectId": {
  828. // "description": "ID of the Cloud project where the trace data is stored.",
  829. // "location": "path",
  830. // "required": true,
  831. // "type": "string"
  832. // },
  833. // "startTime": {
  834. // "description": "Start of the time interval (inclusive) during which the trace data was\ncollected from the application.",
  835. // "format": "google-datetime",
  836. // "location": "query",
  837. // "type": "string"
  838. // },
  839. // "view": {
  840. // "description": "Type of data returned for traces in the list. Optional. Default is\n`MINIMAL`.",
  841. // "enum": [
  842. // "VIEW_TYPE_UNSPECIFIED",
  843. // "MINIMAL",
  844. // "ROOTSPAN",
  845. // "COMPLETE"
  846. // ],
  847. // "location": "query",
  848. // "type": "string"
  849. // }
  850. // },
  851. // "path": "v1/projects/{projectId}/traces",
  852. // "response": {
  853. // "$ref": "ListTracesResponse"
  854. // },
  855. // "scopes": [
  856. // "https://www.googleapis.com/auth/cloud-platform",
  857. // "https://www.googleapis.com/auth/trace.readonly"
  858. // ]
  859. // }
  860. }
  861. // Pages invokes f for each page of results.
  862. // A non-nil error returned from f will halt the iteration.
  863. // The provided context supersedes any context provided to the Context method.
  864. func (c *ProjectsTracesListCall) Pages(ctx context.Context, f func(*ListTracesResponse) error) error {
  865. c.ctx_ = ctx
  866. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  867. for {
  868. x, err := c.Do()
  869. if err != nil {
  870. return err
  871. }
  872. if err := f(x); err != nil {
  873. return err
  874. }
  875. if x.NextPageToken == "" {
  876. return nil
  877. }
  878. c.PageToken(x.NextPageToken)
  879. }
  880. }