diff --git a/semconv/templates/registry/go/instrument.j2 b/semconv/templates/registry/go/instrument.j2 index 3df51a907..25700b640 100644 --- a/semconv/templates/registry/go/instrument.j2 +++ b/semconv/templates/registry/go/instrument.j2 @@ -137,7 +137,7 @@ func (m {{ name }}) Add( {%- macro add_method(metric, inst, pkg="") -%} -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. {%- if metric.attributes is not none and metric.attributes | length > 0 %} {{ params_docs(metric.attributes, pkg=pkg) }} {%- if metric.note is defined %} @@ -168,6 +168,30 @@ func (m {{ h.to_go_name(metric.metric_name, pkg) }}) Add(ctx context.Context, in {%- endif -%} {%- endmacro -%} +{%- macro add_set_method(metric, inst, pkg="") -%} + +// AddSet adds incr to the existing count for set. +{%- if metric.note is defined %} +// +{{ metric.note | comment }} +{%- endif %} +func (m {{ h.to_go_name(metric.metric_name, pkg) }}) AddSet(ctx context.Context, incr {{ value_type(metric) | lower }}, set attribute.Set) { + if set.Len() == 0 { + m.{{ inst }}.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.{{ inst }}.Add(ctx, incr, *o...) +} +{%- endmacro -%} + {%- macro record_method_with_optional(metric, inst, pkg="") -%} {%- set name = h.to_go_name(metric.metric_name, pkg) -%} {%- set req_attr = metric.attributes | required | attribute_sort -%} @@ -198,7 +222,7 @@ func (m {{ name }}) Record( {%- macro record_method(metric, inst, pkg="") -%} -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. {%- if metric.attributes is not none and metric.attributes | length > 0 %} {{ params_docs(metric.attributes, pkg=pkg) }} {%- if metric.note is defined %} @@ -230,6 +254,30 @@ func (m {{ name }}) Record(ctx context.Context, val {{ value_type(metric) | lowe {%- endif -%} {%- endmacro -%} +{%- macro record_set_method(metric, inst, pkg="") -%} +{%- set name = h.to_go_name(metric.metric_name, pkg) -%} + +// RecordSet records val to the current distribution for set. +{%- if metric.note is defined %} +// +{{ metric.note | comment }} +{%- endif %} +func (m {{ name }}) RecordSet(ctx context.Context, val {{ value_type(metric) | lower }}, set attribute.Set) { + if set.Len() == 0 { + m.{{ inst }}.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.{{ inst }}.Record(ctx, val, *o...) +} +{%- endmacro -%} + {%- macro desc(metric) -%} {{metric.brief | replace('\n', ' ') | trim}} {%- endmacro -%} diff --git a/semconv/templates/registry/go/metric.go.j2 b/semconv/templates/registry/go/metric.go.j2 index 98f8792f6..f516d120b 100644 --- a/semconv/templates/registry/go/metric.go.j2 +++ b/semconv/templates/registry/go/metric.go.j2 @@ -106,9 +106,13 @@ func ({{ metric_name }}) Description() string { {%- elif metric.instrument == "counter" or metric.instrument == "updowncounter" %} {{ i.add_method(metric, metric_inst, ctx.root_namespace) }} + +{{ i.add_set_method(metric, metric_inst, ctx.root_namespace) }} {%- elif metric.instrument == "histogram" or metric.instrument == "gauge" %} {{ i.record_method(metric, metric_inst, ctx.root_namespace) }} + +{{ i.record_set_method(metric, metric_inst, ctx.root_namespace) }} {%- endif %} {%- for attr in metric.attributes | not_required | attribute_sort %} {%- set name = h.to_go_name(attr.name, ctx.root_namespace) %} diff --git a/semconv/v1.36.0/azureconv/metric.go b/semconv/v1.36.0/azureconv/metric.go index 8d94f54c9..9d08c2ca7 100644 --- a/semconv/v1.36.0/azureconv/metric.go +++ b/semconv/v1.36.0/azureconv/metric.go @@ -108,7 +108,7 @@ func (CosmosDBClientActiveInstanceCount) Description() string { return "Number of active client instances" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. func (m CosmosDBClientActiveInstanceCount) Add( @@ -137,6 +137,23 @@ func (m CosmosDBClientActiveInstanceCount) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m CosmosDBClientActiveInstanceCount) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // AttrServerPort returns an optional attribute for the "server.port" semantic // convention. It represents the server port number. func (CosmosDBClientActiveInstanceCount) AttrServerPort(val int) attribute.KeyValue { @@ -203,7 +220,7 @@ func (CosmosDBClientOperationRequestCharge) Description() string { return "[Request units](https://learn.microsoft.com/azure/cosmos-db/request-units) consumed by the operation" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The dbOperationName is the the name of the operation or command being // executed. @@ -239,6 +256,22 @@ func (m CosmosDBClientOperationRequestCharge) Record( m.Int64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m CosmosDBClientOperationRequestCharge) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Histogram.Record(ctx, val, *o...) +} + // AttrCosmosDBConsistencyLevel returns an optional attribute for the // "azure.cosmosdb.consistency.level" semantic convention. It represents the // account or request [consistency level]. diff --git a/semconv/v1.36.0/cicdconv/metric.go b/semconv/v1.36.0/cicdconv/metric.go index 367574d41..2e156d394 100644 --- a/semconv/v1.36.0/cicdconv/metric.go +++ b/semconv/v1.36.0/cicdconv/metric.go @@ -140,7 +140,7 @@ func (PipelineRunActive) Description() string { return "The number of pipeline runs currently active in the system by state." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The pipelineName is the the human readable name of the pipeline within a CI/CD // system. @@ -179,6 +179,23 @@ func (m PipelineRunActive) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m PipelineRunActive) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // PipelineRunDuration is an instrument used to record metric values conforming // to the "cicd.pipeline.run.duration" semantic conventions. It represents the // duration of a pipeline run grouped by pipeline, state and result. @@ -229,7 +246,7 @@ func (PipelineRunDuration) Description() string { return "Duration of a pipeline run grouped by pipeline, state and result." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The pipelineName is the the human readable name of the pipeline within a CI/CD // system. @@ -270,6 +287,22 @@ func (m PipelineRunDuration) Record( m.Float64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m PipelineRunDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Histogram.Record(ctx, val, *o...) +} + // AttrPipelineResult returns an optional attribute for the // "cicd.pipeline.result" semantic convention. It represents the result of a // pipeline run. @@ -334,7 +367,7 @@ func (PipelineRunErrors) Description() string { return "The number of errors encountered in pipeline runs (eg. compile, test failures)." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The pipelineName is the the human readable name of the pipeline within a CI/CD // system. @@ -377,6 +410,28 @@ func (m PipelineRunErrors) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// There might be errors in a pipeline run that are non fatal (eg. they are +// suppressed) or in a parallel stage multiple stages could have a fatal error. +// This means that this error count might not be the same as the count of metric +// `cicd.pipeline.run.duration` with run result `failure`. +func (m PipelineRunErrors) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // SystemErrors is an instrument used to record metric values conforming to the // "cicd.system.errors" semantic conventions. It represents the number of errors // in a component of the CICD system (eg. controller, scheduler, agent). @@ -427,7 +482,7 @@ func (SystemErrors) Description() string { return "The number of errors in a component of the CICD system (eg. controller, scheduler, agent)." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The systemComponent is the the name of a component of the CICD system. // @@ -467,6 +522,26 @@ func (m SystemErrors) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// Errors in pipeline run execution are explicitly excluded. Ie a test failure is +// not counted in this metric. +func (m SystemErrors) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // WorkerCount is an instrument used to record metric values conforming to the // "cicd.worker.count" semantic conventions. It represents the number of workers // on the CICD system by state. @@ -517,7 +592,7 @@ func (WorkerCount) Description() string { return "The number of workers on the CICD system by state." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The workerState is the the state of a CICD worker / agent. func (m WorkerCount) Add( @@ -547,5 +622,22 @@ func (m WorkerCount) Add( ), ) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + +// AddSet adds incr to the existing count for set. +func (m WorkerCount) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) m.Int64UpDownCounter.Add(ctx, incr, *o...) } \ No newline at end of file diff --git a/semconv/v1.36.0/containerconv/metric.go b/semconv/v1.36.0/containerconv/metric.go index 01097c9a9..8bcacf5f4 100644 --- a/semconv/v1.36.0/containerconv/metric.go +++ b/semconv/v1.36.0/containerconv/metric.go @@ -121,7 +121,7 @@ func (CPUTime) Description() string { return "Total CPU time consumed" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. // @@ -152,6 +152,25 @@ func (m CPUTime) Add( m.Float64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// Total CPU time consumed by the specific container on all available CPU cores +func (m CPUTime) AddSet(ctx context.Context, incr float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Counter.Add(ctx, incr, *o...) +} + // AttrCPUMode returns an optional attribute for the "cpu.mode" semantic // convention. It represents the CPU mode for this data point. A container's CPU // metric SHOULD be characterized *either* by data points with no `mode` labels, @@ -210,7 +229,7 @@ func (CPUUsage) Description() string { return "Container's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // All additional attrs passed are included in the recorded value. // @@ -242,6 +261,25 @@ func (m CPUUsage) Record( m.Int64Gauge.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// CPU usage of the specific container on all available CPU cores, averaged over +// the sample window +func (m CPUUsage) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Gauge.Record(ctx, val, *o...) +} + // AttrCPUMode returns an optional attribute for the "cpu.mode" semantic // convention. It represents the CPU mode for this data point. A container's CPU // metric SHOULD be characterized *either* by data points with no `mode` labels, @@ -300,7 +338,7 @@ func (DiskIO) Description() string { return "Disk bytes for the container." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. // @@ -332,6 +370,26 @@ func (m DiskIO) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// The total number of bytes read/written successfully (aggregated from all +// disks). +func (m DiskIO) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrDiskIODirection returns an optional attribute for the "disk.io.direction" // semantic convention. It represents the disk IO operation direction. func (DiskIO) AttrDiskIODirection(val DiskIODirectionAttr) attribute.KeyValue { @@ -394,7 +452,7 @@ func (MemoryUsage) Description() string { return "Memory usage of the container." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // Memory usage of the container. func (m MemoryUsage) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { @@ -413,6 +471,25 @@ func (m MemoryUsage) Add(ctx context.Context, incr int64, attrs ...attribute.Key m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// Memory usage of the container. +func (m MemoryUsage) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // NetworkIO is an instrument used to record metric values conforming to the // "container.network.io" semantic conventions. It represents the network bytes // for the container. @@ -463,7 +540,7 @@ func (NetworkIO) Description() string { return "Network bytes for the container." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. // @@ -494,6 +571,25 @@ func (m NetworkIO) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// The number of bytes sent/received on all network interfaces by the container. +func (m NetworkIO) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrNetworkInterfaceName returns an optional attribute for the // "network.interface.name" semantic convention. It represents the network // interface name. @@ -558,7 +654,7 @@ func (Uptime) Description() string { return "The time the container has been running" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // Instrumentations SHOULD use a gauge with type `double` and measure uptime in // seconds as a floating point number with the highest precision available. @@ -577,4 +673,24 @@ func (m Uptime) Record(ctx context.Context, val float64, attrs ...attribute.KeyV *o = append(*o, metric.WithAttributes(attrs...)) m.Float64Gauge.Record(ctx, val, *o...) +} + +// RecordSet records val to the current distribution for set. +// +// Instrumentations SHOULD use a gauge with type `double` and measure uptime in +// seconds as a floating point number with the highest precision available. +// The actual accuracy would depend on the instrumentation and operating system. +func (m Uptime) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Gauge.Record(ctx, val, *o...) } \ No newline at end of file diff --git a/semconv/v1.36.0/dbconv/metric.go b/semconv/v1.36.0/dbconv/metric.go index 685407ef1..1db72b593 100644 --- a/semconv/v1.36.0/dbconv/metric.go +++ b/semconv/v1.36.0/dbconv/metric.go @@ -267,7 +267,7 @@ func (ClientConnectionCount) Description() string { return "The number of connections that are currently in state described by the `state` attribute" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The clientConnectionPoolName is the the name of the connection pool; unique // within the instrumented application. In case the connection pool @@ -310,6 +310,23 @@ func (m ClientConnectionCount) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m ClientConnectionCount) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ClientConnectionCreateTime is an instrument used to record metric values // conforming to the "db.client.connection.create_time" semantic conventions. It // represents the time it took to create a new connection. @@ -361,7 +378,7 @@ func (ClientConnectionCreateTime) Description() string { return "The time it took to create a new connection" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The clientConnectionPoolName is the the name of the connection pool; unique // within the instrumented application. In case the connection pool @@ -400,6 +417,22 @@ func (m ClientConnectionCreateTime) Record( m.Float64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m ClientConnectionCreateTime) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Histogram.Record(ctx, val, *o...) +} + // ClientConnectionIdleMax is an instrument used to record metric values // conforming to the "db.client.connection.idle.max" semantic conventions. It // represents the maximum number of idle open connections allowed. @@ -450,7 +483,7 @@ func (ClientConnectionIdleMax) Description() string { return "The maximum number of idle open connections allowed" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The clientConnectionPoolName is the the name of the connection pool; unique // within the instrumented application. In case the connection pool @@ -489,6 +522,23 @@ func (m ClientConnectionIdleMax) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m ClientConnectionIdleMax) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ClientConnectionIdleMin is an instrument used to record metric values // conforming to the "db.client.connection.idle.min" semantic conventions. It // represents the minimum number of idle open connections allowed. @@ -539,7 +589,7 @@ func (ClientConnectionIdleMin) Description() string { return "The minimum number of idle open connections allowed" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The clientConnectionPoolName is the the name of the connection pool; unique // within the instrumented application. In case the connection pool @@ -578,6 +628,23 @@ func (m ClientConnectionIdleMin) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m ClientConnectionIdleMin) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ClientConnectionMax is an instrument used to record metric values conforming // to the "db.client.connection.max" semantic conventions. It represents the // maximum number of open connections allowed. @@ -628,7 +695,7 @@ func (ClientConnectionMax) Description() string { return "The maximum number of open connections allowed" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The clientConnectionPoolName is the the name of the connection pool; unique // within the instrumented application. In case the connection pool @@ -667,6 +734,23 @@ func (m ClientConnectionMax) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m ClientConnectionMax) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ClientConnectionPendingRequests is an instrument used to record metric values // conforming to the "db.client.connection.pending_requests" semantic // conventions. It represents the number of current pending requests for an open @@ -719,7 +803,7 @@ func (ClientConnectionPendingRequests) Description() string { return "The number of current pending requests for an open connection" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The clientConnectionPoolName is the the name of the connection pool; unique // within the instrumented application. In case the connection pool @@ -758,6 +842,23 @@ func (m ClientConnectionPendingRequests) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m ClientConnectionPendingRequests) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ClientConnectionTimeouts is an instrument used to record metric values // conforming to the "db.client.connection.timeouts" semantic conventions. It // represents the number of connection timeouts that have occurred trying to @@ -809,7 +910,7 @@ func (ClientConnectionTimeouts) Description() string { return "The number of connection timeouts that have occurred trying to obtain a connection from the pool" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The clientConnectionPoolName is the the name of the connection pool; unique // within the instrumented application. In case the connection pool @@ -848,6 +949,23 @@ func (m ClientConnectionTimeouts) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m ClientConnectionTimeouts) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // ClientConnectionUseTime is an instrument used to record metric values // conforming to the "db.client.connection.use_time" semantic conventions. It // represents the time between borrowing a connection and returning it to the @@ -899,7 +1017,7 @@ func (ClientConnectionUseTime) Description() string { return "The time between borrowing a connection and returning it to the pool" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The clientConnectionPoolName is the the name of the connection pool; unique // within the instrumented application. In case the connection pool @@ -938,6 +1056,22 @@ func (m ClientConnectionUseTime) Record( m.Float64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m ClientConnectionUseTime) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Histogram.Record(ctx, val, *o...) +} + // ClientConnectionWaitTime is an instrument used to record metric values // conforming to the "db.client.connection.wait_time" semantic conventions. It // represents the time it took to obtain an open connection from the pool. @@ -988,7 +1122,7 @@ func (ClientConnectionWaitTime) Description() string { return "The time it took to obtain an open connection from the pool" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The clientConnectionPoolName is the the name of the connection pool; unique // within the instrumented application. In case the connection pool @@ -1027,6 +1161,22 @@ func (m ClientConnectionWaitTime) Record( m.Float64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m ClientConnectionWaitTime) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Histogram.Record(ctx, val, *o...) +} + // ClientOperationDuration is an instrument used to record metric values // conforming to the "db.client.operation.duration" semantic conventions. It // represents the duration of database client operations. @@ -1077,7 +1227,7 @@ func (ClientOperationDuration) Description() string { return "Duration of database client operations." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The systemName is the the database management system (DBMS) product as // identified by the client instrumentation. @@ -1115,6 +1265,24 @@ func (m ClientOperationDuration) Record( m.Float64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// Batch operations SHOULD be recorded as a single operation. +func (m ClientOperationDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Histogram.Record(ctx, val, *o...) +} + // AttrCollectionName returns an optional attribute for the "db.collection.name" // semantic convention. It represents the name of a collection (table, container) // within the database. @@ -1247,7 +1415,7 @@ func (ClientResponseReturnedRows) Description() string { return "The actual number of records returned by the database operation." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The systemName is the the database management system (DBMS) product as // identified by the client instrumentation. @@ -1283,6 +1451,22 @@ func (m ClientResponseReturnedRows) Record( m.Int64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m ClientResponseReturnedRows) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Histogram.Record(ctx, val, *o...) +} + // AttrCollectionName returns an optional attribute for the "db.collection.name" // semantic convention. It represents the name of a collection (table, container) // within the database. diff --git a/semconv/v1.36.0/dnsconv/metric.go b/semconv/v1.36.0/dnsconv/metric.go index cce82621a..b5348a23f 100644 --- a/semconv/v1.36.0/dnsconv/metric.go +++ b/semconv/v1.36.0/dnsconv/metric.go @@ -81,7 +81,7 @@ func (LookupDuration) Description() string { return "Measures the time taken to perform a DNS lookup." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The questionName is the the name being queried. // @@ -116,6 +116,22 @@ func (m LookupDuration) Record( m.Float64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m LookupDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Histogram.Record(ctx, val, *o...) +} + // AttrErrorType returns an optional attribute for the "error.type" semantic // convention. It represents the describes the error the DNS lookup failed with. func (LookupDuration) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue { diff --git a/semconv/v1.36.0/faasconv/metric.go b/semconv/v1.36.0/faasconv/metric.go index 2fa23f94b..c952a507e 100644 --- a/semconv/v1.36.0/faasconv/metric.go +++ b/semconv/v1.36.0/faasconv/metric.go @@ -91,7 +91,7 @@ func (Coldstarts) Description() string { return "Number of invocation cold starts" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. func (m Coldstarts) Add( @@ -120,6 +120,23 @@ func (m Coldstarts) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m Coldstarts) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + 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. @@ -177,7 +194,7 @@ func (CPUUsage) Description() string { return "Distribution of CPU usage per invocation" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // All additional attrs passed are included in the recorded value. func (m CPUUsage) Record( @@ -206,6 +223,22 @@ func (m CPUUsage) Record( m.Float64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m CPUUsage) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + 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. @@ -263,7 +296,7 @@ func (Errors) Description() string { return "Number of invocation errors" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. func (m Errors) Add( @@ -292,6 +325,23 @@ func (m Errors) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m Errors) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + 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. @@ -349,7 +399,7 @@ 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. +// Record records val to the current distribution for attrs. // // All additional attrs passed are included in the recorded value. func (m InitDuration) Record( @@ -378,6 +428,22 @@ func (m InitDuration) Record( m.Float64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m InitDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + 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. @@ -435,7 +501,7 @@ func (Invocations) Description() string { return "Number of successful invocations" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. func (m Invocations) Add( @@ -464,6 +530,23 @@ func (m Invocations) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m Invocations) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + 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. @@ -521,7 +604,7 @@ func (InvokeDuration) Description() string { return "Measures the duration of the function's logic execution" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // All additional attrs passed are included in the recorded value. func (m InvokeDuration) Record( @@ -550,6 +633,22 @@ func (m InvokeDuration) Record( m.Float64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m InvokeDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + 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. @@ -607,7 +706,7 @@ func (MemUsage) Description() string { return "Distribution of max memory usage per invocation" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // All additional attrs passed are included in the recorded value. func (m MemUsage) Record( @@ -636,6 +735,22 @@ func (m MemUsage) Record( m.Int64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m MemUsage) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + 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. @@ -693,7 +808,7 @@ func (NetIO) Description() string { return "Distribution of net I/O usage per invocation" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // All additional attrs passed are included in the recorded value. func (m NetIO) Record( @@ -722,6 +837,22 @@ func (m NetIO) Record( m.Int64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m NetIO) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + 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. @@ -779,7 +910,7 @@ func (Timeouts) Description() string { return "Number of invocation timeouts" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. func (m Timeouts) Add( @@ -808,6 +939,23 @@ func (m Timeouts) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m Timeouts) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + 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. diff --git a/semconv/v1.36.0/genaiconv/metric.go b/semconv/v1.36.0/genaiconv/metric.go index 37cc807ef..7b049c1ca 100644 --- a/semconv/v1.36.0/genaiconv/metric.go +++ b/semconv/v1.36.0/genaiconv/metric.go @@ -164,7 +164,7 @@ func (ClientOperationDuration) Description() string { return "GenAI operation duration" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The operationName is the the name of the operation being performed. // @@ -204,6 +204,22 @@ func (m ClientOperationDuration) Record( m.Float64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m ClientOperationDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Histogram.Record(ctx, val, *o...) +} + // AttrErrorType returns an optional attribute for the "error.type" semantic // convention. It represents the describes a class of error the operation ended // with. @@ -287,7 +303,7 @@ func (ClientTokenUsage) Description() string { return "Measures number of input and output tokens used" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The operationName is the the name of the operation being performed. // @@ -331,6 +347,22 @@ func (m ClientTokenUsage) Record( m.Int64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m ClientTokenUsage) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Histogram.Record(ctx, val, *o...) +} + // AttrRequestModel returns an optional attribute for the "gen_ai.request.model" // semantic convention. It represents the name of the GenAI model a request is // being made to. @@ -408,7 +440,7 @@ func (ServerRequestDuration) Description() string { return "Generative AI server request duration such as time-to-last byte or last output token" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The operationName is the the name of the operation being performed. // @@ -448,6 +480,22 @@ func (m ServerRequestDuration) Record( m.Float64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m ServerRequestDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Histogram.Record(ctx, val, *o...) +} + // AttrErrorType returns an optional attribute for the "error.type" semantic // convention. It represents the describes a class of error the operation ended // with. @@ -532,7 +580,7 @@ func (ServerTimePerOutputToken) Description() string { return "Time per output token generated after the first token for successful responses" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The operationName is the the name of the operation being performed. // @@ -572,6 +620,22 @@ func (m ServerTimePerOutputToken) Record( m.Float64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m ServerTimePerOutputToken) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Histogram.Record(ctx, val, *o...) +} + // AttrRequestModel returns an optional attribute for the "gen_ai.request.model" // semantic convention. It represents the name of the GenAI model a request is // being made to. @@ -648,7 +712,7 @@ func (ServerTimeToFirstToken) Description() string { return "Time to generate first token for successful responses" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The operationName is the the name of the operation being performed. // @@ -688,6 +752,22 @@ func (m ServerTimeToFirstToken) Record( m.Float64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m ServerTimeToFirstToken) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Histogram.Record(ctx, val, *o...) +} + // AttrRequestModel returns an optional attribute for the "gen_ai.request.model" // semantic convention. It represents the name of the GenAI model a request is // being made to. diff --git a/semconv/v1.36.0/goconv/metric.go b/semconv/v1.36.0/goconv/metric.go index f2e906471..fe9e2933e 100644 --- a/semconv/v1.36.0/goconv/metric.go +++ b/semconv/v1.36.0/goconv/metric.go @@ -491,7 +491,7 @@ func (ScheduleDuration) Description() string { return "The time goroutines have spent in the scheduler in a runnable state before actually running." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // Computed from `/sched/latencies:seconds`. Bucket boundaries are provided by // the runtime, and are subject to change. @@ -509,4 +509,23 @@ func (m ScheduleDuration) Record(ctx context.Context, val float64, attrs ...attr *o = append(*o, metric.WithAttributes(attrs...)) m.Float64Histogram.Record(ctx, val, *o...) +} + +// RecordSet records val to the current distribution for set. +// +// Computed from `/sched/latencies:seconds`. Bucket boundaries are provided by +// the runtime, and are subject to change. +func (m ScheduleDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Histogram.Record(ctx, val, *o...) } \ No newline at end of file diff --git a/semconv/v1.36.0/httpconv/metric.go b/semconv/v1.36.0/httpconv/metric.go index 214ba9386..552763e31 100644 --- a/semconv/v1.36.0/httpconv/metric.go +++ b/semconv/v1.36.0/httpconv/metric.go @@ -134,7 +134,7 @@ func (ClientActiveRequests) Description() string { return "Number of active HTTP requests." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The serverAddress is the server domain name if available without reverse DNS // lookup; otherwise, IP address or Unix domain socket name. @@ -177,6 +177,23 @@ func (m ClientActiveRequests) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m ClientActiveRequests) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // AttrURLTemplate returns an optional attribute for the "url.template" semantic // convention. It represents the low-cardinality template of an // [absolute path reference]. @@ -252,7 +269,7 @@ func (ClientConnectionDuration) Description() string { return "The duration of the successfully established outbound HTTP connections." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The serverAddress is the server domain name if available without reverse DNS // lookup; otherwise, IP address or Unix domain socket name. @@ -295,6 +312,22 @@ func (m ClientConnectionDuration) Record( m.Float64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m ClientConnectionDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Histogram.Record(ctx, val, *o...) +} + // AttrNetworkPeerAddress returns an optional attribute for the // "network.peer.address" semantic convention. It represents the peer address of // the network connection - IP address or Unix domain socket name. @@ -369,7 +402,7 @@ func (ClientOpenConnections) Description() string { return "Number of outbound HTTP connections that are currently active or idle on the client." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The connectionState is the state of the HTTP connection in the HTTP connection // pool. @@ -417,6 +450,23 @@ func (m ClientOpenConnections) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m ClientOpenConnections) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // AttrNetworkPeerAddress returns an optional attribute for the // "network.peer.address" semantic convention. It represents the peer address of // the network connection - IP address or Unix domain socket name. @@ -490,7 +540,7 @@ func (ClientRequestBodySize) Description() string { return "Size of HTTP client request bodies." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The requestMethod is the HTTP request method. // @@ -545,6 +595,29 @@ func (m ClientRequestBodySize) Record( m.Int64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// The size of the request payload body in bytes. This is the number of bytes +// transferred excluding headers and is often, but not always, present as the +// [Content-Length] header. For requests using transport encoding, this should be +// the compressed size. +// +// [Content-Length]: https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length +func (m ClientRequestBodySize) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Histogram.Record(ctx, val, *o...) +} + // AttrErrorType returns an optional attribute for the "error.type" semantic // convention. It represents the describes a class of error the operation ended // with. @@ -645,7 +718,7 @@ func (ClientRequestDuration) Description() string { return "Duration of HTTP client requests." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The requestMethod is the HTTP request method. // @@ -693,6 +766,22 @@ func (m ClientRequestDuration) Record( m.Float64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m ClientRequestDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Histogram.Record(ctx, val, *o...) +} + // AttrErrorType returns an optional attribute for the "error.type" semantic // convention. It represents the describes a class of error the operation ended // with. @@ -793,7 +882,7 @@ func (ClientResponseBodySize) Description() string { return "Size of HTTP client response bodies." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The requestMethod is the HTTP request method. // @@ -848,6 +937,29 @@ func (m ClientResponseBodySize) Record( m.Int64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// The size of the response payload body in bytes. This is the number of bytes +// transferred excluding headers and is often, but not always, present as the +// [Content-Length] header. For requests using transport encoding, this should be +// the compressed size. +// +// [Content-Length]: https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length +func (m ClientResponseBodySize) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Histogram.Record(ctx, val, *o...) +} + // AttrErrorType returns an optional attribute for the "error.type" semantic // convention. It represents the describes a class of error the operation ended // with. @@ -948,7 +1060,7 @@ func (ServerActiveRequests) Description() string { return "Number of active HTTP server requests." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The requestMethod is the HTTP request method. // @@ -989,6 +1101,23 @@ func (m ServerActiveRequests) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m ServerActiveRequests) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // AttrServerAddress returns an optional attribute for the "server.address" // semantic convention. It represents the name of the local HTTP server that // received the request. @@ -1053,7 +1182,7 @@ func (ServerRequestBodySize) Description() string { return "Size of HTTP server request bodies." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The requestMethod is the HTTP request method. // @@ -1101,6 +1230,29 @@ func (m ServerRequestBodySize) Record( m.Int64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// The size of the request payload body in bytes. This is the number of bytes +// transferred excluding headers and is often, but not always, present as the +// [Content-Length] header. For requests using transport encoding, this should be +// the compressed size. +// +// [Content-Length]: https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length +func (m ServerRequestBodySize) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Histogram.Record(ctx, val, *o...) +} + // AttrErrorType returns an optional attribute for the "error.type" semantic // convention. It represents the describes a class of error the operation ended // with. @@ -1211,7 +1363,7 @@ func (ServerRequestDuration) Description() string { return "Duration of HTTP server requests." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The requestMethod is the HTTP request method. // @@ -1252,6 +1404,22 @@ func (m ServerRequestDuration) Record( m.Float64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m ServerRequestDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Histogram.Record(ctx, val, *o...) +} + // AttrErrorType returns an optional attribute for the "error.type" semantic // convention. It represents the describes a class of error the operation ended // with. @@ -1362,7 +1530,7 @@ func (ServerResponseBodySize) Description() string { return "Size of HTTP server response bodies." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The requestMethod is the HTTP request method. // @@ -1410,6 +1578,29 @@ func (m ServerResponseBodySize) Record( m.Int64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// The size of the response payload body in bytes. This is the number of bytes +// transferred excluding headers and is often, but not always, present as the +// [Content-Length] header. For requests using transport encoding, this should be +// the compressed size. +// +// [Content-Length]: https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length +func (m ServerResponseBodySize) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Histogram.Record(ctx, val, *o...) +} + // AttrErrorType returns an optional attribute for the "error.type" semantic // convention. It represents the describes a class of error the operation ended // with. diff --git a/semconv/v1.36.0/hwconv/metric.go b/semconv/v1.36.0/hwconv/metric.go index 4a2a7d461..2e8ca7f80 100644 --- a/semconv/v1.36.0/hwconv/metric.go +++ b/semconv/v1.36.0/hwconv/metric.go @@ -129,7 +129,7 @@ func (Energy) Description() string { return "Energy consumed by the component" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The id is the an identifier for the hardware component, unique within the // monitored host @@ -169,6 +169,23 @@ func (m Energy) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m Energy) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrName returns an optional attribute for the "hw.name" semantic convention. // It represents an easily-recognizable name for the hardware component. func (Energy) AttrName(val string) attribute.KeyValue { @@ -232,7 +249,7 @@ func (Errors) Description() string { return "Number of errors encountered by the component" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The id is the an identifier for the hardware component, unique within the // monitored host @@ -272,6 +289,23 @@ func (m Errors) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m Errors) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrErrorType returns an optional attribute for the "error.type" semantic // convention. It represents the type of error encountered by the component. func (Errors) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue { @@ -341,7 +375,7 @@ func (HostAmbientTemperature) Description() string { return "Ambient (external) temperature of the physical host" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The id is the an identifier for the hardware component, unique within the // monitored host @@ -377,6 +411,22 @@ func (m HostAmbientTemperature) Record( m.Int64Gauge.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m HostAmbientTemperature) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Gauge.Record(ctx, val, *o...) +} + // AttrName returns an optional attribute for the "hw.name" semantic convention. // It represents an easily-recognizable name for the hardware component. func (HostAmbientTemperature) AttrName(val string) attribute.KeyValue { @@ -440,7 +490,7 @@ func (HostEnergy) Description() string { return "Total energy consumed by the entire physical host, in joules" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The id is the an identifier for the hardware component, unique within the // monitored host @@ -481,6 +531,28 @@ func (m HostEnergy) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// The overall energy usage of a host MUST be reported using the specific +// `hw.host.energy` and `hw.host.power` metrics **only**, instead of the generic +// `hw.energy` and `hw.power` described in the previous section, to prevent +// summing up overlapping values. +func (m HostEnergy) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrName returns an optional attribute for the "hw.name" semantic convention. // It represents an easily-recognizable name for the hardware component. func (HostEnergy) AttrName(val string) attribute.KeyValue { @@ -545,7 +617,7 @@ func (HostHeatingMargin) Description() string { return "By how many degrees Celsius the temperature of the physical host can be increased, before reaching a warning threshold on one of the internal sensors" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The id is the an identifier for the hardware component, unique within the // monitored host @@ -581,6 +653,22 @@ func (m HostHeatingMargin) Record( m.Int64Gauge.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m HostHeatingMargin) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Gauge.Record(ctx, val, *o...) +} + // AttrName returns an optional attribute for the "hw.name" semantic convention. // It represents an easily-recognizable name for the hardware component. func (HostHeatingMargin) AttrName(val string) attribute.KeyValue { @@ -644,7 +732,7 @@ func (HostPower) Description() string { return "Instantaneous power consumed by the entire physical host in Watts (`hw.host.energy` is preferred)" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The id is the an identifier for the hardware component, unique within the // monitored host @@ -685,6 +773,27 @@ func (m HostPower) Record( m.Int64Gauge.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// The overall energy usage of a host MUST be reported using the specific +// `hw.host.energy` and `hw.host.power` metrics **only**, instead of the generic +// `hw.energy` and `hw.power` described in the previous section, to prevent +// summing up overlapping values. +func (m HostPower) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Gauge.Record(ctx, val, *o...) +} + // AttrName returns an optional attribute for the "hw.name" semantic convention. // It represents an easily-recognizable name for the hardware component. func (HostPower) AttrName(val string) attribute.KeyValue { @@ -748,7 +857,7 @@ func (Power) Description() string { return "Instantaneous power consumed by the component" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The id is the an identifier for the hardware component, unique within the // monitored host @@ -790,6 +899,24 @@ func (m Power) Record( m.Int64Gauge.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// It is recommended to report `hw.energy` instead of `hw.power` when possible. +func (m Power) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Gauge.Record(ctx, val, *o...) +} + // AttrName returns an optional attribute for the "hw.name" semantic convention. // It represents an easily-recognizable name for the hardware component. func (Power) AttrName(val string) attribute.KeyValue { @@ -853,7 +980,7 @@ func (Status) Description() string { return "Operational status: `1` (true) or `0` (false) for each of the possible states" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The id is the an identifier for the hardware component, unique within the // monitored host @@ -905,6 +1032,31 @@ func (m Status) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// `hw.status` is currently specified as an *UpDownCounter* but would ideally be +// represented using a [*StateSet* as defined in OpenMetrics]. This semantic +// convention will be updated once *StateSet* is specified in OpenTelemetry. This +// planned change is not expected to have any consequence on the way users query +// their timeseries backend to retrieve the values of `hw.status` over time. +// +// [ [*StateSet* as defined in OpenMetrics]: https://github.com/prometheus/OpenMetrics/blob/v1.0.0/specification/OpenMetrics.md#stateset +func (m Status) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // AttrName returns an optional attribute for the "hw.name" semantic convention. // It represents an easily-recognizable name for the hardware component. func (Status) AttrName(val string) attribute.KeyValue { diff --git a/semconv/v1.36.0/k8sconv/metric.go b/semconv/v1.36.0/k8sconv/metric.go index 3e84cd08d..5f6328b9b 100644 --- a/semconv/v1.36.0/k8sconv/metric.go +++ b/semconv/v1.36.0/k8sconv/metric.go @@ -191,7 +191,7 @@ func (ContainerCPULimit) Description() string { return "Maximum CPU resource limit set for the container" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // See // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core @@ -212,6 +212,27 @@ func (m ContainerCPULimit) Add(ctx context.Context, incr int64, attrs ...attribu m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// See +// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core +// for details. +func (m ContainerCPULimit) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ContainerCPURequest is an instrument used to record metric values conforming // to the "k8s.container.cpu.request" semantic conventions. It represents the CPU // resource requested for the container. @@ -262,7 +283,7 @@ func (ContainerCPURequest) Description() string { return "CPU resource requested for the container" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // See // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core @@ -283,6 +304,27 @@ func (m ContainerCPURequest) Add(ctx context.Context, incr int64, attrs ...attri m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// See +// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core +// for details. +func (m ContainerCPURequest) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ContainerEphemeralStorageLimit is an instrument used to record metric values // conforming to the "k8s.container.ephemeral_storage.limit" semantic // conventions. It represents the maximum ephemeral storage resource limit set @@ -335,7 +377,7 @@ func (ContainerEphemeralStorageLimit) Description() string { return "Maximum ephemeral storage resource limit set for the container" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // See // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core @@ -356,6 +398,27 @@ func (m ContainerEphemeralStorageLimit) Add(ctx context.Context, incr int64, att m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// See +// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core +// for details. +func (m ContainerEphemeralStorageLimit) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ContainerEphemeralStorageRequest is an instrument used to record metric values // conforming to the "k8s.container.ephemeral_storage.request" semantic // conventions. It represents the ephemeral storage resource requested for the @@ -408,7 +471,7 @@ func (ContainerEphemeralStorageRequest) Description() string { return "Ephemeral storage resource requested for the container" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // See // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core @@ -429,6 +492,27 @@ func (m ContainerEphemeralStorageRequest) Add(ctx context.Context, incr int64, a m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// See +// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core +// for details. +func (m ContainerEphemeralStorageRequest) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ContainerMemoryLimit is an instrument used to record metric values conforming // to the "k8s.container.memory.limit" semantic conventions. It represents the // maximum memory resource limit set for the container. @@ -479,7 +563,7 @@ func (ContainerMemoryLimit) Description() string { return "Maximum memory resource limit set for the container" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // See // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core @@ -500,6 +584,27 @@ func (m ContainerMemoryLimit) Add(ctx context.Context, incr int64, attrs ...attr m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// See +// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core +// for details. +func (m ContainerMemoryLimit) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ContainerMemoryRequest is an instrument used to record metric values // conforming to the "k8s.container.memory.request" semantic conventions. It // represents the memory resource requested for the container. @@ -550,7 +655,7 @@ func (ContainerMemoryRequest) Description() string { return "Memory resource requested for the container" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // See // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core @@ -571,6 +676,27 @@ func (m ContainerMemoryRequest) Add(ctx context.Context, incr int64, attrs ...at m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// See +// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core +// for details. +func (m ContainerMemoryRequest) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ContainerReady is an instrument used to record metric values conforming to the // "k8s.container.ready" semantic conventions. It represents the indicates // whether the container is currently marked as ready to accept traffic, based on @@ -622,7 +748,7 @@ func (ContainerReady) Description() string { return "Indicates whether the container is currently marked as ready to accept traffic, based on its readiness probe (1 = ready, 0 = not ready)" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric SHOULD reflect the value of the `ready` field in the // [K8s ContainerStatus]. @@ -644,6 +770,28 @@ func (m ContainerReady) Add(ctx context.Context, incr int64, attrs ...attribute. m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric SHOULD reflect the value of the `ready` field in the +// [K8s ContainerStatus]. +// +// [K8s ContainerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#containerstatus-v1-core +func (m ContainerReady) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ContainerRestartCount is an instrument used to record metric values conforming // to the "k8s.container.restart.count" semantic conventions. It represents the // describes how many times the container has restarted (since the last counter @@ -695,7 +843,7 @@ func (ContainerRestartCount) Description() string { return "Describes how many times the container has restarted (since the last counter reset)" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This value is pulled directly from the K8s API and the value can go // indefinitely high and be reset to 0 @@ -722,6 +870,33 @@ func (m ContainerRestartCount) Add(ctx context.Context, incr int64, attrs ...att m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This value is pulled directly from the K8s API and the value can go +// indefinitely high and be reset to 0 +// at any time depending on how your kubelet is configured to prune dead +// containers. +// It is best to not depend too much on the exact value but rather look at it as +// either == 0, in which case you can conclude there were no restarts in the +// recent past, or > 0, in which case +// you can conclude there were restarts in the recent past, and not try and +// analyze the value beyond that. +func (m ContainerRestartCount) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ContainerStatusReason is an instrument used to record metric values conforming // to the "k8s.container.status.reason" semantic conventions. It represents the // describes the number of K8s containers that are currently in a state for a @@ -773,7 +948,7 @@ func (ContainerStatusReason) Description() string { return "Describes the number of K8s containers that are currently in a state for a given reason" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The containerStatusReason is the the reason for the container state. // Corresponds to the `reason` field of the: [K8s ContainerStateWaiting] or @@ -815,6 +990,27 @@ func (m ContainerStatusReason) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// All possible container state reasons will be reported at each time interval to +// avoid missing metrics. +// Only the value corresponding to the current state reason will be non-zero. +func (m ContainerStatusReason) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ContainerStatusState is an instrument used to record metric values conforming // to the "k8s.container.status.state" semantic conventions. It represents the // describes the number of K8s containers that are currently in a given state. @@ -865,7 +1061,7 @@ func (ContainerStatusState) Description() string { return "Describes the number of K8s containers that are currently in a given state" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The containerStatusState is the the state of the container. // [K8s ContainerState] @@ -905,6 +1101,27 @@ func (m ContainerStatusState) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// All possible container states will be reported at each time interval to avoid +// missing metrics. +// Only the value corresponding to the current state will be non-zero. +func (m ContainerStatusState) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ContainerStorageLimit is an instrument used to record metric values conforming // to the "k8s.container.storage.limit" semantic conventions. It represents the // maximum storage resource limit set for the container. @@ -955,7 +1172,7 @@ func (ContainerStorageLimit) Description() string { return "Maximum storage resource limit set for the container" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // See // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core @@ -976,6 +1193,27 @@ func (m ContainerStorageLimit) Add(ctx context.Context, incr int64, attrs ...att m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// See +// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core +// for details. +func (m ContainerStorageLimit) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ContainerStorageRequest is an instrument used to record metric values // conforming to the "k8s.container.storage.request" semantic conventions. It // represents the storage resource requested for the container. @@ -1026,7 +1264,7 @@ func (ContainerStorageRequest) Description() string { return "Storage resource requested for the container" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // See // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core @@ -1047,6 +1285,27 @@ func (m ContainerStorageRequest) Add(ctx context.Context, incr int64, attrs ...a m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// See +// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#resourcerequirements-v1-core +// for details. +func (m ContainerStorageRequest) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // CronJobActiveJobs is an instrument used to record metric values conforming to // the "k8s.cronjob.active_jobs" semantic conventions. It represents the number // of actively running jobs for a cronjob. @@ -1097,7 +1356,7 @@ func (CronJobActiveJobs) Description() string { return "The number of actively running jobs for a cronjob" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric aligns with the `active` field of the // [K8s CronJobStatus]. @@ -1119,6 +1378,28 @@ func (m CronJobActiveJobs) Add(ctx context.Context, incr int64, attrs ...attribu m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric aligns with the `active` field of the +// [K8s CronJobStatus]. +// +// [K8s CronJobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#cronjobstatus-v1-batch +func (m CronJobActiveJobs) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // DaemonSetCurrentScheduledNodes is an instrument used to record metric values // conforming to the "k8s.daemonset.current_scheduled_nodes" semantic // conventions. It represents the number of nodes that are running at least 1 @@ -1171,7 +1452,7 @@ func (DaemonSetCurrentScheduledNodes) Description() string { return "Number of nodes that are running at least 1 daemon pod and are supposed to run the daemon pod" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric aligns with the `currentNumberScheduled` field of the // [K8s DaemonSetStatus]. @@ -1193,6 +1474,28 @@ func (m DaemonSetCurrentScheduledNodes) Add(ctx context.Context, incr int64, att m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric aligns with the `currentNumberScheduled` field of the +// [K8s DaemonSetStatus]. +// +// [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps +func (m DaemonSetCurrentScheduledNodes) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // DaemonSetDesiredScheduledNodes is an instrument used to record metric values // conforming to the "k8s.daemonset.desired_scheduled_nodes" semantic // conventions. It represents the number of nodes that should be running the @@ -1245,7 +1548,7 @@ func (DaemonSetDesiredScheduledNodes) Description() string { return "Number of nodes that should be running the daemon pod (including nodes currently running the daemon pod)" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric aligns with the `desiredNumberScheduled` field of the // [K8s DaemonSetStatus]. @@ -1267,6 +1570,28 @@ func (m DaemonSetDesiredScheduledNodes) Add(ctx context.Context, incr int64, att m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric aligns with the `desiredNumberScheduled` field of the +// [K8s DaemonSetStatus]. +// +// [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps +func (m DaemonSetDesiredScheduledNodes) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // DaemonSetMisscheduledNodes is an instrument used to record metric values // conforming to the "k8s.daemonset.misscheduled_nodes" semantic conventions. It // represents the number of nodes that are running the daemon pod, but are not @@ -1319,7 +1644,7 @@ func (DaemonSetMisscheduledNodes) Description() string { return "Number of nodes that are running the daemon pod, but are not supposed to run the daemon pod" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric aligns with the `numberMisscheduled` field of the // [K8s DaemonSetStatus]. @@ -1341,6 +1666,28 @@ func (m DaemonSetMisscheduledNodes) Add(ctx context.Context, incr int64, attrs . m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric aligns with the `numberMisscheduled` field of the +// [K8s DaemonSetStatus]. +// +// [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps +func (m DaemonSetMisscheduledNodes) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // DaemonSetReadyNodes is an instrument used to record metric values conforming // to the "k8s.daemonset.ready_nodes" semantic conventions. It represents the // number of nodes that should be running the daemon pod and have one or more of @@ -1392,7 +1739,7 @@ func (DaemonSetReadyNodes) Description() string { return "Number of nodes that should be running the daemon pod and have one or more of the daemon pod running and ready" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric aligns with the `numberReady` field of the // [K8s DaemonSetStatus]. @@ -1414,6 +1761,28 @@ func (m DaemonSetReadyNodes) Add(ctx context.Context, incr int64, attrs ...attri m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric aligns with the `numberReady` field of the +// [K8s DaemonSetStatus]. +// +// [K8s DaemonSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#daemonsetstatus-v1-apps +func (m DaemonSetReadyNodes) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // DeploymentAvailablePods is an instrument used to record metric values // conforming to the "k8s.deployment.available_pods" semantic conventions. It // represents the total number of available replica pods (ready for at least @@ -1465,7 +1834,7 @@ func (DeploymentAvailablePods) Description() string { return "Total number of available replica pods (ready for at least minReadySeconds) targeted by this deployment" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric aligns with the `availableReplicas` field of the // [K8s DeploymentStatus]. @@ -1487,6 +1856,28 @@ func (m DeploymentAvailablePods) Add(ctx context.Context, incr int64, attrs ...a m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric aligns with the `availableReplicas` field of the +// [K8s DeploymentStatus]. +// +// [K8s DeploymentStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#deploymentstatus-v1-apps +func (m DeploymentAvailablePods) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // DeploymentDesiredPods is an instrument used to record metric values conforming // to the "k8s.deployment.desired_pods" semantic conventions. It represents the // number of desired replica pods in this deployment. @@ -1537,7 +1928,7 @@ func (DeploymentDesiredPods) Description() string { return "Number of desired replica pods in this deployment" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric aligns with the `replicas` field of the // [K8s DeploymentSpec]. @@ -1559,6 +1950,28 @@ func (m DeploymentDesiredPods) Add(ctx context.Context, incr int64, attrs ...att m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric aligns with the `replicas` field of the +// [K8s DeploymentSpec]. +// +// [K8s DeploymentSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#deploymentspec-v1-apps +func (m DeploymentDesiredPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // HPACurrentPods is an instrument used to record metric values conforming to the // "k8s.hpa.current_pods" semantic conventions. It represents the current number // of replica pods managed by this horizontal pod autoscaler, as last seen by the @@ -1610,7 +2023,7 @@ func (HPACurrentPods) Description() string { return "Current number of replica pods managed by this horizontal pod autoscaler, as last seen by the autoscaler" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric aligns with the `currentReplicas` field of the // [K8s HorizontalPodAutoscalerStatus] @@ -1632,6 +2045,28 @@ func (m HPACurrentPods) Add(ctx context.Context, incr int64, attrs ...attribute. m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric aligns with the `currentReplicas` field of the +// [K8s HorizontalPodAutoscalerStatus] +// +// [K8s HorizontalPodAutoscalerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerstatus-v2-autoscaling +func (m HPACurrentPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // HPADesiredPods is an instrument used to record metric values conforming to the // "k8s.hpa.desired_pods" semantic conventions. It represents the desired number // of replica pods managed by this horizontal pod autoscaler, as last calculated @@ -1683,7 +2118,7 @@ func (HPADesiredPods) Description() string { return "Desired number of replica pods managed by this horizontal pod autoscaler, as last calculated by the autoscaler" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric aligns with the `desiredReplicas` field of the // [K8s HorizontalPodAutoscalerStatus] @@ -1705,6 +2140,28 @@ func (m HPADesiredPods) Add(ctx context.Context, incr int64, attrs ...attribute. m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric aligns with the `desiredReplicas` field of the +// [K8s HorizontalPodAutoscalerStatus] +// +// [K8s HorizontalPodAutoscalerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerstatus-v2-autoscaling +func (m HPADesiredPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // HPAMaxPods is an instrument used to record metric values conforming to the // "k8s.hpa.max_pods" semantic conventions. It represents the upper limit for the // number of replica pods to which the autoscaler can scale up. @@ -1755,7 +2212,7 @@ func (HPAMaxPods) Description() string { return "The upper limit for the number of replica pods to which the autoscaler can scale up" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric aligns with the `maxReplicas` field of the // [K8s HorizontalPodAutoscalerSpec] @@ -1777,6 +2234,28 @@ func (m HPAMaxPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyV m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric aligns with the `maxReplicas` field of the +// [K8s HorizontalPodAutoscalerSpec] +// +// [K8s HorizontalPodAutoscalerSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerspec-v2-autoscaling +func (m HPAMaxPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // HPAMetricTargetCPUAverageUtilization is an instrument used to record metric // values conforming to the "k8s.hpa.metric.target.cpu.average_utilization" // semantic conventions. It represents the target average utilization, in @@ -1829,7 +2308,7 @@ func (HPAMetricTargetCPUAverageUtilization) Description() string { return "Target average utilization, in percentage, for CPU resource in HPA config." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // All additional attrs passed are included in the recorded value. // @@ -1867,6 +2346,31 @@ func (m HPAMetricTargetCPUAverageUtilization) Record( m.Int64Gauge.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// This metric aligns with the `averageUtilization` field of the +// [K8s HPA MetricTarget]. +// If the type of the metric is [`ContainerResource`], +// the `k8s.container.name` attribute MUST be set to identify the specific +// container within the pod to which the metric applies. +// +// [K8s HPA MetricTarget]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#metrictarget-v2-autoscaling +// [`ContainerResource`]: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis +func (m HPAMetricTargetCPUAverageUtilization) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Gauge.Record(ctx, val, *o...) +} + // AttrContainerName returns an optional attribute for the "k8s.container.name" // semantic convention. It represents the name of the Container from Pod // specification, must be unique within a Pod. Container runtime usually uses @@ -1934,7 +2438,7 @@ func (HPAMetricTargetCPUAverageValue) Description() string { return "Target average value for CPU resource in HPA config." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // All additional attrs passed are included in the recorded value. // @@ -1972,6 +2476,31 @@ func (m HPAMetricTargetCPUAverageValue) Record( m.Int64Gauge.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// This metric aligns with the `averageValue` field of the +// [K8s HPA MetricTarget]. +// If the type of the metric is [`ContainerResource`], +// the `k8s.container.name` attribute MUST be set to identify the specific +// container within the pod to which the metric applies. +// +// [K8s HPA MetricTarget]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#metrictarget-v2-autoscaling +// [`ContainerResource`]: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis +func (m HPAMetricTargetCPUAverageValue) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Gauge.Record(ctx, val, *o...) +} + // AttrContainerName returns an optional attribute for the "k8s.container.name" // semantic convention. It represents the name of the Container from Pod // specification, must be unique within a Pod. Container runtime usually uses @@ -2037,7 +2566,7 @@ func (HPAMetricTargetCPUValue) Description() string { return "Target value for CPU resource in HPA config." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // All additional attrs passed are included in the recorded value. // @@ -2075,6 +2604,31 @@ func (m HPAMetricTargetCPUValue) Record( m.Int64Gauge.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// This metric aligns with the `value` field of the +// [K8s HPA MetricTarget]. +// If the type of the metric is [`ContainerResource`], +// the `k8s.container.name` attribute MUST be set to identify the specific +// container within the pod to which the metric applies. +// +// [K8s HPA MetricTarget]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#metrictarget-v2-autoscaling +// [`ContainerResource`]: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis +func (m HPAMetricTargetCPUValue) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Gauge.Record(ctx, val, *o...) +} + // AttrContainerName returns an optional attribute for the "k8s.container.name" // semantic convention. It represents the name of the Container from Pod // specification, must be unique within a Pod. Container runtime usually uses @@ -2140,7 +2694,7 @@ func (HPAMinPods) Description() string { return "The lower limit for the number of replica pods to which the autoscaler can scale down" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric aligns with the `minReplicas` field of the // [K8s HorizontalPodAutoscalerSpec] @@ -2162,6 +2716,28 @@ func (m HPAMinPods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyV m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric aligns with the `minReplicas` field of the +// [K8s HorizontalPodAutoscalerSpec] +// +// [K8s HorizontalPodAutoscalerSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#horizontalpodautoscalerspec-v2-autoscaling +func (m HPAMinPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // JobActivePods is an instrument used to record metric values conforming to the // "k8s.job.active_pods" semantic conventions. It represents the number of // pending and actively running pods for a job. @@ -2212,7 +2788,7 @@ func (JobActivePods) Description() string { return "The number of pending and actively running pods for a job" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric aligns with the `active` field of the // [K8s JobStatus]. @@ -2234,6 +2810,28 @@ func (m JobActivePods) Add(ctx context.Context, incr int64, attrs ...attribute.K m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric aligns with the `active` field of the +// [K8s JobStatus]. +// +// [K8s JobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch +func (m JobActivePods) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // JobDesiredSuccessfulPods is an instrument used to record metric values // conforming to the "k8s.job.desired_successful_pods" semantic conventions. It // represents the desired number of successfully finished pods the job should be @@ -2285,7 +2883,7 @@ func (JobDesiredSuccessfulPods) Description() string { return "The desired number of successfully finished pods the job should be run with" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric aligns with the `completions` field of the // [K8s JobSpec].. @@ -2307,6 +2905,28 @@ func (m JobDesiredSuccessfulPods) Add(ctx context.Context, incr int64, attrs ... m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric aligns with the `completions` field of the +// [K8s JobSpec].. +// +// [K8s JobSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobspec-v1-batch +func (m JobDesiredSuccessfulPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // JobFailedPods is an instrument used to record metric values conforming to the // "k8s.job.failed_pods" semantic conventions. It represents the number of pods // which reached phase Failed for a job. @@ -2357,7 +2977,7 @@ func (JobFailedPods) Description() string { return "The number of pods which reached phase Failed for a job" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric aligns with the `failed` field of the // [K8s JobStatus]. @@ -2379,6 +2999,28 @@ func (m JobFailedPods) Add(ctx context.Context, incr int64, attrs ...attribute.K m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric aligns with the `failed` field of the +// [K8s JobStatus]. +// +// [K8s JobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch +func (m JobFailedPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // JobMaxParallelPods is an instrument used to record metric values conforming to // the "k8s.job.max_parallel_pods" semantic conventions. It represents the max // desired number of pods the job should run at any given time. @@ -2429,7 +3071,7 @@ func (JobMaxParallelPods) Description() string { return "The max desired number of pods the job should run at any given time" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric aligns with the `parallelism` field of the // [K8s JobSpec]. @@ -2451,6 +3093,28 @@ func (m JobMaxParallelPods) Add(ctx context.Context, incr int64, attrs ...attrib m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric aligns with the `parallelism` field of the +// [K8s JobSpec]. +// +// [K8s JobSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobspec-v1-batch +func (m JobMaxParallelPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // JobSuccessfulPods is an instrument used to record metric values conforming to // the "k8s.job.successful_pods" semantic conventions. It represents the number // of pods which reached phase Succeeded for a job. @@ -2501,7 +3165,7 @@ func (JobSuccessfulPods) Description() string { return "The number of pods which reached phase Succeeded for a job" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric aligns with the `succeeded` field of the // [K8s JobStatus]. @@ -2523,6 +3187,28 @@ func (m JobSuccessfulPods) Add(ctx context.Context, incr int64, attrs ...attribu m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric aligns with the `succeeded` field of the +// [K8s JobStatus]. +// +// [K8s JobStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#jobstatus-v1-batch +func (m JobSuccessfulPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // NamespacePhase is an instrument used to record metric values conforming to the // "k8s.namespace.phase" semantic conventions. It represents the describes number // of K8s namespaces that are currently in a given phase. @@ -2573,7 +3259,7 @@ func (NamespacePhase) Description() string { return "Describes number of K8s namespaces that are currently in a given phase." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The namespacePhase is the the phase of the K8s namespace. func (m NamespacePhase) Add( @@ -2606,6 +3292,23 @@ func (m NamespacePhase) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m NamespacePhase) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // NodeAllocatableCPU is an instrument used to record metric values conforming to // the "k8s.node.allocatable.cpu" semantic conventions. It represents the amount // of cpu allocatable on the node. @@ -2656,7 +3359,7 @@ func (NodeAllocatableCPU) Description() string { return "Amount of cpu allocatable on the node" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. func (m NodeAllocatableCPU) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { if len(attrs) == 0 { m.Int64UpDownCounter.Add(ctx, incr) @@ -2673,6 +3376,23 @@ func (m NodeAllocatableCPU) Add(ctx context.Context, incr int64, attrs ...attrib m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m NodeAllocatableCPU) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // NodeAllocatableEphemeralStorage is an instrument used to record metric values // conforming to the "k8s.node.allocatable.ephemeral_storage" semantic // conventions. It represents the amount of ephemeral-storage allocatable on the @@ -2725,7 +3445,7 @@ func (NodeAllocatableEphemeralStorage) Description() string { return "Amount of ephemeral-storage allocatable on the node" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. func (m NodeAllocatableEphemeralStorage) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { if len(attrs) == 0 { m.Int64UpDownCounter.Add(ctx, incr) @@ -2742,6 +3462,23 @@ func (m NodeAllocatableEphemeralStorage) Add(ctx context.Context, incr int64, at m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m NodeAllocatableEphemeralStorage) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // NodeAllocatableMemory is an instrument used to record metric values conforming // to the "k8s.node.allocatable.memory" semantic conventions. It represents the // amount of memory allocatable on the node. @@ -2792,7 +3529,7 @@ func (NodeAllocatableMemory) Description() string { return "Amount of memory allocatable on the node" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. func (m NodeAllocatableMemory) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { if len(attrs) == 0 { m.Int64UpDownCounter.Add(ctx, incr) @@ -2809,6 +3546,23 @@ func (m NodeAllocatableMemory) Add(ctx context.Context, incr int64, attrs ...att m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m NodeAllocatableMemory) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // NodeAllocatablePods is an instrument used to record metric values conforming // to the "k8s.node.allocatable.pods" semantic conventions. It represents the // amount of pods allocatable on the node. @@ -2859,7 +3613,7 @@ func (NodeAllocatablePods) Description() string { return "Amount of pods allocatable on the node" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. func (m NodeAllocatablePods) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { if len(attrs) == 0 { m.Int64UpDownCounter.Add(ctx, incr) @@ -2876,6 +3630,23 @@ func (m NodeAllocatablePods) Add(ctx context.Context, incr int64, attrs ...attri m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m NodeAllocatablePods) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // NodeConditionStatus is an instrument used to record metric values conforming // to the "k8s.node.condition.status" semantic conventions. It represents the // describes the condition of a particular Node. @@ -2926,7 +3697,7 @@ func (NodeConditionStatus) Description() string { return "Describes the condition of a particular Node." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The nodeConditionStatus is the the status of the condition, one of True, // False, Unknown. @@ -2968,6 +3739,27 @@ func (m NodeConditionStatus) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// All possible node condition pairs (type and status) will be reported at each +// time interval to avoid missing metrics. Condition pairs corresponding to the +// current conditions' statuses will be non-zero. +func (m NodeConditionStatus) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // NodeCPUTime is an instrument used to record metric values conforming to the // "k8s.node.cpu.time" semantic conventions. It represents the total CPU time // consumed. @@ -3018,7 +3810,7 @@ func (NodeCPUTime) Description() string { return "Total CPU time consumed" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // Total CPU time consumed by the specific Node on all available CPU cores func (m NodeCPUTime) Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue) { @@ -3037,6 +3829,25 @@ func (m NodeCPUTime) Add(ctx context.Context, incr float64, attrs ...attribute.K m.Float64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// Total CPU time consumed by the specific Node on all available CPU cores +func (m NodeCPUTime) AddSet(ctx context.Context, incr float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Counter.Add(ctx, incr, *o...) +} + // NodeCPUUsage is an instrument used to record metric values conforming to the // "k8s.node.cpu.usage" semantic conventions. It represents the node's CPU usage, // measured in cpus. Range from 0 to the number of allocatable CPUs. @@ -3087,7 +3898,7 @@ func (NodeCPUUsage) Description() string { return "Node's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // CPU usage of the specific Node on all available CPU cores, averaged over the // sample window @@ -3107,6 +3918,25 @@ func (m NodeCPUUsage) Record(ctx context.Context, val int64, attrs ...attribute. m.Int64Gauge.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// CPU usage of the specific Node on all available CPU cores, averaged over the +// sample window +func (m NodeCPUUsage) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Gauge.Record(ctx, val, *o...) +} + // NodeMemoryUsage is an instrument used to record metric values conforming to // the "k8s.node.memory.usage" semantic conventions. It represents the memory // usage of the Node. @@ -3157,7 +3987,7 @@ func (NodeMemoryUsage) Description() string { return "Memory usage of the Node" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // Total memory usage of the Node func (m NodeMemoryUsage) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) { @@ -3176,6 +4006,24 @@ func (m NodeMemoryUsage) Record(ctx context.Context, val int64, attrs ...attribu m.Int64Gauge.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// Total memory usage of the Node +func (m NodeMemoryUsage) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Gauge.Record(ctx, val, *o...) +} + // NodeNetworkErrors is an instrument used to record metric values conforming to // the "k8s.node.network.errors" semantic conventions. It represents the node // network errors. @@ -3226,7 +4074,7 @@ func (NodeNetworkErrors) Description() string { return "Node network errors" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. func (m NodeNetworkErrors) Add( @@ -3255,6 +4103,23 @@ func (m NodeNetworkErrors) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m NodeNetworkErrors) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrNetworkInterfaceName returns an optional attribute for the // "network.interface.name" semantic convention. It represents the network // interface name. @@ -3319,7 +4184,7 @@ func (NodeNetworkIO) Description() string { return "Network bytes for the Node" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. func (m NodeNetworkIO) Add( @@ -3348,6 +4213,23 @@ func (m NodeNetworkIO) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m NodeNetworkIO) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrNetworkInterfaceName returns an optional attribute for the // "network.interface.name" semantic convention. It represents the network // interface name. @@ -3412,7 +4294,7 @@ func (NodeUptime) Description() string { return "The time the Node has been running" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // Instrumentations SHOULD use a gauge with type `double` and measure uptime in // seconds as a floating point number with the highest precision available. @@ -3433,6 +4315,26 @@ func (m NodeUptime) Record(ctx context.Context, val float64, attrs ...attribute. m.Float64Gauge.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// Instrumentations SHOULD use a gauge with type `double` and measure uptime in +// seconds as a floating point number with the highest precision available. +// The actual accuracy would depend on the instrumentation and operating system. +func (m NodeUptime) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Gauge.Record(ctx, val, *o...) +} + // PodCPUTime is an instrument used to record metric values conforming to the // "k8s.pod.cpu.time" semantic conventions. It represents the total CPU time // consumed. @@ -3483,7 +4385,7 @@ func (PodCPUTime) Description() string { return "Total CPU time consumed" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // Total CPU time consumed by the specific Pod on all available CPU cores func (m PodCPUTime) Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue) { @@ -3502,6 +4404,25 @@ func (m PodCPUTime) Add(ctx context.Context, incr float64, attrs ...attribute.Ke m.Float64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// Total CPU time consumed by the specific Pod on all available CPU cores +func (m PodCPUTime) AddSet(ctx context.Context, incr float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Counter.Add(ctx, incr, *o...) +} + // PodCPUUsage is an instrument used to record metric values conforming to the // "k8s.pod.cpu.usage" semantic conventions. It represents the pod's CPU usage, // measured in cpus. Range from 0 to the number of allocatable CPUs. @@ -3552,7 +4473,7 @@ func (PodCPUUsage) Description() string { return "Pod's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // CPU usage of the specific Pod on all available CPU cores, averaged over the // sample window @@ -3572,6 +4493,25 @@ func (m PodCPUUsage) Record(ctx context.Context, val int64, attrs ...attribute.K m.Int64Gauge.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// CPU usage of the specific Pod on all available CPU cores, averaged over the +// sample window +func (m PodCPUUsage) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Gauge.Record(ctx, val, *o...) +} + // PodMemoryUsage is an instrument used to record metric values conforming to the // "k8s.pod.memory.usage" semantic conventions. It represents the memory usage of // the Pod. @@ -3622,7 +4562,7 @@ func (PodMemoryUsage) Description() string { return "Memory usage of the Pod" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // Total memory usage of the Pod func (m PodMemoryUsage) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) { @@ -3641,6 +4581,24 @@ func (m PodMemoryUsage) Record(ctx context.Context, val int64, attrs ...attribut m.Int64Gauge.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// Total memory usage of the Pod +func (m PodMemoryUsage) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Gauge.Record(ctx, val, *o...) +} + // PodNetworkErrors is an instrument used to record metric values conforming to // the "k8s.pod.network.errors" semantic conventions. It represents the pod // network errors. @@ -3691,7 +4649,7 @@ func (PodNetworkErrors) Description() string { return "Pod network errors" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. func (m PodNetworkErrors) Add( @@ -3720,6 +4678,23 @@ func (m PodNetworkErrors) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m PodNetworkErrors) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrNetworkInterfaceName returns an optional attribute for the // "network.interface.name" semantic convention. It represents the network // interface name. @@ -3784,7 +4759,7 @@ func (PodNetworkIO) Description() string { return "Network bytes for the Pod" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. func (m PodNetworkIO) Add( @@ -3813,6 +4788,23 @@ func (m PodNetworkIO) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m PodNetworkIO) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrNetworkInterfaceName returns an optional attribute for the // "network.interface.name" semantic convention. It represents the network // interface name. @@ -3877,7 +4869,7 @@ func (PodUptime) Description() string { return "The time the Pod has been running" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // Instrumentations SHOULD use a gauge with type `double` and measure uptime in // seconds as a floating point number with the highest precision available. @@ -3898,6 +4890,26 @@ func (m PodUptime) Record(ctx context.Context, val float64, attrs ...attribute.K m.Float64Gauge.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// Instrumentations SHOULD use a gauge with type `double` and measure uptime in +// seconds as a floating point number with the highest precision available. +// The actual accuracy would depend on the instrumentation and operating system. +func (m PodUptime) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Gauge.Record(ctx, val, *o...) +} + // ReplicaSetAvailablePods is an instrument used to record metric values // conforming to the "k8s.replicaset.available_pods" semantic conventions. It // represents the total number of available replica pods (ready for at least @@ -3949,7 +4961,7 @@ func (ReplicaSetAvailablePods) Description() string { return "Total number of available replica pods (ready for at least minReadySeconds) targeted by this replicaset" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric aligns with the `availableReplicas` field of the // [K8s ReplicaSetStatus]. @@ -3971,6 +4983,28 @@ func (m ReplicaSetAvailablePods) Add(ctx context.Context, incr int64, attrs ...a m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric aligns with the `availableReplicas` field of the +// [K8s ReplicaSetStatus]. +// +// [K8s ReplicaSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicasetstatus-v1-apps +func (m ReplicaSetAvailablePods) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ReplicaSetDesiredPods is an instrument used to record metric values conforming // to the "k8s.replicaset.desired_pods" semantic conventions. It represents the // number of desired replica pods in this replicaset. @@ -4021,7 +5055,7 @@ func (ReplicaSetDesiredPods) Description() string { return "Number of desired replica pods in this replicaset" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric aligns with the `replicas` field of the // [K8s ReplicaSetSpec]. @@ -4043,6 +5077,28 @@ func (m ReplicaSetDesiredPods) Add(ctx context.Context, incr int64, attrs ...att m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric aligns with the `replicas` field of the +// [K8s ReplicaSetSpec]. +// +// [K8s ReplicaSetSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicasetspec-v1-apps +func (m ReplicaSetDesiredPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ReplicationControllerAvailablePods is an instrument used to record metric // values conforming to the "k8s.replicationcontroller.available_pods" semantic // conventions. It represents the total number of available replica pods (ready @@ -4095,7 +5151,7 @@ func (ReplicationControllerAvailablePods) Description() string { return "Total number of available replica pods (ready for at least minReadySeconds) targeted by this replication controller" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric aligns with the `availableReplicas` field of the // [K8s ReplicationControllerStatus] @@ -4117,6 +5173,28 @@ func (m ReplicationControllerAvailablePods) Add(ctx context.Context, incr int64, m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric aligns with the `availableReplicas` field of the +// [K8s ReplicationControllerStatus] +// +// [K8s ReplicationControllerStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicationcontrollerstatus-v1-core +func (m ReplicationControllerAvailablePods) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ReplicationControllerDesiredPods is an instrument used to record metric values // conforming to the "k8s.replicationcontroller.desired_pods" semantic // conventions. It represents the number of desired replica pods in this @@ -4169,7 +5247,7 @@ func (ReplicationControllerDesiredPods) Description() string { return "Number of desired replica pods in this replication controller" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric aligns with the `replicas` field of the // [K8s ReplicationControllerSpec] @@ -4191,6 +5269,28 @@ func (m ReplicationControllerDesiredPods) Add(ctx context.Context, incr int64, a m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric aligns with the `replicas` field of the +// [K8s ReplicationControllerSpec] +// +// [K8s ReplicationControllerSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#replicationcontrollerspec-v1-core +func (m ReplicationControllerDesiredPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ResourceQuotaCPULimitHard is an instrument used to record metric values // conforming to the "k8s.resourcequota.cpu.limit.hard" semantic conventions. It // represents the CPU limits in a specific namespace. @@ -4244,7 +5344,7 @@ func (ResourceQuotaCPULimitHard) Description() string { return "The CPU limits in a specific namespace. The value represents the configured quota limit of the resource in the namespace." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric is retrieved from the `hard` field of the // [K8s ResourceQuotaStatus]. @@ -4266,6 +5366,28 @@ func (m ResourceQuotaCPULimitHard) Add(ctx context.Context, incr int64, attrs .. m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric is retrieved from the `hard` field of the +// [K8s ResourceQuotaStatus]. +// +// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core +func (m ResourceQuotaCPULimitHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ResourceQuotaCPULimitUsed is an instrument used to record metric values // conforming to the "k8s.resourcequota.cpu.limit.used" semantic conventions. It // represents the CPU limits in a specific namespace. @@ -4319,7 +5441,7 @@ func (ResourceQuotaCPULimitUsed) Description() string { return "The CPU limits in a specific namespace. The value represents the current observed total usage of the resource in the namespace." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric is retrieved from the `used` field of the // [K8s ResourceQuotaStatus]. @@ -4341,6 +5463,28 @@ func (m ResourceQuotaCPULimitUsed) Add(ctx context.Context, incr int64, attrs .. m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric is retrieved from the `used` field of the +// [K8s ResourceQuotaStatus]. +// +// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core +func (m ResourceQuotaCPULimitUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ResourceQuotaCPURequestHard is an instrument used to record metric values // conforming to the "k8s.resourcequota.cpu.request.hard" semantic conventions. // It represents the CPU requests in a specific namespace. @@ -4394,7 +5538,7 @@ func (ResourceQuotaCPURequestHard) Description() string { return "The CPU requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric is retrieved from the `hard` field of the // [K8s ResourceQuotaStatus]. @@ -4416,6 +5560,28 @@ func (m ResourceQuotaCPURequestHard) Add(ctx context.Context, incr int64, attrs m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric is retrieved from the `hard` field of the +// [K8s ResourceQuotaStatus]. +// +// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core +func (m ResourceQuotaCPURequestHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ResourceQuotaCPURequestUsed is an instrument used to record metric values // conforming to the "k8s.resourcequota.cpu.request.used" semantic conventions. // It represents the CPU requests in a specific namespace. @@ -4469,7 +5635,7 @@ func (ResourceQuotaCPURequestUsed) Description() string { return "The CPU requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric is retrieved from the `used` field of the // [K8s ResourceQuotaStatus]. @@ -4491,6 +5657,28 @@ func (m ResourceQuotaCPURequestUsed) Add(ctx context.Context, incr int64, attrs m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric is retrieved from the `used` field of the +// [K8s ResourceQuotaStatus]. +// +// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core +func (m ResourceQuotaCPURequestUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ResourceQuotaEphemeralStorageLimitHard is an instrument used to record metric // values conforming to the "k8s.resourcequota.ephemeral_storage.limit.hard" // semantic conventions. It represents the sum of local ephemeral storage limits @@ -4545,7 +5733,7 @@ func (ResourceQuotaEphemeralStorageLimitHard) Description() string { return "The sum of local ephemeral storage limits in the namespace. The value represents the configured quota limit of the resource in the namespace." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric is retrieved from the `hard` field of the // [K8s ResourceQuotaStatus]. @@ -4567,6 +5755,28 @@ func (m ResourceQuotaEphemeralStorageLimitHard) Add(ctx context.Context, incr in m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric is retrieved from the `hard` field of the +// [K8s ResourceQuotaStatus]. +// +// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core +func (m ResourceQuotaEphemeralStorageLimitHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ResourceQuotaEphemeralStorageLimitUsed is an instrument used to record metric // values conforming to the "k8s.resourcequota.ephemeral_storage.limit.used" // semantic conventions. It represents the sum of local ephemeral storage limits @@ -4621,7 +5831,7 @@ func (ResourceQuotaEphemeralStorageLimitUsed) Description() string { return "The sum of local ephemeral storage limits in the namespace. The value represents the current observed total usage of the resource in the namespace." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric is retrieved from the `used` field of the // [K8s ResourceQuotaStatus]. @@ -4643,6 +5853,28 @@ func (m ResourceQuotaEphemeralStorageLimitUsed) Add(ctx context.Context, incr in m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric is retrieved from the `used` field of the +// [K8s ResourceQuotaStatus]. +// +// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core +func (m ResourceQuotaEphemeralStorageLimitUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ResourceQuotaEphemeralStorageRequestHard is an instrument used to record // metric values conforming to the // "k8s.resourcequota.ephemeral_storage.request.hard" semantic conventions. It @@ -4697,7 +5929,7 @@ func (ResourceQuotaEphemeralStorageRequestHard) Description() string { return "The sum of local ephemeral storage requests in the namespace. The value represents the configured quota limit of the resource in the namespace." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric is retrieved from the `hard` field of the // [K8s ResourceQuotaStatus]. @@ -4719,6 +5951,28 @@ func (m ResourceQuotaEphemeralStorageRequestHard) Add(ctx context.Context, incr m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric is retrieved from the `hard` field of the +// [K8s ResourceQuotaStatus]. +// +// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core +func (m ResourceQuotaEphemeralStorageRequestHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ResourceQuotaEphemeralStorageRequestUsed is an instrument used to record // metric values conforming to the // "k8s.resourcequota.ephemeral_storage.request.used" semantic conventions. It @@ -4773,7 +6027,7 @@ func (ResourceQuotaEphemeralStorageRequestUsed) Description() string { return "The sum of local ephemeral storage requests in the namespace. The value represents the current observed total usage of the resource in the namespace." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric is retrieved from the `used` field of the // [K8s ResourceQuotaStatus]. @@ -4795,6 +6049,28 @@ func (m ResourceQuotaEphemeralStorageRequestUsed) Add(ctx context.Context, incr m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric is retrieved from the `used` field of the +// [K8s ResourceQuotaStatus]. +// +// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core +func (m ResourceQuotaEphemeralStorageRequestUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ResourceQuotaHugepageCountRequestHard is an instrument used to record metric // values conforming to the "k8s.resourcequota.hugepage_count.request.hard" // semantic conventions. It represents the huge page requests in a specific @@ -4849,7 +6125,7 @@ func (ResourceQuotaHugepageCountRequestHard) Description() string { return "The huge page requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The hugepageSize is the the size (identifier) of the K8s huge page. // @@ -4887,6 +6163,28 @@ func (m ResourceQuotaHugepageCountRequestHard) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric is retrieved from the `hard` field of the +// [K8s ResourceQuotaStatus]. +// +// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core +func (m ResourceQuotaHugepageCountRequestHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ResourceQuotaHugepageCountRequestUsed is an instrument used to record metric // values conforming to the "k8s.resourcequota.hugepage_count.request.used" // semantic conventions. It represents the huge page requests in a specific @@ -4941,7 +6239,7 @@ func (ResourceQuotaHugepageCountRequestUsed) Description() string { return "The huge page requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The hugepageSize is the the size (identifier) of the K8s huge page. // @@ -4979,6 +6277,28 @@ func (m ResourceQuotaHugepageCountRequestUsed) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric is retrieved from the `used` field of the +// [K8s ResourceQuotaStatus]. +// +// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core +func (m ResourceQuotaHugepageCountRequestUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ResourceQuotaMemoryLimitHard is an instrument used to record metric values // conforming to the "k8s.resourcequota.memory.limit.hard" semantic conventions. // It represents the memory limits in a specific namespace. @@ -5032,7 +6352,7 @@ func (ResourceQuotaMemoryLimitHard) Description() string { return "The memory limits in a specific namespace. The value represents the configured quota limit of the resource in the namespace." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric is retrieved from the `hard` field of the // [K8s ResourceQuotaStatus]. @@ -5054,6 +6374,28 @@ func (m ResourceQuotaMemoryLimitHard) Add(ctx context.Context, incr int64, attrs m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric is retrieved from the `hard` field of the +// [K8s ResourceQuotaStatus]. +// +// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core +func (m ResourceQuotaMemoryLimitHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ResourceQuotaMemoryLimitUsed is an instrument used to record metric values // conforming to the "k8s.resourcequota.memory.limit.used" semantic conventions. // It represents the memory limits in a specific namespace. @@ -5107,7 +6449,7 @@ func (ResourceQuotaMemoryLimitUsed) Description() string { return "The memory limits in a specific namespace. The value represents the current observed total usage of the resource in the namespace." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric is retrieved from the `used` field of the // [K8s ResourceQuotaStatus]. @@ -5129,6 +6471,28 @@ func (m ResourceQuotaMemoryLimitUsed) Add(ctx context.Context, incr int64, attrs m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric is retrieved from the `used` field of the +// [K8s ResourceQuotaStatus]. +// +// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core +func (m ResourceQuotaMemoryLimitUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ResourceQuotaMemoryRequestHard is an instrument used to record metric values // conforming to the "k8s.resourcequota.memory.request.hard" semantic // conventions. It represents the memory requests in a specific namespace. @@ -5182,7 +6546,7 @@ func (ResourceQuotaMemoryRequestHard) Description() string { return "The memory requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric is retrieved from the `hard` field of the // [K8s ResourceQuotaStatus]. @@ -5204,6 +6568,28 @@ func (m ResourceQuotaMemoryRequestHard) Add(ctx context.Context, incr int64, att m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric is retrieved from the `hard` field of the +// [K8s ResourceQuotaStatus]. +// +// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core +func (m ResourceQuotaMemoryRequestHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ResourceQuotaMemoryRequestUsed is an instrument used to record metric values // conforming to the "k8s.resourcequota.memory.request.used" semantic // conventions. It represents the memory requests in a specific namespace. @@ -5257,7 +6643,7 @@ func (ResourceQuotaMemoryRequestUsed) Description() string { return "The memory requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric is retrieved from the `used` field of the // [K8s ResourceQuotaStatus]. @@ -5279,6 +6665,28 @@ func (m ResourceQuotaMemoryRequestUsed) Add(ctx context.Context, incr int64, att m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric is retrieved from the `used` field of the +// [K8s ResourceQuotaStatus]. +// +// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core +func (m ResourceQuotaMemoryRequestUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ResourceQuotaObjectCountHard is an instrument used to record metric values // conforming to the "k8s.resourcequota.object_count.hard" semantic conventions. // It represents the object count limits in a specific namespace. @@ -5332,7 +6740,7 @@ func (ResourceQuotaObjectCountHard) Description() string { return "The object count limits in a specific namespace. The value represents the configured quota limit of the resource in the namespace." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The resourcequotaResourceName is the the name of the K8s resource a resource // quota defines. @@ -5371,6 +6779,28 @@ func (m ResourceQuotaObjectCountHard) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric is retrieved from the `hard` field of the +// [K8s ResourceQuotaStatus]. +// +// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core +func (m ResourceQuotaObjectCountHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ResourceQuotaObjectCountUsed is an instrument used to record metric values // conforming to the "k8s.resourcequota.object_count.used" semantic conventions. // It represents the object count limits in a specific namespace. @@ -5424,7 +6854,7 @@ func (ResourceQuotaObjectCountUsed) Description() string { return "The object count limits in a specific namespace. The value represents the current observed total usage of the resource in the namespace." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The resourcequotaResourceName is the the name of the K8s resource a resource // quota defines. @@ -5463,6 +6893,28 @@ func (m ResourceQuotaObjectCountUsed) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric is retrieved from the `used` field of the +// [K8s ResourceQuotaStatus]. +// +// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core +func (m ResourceQuotaObjectCountUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // ResourceQuotaPersistentvolumeclaimCountHard is an instrument used to record // metric values conforming to the // "k8s.resourcequota.persistentvolumeclaim_count.hard" semantic conventions. It @@ -5518,7 +6970,7 @@ func (ResourceQuotaPersistentvolumeclaimCountHard) Description() string { return "The total number of PersistentVolumeClaims that can exist in the namespace. The value represents the configured quota limit of the resource in the namespace." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. // @@ -5556,6 +7008,32 @@ func (m ResourceQuotaPersistentvolumeclaimCountHard) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric is retrieved from the `hard` field of the +// [K8s ResourceQuotaStatus]. +// +// The `k8s.storageclass.name` should be required when a resource quota is +// defined for a specific +// storage class. +// +// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core +func (m ResourceQuotaPersistentvolumeclaimCountHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // AttrStorageclassName returns an optional attribute for the // "k8s.storageclass.name" semantic convention. It represents the name of K8s // [StorageClass] object. @@ -5620,7 +7098,7 @@ func (ResourceQuotaPersistentvolumeclaimCountUsed) Description() string { return "The total number of PersistentVolumeClaims that can exist in the namespace. The value represents the current observed total usage of the resource in the namespace." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. // @@ -5658,6 +7136,32 @@ func (m ResourceQuotaPersistentvolumeclaimCountUsed) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric is retrieved from the `used` field of the +// [K8s ResourceQuotaStatus]. +// +// The `k8s.storageclass.name` should be required when a resource quota is +// defined for a specific +// storage class. +// +// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core +func (m ResourceQuotaPersistentvolumeclaimCountUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // AttrStorageclassName returns an optional attribute for the // "k8s.storageclass.name" semantic convention. It represents the name of K8s // [StorageClass] object. @@ -5720,7 +7224,7 @@ func (ResourceQuotaStorageRequestHard) Description() string { return "The storage requests in a specific namespace. The value represents the configured quota limit of the resource in the namespace." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. // @@ -5758,6 +7262,32 @@ func (m ResourceQuotaStorageRequestHard) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric is retrieved from the `hard` field of the +// [K8s ResourceQuotaStatus]. +// +// The `k8s.storageclass.name` should be required when a resource quota is +// defined for a specific +// storage class. +// +// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core +func (m ResourceQuotaStorageRequestHard) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // AttrStorageclassName returns an optional attribute for the // "k8s.storageclass.name" semantic convention. It represents the name of K8s // [StorageClass] object. @@ -5820,7 +7350,7 @@ func (ResourceQuotaStorageRequestUsed) Description() string { return "The storage requests in a specific namespace. The value represents the current observed total usage of the resource in the namespace." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. // @@ -5858,6 +7388,32 @@ func (m ResourceQuotaStorageRequestUsed) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric is retrieved from the `used` field of the +// [K8s ResourceQuotaStatus]. +// +// The `k8s.storageclass.name` should be required when a resource quota is +// defined for a specific +// storage class. +// +// [K8s ResourceQuotaStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core +func (m ResourceQuotaStorageRequestUsed) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // AttrStorageclassName returns an optional attribute for the // "k8s.storageclass.name" semantic convention. It represents the name of K8s // [StorageClass] object. @@ -5918,7 +7474,7 @@ func (StatefulSetCurrentPods) Description() string { return "The number of replica pods created by the statefulset controller from the statefulset version indicated by currentRevision" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric aligns with the `currentReplicas` field of the // [K8s StatefulSetStatus]. @@ -5940,6 +7496,28 @@ func (m StatefulSetCurrentPods) Add(ctx context.Context, incr int64, attrs ...at m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric aligns with the `currentReplicas` field of the +// [K8s StatefulSetStatus]. +// +// [K8s StatefulSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetstatus-v1-apps +func (m StatefulSetCurrentPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // StatefulSetDesiredPods is an instrument used to record metric values // conforming to the "k8s.statefulset.desired_pods" semantic conventions. It // represents the number of desired replica pods in this statefulset. @@ -5990,7 +7568,7 @@ func (StatefulSetDesiredPods) Description() string { return "Number of desired replica pods in this statefulset" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric aligns with the `replicas` field of the // [K8s StatefulSetSpec]. @@ -6012,6 +7590,28 @@ func (m StatefulSetDesiredPods) Add(ctx context.Context, incr int64, attrs ...at m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric aligns with the `replicas` field of the +// [K8s StatefulSetSpec]. +// +// [K8s StatefulSetSpec]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetspec-v1-apps +func (m StatefulSetDesiredPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // StatefulSetReadyPods is an instrument used to record metric values conforming // to the "k8s.statefulset.ready_pods" semantic conventions. It represents the // number of replica pods created for this statefulset with a Ready Condition. @@ -6062,7 +7662,7 @@ func (StatefulSetReadyPods) Description() string { return "The number of replica pods created for this statefulset with a Ready Condition" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric aligns with the `readyReplicas` field of the // [K8s StatefulSetStatus]. @@ -6084,6 +7684,28 @@ func (m StatefulSetReadyPods) Add(ctx context.Context, incr int64, attrs ...attr m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric aligns with the `readyReplicas` field of the +// [K8s StatefulSetStatus]. +// +// [K8s StatefulSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetstatus-v1-apps +func (m StatefulSetReadyPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // StatefulSetUpdatedPods is an instrument used to record metric values // conforming to the "k8s.statefulset.updated_pods" semantic conventions. It // represents the number of replica pods created by the statefulset controller @@ -6135,7 +7757,7 @@ func (StatefulSetUpdatedPods) Description() string { return "Number of replica pods created by the statefulset controller from the statefulset version indicated by updateRevision" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This metric aligns with the `updatedReplicas` field of the // [K8s StatefulSetStatus]. @@ -6155,4 +7777,26 @@ func (m StatefulSetUpdatedPods) Add(ctx context.Context, incr int64, attrs ...at *o = append(*o, metric.WithAttributes(attrs...)) m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + +// AddSet adds incr to the existing count for set. +// +// This metric aligns with the `updatedReplicas` field of the +// [K8s StatefulSetStatus]. +// +// [K8s StatefulSetStatus]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#statefulsetstatus-v1-apps +func (m StatefulSetUpdatedPods) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) } \ No newline at end of file diff --git a/semconv/v1.36.0/messagingconv/metric.go b/semconv/v1.36.0/messagingconv/metric.go index 131827839..5f1837fe6 100644 --- a/semconv/v1.36.0/messagingconv/metric.go +++ b/semconv/v1.36.0/messagingconv/metric.go @@ -136,7 +136,7 @@ func (ClientConsumedMessages) Description() string { return "Number of messages that were delivered to the application." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The operationName is the the system-specific name of the messaging operation. // @@ -183,6 +183,30 @@ func (m ClientConsumedMessages) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// Records the number of messages pulled from the broker or number of messages +// dispatched to the application in push-based scenarios. +// The metric SHOULD be reported once per message delivery. For example, if +// receiving and processing operations are both instrumented for a single message +// delivery, this counter is incremented when the message is received and not +// reported when it is processed. +func (m ClientConsumedMessages) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrErrorType returns an optional attribute for the "error.type" semantic // convention. It represents the describes a class of error the operation ended // with. @@ -290,7 +314,7 @@ func (ClientOperationDuration) Description() string { return "Duration of messaging operation initiated by a producer or consumer client." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The operationName is the the system-specific name of the messaging operation. // @@ -333,6 +357,25 @@ func (m ClientOperationDuration) Record( m.Float64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// This metric SHOULD NOT be used to report processing duration - processing +// duration is reported in `messaging.process.duration` metric. +func (m ClientOperationDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Histogram.Record(ctx, val, *o...) +} + // AttrErrorType returns an optional attribute for the "error.type" semantic // convention. It represents the describes a class of error the operation ended // with. @@ -446,7 +489,7 @@ func (ClientSentMessages) Description() string { return "Number of messages producer attempted to send to the broker." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The operationName is the the system-specific name of the messaging operation. // @@ -489,6 +532,26 @@ func (m ClientSentMessages) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This metric MUST NOT count messages that were created but haven't yet been +// sent. +func (m ClientSentMessages) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrErrorType returns an optional attribute for the "error.type" semantic // convention. It represents the describes a class of error the operation ended // with. @@ -581,7 +644,7 @@ func (ProcessDuration) Description() string { return "Duration of processing operation." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The operationName is the the system-specific name of the messaging operation. // @@ -624,6 +687,25 @@ func (m ProcessDuration) Record( m.Float64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// This metric MUST be reported for operations with `messaging.operation.type` +// that matches `process`. +func (m ProcessDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Histogram.Record(ctx, val, *o...) +} + // AttrErrorType returns an optional attribute for the "error.type" semantic // convention. It represents the describes a class of error the operation ended // with. diff --git a/semconv/v1.36.0/otelconv/metric.go b/semconv/v1.36.0/otelconv/metric.go index 803b725ef..f5dd8fe80 100644 --- a/semconv/v1.36.0/otelconv/metric.go +++ b/semconv/v1.36.0/otelconv/metric.go @@ -215,7 +215,7 @@ func (SDKExporterLogExported) Description() string { return "The number of log records for which the export has finished, either successful or failed" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. // @@ -252,6 +252,31 @@ func (m SDKExporterLogExported) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// For successful exports, `error.type` MUST NOT be set. For failed exports, +// `error.type` MUST contain the failure cause. +// For exporters with partial success semantics (e.g. OTLP with +// `rejected_log_records`), rejected log records MUST count as failed and only +// non-rejected log records count as success. +// If no rejection reason is available, `rejected` SHOULD be used as value for +// `error.type`. +func (m SDKExporterLogExported) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrErrorType returns an optional attribute for the "error.type" semantic // convention. It represents the describes a class of error the operation ended // with. @@ -337,7 +362,7 @@ func (SDKExporterLogInflight) Description() string { return "The number of log records which were passed to the exporter, but that have not been exported yet (neither successful, nor failed)" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. // @@ -369,6 +394,26 @@ func (m SDKExporterLogInflight) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// For successful exports, `error.type` MUST NOT be set. For failed exports, +// `error.type` MUST contain the failure cause. +func (m SDKExporterLogInflight) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // AttrComponentName returns an optional attribute for the "otel.component.name" // semantic convention. It represents a name uniquely identifying the instance of // the OpenTelemetry component within its containing SDK instance. @@ -448,7 +493,7 @@ func (SDKExporterMetricDataPointExported) Description() string { return "The number of metric data points for which the export has finished, either successful or failed" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. // @@ -485,6 +530,31 @@ func (m SDKExporterMetricDataPointExported) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// For successful exports, `error.type` MUST NOT be set. For failed exports, +// `error.type` MUST contain the failure cause. +// For exporters with partial success semantics (e.g. OTLP with +// `rejected_data_points`), rejected data points MUST count as failed and only +// non-rejected data points count as success. +// If no rejection reason is available, `rejected` SHOULD be used as value for +// `error.type`. +func (m SDKExporterMetricDataPointExported) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrErrorType returns an optional attribute for the "error.type" semantic // convention. It represents the describes a class of error the operation ended // with. @@ -572,7 +642,7 @@ func (SDKExporterMetricDataPointInflight) Description() string { return "The number of metric data points which were passed to the exporter, but that have not been exported yet (neither successful, nor failed)" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. // @@ -604,6 +674,26 @@ func (m SDKExporterMetricDataPointInflight) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// For successful exports, `error.type` MUST NOT be set. For failed exports, +// `error.type` MUST contain the failure cause. +func (m SDKExporterMetricDataPointInflight) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // AttrComponentName returns an optional attribute for the "otel.component.name" // semantic convention. It represents a name uniquely identifying the instance of // the OpenTelemetry component within its containing SDK instance. @@ -682,7 +772,7 @@ func (SDKExporterOperationDuration) Description() string { return "The duration of exporting a batch of telemetry records." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // All additional attrs passed are included in the recorded value. // @@ -721,6 +811,32 @@ func (m SDKExporterOperationDuration) Record( m.Float64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// This metric defines successful operations using the full success definitions +// for [http] +// and [grpc]. Anything else is defined as an unsuccessful operation. For +// successful +// operations, `error.type` MUST NOT be set. For unsuccessful export operations, +// `error.type` MUST contain a relevant failure cause. +// +// [http]: https://github.com/open-telemetry/opentelemetry-proto/blob/v1.5.0/docs/specification.md#full-success-1 +// [grpc]: https://github.com/open-telemetry/opentelemetry-proto/blob/v1.5.0/docs/specification.md#full-success +func (m SDKExporterOperationDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Histogram.Record(ctx, val, *o...) +} + // AttrErrorType returns an optional attribute for the "error.type" semantic // convention. It represents the describes a class of error the operation ended // with. @@ -820,7 +936,7 @@ func (SDKExporterSpanExported) Description() string { return "The number of spans for which the export has finished, either successful or failed" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. // @@ -857,6 +973,31 @@ func (m SDKExporterSpanExported) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// For successful exports, `error.type` MUST NOT be set. For failed exports, +// `error.type` MUST contain the failure cause. +// For exporters with partial success semantics (e.g. OTLP with `rejected_spans` +// ), rejected spans MUST count as failed and only non-rejected spans count as +// success. +// If no rejection reason is available, `rejected` SHOULD be used as value for +// `error.type`. +func (m SDKExporterSpanExported) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrErrorType returns an optional attribute for the "error.type" semantic // convention. It represents the describes a class of error the operation ended // with. @@ -942,7 +1083,7 @@ func (SDKExporterSpanInflight) Description() string { return "The number of spans which were passed to the exporter, but that have not been exported yet (neither successful, nor failed)" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. // @@ -974,6 +1115,26 @@ func (m SDKExporterSpanInflight) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// For successful exports, `error.type` MUST NOT be set. For failed exports, +// `error.type` MUST contain the failure cause. +func (m SDKExporterSpanInflight) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // AttrComponentName returns an optional attribute for the "otel.component.name" // semantic convention. It represents a name uniquely identifying the instance of // the OpenTelemetry component within its containing SDK instance. @@ -1051,7 +1212,7 @@ func (SDKLogCreated) Description() string { return "The number of logs submitted to enabled SDK Loggers" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. func (m SDKLogCreated) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { if len(attrs) == 0 { m.Int64Counter.Add(ctx, incr) @@ -1068,6 +1229,23 @@ func (m SDKLogCreated) Add(ctx context.Context, incr int64, attrs ...attribute.K m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m SDKLogCreated) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // SDKMetricReaderCollectionDuration is an instrument used to record metric // values conforming to the "otel.sdk.metric_reader.collection.duration" semantic // conventions. It represents the duration of the collect operation of the metric @@ -1120,7 +1298,7 @@ func (SDKMetricReaderCollectionDuration) Description() string { return "The duration of the collect operation of the metric reader." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // All additional attrs passed are included in the recorded value. // @@ -1155,6 +1333,28 @@ func (m SDKMetricReaderCollectionDuration) Record( m.Float64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// For successful collections, `error.type` MUST NOT be set. For failed +// collections, `error.type` SHOULD contain the failure cause. +// It can happen that metrics collection is successful for some MetricProducers, +// while others fail. In that case `error.type` SHOULD be set to any of the +// failure causes. +func (m SDKMetricReaderCollectionDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Histogram.Record(ctx, val, *o...) +} + // AttrErrorType returns an optional attribute for the "error.type" semantic // convention. It represents the describes a class of error the operation ended // with. @@ -1227,7 +1427,7 @@ func (SDKProcessorLogProcessed) Description() string { return "The number of log records for which the processing has finished, either successful or failed" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. // @@ -1262,6 +1462,29 @@ func (m SDKProcessorLogProcessed) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// For successful processing, `error.type` MUST NOT be set. For failed +// processing, `error.type` MUST contain the failure cause. +// For the SDK Simple and Batching Log Record Processor a log record is +// considered to be processed already when it has been submitted to the exporter, +// not when the corresponding export call has finished. +func (m SDKProcessorLogProcessed) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrErrorType returns an optional attribute for the "error.type" semantic // convention. It represents a low-cardinality description of the failure reason. // SDK Batching Log Record Processors MUST use `queue_full` for log records @@ -1467,7 +1690,7 @@ func (SDKProcessorSpanProcessed) Description() string { return "The number of spans for which the processing has finished, either successful or failed" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. // @@ -1502,6 +1725,29 @@ func (m SDKProcessorSpanProcessed) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// For successful processing, `error.type` MUST NOT be set. For failed +// processing, `error.type` MUST contain the failure cause. +// For the SDK Simple and Batching Span Processor a span is considered to be +// processed already when it has been submitted to the exporter, not when the +// corresponding export call has finished. +func (m SDKProcessorSpanProcessed) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrErrorType returns an optional attribute for the "error.type" semantic // convention. It represents a low-cardinality description of the failure reason. // SDK Batching Span Processors MUST use `queue_full` for spans dropped due to a @@ -1707,7 +1953,7 @@ func (SDKSpanLive) Description() string { return "The number of created spans with `recording=true` for which the end operation has not been called yet" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. func (m SDKSpanLive) Add( @@ -1736,6 +1982,23 @@ func (m SDKSpanLive) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m SDKSpanLive) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // AttrSpanSamplingResult returns an optional attribute for the // "otel.span.sampling_result" semantic convention. It represents the result // value of the sampler for this span. @@ -1793,7 +2056,7 @@ func (SDKSpanStarted) Description() string { return "The number of created spans" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. // @@ -1825,6 +2088,26 @@ func (m SDKSpanStarted) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// Implementations MUST record this metric for all spans, even for non-recording +// ones. +func (m SDKSpanStarted) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrSpanParentOrigin returns an optional attribute for the // "otel.span.parent.origin" semantic convention. It represents the determines // whether the span has a parent span, and if so, [whether it is a remote parent] diff --git a/semconv/v1.36.0/processconv/metric.go b/semconv/v1.36.0/processconv/metric.go index 673904290..608c62126 100644 --- a/semconv/v1.36.0/processconv/metric.go +++ b/semconv/v1.36.0/processconv/metric.go @@ -150,7 +150,7 @@ func (ContextSwitches) Description() string { return "Number of times the process has been context switched." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. func (m ContextSwitches) Add( @@ -179,6 +179,23 @@ func (m ContextSwitches) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m ContextSwitches) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrContextSwitchType returns an optional attribute for the // "process.context_switch_type" semantic convention. It represents the specifies // whether the context switches for this data point were voluntary or @@ -295,7 +312,7 @@ func (CPUUtilization) Description() string { return "Difference in process.cpu.time since the last measurement, divided by the elapsed time and number of CPUs available to the process." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // All additional attrs passed are included in the recorded value. func (m CPUUtilization) Record( @@ -324,6 +341,22 @@ func (m CPUUtilization) Record( m.Int64Gauge.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m CPUUtilization) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Gauge.Record(ctx, val, *o...) +} + // AttrCPUMode returns an optional attribute for the "cpu.mode" semantic // convention. It represents a process SHOULD be characterized *either* by data // points with no `mode` labels, *or only* data points with `mode` labels. @@ -381,7 +414,7 @@ func (DiskIO) Description() string { return "Disk bytes transferred." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. func (m DiskIO) Add( @@ -410,6 +443,23 @@ func (m DiskIO) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m DiskIO) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrDiskIODirection returns an optional attribute for the "disk.io.direction" // semantic convention. It represents the disk IO operation direction. func (DiskIO) AttrDiskIODirection(val DiskIODirectionAttr) attribute.KeyValue { @@ -466,7 +516,7 @@ func (MemoryUsage) Description() string { return "The amount of physical memory in use." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. func (m MemoryUsage) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { if len(attrs) == 0 { m.Int64UpDownCounter.Add(ctx, incr) @@ -483,6 +533,23 @@ func (m MemoryUsage) Add(ctx context.Context, incr int64, attrs ...attribute.Key m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m MemoryUsage) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // MemoryVirtual is an instrument used to record metric values conforming to the // "process.memory.virtual" semantic conventions. It represents the amount of // committed virtual memory. @@ -533,7 +600,7 @@ func (MemoryVirtual) Description() string { return "The amount of committed virtual memory." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. func (m MemoryVirtual) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { if len(attrs) == 0 { m.Int64UpDownCounter.Add(ctx, incr) @@ -550,6 +617,23 @@ func (m MemoryVirtual) Add(ctx context.Context, incr int64, attrs ...attribute.K m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m MemoryVirtual) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // NetworkIO is an instrument used to record metric values conforming to the // "process.network.io" semantic conventions. It represents the network bytes // transferred. @@ -600,7 +684,7 @@ func (NetworkIO) Description() string { return "Network bytes transferred." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. func (m NetworkIO) Add( @@ -629,6 +713,23 @@ func (m NetworkIO) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m NetworkIO) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrNetworkIODirection returns an optional attribute for the // "network.io.direction" semantic convention. It represents the network IO // operation direction. @@ -686,7 +787,7 @@ func (OpenFileDescriptorCount) Description() string { return "Number of file descriptors in use by the process." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. func (m OpenFileDescriptorCount) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { if len(attrs) == 0 { m.Int64UpDownCounter.Add(ctx, incr) @@ -703,6 +804,23 @@ func (m OpenFileDescriptorCount) Add(ctx context.Context, incr int64, attrs ...a m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m OpenFileDescriptorCount) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // PagingFaults is an instrument used to record metric values conforming to the // "process.paging.faults" semantic conventions. It represents the number of page // faults the process has made. @@ -753,7 +871,7 @@ func (PagingFaults) Description() string { return "Number of page faults the process has made." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. func (m PagingFaults) Add( @@ -782,6 +900,23 @@ func (m PagingFaults) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m PagingFaults) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrPagingFaultType returns an optional attribute for the // "process.paging.fault_type" semantic convention. It represents the type of // page fault for this data point. Type `major` is for major/hard page faults, @@ -840,7 +975,7 @@ func (ThreadCount) Description() string { return "Process threads count." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. func (m ThreadCount) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { if len(attrs) == 0 { m.Int64UpDownCounter.Add(ctx, incr) @@ -857,6 +992,23 @@ func (m ThreadCount) Add(ctx context.Context, incr int64, attrs ...attribute.Key m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m ThreadCount) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // Uptime is an instrument used to record metric values conforming to the // "process.uptime" semantic conventions. It represents the time the process has // been running. @@ -907,7 +1059,7 @@ func (Uptime) Description() string { return "The time the process has been running." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // Instrumentations SHOULD use a gauge with type `double` and measure uptime in // seconds as a floating point number with the highest precision available. @@ -926,4 +1078,24 @@ func (m Uptime) Record(ctx context.Context, val float64, attrs ...attribute.KeyV *o = append(*o, metric.WithAttributes(attrs...)) m.Float64Gauge.Record(ctx, val, *o...) +} + +// RecordSet records val to the current distribution for set. +// +// Instrumentations SHOULD use a gauge with type `double` and measure uptime in +// seconds as a floating point number with the highest precision available. +// The actual accuracy would depend on the instrumentation and operating system. +func (m Uptime) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Gauge.Record(ctx, val, *o...) } \ No newline at end of file diff --git a/semconv/v1.36.0/rpcconv/metric.go b/semconv/v1.36.0/rpcconv/metric.go index d81499e5c..146b7eda6 100644 --- a/semconv/v1.36.0/rpcconv/metric.go +++ b/semconv/v1.36.0/rpcconv/metric.go @@ -71,7 +71,7 @@ func (ClientDuration) Description() string { return "Measures the duration of outbound RPC." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // While streaming RPCs may record this metric as start-of-batch // to end-of-batch, it's hard to interpret in practice. @@ -93,6 +93,27 @@ func (m ClientDuration) Record(ctx context.Context, val float64, attrs ...attrib m.Float64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// While streaming RPCs may record this metric as start-of-batch +// to end-of-batch, it's hard to interpret in practice. +// +// **Streaming**: N/A. +func (m ClientDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Histogram.Record(ctx, val, *o...) +} + // ClientRequestSize is an instrument used to record metric values conforming to // the "rpc.client.request.size" semantic conventions. It represents the measures // the size of RPC request messages (uncompressed). @@ -143,7 +164,7 @@ func (ClientRequestSize) Description() string { return "Measures the size of RPC request messages (uncompressed)." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // **Streaming**: Recorded per message in a streaming batch func (m ClientRequestSize) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) { @@ -162,6 +183,24 @@ func (m ClientRequestSize) Record(ctx context.Context, val int64, attrs ...attri m.Int64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// **Streaming**: Recorded per message in a streaming batch +func (m ClientRequestSize) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Histogram.Record(ctx, val, *o...) +} + // ClientRequestsPerRPC is an instrument used to record metric values conforming // to the "rpc.client.requests_per_rpc" semantic conventions. It represents the // measures the number of messages received per RPC. @@ -212,7 +251,7 @@ func (ClientRequestsPerRPC) Description() string { return "Measures the number of messages received per RPC." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // Should be 1 for all non-streaming RPCs. // @@ -233,6 +272,26 @@ func (m ClientRequestsPerRPC) Record(ctx context.Context, val int64, attrs ...at m.Int64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// Should be 1 for all non-streaming RPCs. +// +// **Streaming**: This metric is required for server and client streaming RPCs +func (m ClientRequestsPerRPC) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Histogram.Record(ctx, val, *o...) +} + // ClientResponseSize is an instrument used to record metric values conforming to // the "rpc.client.response.size" semantic conventions. It represents the // measures the size of RPC response messages (uncompressed). @@ -283,7 +342,7 @@ func (ClientResponseSize) Description() string { return "Measures the size of RPC response messages (uncompressed)." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // **Streaming**: Recorded per response in a streaming batch func (m ClientResponseSize) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) { @@ -302,6 +361,24 @@ func (m ClientResponseSize) Record(ctx context.Context, val int64, attrs ...attr m.Int64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// **Streaming**: Recorded per response in a streaming batch +func (m ClientResponseSize) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Histogram.Record(ctx, val, *o...) +} + // ClientResponsesPerRPC is an instrument used to record metric values conforming // to the "rpc.client.responses_per_rpc" semantic conventions. It represents the // measures the number of messages sent per RPC. @@ -352,7 +429,7 @@ func (ClientResponsesPerRPC) Description() string { return "Measures the number of messages sent per RPC." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // Should be 1 for all non-streaming RPCs. // @@ -373,6 +450,26 @@ func (m ClientResponsesPerRPC) Record(ctx context.Context, val int64, attrs ...a m.Int64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// Should be 1 for all non-streaming RPCs. +// +// **Streaming**: This metric is required for server and client streaming RPCs +func (m ClientResponsesPerRPC) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Histogram.Record(ctx, val, *o...) +} + // ServerDuration is an instrument used to record metric values conforming to the // "rpc.server.duration" semantic conventions. It represents the measures the // duration of inbound RPC. @@ -423,7 +520,7 @@ func (ServerDuration) Description() string { return "Measures the duration of inbound RPC." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // While streaming RPCs may record this metric as start-of-batch // to end-of-batch, it's hard to interpret in practice. @@ -445,6 +542,27 @@ func (m ServerDuration) Record(ctx context.Context, val float64, attrs ...attrib m.Float64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// While streaming RPCs may record this metric as start-of-batch +// to end-of-batch, it's hard to interpret in practice. +// +// **Streaming**: N/A. +func (m ServerDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Histogram.Record(ctx, val, *o...) +} + // ServerRequestSize is an instrument used to record metric values conforming to // the "rpc.server.request.size" semantic conventions. It represents the measures // the size of RPC request messages (uncompressed). @@ -495,7 +613,7 @@ func (ServerRequestSize) Description() string { return "Measures the size of RPC request messages (uncompressed)." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // **Streaming**: Recorded per message in a streaming batch func (m ServerRequestSize) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) { @@ -514,6 +632,24 @@ func (m ServerRequestSize) Record(ctx context.Context, val int64, attrs ...attri m.Int64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// **Streaming**: Recorded per message in a streaming batch +func (m ServerRequestSize) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Histogram.Record(ctx, val, *o...) +} + // ServerRequestsPerRPC is an instrument used to record metric values conforming // to the "rpc.server.requests_per_rpc" semantic conventions. It represents the // measures the number of messages received per RPC. @@ -564,7 +700,7 @@ func (ServerRequestsPerRPC) Description() string { return "Measures the number of messages received per RPC." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // Should be 1 for all non-streaming RPCs. // @@ -585,6 +721,26 @@ func (m ServerRequestsPerRPC) Record(ctx context.Context, val int64, attrs ...at m.Int64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// Should be 1 for all non-streaming RPCs. +// +// **Streaming** : This metric is required for server and client streaming RPCs +func (m ServerRequestsPerRPC) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Histogram.Record(ctx, val, *o...) +} + // ServerResponseSize is an instrument used to record metric values conforming to // the "rpc.server.response.size" semantic conventions. It represents the // measures the size of RPC response messages (uncompressed). @@ -635,7 +791,7 @@ func (ServerResponseSize) Description() string { return "Measures the size of RPC response messages (uncompressed)." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // **Streaming**: Recorded per response in a streaming batch func (m ServerResponseSize) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) { @@ -654,6 +810,24 @@ func (m ServerResponseSize) Record(ctx context.Context, val int64, attrs ...attr m.Int64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// **Streaming**: Recorded per response in a streaming batch +func (m ServerResponseSize) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Histogram.Record(ctx, val, *o...) +} + // ServerResponsesPerRPC is an instrument used to record metric values conforming // to the "rpc.server.responses_per_rpc" semantic conventions. It represents the // measures the number of messages sent per RPC. @@ -704,7 +878,7 @@ func (ServerResponsesPerRPC) Description() string { return "Measures the number of messages sent per RPC." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // Should be 1 for all non-streaming RPCs. // @@ -723,4 +897,24 @@ func (m ServerResponsesPerRPC) Record(ctx context.Context, val int64, attrs ...a *o = append(*o, metric.WithAttributes(attrs...)) m.Int64Histogram.Record(ctx, val, *o...) +} + +// RecordSet records val to the current distribution for set. +// +// Should be 1 for all non-streaming RPCs. +// +// **Streaming**: This metric is required for server and client streaming RPCs +func (m ServerResponsesPerRPC) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Histogram.Record(ctx, val, *o...) } \ No newline at end of file diff --git a/semconv/v1.36.0/signalrconv/metric.go b/semconv/v1.36.0/signalrconv/metric.go index 21dd89c19..57fb95286 100644 --- a/semconv/v1.36.0/signalrconv/metric.go +++ b/semconv/v1.36.0/signalrconv/metric.go @@ -101,7 +101,7 @@ func (ServerActiveConnections) Description() string { return "Number of connections that are currently active on the server." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. // @@ -133,6 +133,26 @@ func (m ServerActiveConnections) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// Meter name: `Microsoft.AspNetCore.Http.Connections`; Added in: ASP.NET Core +// 8.0 +func (m ServerActiveConnections) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // AttrConnectionStatus returns an optional attribute for the // "signalr.connection.status" semantic convention. It represents the signalR // HTTP connection closure status. @@ -198,7 +218,7 @@ func (ServerConnectionDuration) Description() string { return "The duration of connections on the server." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // All additional attrs passed are included in the recorded value. // @@ -230,6 +250,25 @@ func (m ServerConnectionDuration) Record( m.Float64Histogram.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// Meter name: `Microsoft.AspNetCore.Http.Connections`; Added in: ASP.NET Core +// 8.0 +func (m ServerConnectionDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Histogram.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Histogram.Record(ctx, val, *o...) +} + // AttrConnectionStatus returns an optional attribute for the // "signalr.connection.status" semantic convention. It represents the signalR // HTTP connection closure status. diff --git a/semconv/v1.36.0/systemconv/metric.go b/semconv/v1.36.0/systemconv/metric.go index 4bdb21643..30dd2d24b 100644 --- a/semconv/v1.36.0/systemconv/metric.go +++ b/semconv/v1.36.0/systemconv/metric.go @@ -299,7 +299,7 @@ func (CPUFrequency) Description() string { return "Operating frequency of the logical CPU in Hertz." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // All additional attrs passed are included in the recorded value. func (m CPUFrequency) Record( @@ -328,6 +328,22 @@ func (m CPUFrequency) Record( m.Int64Gauge.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m CPUFrequency) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Gauge.Record(ctx, val, *o...) +} + // AttrCPULogicalNumber returns an optional attribute for the // "cpu.logical_number" semantic convention. It represents the logical CPU number // [0..n-1]. @@ -386,7 +402,7 @@ func (CPULogicalCount) Description() string { return "Reports the number of logical (virtual) processor cores created by the operating system to manage multitasking" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // Calculated by multiplying the number of sockets by the number of cores per // socket, and then by the number of threads per core @@ -406,6 +422,26 @@ func (m CPULogicalCount) Add(ctx context.Context, incr int64, attrs ...attribute m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// Calculated by multiplying the number of sockets by the number of cores per +// socket, and then by the number of threads per core +func (m CPULogicalCount) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // CPUPhysicalCount is an instrument used to record metric values conforming to // the "system.cpu.physical.count" semantic conventions. It represents the // reports the number of actual physical processor cores on the hardware. @@ -456,7 +492,7 @@ func (CPUPhysicalCount) Description() string { return "Reports the number of actual physical processor cores on the hardware" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // Calculated by multiplying the number of sockets by the number of cores per // socket @@ -476,6 +512,26 @@ func (m CPUPhysicalCount) Add(ctx context.Context, incr int64, attrs ...attribut m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// Calculated by multiplying the number of sockets by the number of cores per +// socket +func (m CPUPhysicalCount) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // CPUTime is an instrument used to record metric values conforming to the // "system.cpu.time" semantic conventions. It represents the seconds each logical // CPU spent on each mode. @@ -590,7 +646,7 @@ func (CPUUtilization) Description() string { return "For each logical CPU, the utilization is calculated as the change in cumulative CPU time (cpu.time) over a measurement interval, divided by the elapsed time." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // All additional attrs passed are included in the recorded value. func (m CPUUtilization) Record( @@ -619,6 +675,22 @@ func (m CPUUtilization) Record( m.Int64Gauge.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m CPUUtilization) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Gauge.Record(ctx, val, *o...) +} + // AttrCPULogicalNumber returns an optional attribute for the // "cpu.logical_number" semantic convention. It represents the logical CPU number // [0..n-1]. @@ -676,7 +748,7 @@ func (DiskIO) Unit() string { return "By" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. func (m DiskIO) Add( @@ -705,6 +777,23 @@ func (m DiskIO) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m DiskIO) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrDiskIODirection returns an optional attribute for the "disk.io.direction" // semantic convention. It represents the disk IO operation direction. func (DiskIO) AttrDiskIODirection(val DiskIODirectionAttr) attribute.KeyValue { @@ -767,7 +856,7 @@ func (DiskIOTime) Description() string { return "Time disk spent activated" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. // @@ -808,6 +897,35 @@ func (m DiskIOTime) Add( m.Float64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// The real elapsed time ("wall clock") used in the I/O path (time from +// operations running in parallel are not counted). Measured as: +// +// - Linux: Field 13 from [procfs-diskstats] +// - Windows: The complement of +// ["Disk% Idle Time"] +// performance counter: `uptime * (100 - "Disk\% Idle Time") / 100` +// +// +// [procfs-diskstats]: https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats +// ["Disk% Idle Time"]: https://learn.microsoft.com/archive/blogs/askcore/windows-performance-monitor-disk-counters-explained#windows-performance-monitor-disk-counters-explained +func (m DiskIOTime) AddSet(ctx context.Context, incr float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Counter.Add(ctx, incr, *o...) +} + // AttrDevice returns an optional attribute for the "system.device" semantic // convention. It represents the device identifier. func (DiskIOTime) AttrDevice(val string) attribute.KeyValue { @@ -864,7 +982,7 @@ func (DiskLimit) Description() string { return "The total storage capacity of the disk" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. func (m DiskLimit) Add( @@ -893,6 +1011,23 @@ func (m DiskLimit) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m DiskLimit) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // AttrDevice returns an optional attribute for the "system.device" semantic // convention. It represents the device identifier. func (DiskLimit) AttrDevice(val string) attribute.KeyValue { @@ -943,7 +1078,7 @@ func (DiskMerged) Unit() string { return "{operation}" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. func (m DiskMerged) Add( @@ -972,6 +1107,23 @@ func (m DiskMerged) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m DiskMerged) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrDiskIODirection returns an optional attribute for the "disk.io.direction" // semantic convention. It represents the disk IO operation direction. func (DiskMerged) AttrDiskIODirection(val DiskIODirectionAttr) attribute.KeyValue { @@ -1034,7 +1186,7 @@ func (DiskOperationTime) Description() string { return "Sum of the time each operation took to complete" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. // @@ -1073,6 +1225,33 @@ func (m DiskOperationTime) Add( m.Float64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// Because it is the sum of time each request took, parallel-issued requests each +// contribute to make the count grow. Measured as: +// +// - Linux: Fields 7 & 11 from [procfs-diskstats] +// - Windows: "Avg. Disk sec/Read" perf counter multiplied by "Disk Reads/sec" +// perf counter (similar for Writes) +// +// +// [procfs-diskstats]: https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats +func (m DiskOperationTime) AddSet(ctx context.Context, incr float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Counter.Add(ctx, incr, *o...) +} + // AttrDiskIODirection returns an optional attribute for the "disk.io.direction" // semantic convention. It represents the disk IO operation direction. func (DiskOperationTime) AttrDiskIODirection(val DiskIODirectionAttr) attribute.KeyValue { @@ -1129,7 +1308,7 @@ func (DiskOperations) Unit() string { return "{operation}" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. func (m DiskOperations) Add( @@ -1158,6 +1337,23 @@ func (m DiskOperations) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m DiskOperations) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrDiskIODirection returns an optional attribute for the "disk.io.direction" // semantic convention. It represents the disk IO operation direction. func (DiskOperations) AttrDiskIODirection(val DiskIODirectionAttr) attribute.KeyValue { @@ -1220,7 +1416,7 @@ func (FilesystemLimit) Description() string { return "The total storage capacity of the filesystem" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. func (m FilesystemLimit) Add( @@ -1249,6 +1445,23 @@ func (m FilesystemLimit) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m FilesystemLimit) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // AttrDevice returns an optional attribute for the "system.device" semantic // convention. It represents the identifier for the device where the filesystem // resides. @@ -1327,7 +1540,7 @@ func (FilesystemUsage) Description() string { return "Reports a filesystem's space usage across different states." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. // @@ -1361,6 +1574,28 @@ func (m FilesystemUsage) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// The sum of all `system.filesystem.usage` values over the different +// `system.filesystem.state` attributes +// SHOULD equal the total storage capacity of the filesystem, that is +// `system.filesystem.limit`. +func (m FilesystemUsage) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // AttrDevice returns an optional attribute for the "system.device" semantic // convention. It represents the identifier for the device where the filesystem // resides. @@ -1440,7 +1675,7 @@ func (FilesystemUtilization) Unit() string { return "1" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // All additional attrs passed are included in the recorded value. func (m FilesystemUtilization) Record( @@ -1469,6 +1704,22 @@ func (m FilesystemUtilization) Record( m.Int64Gauge.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m FilesystemUtilization) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Gauge.Record(ctx, val, *o...) +} + // AttrDevice returns an optional attribute for the "system.device" semantic // convention. It represents the identifier for the device where the filesystem // resides. @@ -1555,7 +1806,7 @@ func (LinuxMemoryAvailable) Description() string { return "An estimate of how much memory is available for starting new applications, without causing swapping" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // This is an alternative to `system.memory.usage` metric with `state=free`. // Linux starting from 3.14 exports "available" memory. It takes "free" memory as @@ -1582,6 +1833,33 @@ func (m LinuxMemoryAvailable) Add(ctx context.Context, incr int64, attrs ...attr m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// This is an alternative to `system.memory.usage` metric with `state=free`. +// Linux starting from 3.14 exports "available" memory. It takes "free" memory as +// a baseline, and then factors in kernel-specific values. +// This is supposed to be more accurate than just "free" memory. +// For reference, see the calculations [here]. +// See also `MemAvailable` in [/proc/meminfo]. +// +// [here]: https://superuser.com/a/980821 +// [/proc/meminfo]: https://man7.org/linux/man-pages/man5/proc.5.html +func (m LinuxMemoryAvailable) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // LinuxMemorySlabUsage is an instrument used to record metric values conforming // to the "system.linux.memory.slab.usage" semantic conventions. It represents // the reports the memory used by the Linux kernel for managing caches of @@ -1633,7 +1911,7 @@ func (LinuxMemorySlabUsage) Description() string { return "Reports the memory used by the Linux kernel for managing caches of frequently used objects." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. // @@ -1671,6 +1949,32 @@ func (m LinuxMemorySlabUsage) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// The sum over the `reclaimable` and `unreclaimable` state values in +// `linux.memory.slab.usage` SHOULD be equal to the total slab memory available +// on the system. +// Note that the total slab memory is not constant and may vary over time. +// See also the [Slab allocator] and `Slab` in [/proc/meminfo]. +// +// [Slab allocator]: https://blogs.oracle.com/linux/post/understanding-linux-kernel-memory-statistics +// [/proc/meminfo]: https://man7.org/linux/man-pages/man5/proc.5.html +func (m LinuxMemorySlabUsage) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // AttrLinuxMemorySlabState returns an optional attribute for the // "linux.memory.slab.state" semantic convention. It represents the Linux Slab // memory state. @@ -1728,7 +2032,7 @@ func (MemoryLimit) Description() string { return "Total memory available in the system." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // Its value SHOULD equal the sum of `system.memory.state` over all states. func (m MemoryLimit) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { @@ -1747,6 +2051,25 @@ func (m MemoryLimit) Add(ctx context.Context, incr int64, attrs ...attribute.Key m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// Its value SHOULD equal the sum of `system.memory.state` over all states. +func (m MemoryLimit) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // MemoryShared is an instrument used to record metric values conforming to the // "system.memory.shared" semantic conventions. It represents the shared memory // used (mostly by tmpfs). @@ -1797,7 +2120,7 @@ func (MemoryShared) Description() string { return "Shared memory used (mostly by tmpfs)." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // Equivalent of `shared` from [`free` command] or // `Shmem` from [`/proc/meminfo`]" @@ -1820,6 +2143,29 @@ func (m MemoryShared) Add(ctx context.Context, incr int64, attrs ...attribute.Ke m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// Equivalent of `shared` from [`free` command] or +// `Shmem` from [`/proc/meminfo`]" +// +// [`free` command]: https://man7.org/linux/man-pages/man1/free.1.html +// [`/proc/meminfo`]: https://man7.org/linux/man-pages/man5/proc.5.html +func (m MemoryShared) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // MemoryUsage is an instrument used to record metric values conforming to the // "system.memory.usage" semantic conventions. It represents the reports memory // in use by state. @@ -1970,7 +2316,7 @@ func (NetworkConnectionCount) Unit() string { return "{connection}" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. func (m NetworkConnectionCount) Add( @@ -1999,6 +2345,23 @@ func (m NetworkConnectionCount) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m NetworkConnectionCount) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // AttrNetworkConnectionState returns an optional attribute for the // "network.connection.state" semantic convention. It represents the state of // network connection. @@ -2073,7 +2436,7 @@ func (NetworkDropped) Description() string { return "Count of packets that are dropped or discarded even though there was no error" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. // @@ -2113,6 +2476,34 @@ func (m NetworkDropped) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// Measured as: +// +// - Linux: the `drop` column in `/proc/dev/net` ([source]) +// - Windows: [`InDiscards`/`OutDiscards`] +// from [`GetIfEntry2`] +// +// +// [source]: https://web.archive.org/web/20180321091318/http://www.onlamp.com/pub/a/linux/2000/11/16/LinuxAdmin.html +// [`InDiscards`/`OutDiscards`]: https://docs.microsoft.com/windows/win32/api/netioapi/ns-netioapi-mib_if_row2 +// [`GetIfEntry2`]: https://docs.microsoft.com/windows/win32/api/netioapi/nf-netioapi-getifentry2 +func (m NetworkDropped) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrNetworkInterfaceName returns an optional attribute for the // "network.interface.name" semantic convention. It represents the network // interface name. @@ -2177,7 +2568,7 @@ func (NetworkErrors) Description() string { return "Count of network errors detected" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. // @@ -2217,6 +2608,34 @@ func (m NetworkErrors) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +// +// Measured as: +// +// - Linux: the `errs` column in `/proc/dev/net` ([source]). +// - Windows: [`InErrors`/`OutErrors`] +// from [`GetIfEntry2`]. +// +// +// [source]: https://web.archive.org/web/20180321091318/http://www.onlamp.com/pub/a/linux/2000/11/16/LinuxAdmin.html +// [`InErrors`/`OutErrors`]: https://docs.microsoft.com/windows/win32/api/netioapi/ns-netioapi-mib_if_row2 +// [`GetIfEntry2`]: https://docs.microsoft.com/windows/win32/api/netioapi/nf-netioapi-getifentry2 +func (m NetworkErrors) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrNetworkInterfaceName returns an optional attribute for the // "network.interface.name" semantic convention. It represents the network // interface name. @@ -2333,7 +2752,7 @@ func (NetworkPackets) Unit() string { return "{packet}" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. func (m NetworkPackets) Add( @@ -2362,6 +2781,23 @@ func (m NetworkPackets) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m NetworkPackets) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrNetworkIODirection returns an optional attribute for the // "network.io.direction" semantic convention. It represents the network IO // operation direction. @@ -2419,7 +2855,7 @@ func (PagingFaults) Unit() string { return "{fault}" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. func (m PagingFaults) Add( @@ -2448,6 +2884,23 @@ func (m PagingFaults) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m PagingFaults) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrPagingType returns an optional attribute for the "system.paging.type" // semantic convention. It represents the memory paging type. func (PagingFaults) AttrPagingType(val PagingTypeAttr) attribute.KeyValue { @@ -2498,7 +2951,7 @@ func (PagingOperations) Unit() string { return "{operation}" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. func (m PagingOperations) Add( @@ -2527,6 +2980,23 @@ func (m PagingOperations) Add( m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m PagingOperations) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // AttrPagingDirection returns an optional attribute for the // "system.paging.direction" semantic convention. It represents the paging access // direction. @@ -2590,7 +3060,7 @@ func (PagingUsage) Description() string { return "Unix swap or windows pagefile usage" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. func (m PagingUsage) Add( @@ -2619,6 +3089,23 @@ func (m PagingUsage) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m PagingUsage) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // AttrDevice returns an optional attribute for the "system.device" semantic // convention. It represents the unique identifier for the device responsible for // managing paging operations. @@ -2676,7 +3163,7 @@ func (PagingUtilization) Unit() string { return "1" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // All additional attrs passed are included in the recorded value. func (m PagingUtilization) Record( @@ -2705,6 +3192,22 @@ func (m PagingUtilization) Record( m.Int64Gauge.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m PagingUtilization) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Gauge.Record(ctx, val, *o...) +} + // AttrDevice returns an optional attribute for the "system.device" semantic // convention. It represents the unique identifier for the device responsible for // managing paging operations. @@ -2768,7 +3271,7 @@ func (ProcessCount) Description() string { return "Total number of processes in each state" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. func (m ProcessCount) Add( @@ -2797,6 +3300,23 @@ func (m ProcessCount) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m ProcessCount) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // AttrProcessStatus returns an optional attribute for the // "system.process.status" semantic convention. It represents the process state, // e.g., [Linux Process State Codes]. @@ -2856,7 +3376,7 @@ func (ProcessCreated) Description() string { return "Total number of processes created over uptime of the host" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. func (m ProcessCreated) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) { if len(attrs) == 0 { m.Int64Counter.Add(ctx, incr) @@ -2873,6 +3393,23 @@ func (m ProcessCreated) Add(ctx context.Context, incr int64, attrs ...attribute. m.Int64Counter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m ProcessCreated) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Counter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Counter.Add(ctx, incr, *o...) +} + // Uptime is an instrument used to record metric values conforming to the // "system.uptime" semantic conventions. It represents the time the system has // been running. @@ -2923,7 +3460,7 @@ func (Uptime) Description() string { return "The time the system has been running" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // Instrumentations SHOULD use a gauge with type `double` and measure uptime in // seconds as a floating point number with the highest precision available. @@ -2942,4 +3479,24 @@ func (m Uptime) Record(ctx context.Context, val float64, attrs ...attribute.KeyV *o = append(*o, metric.WithAttributes(attrs...)) m.Float64Gauge.Record(ctx, val, *o...) +} + +// RecordSet records val to the current distribution for set. +// +// Instrumentations SHOULD use a gauge with type `double` and measure uptime in +// seconds as a floating point number with the highest precision available. +// The actual accuracy would depend on the instrumentation and operating system. +func (m Uptime) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Gauge.Record(ctx, val, *o...) } \ No newline at end of file diff --git a/semconv/v1.36.0/vcsconv/metric.go b/semconv/v1.36.0/vcsconv/metric.go index cb586286f..5f1974cd3 100644 --- a/semconv/v1.36.0/vcsconv/metric.go +++ b/semconv/v1.36.0/vcsconv/metric.go @@ -196,7 +196,7 @@ func (ChangeCount) Description() string { return "The number of changes (pull requests/merge requests/changelists) in a repository, categorized by their state (e.g. open or merged)" } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The changeState is the the state of the change (pull request/merge // request/changelist). @@ -240,6 +240,23 @@ func (m ChangeCount) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m ChangeCount) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // AttrOwnerName returns an optional attribute for the "vcs.owner.name" semantic // convention. It represents the group owner within the version control system. func (ChangeCount) AttrOwnerName(val string) attribute.KeyValue { @@ -311,7 +328,7 @@ func (ChangeDuration) Description() string { return "The time duration a change (pull request/merge request/changelist) has been in a given state." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The changeState is the the state of the change (pull request/merge // request/changelist). @@ -361,6 +378,22 @@ func (m ChangeDuration) Record( m.Float64Gauge.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m ChangeDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Gauge.Record(ctx, val, *o...) +} + // AttrOwnerName returns an optional attribute for the "vcs.owner.name" semantic // convention. It represents the group owner within the version control system. func (ChangeDuration) AttrOwnerName(val string) attribute.KeyValue { @@ -433,7 +466,7 @@ func (ChangeTimeToApproval) Description() string { return "The amount of time since its creation it took a change (pull request/merge request/changelist) to get the first approval." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The refHeadName is the the name of the [reference] such as **branch** or // **tag** in the repository. @@ -478,6 +511,22 @@ func (m ChangeTimeToApproval) Record( m.Float64Gauge.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m ChangeTimeToApproval) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Gauge.Record(ctx, val, *o...) +} + // AttrOwnerName returns an optional attribute for the "vcs.owner.name" semantic // convention. It represents the group owner within the version control system. func (ChangeTimeToApproval) AttrOwnerName(val string) attribute.KeyValue { @@ -579,7 +628,7 @@ func (ChangeTimeToMerge) Description() string { return "The amount of time since its creation it took a change (pull request/merge request/changelist) to get merged into the target(base) ref." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The refHeadName is the the name of the [reference] such as **branch** or // **tag** in the repository. @@ -624,6 +673,22 @@ func (m ChangeTimeToMerge) Record( m.Float64Gauge.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m ChangeTimeToMerge) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Gauge.Record(ctx, val, *o...) +} + // AttrOwnerName returns an optional attribute for the "vcs.owner.name" semantic // convention. It represents the group owner within the version control system. func (ChangeTimeToMerge) AttrOwnerName(val string) attribute.KeyValue { @@ -724,7 +789,7 @@ func (ContributorCount) Description() string { return "The number of unique contributors to a repository" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The repositoryUrlFull is the the [canonical URL] of the repository providing // the complete HTTP(S) address in order to locate and identify the repository @@ -763,6 +828,22 @@ func (m ContributorCount) Record( m.Int64Gauge.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m ContributorCount) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Gauge.Record(ctx, val, *o...) +} + // AttrOwnerName returns an optional attribute for the "vcs.owner.name" semantic // convention. It represents the group owner within the version control system. func (ContributorCount) AttrOwnerName(val string) attribute.KeyValue { @@ -834,7 +915,7 @@ func (RefCount) Description() string { return "The number of refs of type branch or tag in a repository." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // The refType is the the type of the [reference] in the repository. // @@ -878,6 +959,23 @@ func (m RefCount) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m RefCount) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // AttrOwnerName returns an optional attribute for the "vcs.owner.name" semantic // convention. It represents the group owner within the version control system. func (RefCount) AttrOwnerName(val string) attribute.KeyValue { @@ -950,7 +1048,7 @@ func (RefLinesDelta) Description() string { return "The number of lines added/removed in a ref (branch) relative to the ref from the `vcs.ref.base.name` attribute." } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The lineChangeType is the the type of line change being measured on a branch // or change. @@ -1023,6 +1121,29 @@ func (m RefLinesDelta) Record( m.Int64Gauge.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// This metric should be reported for each `vcs.line_change.type` value. For +// example if a ref added 3 lines and removed 2 lines, +// instrumentation SHOULD report two measurements: 3 and 2 (both positive +// numbers). +// If number of lines added/removed should be calculated from the start of time, +// then `vcs.ref.base.name` SHOULD be set to an empty string. +func (m RefLinesDelta) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Gauge.Record(ctx, val, *o...) +} + // AttrChangeID returns an optional attribute for the "vcs.change.id" semantic // convention. It represents the ID of the change (pull request/merge // request/changelist) if applicable. This is usually a unique (within @@ -1103,7 +1224,7 @@ func (RefRevisionsDelta) Description() string { return "The number of revisions (commits) a ref (branch) is ahead/behind the branch from the `vcs.ref.base.name` attribute" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The refBaseName is the the name of the [reference] such as **branch** or // **tag** in the repository. @@ -1173,6 +1294,27 @@ func (m RefRevisionsDelta) Record( m.Int64Gauge.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +// +// This metric should be reported for each `vcs.revision_delta.direction` value. +// For example if branch `a` is 3 commits behind and 2 commits ahead of `trunk`, +// instrumentation SHOULD report two measurements: 3 and 2 (both positive +// numbers) and `vcs.ref.base.name` is set to `trunk`. +func (m RefRevisionsDelta) RecordSet(ctx context.Context, val int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64Gauge.Record(ctx, val, *o...) +} + // AttrChangeID returns an optional attribute for the "vcs.change.id" semantic // convention. It represents the ID of the change (pull request/merge // request/changelist) if applicable. This is usually a unique (within @@ -1253,7 +1395,7 @@ func (RefTime) Description() string { return "Time a ref (branch) created from the default branch (trunk) has existed. The `ref.type` attribute will always be `branch`" } -// Record records val to the current distribution. +// Record records val to the current distribution for attrs. // // The refHeadName is the the name of the [reference] such as **branch** or // **tag** in the repository. @@ -1303,6 +1445,22 @@ func (m RefTime) Record( m.Float64Gauge.Record(ctx, val, *o...) } +// RecordSet records val to the current distribution for set. +func (m RefTime) RecordSet(ctx context.Context, val float64, set attribute.Set) { + if set.Len() == 0 { + m.Float64Gauge.Record(ctx, val) + } + + o := recOptPool.Get().(*[]metric.RecordOption) + defer func() { + *o = (*o)[:0] + recOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Float64Gauge.Record(ctx, val, *o...) +} + // AttrOwnerName returns an optional attribute for the "vcs.owner.name" semantic // convention. It represents the group owner within the version control system. func (RefTime) AttrOwnerName(val string) attribute.KeyValue { @@ -1374,7 +1532,7 @@ func (RepositoryCount) Description() string { return "The number of repositories in an organization." } -// Add adds incr to the existing count. +// Add adds incr to the existing count for attrs. // // All additional attrs passed are included in the recorded value. func (m RepositoryCount) Add( @@ -1403,6 +1561,23 @@ func (m RepositoryCount) Add( m.Int64UpDownCounter.Add(ctx, incr, *o...) } +// AddSet adds incr to the existing count for set. +func (m RepositoryCount) AddSet(ctx context.Context, incr int64, set attribute.Set) { + if set.Len() == 0 { + m.Int64UpDownCounter.Add(ctx, incr) + return + } + + o := addOptPool.Get().(*[]metric.AddOption) + defer func() { + *o = (*o)[:0] + addOptPool.Put(o) + }() + + *o = append(*o, metric.WithAttributeSet(set)) + m.Int64UpDownCounter.Add(ctx, incr, *o...) +} + // AttrOwnerName returns an optional attribute for the "vcs.owner.name" semantic // convention. It represents the group owner within the version control system. func (RepositoryCount) AttrOwnerName(val string) attribute.KeyValue {