1 // Copyright 2024 Google LLC. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Code generated file. DO NOT EDIT. 6 7 // Package cloudtrace provides access to the Cloud Trace API. 8 // 9 // For product documentation, see: https://cloud.google.com/trace 10 // 11 // # Library status 12 // 13 // These client libraries are officially supported by Google. However, this 14 // library is considered complete and is in maintenance mode. This means 15 // that we will address critical bugs and security issues but will not add 16 // any new features. 17 // 18 // When possible, we recommend using our newer 19 // [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go) 20 // that are still actively being worked and iterated on. 21 // 22 // # Creating a client 23 // 24 // Usage example: 25 // 26 // import "google.golang.org/api/cloudtrace/v2" 27 // ... 28 // ctx := context.Background() 29 // cloudtraceService, err := cloudtrace.NewService(ctx) 30 // 31 // In this example, Google Application Default Credentials are used for 32 // authentication. For information on how to create and obtain Application 33 // Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials. 34 // 35 // # Other authentication options 36 // 37 // By default, all available scopes (see "Constants") are used to authenticate. 38 // To restrict scopes, use [google.golang.org/api/option.WithScopes]: 39 // 40 // cloudtraceService, err := cloudtrace.NewService(ctx, option.WithScopes(cloudtrace.TraceAppendScope)) 41 // 42 // To use an API key for authentication (note: some APIs do not support API 43 // keys), use [google.golang.org/api/option.WithAPIKey]: 44 // 45 // cloudtraceService, err := cloudtrace.NewService(ctx, option.WithAPIKey("AIza...")) 46 // 47 // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth 48 // flow, use [google.golang.org/api/option.WithTokenSource]: 49 // 50 // config := &oauth2.Config{...} 51 // // ... 52 // token, err := config.Exchange(ctx, ...) 53 // cloudtraceService, err := cloudtrace.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token))) 54 // 55 // See [google.golang.org/api/option.ClientOption] for details on options. 56 package cloudtrace // import "google.golang.org/api/cloudtrace/v2" 57 58 import ( 59 "bytes" 60 "context" 61 "encoding/json" 62 "errors" 63 "fmt" 64 "io" 65 "net/http" 66 "net/url" 67 "strconv" 68 "strings" 69 70 googleapi "google.golang.org/api/googleapi" 71 internal "google.golang.org/api/internal" 72 gensupport "google.golang.org/api/internal/gensupport" 73 option "google.golang.org/api/option" 74 internaloption "google.golang.org/api/option/internaloption" 75 htransport "google.golang.org/api/transport/http" 76 ) 77 78 // Always reference these packages, just in case the auto-generated code 79 // below doesn't. 80 var _ = bytes.NewBuffer 81 var _ = strconv.Itoa 82 var _ = fmt.Sprintf 83 var _ = json.NewDecoder 84 var _ = io.Copy 85 var _ = url.Parse 86 var _ = gensupport.MarshalJSON 87 var _ = googleapi.Version 88 var _ = errors.New 89 var _ = strings.Replace 90 var _ = context.Canceled 91 var _ = internaloption.WithDefaultEndpoint 92 var _ = internal.Version 93 94 const apiId = "cloudtrace:v2" 95 const apiName = "cloudtrace" 96 const apiVersion = "v2" 97 const basePath = "https://cloudtrace.googleapis.com/" 98 const basePathTemplate = "https://cloudtrace.UNIVERSE_DOMAIN/" 99 const mtlsBasePath = "https://cloudtrace.mtls.googleapis.com/" 100 101 // OAuth2 scopes used by this API. 102 const ( 103 // See, edit, configure, and delete your Google Cloud data and see the email 104 // address for your Google Account. 105 CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform" 106 107 // Write Trace data for a project or application 108 TraceAppendScope = "https://www.googleapis.com/auth/trace.append" 109 ) 110 111 // NewService creates a new Service. 112 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) { 113 scopesOption := internaloption.WithDefaultScopes( 114 "https://www.googleapis.com/auth/cloud-platform", 115 "https://www.googleapis.com/auth/trace.append", 116 ) 117 // NOTE: prepend, so we don't override user-specified scopes. 118 opts = append([]option.ClientOption{scopesOption}, opts...) 119 opts = append(opts, internaloption.WithDefaultEndpoint(basePath)) 120 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate)) 121 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath)) 122 opts = append(opts, internaloption.EnableNewAuthLibrary()) 123 client, endpoint, err := htransport.NewClient(ctx, opts...) 124 if err != nil { 125 return nil, err 126 } 127 s, err := New(client) 128 if err != nil { 129 return nil, err 130 } 131 if endpoint != "" { 132 s.BasePath = endpoint 133 } 134 return s, nil 135 } 136 137 // New creates a new Service. It uses the provided http.Client for requests. 138 // 139 // Deprecated: please use NewService instead. 140 // To provide a custom HTTP client, use option.WithHTTPClient. 141 // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead. 142 func New(client *http.Client) (*Service, error) { 143 if client == nil { 144 return nil, errors.New("client is nil") 145 } 146 s := &Service{client: client, BasePath: basePath} 147 s.Projects = NewProjectsService(s) 148 return s, nil 149 } 150 151 type Service struct { 152 client *http.Client 153 BasePath string // API endpoint base URL 154 UserAgent string // optional additional User-Agent fragment 155 156 Projects *ProjectsService 157 } 158 159 func (s *Service) userAgent() string { 160 if s.UserAgent == "" { 161 return googleapi.UserAgent 162 } 163 return googleapi.UserAgent + " " + s.UserAgent 164 } 165 166 func NewProjectsService(s *Service) *ProjectsService { 167 rs := &ProjectsService{s: s} 168 rs.Traces = NewProjectsTracesService(s) 169 return rs 170 } 171 172 type ProjectsService struct { 173 s *Service 174 175 Traces *ProjectsTracesService 176 } 177 178 func NewProjectsTracesService(s *Service) *ProjectsTracesService { 179 rs := &ProjectsTracesService{s: s} 180 rs.Spans = NewProjectsTracesSpansService(s) 181 return rs 182 } 183 184 type ProjectsTracesService struct { 185 s *Service 186 187 Spans *ProjectsTracesSpansService 188 } 189 190 func NewProjectsTracesSpansService(s *Service) *ProjectsTracesSpansService { 191 rs := &ProjectsTracesSpansService{s: s} 192 return rs 193 } 194 195 type ProjectsTracesSpansService struct { 196 s *Service 197 } 198 199 // Annotation: Text annotation with a set of attributes. 200 type Annotation struct { 201 // Attributes: A set of attributes on the annotation. You can have up to 4 202 // attributes per Annotation. 203 Attributes *Attributes `json:"attributes,omitempty"` 204 // Description: A user-supplied message describing the event. The maximum 205 // length for the description is 256 bytes. 206 Description *TruncatableString `json:"description,omitempty"` 207 // ForceSendFields is a list of field names (e.g. "Attributes") to 208 // unconditionally include in API requests. By default, fields with empty or 209 // default values are omitted from API requests. See 210 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 211 // details. 212 ForceSendFields []string `json:"-"` 213 // NullFields is a list of field names (e.g. "Attributes") to include in API 214 // requests with the JSON null value. By default, fields with empty values are 215 // omitted from API requests. See 216 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 217 NullFields []string `json:"-"` 218 } 219 220 func (s *Annotation) MarshalJSON() ([]byte, error) { 221 type NoMethod Annotation 222 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 223 } 224 225 // AttributeValue: The allowed types for `[VALUE]` in a `[KEY]:[VALUE]` 226 // attribute. 227 type AttributeValue struct { 228 // BoolValue: A Boolean value represented by `true` or `false`. 229 BoolValue bool `json:"boolValue,omitempty"` 230 // IntValue: A 64-bit signed integer. 231 IntValue int64 `json:"intValue,omitempty,string"` 232 // StringValue: A string up to 256 bytes long. 233 StringValue *TruncatableString `json:"stringValue,omitempty"` 234 // ForceSendFields is a list of field names (e.g. "BoolValue") to 235 // unconditionally include in API requests. By default, fields with empty or 236 // default values are omitted from API requests. See 237 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 238 // details. 239 ForceSendFields []string `json:"-"` 240 // NullFields is a list of field names (e.g. "BoolValue") to include in API 241 // requests with the JSON null value. By default, fields with empty values are 242 // omitted from API requests. See 243 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 244 NullFields []string `json:"-"` 245 } 246 247 func (s *AttributeValue) MarshalJSON() ([]byte, error) { 248 type NoMethod AttributeValue 249 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 250 } 251 252 // Attributes: A set of attributes as key-value pairs. 253 type Attributes struct { 254 // AttributeMap: A set of attributes. Each attribute's key can be up to 128 255 // bytes long. The value can be a string up to 256 bytes, a signed 64-bit 256 // integer, or the boolean values `true` or `false`. For example: 257 // "/instance_id": { "string_value": { "value": "my-instance" } } 258 // "/http/request_bytes": { "int_value": 300 } "example.com/myattribute": { 259 // "bool_value": false } 260 AttributeMap map[string]AttributeValue `json:"attributeMap,omitempty"` 261 // DroppedAttributesCount: The number of attributes that were discarded. 262 // Attributes can be discarded because their keys are too long or because there 263 // are too many attributes. If this value is 0 then all attributes are valid. 264 DroppedAttributesCount int64 `json:"droppedAttributesCount,omitempty"` 265 // ForceSendFields is a list of field names (e.g. "AttributeMap") to 266 // unconditionally include in API requests. By default, fields with empty or 267 // default values are omitted from API requests. See 268 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 269 // details. 270 ForceSendFields []string `json:"-"` 271 // NullFields is a list of field names (e.g. "AttributeMap") to include in API 272 // requests with the JSON null value. By default, fields with empty values are 273 // omitted from API requests. See 274 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 275 NullFields []string `json:"-"` 276 } 277 278 func (s *Attributes) MarshalJSON() ([]byte, error) { 279 type NoMethod Attributes 280 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 281 } 282 283 // BatchWriteSpansRequest: The request message for the `BatchWriteSpans` 284 // method. 285 type BatchWriteSpansRequest struct { 286 // Spans: Required. A list of new spans. The span names must not match existing 287 // spans, otherwise the results are undefined. 288 Spans []*Span `json:"spans,omitempty"` 289 // ForceSendFields is a list of field names (e.g. "Spans") to unconditionally 290 // include in API requests. By default, fields with empty or default values are 291 // omitted from API requests. See 292 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 293 // details. 294 ForceSendFields []string `json:"-"` 295 // NullFields is a list of field names (e.g. "Spans") to include in API 296 // requests with the JSON null value. By default, fields with empty values are 297 // omitted from API requests. See 298 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 299 NullFields []string `json:"-"` 300 } 301 302 func (s *BatchWriteSpansRequest) MarshalJSON() ([]byte, error) { 303 type NoMethod BatchWriteSpansRequest 304 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 305 } 306 307 // Empty: A generic empty message that you can re-use to avoid defining 308 // duplicated empty messages in your APIs. A typical example is to use it as 309 // the request or the response type of an API method. For instance: service Foo 310 // { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); } 311 type Empty struct { 312 // ServerResponse contains the HTTP response code and headers from the server. 313 googleapi.ServerResponse `json:"-"` 314 } 315 316 // Link: A pointer from the current span to another span in the same trace or 317 // in a different trace. For example, this can be used in batching operations, 318 // where a single batch handler processes multiple requests from different 319 // traces or when the handler receives a request from a different project. 320 type Link struct { 321 // Attributes: A set of attributes on the link. Up to 32 attributes can be 322 // specified per link. 323 Attributes *Attributes `json:"attributes,omitempty"` 324 // SpanId: The `[SPAN_ID]` for a span within a trace. 325 SpanId string `json:"spanId,omitempty"` 326 // TraceId: The `[TRACE_ID]` for a trace within a project. 327 TraceId string `json:"traceId,omitempty"` 328 // Type: The relationship of the current span relative to the linked span. 329 // 330 // Possible values: 331 // "TYPE_UNSPECIFIED" - The relationship of the two spans is unknown. 332 // "CHILD_LINKED_SPAN" - The linked span is a child of the current span. 333 // "PARENT_LINKED_SPAN" - The linked span is a parent of the current span. 334 Type string `json:"type,omitempty"` 335 // ForceSendFields is a list of field names (e.g. "Attributes") to 336 // unconditionally include in API requests. By default, fields with empty or 337 // default values are omitted from API requests. See 338 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 339 // details. 340 ForceSendFields []string `json:"-"` 341 // NullFields is a list of field names (e.g. "Attributes") to include in API 342 // requests with the JSON null value. By default, fields with empty values are 343 // omitted from API requests. See 344 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 345 NullFields []string `json:"-"` 346 } 347 348 func (s *Link) MarshalJSON() ([]byte, error) { 349 type NoMethod Link 350 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 351 } 352 353 // Links: A collection of links, which are references from this span to a span 354 // in the same or different trace. 355 type Links struct { 356 // DroppedLinksCount: The number of dropped links after the maximum size was 357 // enforced. If this value is 0, then no links were dropped. 358 DroppedLinksCount int64 `json:"droppedLinksCount,omitempty"` 359 // Link: A collection of links. 360 Link []*Link `json:"link,omitempty"` 361 // ForceSendFields is a list of field names (e.g. "DroppedLinksCount") to 362 // unconditionally include in API requests. By default, fields with empty or 363 // default values are omitted from API requests. See 364 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 365 // details. 366 ForceSendFields []string `json:"-"` 367 // NullFields is a list of field names (e.g. "DroppedLinksCount") to include in 368 // API requests with the JSON null value. By default, fields with empty values 369 // are omitted from API requests. See 370 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 371 NullFields []string `json:"-"` 372 } 373 374 func (s *Links) MarshalJSON() ([]byte, error) { 375 type NoMethod Links 376 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 377 } 378 379 // MessageEvent: An event describing a message sent/received between Spans. 380 type MessageEvent struct { 381 // CompressedSizeBytes: The number of compressed bytes sent or received. If 382 // missing, the compressed size is assumed to be the same size as the 383 // uncompressed size. 384 CompressedSizeBytes int64 `json:"compressedSizeBytes,omitempty,string"` 385 // Id: An identifier for the MessageEvent's message that can be used to match 386 // `SENT` and `RECEIVED` MessageEvents. 387 Id int64 `json:"id,omitempty,string"` 388 // Type: Type of MessageEvent. Indicates whether the message was sent or 389 // received. 390 // 391 // Possible values: 392 // "TYPE_UNSPECIFIED" - Unknown event type. 393 // "SENT" - Indicates a sent message. 394 // "RECEIVED" - Indicates a received message. 395 Type string `json:"type,omitempty"` 396 // UncompressedSizeBytes: The number of uncompressed bytes sent or received. 397 UncompressedSizeBytes int64 `json:"uncompressedSizeBytes,omitempty,string"` 398 // ForceSendFields is a list of field names (e.g. "CompressedSizeBytes") to 399 // unconditionally include in API requests. By default, fields with empty or 400 // default values are omitted from API requests. See 401 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 402 // details. 403 ForceSendFields []string `json:"-"` 404 // NullFields is a list of field names (e.g. "CompressedSizeBytes") to include 405 // in API requests with the JSON null value. By default, fields with empty 406 // values are omitted from API requests. See 407 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 408 NullFields []string `json:"-"` 409 } 410 411 func (s *MessageEvent) MarshalJSON() ([]byte, error) { 412 type NoMethod MessageEvent 413 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 414 } 415 416 // Module: Binary module. 417 type Module struct { 418 // BuildId: A unique identifier for the module, usually a hash of its contents 419 // (up to 128 bytes). 420 BuildId *TruncatableString `json:"buildId,omitempty"` 421 // Module: For example: main binary, kernel modules, and dynamic libraries such 422 // as libc.so, sharedlib.so (up to 256 bytes). 423 Module *TruncatableString `json:"module,omitempty"` 424 // ForceSendFields is a list of field names (e.g. "BuildId") to unconditionally 425 // include in API requests. By default, fields with empty or default values are 426 // omitted from API requests. See 427 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 428 // details. 429 ForceSendFields []string `json:"-"` 430 // NullFields is a list of field names (e.g. "BuildId") to include in API 431 // requests with the JSON null value. By default, fields with empty values are 432 // omitted from API requests. See 433 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 434 NullFields []string `json:"-"` 435 } 436 437 func (s *Module) MarshalJSON() ([]byte, error) { 438 type NoMethod Module 439 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 440 } 441 442 // Span: A span represents a single operation within a trace. Spans can be 443 // nested to form a trace tree. Often, a trace contains a root span that 444 // describes the end-to-end latency, and one or more subspans for its 445 // sub-operations. A trace can also contain multiple root spans, or none at 446 // all. Spans do not need to be contiguous. There might be gaps or overlaps 447 // between spans in a trace. 448 type Span struct { 449 // Attributes: A set of attributes on the span. You can have up to 32 450 // attributes per span. 451 Attributes *Attributes `json:"attributes,omitempty"` 452 // ChildSpanCount: Optional. The number of child spans that were generated 453 // while this span was active. If set, allows implementation to detect missing 454 // child spans. 455 ChildSpanCount int64 `json:"childSpanCount,omitempty"` 456 // DisplayName: Required. A description of the span's operation (up to 128 457 // bytes). Cloud Trace displays the description in the Cloud console. For 458 // example, the display name can be a qualified method name or a file name and 459 // a line number where the operation is called. A best practice is to use the 460 // same display name within an application and at the same call point. This 461 // makes it easier to correlate spans in different traces. 462 DisplayName *TruncatableString `json:"displayName,omitempty"` 463 // EndTime: Required. The end time of the span. On the client side, this is the 464 // time kept by the local machine where the span execution ends. On the server 465 // side, this is the time when the server application handler stops running. 466 EndTime string `json:"endTime,omitempty"` 467 // Links: Links associated with the span. You can have up to 128 links per 468 // Span. 469 Links *Links `json:"links,omitempty"` 470 // Name: Required. The resource name of the span in the following format: * 471 // `projects/[PROJECT_ID]/traces/[TRACE_ID]/spans/[SPAN_ID]` `[TRACE_ID]` is a 472 // unique identifier for a trace within a project; it is a 32-character 473 // hexadecimal encoding of a 16-byte array. It should not be zero. `[SPAN_ID]` 474 // is a unique identifier for a span within a trace; it is a 16-character 475 // hexadecimal encoding of an 8-byte array. It should not be zero. . 476 Name string `json:"name,omitempty"` 477 // ParentSpanId: The `[SPAN_ID]` of this span's parent span. If this is a root 478 // span, then this field must be empty. 479 ParentSpanId string `json:"parentSpanId,omitempty"` 480 // SameProcessAsParentSpan: Optional. Set this parameter to indicate whether 481 // this span is in the same process as its parent. If you do not set this 482 // parameter, Trace is unable to take advantage of this helpful information. 483 SameProcessAsParentSpan bool `json:"sameProcessAsParentSpan,omitempty"` 484 // SpanId: Required. The `[SPAN_ID]` portion of the span's resource name. 485 SpanId string `json:"spanId,omitempty"` 486 // SpanKind: Optional. Distinguishes between spans generated in a particular 487 // context. For example, two spans with the same name may be distinguished 488 // using `CLIENT` (caller) and `SERVER` (callee) to identify an RPC call. 489 // 490 // Possible values: 491 // "SPAN_KIND_UNSPECIFIED" - Unspecified. Do NOT use as default. 492 // Implementations MAY assume SpanKind.INTERNAL to be default. 493 // "INTERNAL" - Indicates that the span is used internally. Default value. 494 // "SERVER" - Indicates that the span covers server-side handling of an RPC 495 // or other remote network request. 496 // "CLIENT" - Indicates that the span covers the client-side wrapper around 497 // an RPC or other remote request. 498 // "PRODUCER" - Indicates that the span describes producer sending a message 499 // to a broker. Unlike client and server, there is no direct critical path 500 // latency relationship between producer and consumer spans (e.g. publishing a 501 // message to a pubsub service). 502 // "CONSUMER" - Indicates that the span describes consumer receiving a 503 // message from a broker. Unlike client and server, there is no direct critical 504 // path latency relationship between producer and consumer spans (e.g. 505 // receiving a message from a pubsub service subscription). 506 SpanKind string `json:"spanKind,omitempty"` 507 // StackTrace: Stack trace captured at the start of the span. 508 StackTrace *StackTrace `json:"stackTrace,omitempty"` 509 // StartTime: Required. The start time of the span. On the client side, this is 510 // the time kept by the local machine where the span execution starts. On the 511 // server side, this is the time when the server's application handler starts 512 // running. 513 StartTime string `json:"startTime,omitempty"` 514 // Status: Optional. The final status for this span. 515 Status *Status `json:"status,omitempty"` 516 // TimeEvents: A set of time events. You can have up to 32 annotations and 128 517 // message events per span. 518 TimeEvents *TimeEvents `json:"timeEvents,omitempty"` 519 520 // ServerResponse contains the HTTP response code and headers from the server. 521 googleapi.ServerResponse `json:"-"` 522 // ForceSendFields is a list of field names (e.g. "Attributes") to 523 // unconditionally include in API requests. By default, fields with empty or 524 // default values are omitted from API requests. See 525 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 526 // details. 527 ForceSendFields []string `json:"-"` 528 // NullFields is a list of field names (e.g. "Attributes") to include in API 529 // requests with the JSON null value. By default, fields with empty values are 530 // omitted from API requests. See 531 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 532 NullFields []string `json:"-"` 533 } 534 535 func (s *Span) MarshalJSON() ([]byte, error) { 536 type NoMethod Span 537 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 538 } 539 540 // StackFrame: Represents a single stack frame in a stack trace. 541 type StackFrame struct { 542 // ColumnNumber: The column number where the function call appears, if 543 // available. This is important in JavaScript because of its anonymous 544 // functions. 545 ColumnNumber int64 `json:"columnNumber,omitempty,string"` 546 // FileName: The name of the source file where the function call appears (up to 547 // 256 bytes). 548 FileName *TruncatableString `json:"fileName,omitempty"` 549 // FunctionName: The fully-qualified name that uniquely identifies the function 550 // or method that is active in this frame (up to 1024 bytes). 551 FunctionName *TruncatableString `json:"functionName,omitempty"` 552 // LineNumber: The line number in `file_name` where the function call appears. 553 LineNumber int64 `json:"lineNumber,omitempty,string"` 554 // LoadModule: The binary module from where the code was loaded. 555 LoadModule *Module `json:"loadModule,omitempty"` 556 // OriginalFunctionName: An un-mangled function name, if `function_name` is 557 // mangled. To get information about name mangling, run this search 558 // (https://www.google.com/search?q=cxx+name+mangling). The name can be 559 // fully-qualified (up to 1024 bytes). 560 OriginalFunctionName *TruncatableString `json:"originalFunctionName,omitempty"` 561 // SourceVersion: The version of the deployed source code (up to 128 bytes). 562 SourceVersion *TruncatableString `json:"sourceVersion,omitempty"` 563 // ForceSendFields is a list of field names (e.g. "ColumnNumber") to 564 // unconditionally include in API requests. By default, fields with empty or 565 // default values are omitted from API requests. See 566 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 567 // details. 568 ForceSendFields []string `json:"-"` 569 // NullFields is a list of field names (e.g. "ColumnNumber") to include in API 570 // requests with the JSON null value. By default, fields with empty values are 571 // omitted from API requests. See 572 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 573 NullFields []string `json:"-"` 574 } 575 576 func (s *StackFrame) MarshalJSON() ([]byte, error) { 577 type NoMethod StackFrame 578 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 579 } 580 581 // StackFrames: A collection of stack frames, which can be truncated. 582 type StackFrames struct { 583 // DroppedFramesCount: The number of stack frames that were dropped because 584 // there were too many stack frames. If this value is 0, then no stack frames 585 // were dropped. 586 DroppedFramesCount int64 `json:"droppedFramesCount,omitempty"` 587 // Frame: Stack frames in this call stack. 588 Frame []*StackFrame `json:"frame,omitempty"` 589 // ForceSendFields is a list of field names (e.g. "DroppedFramesCount") to 590 // unconditionally include in API requests. By default, fields with empty or 591 // default values are omitted from API requests. See 592 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 593 // details. 594 ForceSendFields []string `json:"-"` 595 // NullFields is a list of field names (e.g. "DroppedFramesCount") to include 596 // in API requests with the JSON null value. By default, fields with empty 597 // values are omitted from API requests. See 598 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 599 NullFields []string `json:"-"` 600 } 601 602 func (s *StackFrames) MarshalJSON() ([]byte, error) { 603 type NoMethod StackFrames 604 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 605 } 606 607 // StackTrace: A call stack appearing in a trace. 608 type StackTrace struct { 609 // StackFrames: Stack frames in this stack trace. A maximum of 128 frames are 610 // allowed. 611 StackFrames *StackFrames `json:"stackFrames,omitempty"` 612 // StackTraceHashId: The hash ID is used to conserve network bandwidth for 613 // duplicate stack traces within a single trace. Often multiple spans will have 614 // identical stack traces. The first occurrence of a stack trace should contain 615 // both the `stackFrame` content and a value in `stackTraceHashId`. Subsequent 616 // spans within the same request can refer to that stack trace by only setting 617 // `stackTraceHashId`. 618 StackTraceHashId int64 `json:"stackTraceHashId,omitempty,string"` 619 // ForceSendFields is a list of field names (e.g. "StackFrames") to 620 // unconditionally include in API requests. By default, fields with empty or 621 // default values are omitted from API requests. See 622 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 623 // details. 624 ForceSendFields []string `json:"-"` 625 // NullFields is a list of field names (e.g. "StackFrames") to include in API 626 // requests with the JSON null value. By default, fields with empty values are 627 // omitted from API requests. See 628 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 629 NullFields []string `json:"-"` 630 } 631 632 func (s *StackTrace) MarshalJSON() ([]byte, error) { 633 type NoMethod StackTrace 634 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 635 } 636 637 // Status: The `Status` type defines a logical error model that is suitable for 638 // different programming environments, including REST APIs and RPC APIs. It is 639 // used by gRPC (https://github.com/grpc). Each `Status` message contains three 640 // pieces of data: error code, error message, and error details. You can find 641 // out more about this error model and how to work with it in the API Design 642 // Guide (https://cloud.google.com/apis/design/errors). 643 type Status struct { 644 // Code: The status code, which should be an enum value of google.rpc.Code. 645 Code int64 `json:"code,omitempty"` 646 // Details: A list of messages that carry the error details. There is a common 647 // set of message types for APIs to use. 648 Details []googleapi.RawMessage `json:"details,omitempty"` 649 // Message: A developer-facing error message, which should be in English. Any 650 // user-facing error message should be localized and sent in the 651 // google.rpc.Status.details field, or localized by the client. 652 Message string `json:"message,omitempty"` 653 // ForceSendFields is a list of field names (e.g. "Code") to unconditionally 654 // include in API requests. By default, fields with empty or default values are 655 // omitted from API requests. See 656 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 657 // details. 658 ForceSendFields []string `json:"-"` 659 // NullFields is a list of field names (e.g. "Code") to include in API requests 660 // with the JSON null value. By default, fields with empty values are omitted 661 // from API requests. See 662 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 663 NullFields []string `json:"-"` 664 } 665 666 func (s *Status) MarshalJSON() ([]byte, error) { 667 type NoMethod Status 668 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 669 } 670 671 // TimeEvent: A time-stamped annotation or message event in the Span. 672 type TimeEvent struct { 673 // Annotation: Text annotation with a set of attributes. 674 Annotation *Annotation `json:"annotation,omitempty"` 675 // MessageEvent: An event describing a message sent/received between Spans. 676 MessageEvent *MessageEvent `json:"messageEvent,omitempty"` 677 // Time: The timestamp indicating the time the event occurred. 678 Time string `json:"time,omitempty"` 679 // ForceSendFields is a list of field names (e.g. "Annotation") to 680 // unconditionally include in API requests. By default, fields with empty or 681 // default values are omitted from API requests. See 682 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 683 // details. 684 ForceSendFields []string `json:"-"` 685 // NullFields is a list of field names (e.g. "Annotation") to include in API 686 // requests with the JSON null value. By default, fields with empty values are 687 // omitted from API requests. See 688 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 689 NullFields []string `json:"-"` 690 } 691 692 func (s *TimeEvent) MarshalJSON() ([]byte, error) { 693 type NoMethod TimeEvent 694 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 695 } 696 697 // TimeEvents: A collection of `TimeEvent`s. A `TimeEvent` is a time-stamped 698 // annotation on the span, consisting of either user-supplied key:value pairs, 699 // or details of a message sent/received between Spans. 700 type TimeEvents struct { 701 // DroppedAnnotationsCount: The number of dropped annotations in all the 702 // included time events. If the value is 0, then no annotations were dropped. 703 DroppedAnnotationsCount int64 `json:"droppedAnnotationsCount,omitempty"` 704 // DroppedMessageEventsCount: The number of dropped message events in all the 705 // included time events. If the value is 0, then no message events were 706 // dropped. 707 DroppedMessageEventsCount int64 `json:"droppedMessageEventsCount,omitempty"` 708 // TimeEvent: A collection of `TimeEvent`s. 709 TimeEvent []*TimeEvent `json:"timeEvent,omitempty"` 710 // ForceSendFields is a list of field names (e.g. "DroppedAnnotationsCount") to 711 // unconditionally include in API requests. By default, fields with empty or 712 // default values are omitted from API requests. See 713 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 714 // details. 715 ForceSendFields []string `json:"-"` 716 // NullFields is a list of field names (e.g. "DroppedAnnotationsCount") to 717 // include in API requests with the JSON null value. By default, fields with 718 // empty values are omitted from API requests. See 719 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 720 NullFields []string `json:"-"` 721 } 722 723 func (s *TimeEvents) MarshalJSON() ([]byte, error) { 724 type NoMethod TimeEvents 725 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 726 } 727 728 // TruncatableString: Represents a string that might be shortened to a 729 // specified length. 730 type TruncatableString struct { 731 // TruncatedByteCount: The number of bytes removed from the original string. If 732 // this value is 0, then the string was not shortened. 733 TruncatedByteCount int64 `json:"truncatedByteCount,omitempty"` 734 // Value: The shortened string. For example, if the original string is 500 735 // bytes long and the limit of the string is 128 bytes, then `value` contains 736 // the first 128 bytes of the 500-byte string. Truncation always happens on a 737 // UTF8 character boundary. If there are multi-byte characters in the string, 738 // then the length of the shortened string might be less than the size limit. 739 Value string `json:"value,omitempty"` 740 // ForceSendFields is a list of field names (e.g. "TruncatedByteCount") to 741 // unconditionally include in API requests. By default, fields with empty or 742 // default values are omitted from API requests. See 743 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 744 // details. 745 ForceSendFields []string `json:"-"` 746 // NullFields is a list of field names (e.g. "TruncatedByteCount") to include 747 // in API requests with the JSON null value. By default, fields with empty 748 // values are omitted from API requests. See 749 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 750 NullFields []string `json:"-"` 751 } 752 753 func (s *TruncatableString) MarshalJSON() ([]byte, error) { 754 type NoMethod TruncatableString 755 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 756 } 757 758 type ProjectsTracesBatchWriteCall struct { 759 s *Service 760 name string 761 batchwritespansrequest *BatchWriteSpansRequest 762 urlParams_ gensupport.URLParams 763 ctx_ context.Context 764 header_ http.Header 765 } 766 767 // BatchWrite: Batch writes new spans to new or existing traces. You cannot 768 // update existing spans. 769 // 770 // - name: The name of the project where the spans belong. The format is 771 // `projects/[PROJECT_ID]`. 772 func (r *ProjectsTracesService) BatchWrite(name string, batchwritespansrequest *BatchWriteSpansRequest) *ProjectsTracesBatchWriteCall { 773 c := &ProjectsTracesBatchWriteCall{s: r.s, urlParams_: make(gensupport.URLParams)} 774 c.name = name 775 c.batchwritespansrequest = batchwritespansrequest 776 return c 777 } 778 779 // Fields allows partial responses to be retrieved. See 780 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 781 // details. 782 func (c *ProjectsTracesBatchWriteCall) Fields(s ...googleapi.Field) *ProjectsTracesBatchWriteCall { 783 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 784 return c 785 } 786 787 // Context sets the context to be used in this call's Do method. 788 func (c *ProjectsTracesBatchWriteCall) Context(ctx context.Context) *ProjectsTracesBatchWriteCall { 789 c.ctx_ = ctx 790 return c 791 } 792 793 // Header returns a http.Header that can be modified by the caller to add 794 // headers to the request. 795 func (c *ProjectsTracesBatchWriteCall) Header() http.Header { 796 if c.header_ == nil { 797 c.header_ = make(http.Header) 798 } 799 return c.header_ 800 } 801 802 func (c *ProjectsTracesBatchWriteCall) doRequest(alt string) (*http.Response, error) { 803 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_) 804 var body io.Reader = nil 805 body, err := googleapi.WithoutDataWrapper.JSONReader(c.batchwritespansrequest) 806 if err != nil { 807 return nil, err 808 } 809 c.urlParams_.Set("alt", alt) 810 c.urlParams_.Set("prettyPrint", "false") 811 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+name}/traces:batchWrite") 812 urls += "?" + c.urlParams_.Encode() 813 req, err := http.NewRequest("POST", urls, body) 814 if err != nil { 815 return nil, err 816 } 817 req.Header = reqHeaders 818 googleapi.Expand(req.URL, map[string]string{ 819 "name": c.name, 820 }) 821 return gensupport.SendRequest(c.ctx_, c.s.client, req) 822 } 823 824 // Do executes the "cloudtrace.projects.traces.batchWrite" call. 825 // Any non-2xx status code is an error. Response headers are in either 826 // *Empty.ServerResponse.Header or (if a response was returned at all) in 827 // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check 828 // whether the returned error was because http.StatusNotModified was returned. 829 func (c *ProjectsTracesBatchWriteCall) Do(opts ...googleapi.CallOption) (*Empty, error) { 830 gensupport.SetOptions(c.urlParams_, opts...) 831 res, err := c.doRequest("json") 832 if res != nil && res.StatusCode == http.StatusNotModified { 833 if res.Body != nil { 834 res.Body.Close() 835 } 836 return nil, gensupport.WrapError(&googleapi.Error{ 837 Code: res.StatusCode, 838 Header: res.Header, 839 }) 840 } 841 if err != nil { 842 return nil, err 843 } 844 defer googleapi.CloseBody(res) 845 if err := googleapi.CheckResponse(res); err != nil { 846 return nil, gensupport.WrapError(err) 847 } 848 ret := &Empty{ 849 ServerResponse: googleapi.ServerResponse{ 850 Header: res.Header, 851 HTTPStatusCode: res.StatusCode, 852 }, 853 } 854 target := &ret 855 if err := gensupport.DecodeResponse(target, res); err != nil { 856 return nil, err 857 } 858 return ret, nil 859 } 860 861 type ProjectsTracesSpansCreateSpanCall struct { 862 s *Service 863 nameid string 864 span *Span 865 urlParams_ gensupport.URLParams 866 ctx_ context.Context 867 header_ http.Header 868 } 869 870 // CreateSpan: Creates a new span. 871 // 872 // - name: The resource name of the span in the following format: * 873 // `projects/[PROJECT_ID]/traces/[TRACE_ID]/spans/[SPAN_ID]` `[TRACE_ID]` is 874 // a unique identifier for a trace within a project; it is a 32-character 875 // hexadecimal encoding of a 16-byte array. It should not be zero. 876 // `[SPAN_ID]` is a unique identifier for a span within a trace; it is a 877 // 16-character hexadecimal encoding of an 8-byte array. It should not be 878 // zero. . 879 func (r *ProjectsTracesSpansService) CreateSpan(nameid string, span *Span) *ProjectsTracesSpansCreateSpanCall { 880 c := &ProjectsTracesSpansCreateSpanCall{s: r.s, urlParams_: make(gensupport.URLParams)} 881 c.nameid = nameid 882 c.span = span 883 return c 884 } 885 886 // Fields allows partial responses to be retrieved. See 887 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 888 // details. 889 func (c *ProjectsTracesSpansCreateSpanCall) Fields(s ...googleapi.Field) *ProjectsTracesSpansCreateSpanCall { 890 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 891 return c 892 } 893 894 // Context sets the context to be used in this call's Do method. 895 func (c *ProjectsTracesSpansCreateSpanCall) Context(ctx context.Context) *ProjectsTracesSpansCreateSpanCall { 896 c.ctx_ = ctx 897 return c 898 } 899 900 // Header returns a http.Header that can be modified by the caller to add 901 // headers to the request. 902 func (c *ProjectsTracesSpansCreateSpanCall) Header() http.Header { 903 if c.header_ == nil { 904 c.header_ = make(http.Header) 905 } 906 return c.header_ 907 } 908 909 func (c *ProjectsTracesSpansCreateSpanCall) doRequest(alt string) (*http.Response, error) { 910 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_) 911 var body io.Reader = nil 912 body, err := googleapi.WithoutDataWrapper.JSONReader(c.span) 913 if err != nil { 914 return nil, err 915 } 916 c.urlParams_.Set("alt", alt) 917 c.urlParams_.Set("prettyPrint", "false") 918 urls := googleapi.ResolveRelative(c.s.BasePath, "v2/{+name}") 919 urls += "?" + c.urlParams_.Encode() 920 req, err := http.NewRequest("POST", urls, body) 921 if err != nil { 922 return nil, err 923 } 924 req.Header = reqHeaders 925 googleapi.Expand(req.URL, map[string]string{ 926 "name": c.nameid, 927 }) 928 return gensupport.SendRequest(c.ctx_, c.s.client, req) 929 } 930 931 // Do executes the "cloudtrace.projects.traces.spans.createSpan" call. 932 // Any non-2xx status code is an error. Response headers are in either 933 // *Span.ServerResponse.Header or (if a response was returned at all) in 934 // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check 935 // whether the returned error was because http.StatusNotModified was returned. 936 func (c *ProjectsTracesSpansCreateSpanCall) Do(opts ...googleapi.CallOption) (*Span, error) { 937 gensupport.SetOptions(c.urlParams_, opts...) 938 res, err := c.doRequest("json") 939 if res != nil && res.StatusCode == http.StatusNotModified { 940 if res.Body != nil { 941 res.Body.Close() 942 } 943 return nil, gensupport.WrapError(&googleapi.Error{ 944 Code: res.StatusCode, 945 Header: res.Header, 946 }) 947 } 948 if err != nil { 949 return nil, err 950 } 951 defer googleapi.CloseBody(res) 952 if err := googleapi.CheckResponse(res); err != nil { 953 return nil, gensupport.WrapError(err) 954 } 955 ret := &Span{ 956 ServerResponse: googleapi.ServerResponse{ 957 Header: res.Header, 958 HTTPStatusCode: res.StatusCode, 959 }, 960 } 961 target := &ret 962 if err := gensupport.DecodeResponse(target, res); err != nil { 963 return nil, err 964 } 965 return ret, nil 966 } 967