1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2026-06-03 18:35:08 +02:00
Files
opentelemetry-go/semconv/v1.32.0/faasconv/metric.go
T
Tyler Yahn 2d4c9dc115 Add semconv/v1.32.0 (#6782)
- Add the new metric API package structure prototyped in
https://github.com/MrAlias/semconv-go

  Prototypes of new metric API use:
   - https://github.com/MrAlias/opentelemetry-go-contrib/pull/6136
   - https://github.com/MrAlias/opentelemetry-go-contrib/pull/6135
   - https://github.com/MrAlias/opentelemetry-go-contrib/pull/6134
- Generate `semconv/v1.32.0`
- Drop the `kestrel` metric namespace as this is a Java specific
technology

## [`v1.32.0` semantic convention release
notes](https://github.com/open-telemetry/semantic-conventions/releases/tag/v1.32.0):

<div data-pjax="true" data-test-selector="body-content"
data-view-component="true" class="markdown-body my-3"><p>📣 This release
is the second release candidate for the Database Semantic Conventions,
with <strong>db conventions stability planned to be declared in the
subsequent release</strong>.</p>
<h3>🛑 Breaking changes 🛑</h3>
<ul>
<li><code>device</code>: Change the definition of <code>device.id</code>
and make it opt-in. (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1874"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/1874/hovercard">#1874</a>,
<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1951"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/1951/hovercard">#1951</a>)</li>
<li><code>feature_flag</code>: Rename <code>evaluation</code> to
<code>result</code> for feature flag evaluation result attributes (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1989"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/1989/hovercard">#1989</a>)</li>
</ul>
<h3>🚀 New components 🚀</h3>
<ul>
<li><code>app</code>: Create <code>app.installation.id</code> attribute
(<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1874"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/1874/hovercard">#1874</a>,
<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1897"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/1897/hovercard">#1897</a>)</li>
<li><code>cpython</code>: Add CPython runtime garbage collector metrics
(<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1930"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/1930/hovercard">#1930</a>)</li>
</ul>
<h3>💡 Enhancements 💡</h3>
<ul>
<li><code>vcs</code>: Add owner and provider name to VCS attribute
registry (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1452"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/1452/hovercard">#1452</a>)</li>
<li><code>vcs</code>: Remove fallback value for VCS provider name
attribute (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2020"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/2020/hovercard">#2020</a>)</li>
<li><code>db</code>: Truncate <code>db.query.summary</code> to 255
characters if parsed from the query (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1978"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/1978/hovercard">#1978</a>)</li>
<li><code>db</code>: Normalize spaces in <code>db.operation.name</code>
(if any) (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2028"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/2028/hovercard">#2028</a>)</li>
<li><code>db</code>: <code>db.operation.parameter.&lt;key&gt;</code>
should not be captured for batch operations (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2026"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/2026/hovercard">#2026</a>)</li>
<li><code>db</code>: Add <code>db.stored_procedure.name</code> (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1491"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/1491/hovercard">#1491</a>)</li>
<li><code>gcp</code>: Adds GCP AppHub labels for resource. (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2006"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/2006/hovercard">#2006</a>)</li>
<li><code>error</code>: Add <code>error.message</code> property for
human-readable error message on events. (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1992"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/1992/hovercard">#1992</a>)</li>
<li><code>profile</code>: Extend the list of known frame types with a
value for Go and Rust (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2003"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/2003/hovercard">#2003</a>)</li>
<li><code>otel</code>: Adds SDK self-monitoring metrics for log
processing (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1921"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/1921/hovercard">#1921</a>)</li>
</ul>
2025-05-20 10:33:50 -07:00

768 lines
19 KiB
Go

// Code generated from semantic convention specification. DO NOT EDIT.
// Package httpconv provides types and functionality for OpenTelemetry semantic
// conventions in the "faas" namespace.
package faasconv
import (
"context"
"sync"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/noop"
)
var (
addOptPool = &sync.Pool{New: func() any { return &[]metric.AddOption{} }}
recOptPool = &sync.Pool{New: func() any { return &[]metric.RecordOption{} }}
)
// TriggerAttr is an attribute conforming to the faas.trigger semantic
// conventions. It represents the type of the trigger which caused this function
// invocation.
type TriggerAttr string
var (
// TriggerDatasource is a response to some data source operation such as a
// database or filesystem read/write.
TriggerDatasource TriggerAttr = "datasource"
// TriggerHTTP is the to provide an answer to an inbound HTTP request.
TriggerHTTP TriggerAttr = "http"
// TriggerPubSub is a function is set to be executed when messages are sent to a
// messaging system.
TriggerPubSub TriggerAttr = "pubsub"
// TriggerTimer is a function is scheduled to be executed regularly.
TriggerTimer TriggerAttr = "timer"
// TriggerOther is the if none of the others apply.
TriggerOther TriggerAttr = "other"
)
// Coldstarts is an instrument used to record metric values conforming to the
// "faas.coldstarts" semantic conventions. It represents the number of invocation
// cold starts.
type Coldstarts struct {
metric.Int64Counter
}
// NewColdstarts returns a new Coldstarts instrument.
func NewColdstarts(
m metric.Meter,
opt ...metric.Int64CounterOption,
) (Coldstarts, error) {
// Check if the meter is nil.
if m == nil {
return Coldstarts{noop.Int64Counter{}}, nil
}
i, err := m.Int64Counter(
"faas.coldstarts",
append([]metric.Int64CounterOption{
metric.WithDescription("Number of invocation cold starts"),
metric.WithUnit("{coldstart}"),
}, opt...)...,
)
if err != nil {
return Coldstarts{noop.Int64Counter{}}, err
}
return Coldstarts{i}, nil
}
// Inst returns the underlying metric instrument.
func (m Coldstarts) Inst() metric.Int64Counter {
return m.Int64Counter
}
// Name returns the semantic convention name of the instrument.
func (Coldstarts) Name() string {
return "faas.coldstarts"
}
// Unit returns the semantic convention unit of the instrument
func (Coldstarts) Unit() string {
return "{coldstart}"
}
// Description returns the semantic convention description of the instrument
func (Coldstarts) Description() string {
return "Number of invocation cold starts"
}
// Add adds incr to the existing count.
//
// All additional attrs passed are included in the recorded value.
func (m Coldstarts) Add(
ctx context.Context,
incr int64,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Int64Counter.Add(ctx, incr, *o...)
}
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
// convention. It represents the type of the trigger which caused this function
// invocation.
func (Coldstarts) AttrTrigger(val TriggerAttr) attribute.KeyValue {
return attribute.String("faas.trigger", string(val))
}
// CPUUsage is an instrument used to record metric values conforming to the
// "faas.cpu_usage" semantic conventions. It represents the distribution of CPU
// usage per invocation.
type CPUUsage struct {
metric.Float64Histogram
}
// NewCPUUsage returns a new CPUUsage instrument.
func NewCPUUsage(
m metric.Meter,
opt ...metric.Float64HistogramOption,
) (CPUUsage, error) {
// Check if the meter is nil.
if m == nil {
return CPUUsage{noop.Float64Histogram{}}, nil
}
i, err := m.Float64Histogram(
"faas.cpu_usage",
append([]metric.Float64HistogramOption{
metric.WithDescription("Distribution of CPU usage per invocation"),
metric.WithUnit("s"),
}, opt...)...,
)
if err != nil {
return CPUUsage{noop.Float64Histogram{}}, err
}
return CPUUsage{i}, nil
}
// Inst returns the underlying metric instrument.
func (m CPUUsage) Inst() metric.Float64Histogram {
return m.Float64Histogram
}
// Name returns the semantic convention name of the instrument.
func (CPUUsage) Name() string {
return "faas.cpu_usage"
}
// Unit returns the semantic convention unit of the instrument
func (CPUUsage) Unit() string {
return "s"
}
// Description returns the semantic convention description of the instrument
func (CPUUsage) Description() string {
return "Distribution of CPU usage per invocation"
}
// Record records val to the current distribution.
//
// All additional attrs passed are included in the recorded value.
func (m CPUUsage) Record(
ctx context.Context,
val float64,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Float64Histogram.Record(ctx, val, *o...)
}
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
// convention. It represents the type of the trigger which caused this function
// invocation.
func (CPUUsage) AttrTrigger(val TriggerAttr) attribute.KeyValue {
return attribute.String("faas.trigger", string(val))
}
// Errors is an instrument used to record metric values conforming to the
// "faas.errors" semantic conventions. It represents the number of invocation
// errors.
type Errors struct {
metric.Int64Counter
}
// NewErrors returns a new Errors instrument.
func NewErrors(
m metric.Meter,
opt ...metric.Int64CounterOption,
) (Errors, error) {
// Check if the meter is nil.
if m == nil {
return Errors{noop.Int64Counter{}}, nil
}
i, err := m.Int64Counter(
"faas.errors",
append([]metric.Int64CounterOption{
metric.WithDescription("Number of invocation errors"),
metric.WithUnit("{error}"),
}, opt...)...,
)
if err != nil {
return Errors{noop.Int64Counter{}}, err
}
return Errors{i}, nil
}
// Inst returns the underlying metric instrument.
func (m Errors) Inst() metric.Int64Counter {
return m.Int64Counter
}
// Name returns the semantic convention name of the instrument.
func (Errors) Name() string {
return "faas.errors"
}
// Unit returns the semantic convention unit of the instrument
func (Errors) Unit() string {
return "{error}"
}
// Description returns the semantic convention description of the instrument
func (Errors) Description() string {
return "Number of invocation errors"
}
// Add adds incr to the existing count.
//
// All additional attrs passed are included in the recorded value.
func (m Errors) Add(
ctx context.Context,
incr int64,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Int64Counter.Add(ctx, incr, *o...)
}
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
// convention. It represents the type of the trigger which caused this function
// invocation.
func (Errors) AttrTrigger(val TriggerAttr) attribute.KeyValue {
return attribute.String("faas.trigger", string(val))
}
// InitDuration is an instrument used to record metric values conforming to the
// "faas.init_duration" semantic conventions. It represents the measures the
// duration of the function's initialization, such as a cold start.
type InitDuration struct {
metric.Float64Histogram
}
// NewInitDuration returns a new InitDuration instrument.
func NewInitDuration(
m metric.Meter,
opt ...metric.Float64HistogramOption,
) (InitDuration, error) {
// Check if the meter is nil.
if m == nil {
return InitDuration{noop.Float64Histogram{}}, nil
}
i, err := m.Float64Histogram(
"faas.init_duration",
append([]metric.Float64HistogramOption{
metric.WithDescription("Measures the duration of the function's initialization, such as a cold start"),
metric.WithUnit("s"),
}, opt...)...,
)
if err != nil {
return InitDuration{noop.Float64Histogram{}}, err
}
return InitDuration{i}, nil
}
// Inst returns the underlying metric instrument.
func (m InitDuration) Inst() metric.Float64Histogram {
return m.Float64Histogram
}
// Name returns the semantic convention name of the instrument.
func (InitDuration) Name() string {
return "faas.init_duration"
}
// Unit returns the semantic convention unit of the instrument
func (InitDuration) Unit() string {
return "s"
}
// Description returns the semantic convention description of the instrument
func (InitDuration) Description() string {
return "Measures the duration of the function's initialization, such as a cold start"
}
// Record records val to the current distribution.
//
// All additional attrs passed are included in the recorded value.
func (m InitDuration) Record(
ctx context.Context,
val float64,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Float64Histogram.Record(ctx, val, *o...)
}
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
// convention. It represents the type of the trigger which caused this function
// invocation.
func (InitDuration) AttrTrigger(val TriggerAttr) attribute.KeyValue {
return attribute.String("faas.trigger", string(val))
}
// Invocations is an instrument used to record metric values conforming to the
// "faas.invocations" semantic conventions. It represents the number of
// successful invocations.
type Invocations struct {
metric.Int64Counter
}
// NewInvocations returns a new Invocations instrument.
func NewInvocations(
m metric.Meter,
opt ...metric.Int64CounterOption,
) (Invocations, error) {
// Check if the meter is nil.
if m == nil {
return Invocations{noop.Int64Counter{}}, nil
}
i, err := m.Int64Counter(
"faas.invocations",
append([]metric.Int64CounterOption{
metric.WithDescription("Number of successful invocations"),
metric.WithUnit("{invocation}"),
}, opt...)...,
)
if err != nil {
return Invocations{noop.Int64Counter{}}, err
}
return Invocations{i}, nil
}
// Inst returns the underlying metric instrument.
func (m Invocations) Inst() metric.Int64Counter {
return m.Int64Counter
}
// Name returns the semantic convention name of the instrument.
func (Invocations) Name() string {
return "faas.invocations"
}
// Unit returns the semantic convention unit of the instrument
func (Invocations) Unit() string {
return "{invocation}"
}
// Description returns the semantic convention description of the instrument
func (Invocations) Description() string {
return "Number of successful invocations"
}
// Add adds incr to the existing count.
//
// All additional attrs passed are included in the recorded value.
func (m Invocations) Add(
ctx context.Context,
incr int64,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Int64Counter.Add(ctx, incr, *o...)
}
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
// convention. It represents the type of the trigger which caused this function
// invocation.
func (Invocations) AttrTrigger(val TriggerAttr) attribute.KeyValue {
return attribute.String("faas.trigger", string(val))
}
// InvokeDuration is an instrument used to record metric values conforming to the
// "faas.invoke_duration" semantic conventions. It represents the measures the
// duration of the function's logic execution.
type InvokeDuration struct {
metric.Float64Histogram
}
// NewInvokeDuration returns a new InvokeDuration instrument.
func NewInvokeDuration(
m metric.Meter,
opt ...metric.Float64HistogramOption,
) (InvokeDuration, error) {
// Check if the meter is nil.
if m == nil {
return InvokeDuration{noop.Float64Histogram{}}, nil
}
i, err := m.Float64Histogram(
"faas.invoke_duration",
append([]metric.Float64HistogramOption{
metric.WithDescription("Measures the duration of the function's logic execution"),
metric.WithUnit("s"),
}, opt...)...,
)
if err != nil {
return InvokeDuration{noop.Float64Histogram{}}, err
}
return InvokeDuration{i}, nil
}
// Inst returns the underlying metric instrument.
func (m InvokeDuration) Inst() metric.Float64Histogram {
return m.Float64Histogram
}
// Name returns the semantic convention name of the instrument.
func (InvokeDuration) Name() string {
return "faas.invoke_duration"
}
// Unit returns the semantic convention unit of the instrument
func (InvokeDuration) Unit() string {
return "s"
}
// Description returns the semantic convention description of the instrument
func (InvokeDuration) Description() string {
return "Measures the duration of the function's logic execution"
}
// Record records val to the current distribution.
//
// All additional attrs passed are included in the recorded value.
func (m InvokeDuration) Record(
ctx context.Context,
val float64,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Float64Histogram.Record(ctx, val, *o...)
}
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
// convention. It represents the type of the trigger which caused this function
// invocation.
func (InvokeDuration) AttrTrigger(val TriggerAttr) attribute.KeyValue {
return attribute.String("faas.trigger", string(val))
}
// MemUsage is an instrument used to record metric values conforming to the
// "faas.mem_usage" semantic conventions. It represents the distribution of max
// memory usage per invocation.
type MemUsage struct {
metric.Int64Histogram
}
// NewMemUsage returns a new MemUsage instrument.
func NewMemUsage(
m metric.Meter,
opt ...metric.Int64HistogramOption,
) (MemUsage, error) {
// Check if the meter is nil.
if m == nil {
return MemUsage{noop.Int64Histogram{}}, nil
}
i, err := m.Int64Histogram(
"faas.mem_usage",
append([]metric.Int64HistogramOption{
metric.WithDescription("Distribution of max memory usage per invocation"),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return MemUsage{noop.Int64Histogram{}}, err
}
return MemUsage{i}, nil
}
// Inst returns the underlying metric instrument.
func (m MemUsage) Inst() metric.Int64Histogram {
return m.Int64Histogram
}
// Name returns the semantic convention name of the instrument.
func (MemUsage) Name() string {
return "faas.mem_usage"
}
// Unit returns the semantic convention unit of the instrument
func (MemUsage) Unit() string {
return "By"
}
// Description returns the semantic convention description of the instrument
func (MemUsage) Description() string {
return "Distribution of max memory usage per invocation"
}
// Record records val to the current distribution.
//
// All additional attrs passed are included in the recorded value.
func (m MemUsage) Record(
ctx context.Context,
val int64,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Int64Histogram.Record(ctx, val, *o...)
}
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
// convention. It represents the type of the trigger which caused this function
// invocation.
func (MemUsage) AttrTrigger(val TriggerAttr) attribute.KeyValue {
return attribute.String("faas.trigger", string(val))
}
// NetIO is an instrument used to record metric values conforming to the
// "faas.net_io" semantic conventions. It represents the distribution of net I/O
// usage per invocation.
type NetIO struct {
metric.Int64Histogram
}
// NewNetIO returns a new NetIO instrument.
func NewNetIO(
m metric.Meter,
opt ...metric.Int64HistogramOption,
) (NetIO, error) {
// Check if the meter is nil.
if m == nil {
return NetIO{noop.Int64Histogram{}}, nil
}
i, err := m.Int64Histogram(
"faas.net_io",
append([]metric.Int64HistogramOption{
metric.WithDescription("Distribution of net I/O usage per invocation"),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return NetIO{noop.Int64Histogram{}}, err
}
return NetIO{i}, nil
}
// Inst returns the underlying metric instrument.
func (m NetIO) Inst() metric.Int64Histogram {
return m.Int64Histogram
}
// Name returns the semantic convention name of the instrument.
func (NetIO) Name() string {
return "faas.net_io"
}
// Unit returns the semantic convention unit of the instrument
func (NetIO) Unit() string {
return "By"
}
// Description returns the semantic convention description of the instrument
func (NetIO) Description() string {
return "Distribution of net I/O usage per invocation"
}
// Record records val to the current distribution.
//
// All additional attrs passed are included in the recorded value.
func (m NetIO) Record(
ctx context.Context,
val int64,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Int64Histogram.Record(ctx, val, *o...)
}
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
// convention. It represents the type of the trigger which caused this function
// invocation.
func (NetIO) AttrTrigger(val TriggerAttr) attribute.KeyValue {
return attribute.String("faas.trigger", string(val))
}
// Timeouts is an instrument used to record metric values conforming to the
// "faas.timeouts" semantic conventions. It represents the number of invocation
// timeouts.
type Timeouts struct {
metric.Int64Counter
}
// NewTimeouts returns a new Timeouts instrument.
func NewTimeouts(
m metric.Meter,
opt ...metric.Int64CounterOption,
) (Timeouts, error) {
// Check if the meter is nil.
if m == nil {
return Timeouts{noop.Int64Counter{}}, nil
}
i, err := m.Int64Counter(
"faas.timeouts",
append([]metric.Int64CounterOption{
metric.WithDescription("Number of invocation timeouts"),
metric.WithUnit("{timeout}"),
}, opt...)...,
)
if err != nil {
return Timeouts{noop.Int64Counter{}}, err
}
return Timeouts{i}, nil
}
// Inst returns the underlying metric instrument.
func (m Timeouts) Inst() metric.Int64Counter {
return m.Int64Counter
}
// Name returns the semantic convention name of the instrument.
func (Timeouts) Name() string {
return "faas.timeouts"
}
// Unit returns the semantic convention unit of the instrument
func (Timeouts) Unit() string {
return "{timeout}"
}
// Description returns the semantic convention description of the instrument
func (Timeouts) Description() string {
return "Number of invocation timeouts"
}
// Add adds incr to the existing count.
//
// All additional attrs passed are included in the recorded value.
func (m Timeouts) Add(
ctx context.Context,
incr int64,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Int64Counter.Add(ctx, incr, *o...)
}
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
// convention. It represents the type of the trigger which caused this function
// invocation.
func (Timeouts) AttrTrigger(val TriggerAttr) attribute.KeyValue {
return attribute.String("faas.trigger", string(val))
}