blob: c347da78f155c9d932dd2732d1c230cbf0cf4ac7 [file] [log] [blame]
serkant.uluderyae5afeff2021-02-23 18:00:23 +03001// Copyright The OpenTelemetry 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
15package metric
16
17// BatchObserver represents an Observer callback that can report
18// observations for multiple instruments.
19type BatchObserver struct {
20 meter Meter
21 runner AsyncBatchRunner
22}
23
24// Int64ValueObserver is a metric that captures a set of int64 values at a
25// point in time.
26type Int64ValueObserver struct {
27 asyncInstrument
28}
29
30// Float64ValueObserver is a metric that captures a set of float64 values
31// at a point in time.
32type Float64ValueObserver struct {
33 asyncInstrument
34}
35
36// Int64SumObserver is a metric that captures a precomputed sum of
37// int64 values at a point in time.
38type Int64SumObserver struct {
39 asyncInstrument
40}
41
42// Float64SumObserver is a metric that captures a precomputed sum of
43// float64 values at a point in time.
44type Float64SumObserver struct {
45 asyncInstrument
46}
47
48// Int64UpDownSumObserver is a metric that captures a precomputed sum of
49// int64 values at a point in time.
50type Int64UpDownSumObserver struct {
51 asyncInstrument
52}
53
54// Float64UpDownSumObserver is a metric that captures a precomputed sum of
55// float64 values at a point in time.
56type Float64UpDownSumObserver struct {
57 asyncInstrument
58}
59
60// Observation returns an Observation, a BatchObserverFunc
61// argument, for an asynchronous integer instrument.
62// This returns an implementation-level object for use by the SDK,
63// users should not refer to this.
64func (i Int64ValueObserver) Observation(v int64) Observation {
65 return Observation{
66 number: NewInt64Number(v),
67 instrument: i.instrument,
68 }
69}
70
71// Observation returns an Observation, a BatchObserverFunc
72// argument, for an asynchronous integer instrument.
73// This returns an implementation-level object for use by the SDK,
74// users should not refer to this.
75func (f Float64ValueObserver) Observation(v float64) Observation {
76 return Observation{
77 number: NewFloat64Number(v),
78 instrument: f.instrument,
79 }
80}
81
82// Observation returns an Observation, a BatchObserverFunc
83// argument, for an asynchronous integer instrument.
84// This returns an implementation-level object for use by the SDK,
85// users should not refer to this.
86func (i Int64SumObserver) Observation(v int64) Observation {
87 return Observation{
88 number: NewInt64Number(v),
89 instrument: i.instrument,
90 }
91}
92
93// Observation returns an Observation, a BatchObserverFunc
94// argument, for an asynchronous integer instrument.
95// This returns an implementation-level object for use by the SDK,
96// users should not refer to this.
97func (f Float64SumObserver) Observation(v float64) Observation {
98 return Observation{
99 number: NewFloat64Number(v),
100 instrument: f.instrument,
101 }
102}
103
104// Observation returns an Observation, a BatchObserverFunc
105// argument, for an asynchronous integer instrument.
106// This returns an implementation-level object for use by the SDK,
107// users should not refer to this.
108func (i Int64UpDownSumObserver) Observation(v int64) Observation {
109 return Observation{
110 number: NewInt64Number(v),
111 instrument: i.instrument,
112 }
113}
114
115// Observation returns an Observation, a BatchObserverFunc
116// argument, for an asynchronous integer instrument.
117// This returns an implementation-level object for use by the SDK,
118// users should not refer to this.
119func (f Float64UpDownSumObserver) Observation(v float64) Observation {
120 return Observation{
121 number: NewFloat64Number(v),
122 instrument: f.instrument,
123 }
124}