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.
 
 
 

98 lines
2.6 KiB

  1. // Copyright 2019 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // https://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // Code generated by gapic-generator. DO NOT EDIT.
  15. // Package trace is an auto-generated package for the
  16. // Stackdriver Trace API.
  17. //
  18. // NOTE: This package is in alpha. It is not stable, and is likely to change.
  19. //
  20. // Sends application trace data to Stackdriver Trace for viewing. Trace data
  21. // is
  22. // collected for all App Engine applications by default. Trace data from
  23. // other
  24. // applications can be provided using this API.
  25. //
  26. // Use the client at cloud.google.com/go/trace in preference to this.
  27. package trace // import "cloud.google.com/go/trace/apiv1"
  28. import (
  29. "context"
  30. "runtime"
  31. "strings"
  32. "unicode"
  33. "google.golang.org/grpc/metadata"
  34. )
  35. func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context {
  36. out, _ := metadata.FromOutgoingContext(ctx)
  37. out = out.Copy()
  38. for _, md := range mds {
  39. for k, v := range md {
  40. out[k] = append(out[k], v...)
  41. }
  42. }
  43. return metadata.NewOutgoingContext(ctx, out)
  44. }
  45. // DefaultAuthScopes reports the default set of authentication scopes to use with this package.
  46. func DefaultAuthScopes() []string {
  47. return []string{
  48. "https://www.googleapis.com/auth/cloud-platform",
  49. "https://www.googleapis.com/auth/trace.append",
  50. "https://www.googleapis.com/auth/trace.readonly",
  51. }
  52. }
  53. // versionGo returns the Go runtime version. The returned string
  54. // has no whitespace, suitable for reporting in header.
  55. func versionGo() string {
  56. const develPrefix = "devel +"
  57. s := runtime.Version()
  58. if strings.HasPrefix(s, develPrefix) {
  59. s = s[len(develPrefix):]
  60. if p := strings.IndexFunc(s, unicode.IsSpace); p >= 0 {
  61. s = s[:p]
  62. }
  63. return s
  64. }
  65. notSemverRune := func(r rune) bool {
  66. return strings.IndexRune("0123456789.", r) < 0
  67. }
  68. if strings.HasPrefix(s, "go1") {
  69. s = s[2:]
  70. var prerelease string
  71. if p := strings.IndexFunc(s, notSemverRune); p >= 0 {
  72. s, prerelease = s[:p], s[p:]
  73. }
  74. if strings.HasSuffix(s, ".") {
  75. s += "0"
  76. } else if strings.Count(s, ".") < 2 {
  77. s += ".0"
  78. }
  79. if prerelease != "" {
  80. s += "-" + prerelease
  81. }
  82. return s
  83. }
  84. return "UNKNOWN"
  85. }
  86. const versionClient = "20190306"