Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

53 linhas
1.3 KiB

  1. // Copyright 2016 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. // http://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. package logadmin_test
  15. import (
  16. "context"
  17. "fmt"
  18. "cloud.google.com/go/logging/logadmin"
  19. "google.golang.org/api/iterator"
  20. )
  21. func ExampleClient_Metrics() {
  22. ctx := context.Background()
  23. client, err := logadmin.NewClient(ctx, "my-project")
  24. if err != nil {
  25. // TODO: Handle error.
  26. }
  27. it := client.Metrics(ctx)
  28. _ = it // TODO: iterate using Next or iterator.Pager.
  29. }
  30. func ExampleMetricIterator_Next() {
  31. ctx := context.Background()
  32. client, err := logadmin.NewClient(ctx, "my-project")
  33. if err != nil {
  34. // TODO: Handle error.
  35. }
  36. it := client.Metrics(ctx)
  37. for {
  38. metric, err := it.Next()
  39. if err == iterator.Done {
  40. break
  41. }
  42. if err != nil {
  43. // TODO: Handle error.
  44. }
  45. fmt.Println(metric)
  46. }
  47. }