metric.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2018, OpenCensus Authors
  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 metricdata
  15. import (
  16. "time"
  17. "go.opencensus.io/resource"
  18. )
  19. // Descriptor holds metadata about a metric.
  20. type Descriptor struct {
  21. Name string // full name of the metric
  22. Description string // human-readable description
  23. Unit Unit // units for the measure
  24. Type Type // type of measure
  25. LabelKeys []LabelKey // label keys
  26. }
  27. // Metric represents a quantity measured against a resource with different
  28. // label value combinations.
  29. type Metric struct {
  30. Descriptor Descriptor // metric descriptor
  31. Resource *resource.Resource // resource against which this was measured
  32. TimeSeries []*TimeSeries // one time series for each combination of label values
  33. }
  34. // TimeSeries is a sequence of points associated with a combination of label
  35. // values.
  36. type TimeSeries struct {
  37. LabelValues []LabelValue // label values, same order as keys in the metric descriptor
  38. Points []Point // points sequence
  39. StartTime time.Time // time we started recording this time series
  40. }