| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
package pmetric |
| 8 |
|
| 9 |
import ( |
| 10 |
"go.opentelemetry.io/collector/pdata/internal" |
| 11 |
"go.opentelemetry.io/collector/pdata/pcommon" |
| 12 |
) |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
type ScopeMetrics struct { |
| 22 |
orig *internal.ScopeMetrics |
| 23 |
state *internal.State |
| 24 |
} |
| 25 |
|
| 26 |
func newScopeMetrics(orig *internal.ScopeMetrics, state *internal.State) ScopeMetrics { |
| 27 |
return ScopeMetrics{orig: orig, state: state} |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
func NewScopeMetrics() ScopeMetrics { |
| 35 |
return newScopeMetrics(internal.NewScopeMetrics(), internal.NewState()) |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
func (ms ScopeMetrics) MoveTo(dest ScopeMetrics) { |
| 41 |
ms.state.AssertMutable() |
| 42 |
dest.state.AssertMutable() |
| 43 |
|
| 44 |
if ms.orig == dest.orig { |
| 45 |
return |
| 46 |
} |
| 47 |
internal.DeleteScopeMetrics(dest.orig, false) |
| 48 |
*dest.orig, *ms.orig = *ms.orig, *dest.orig |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
func (ms ScopeMetrics) Scope() pcommon.InstrumentationScope { |
| 53 |
return pcommon.InstrumentationScope(internal.NewInstrumentationScopeWrapper(&ms.orig.Scope, ms.state)) |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
func (ms ScopeMetrics) Metrics() MetricSlice { |
| 58 |
return newMetricSlice(&ms.orig.Metrics, ms.state) |
| 59 |
} |
| 60 |
|
| 61 |
|
| 62 |
func (ms ScopeMetrics) SchemaUrl() string { |
| 63 |
return ms.orig.SchemaUrl |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
func (ms ScopeMetrics) SetSchemaUrl(v string) { |
| 68 |
ms.state.AssertMutable() |
| 69 |
ms.orig.SchemaUrl = v |
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
func (ms ScopeMetrics) CopyTo(dest ScopeMetrics) { |
| 74 |
dest.state.AssertMutable() |
| 75 |
internal.CopyScopeMetrics(dest.orig, ms.orig) |
| 76 |
} |