1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-11-27 22:49:15 +02:00
Files
opentelemetry-go/semconv/v1.33.0/messagingconv/metric.go
Tyler Yahn 3dbeacaa58 Generate semconv/v1.33.0 (#6799)
- Generate the new `semconv/v1.33.0` package and all sub-packages
- Fix the metric util package generation to support `int64` attribute
definitions

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

<div data-pjax="true" data-test-selector="body-content"
data-view-component="true" class="markdown-body my-3"><p>This release
marks the first where the core of database semantic conventions have
stabilized.</p>
<h3>🛑 Breaking changes 🛑</h3>
<ul>
<li><code>db</code>: Add <code>db.query.parameter</code>, replace
relevant usages of <code>db.operation.parameter</code> (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2093"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/2093/hovercard">#2093</a>)</li>
<li><code>db</code>: Make <code>db.response.returned_rows</code> opt-in
on <code>release_candidate</code> spans (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2211"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/2211/hovercard">#2211</a>)</li>
<li><code>db</code>: Use <code>|</code> as the separator when
<code>db.namespace</code> is a concatenation of multiple components. (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2067"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/2067/hovercard">#2067</a>)</li>
<li><code>feature_flag</code>: Rename
<code>feature_flag.provider_name</code> to
<code>feature_flag.provider.name</code> (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1982"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/1982/hovercard">#1982</a>)</li>
<li><code>feature_flag</code>: Use generic <code>error.message</code> in
feature flag evaluation event (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1994"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/1994/hovercard">#1994</a>)</li>
<li><code>gen-ai</code>: Refine the values for
<code>gen_ai.system</code> related to Google's AI endpoints. (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1950"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/1950/hovercard">#1950</a>)<br>
Enable sharing of attributes between Vertex AI and Gemini through a
common prefix.</li>
<li><code>k8s</code>: Make k8s Node and Pod labels optional (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2079"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/2079/hovercard">#2079</a>)</li>
<li><code>otel</code>: Rename span health metrics to remove the .count
suffixes (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1979"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/1979/hovercard">#1979</a>)</li>
</ul>
<h3>🚀 New components 🚀</h3>
<ul>
<li><code>db</code>: Adding semantic conventions for
<code>oracledb</code> instrumentations. (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2612">#2612</a>)<br>
Oracle Database semantic conventions.</li>
<li><code>browser</code>: Add browser web vitals event. (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1940"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/1940/hovercard">#1940</a>)</li>
</ul>
<h3>💡 Enhancements 💡</h3>
<ul>
<li><code>cicd</code>: Add resource conventions for CICD systems and
define spans for CICD pipeline runs. (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1713"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/1713/hovercard">#1713</a>)<br>
Define spans <code>cicd.pipeline.run.server</code> and
<code>cicd.pipeline.task.internal</code>.<br>
Add <code>cicd.pipeline.action.name</code>, <code>cicd.worker.id</code>,
<code>cicd.worker.name</code>, <code>cicd.worker.url.full</code>
and<code>cicd.pipeline.task.run.result</code> to attribute registry.<br>
Define resources <code>cicd.pipeline</code>,
<code>cicd.pipeline.run</code> and <code>cicd.worker</code>.<br>
Add entity associations in cicd metrics for these new cicd
resources.</li>
<li><code>vcs</code>: Add resource conventions for VCS systems and VCS
references. (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1713"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/1713/hovercard">#1713</a>)<br>
Define resources <code>vcs.repo</code> and <code>vcs.ref</code>.<br>
Add entity associations in vcs metrics for these new vcs resources.</li>
<li><code>gen-ai</code>: Adding span for invoke agent (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1842"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/1842/hovercard">#1842</a>)</li>
<li><code>gen-ai</code>: Adding gen_ai.tool.description to the span
attributes (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2087"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/2087/hovercard">#2087</a>)</li>
<li><code>gen-ai</code>: Separate inference and embeddings span
definitions, remove irrelevant attributes from the create agent span.
(<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1924"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/1924/hovercard">#1924</a>,
<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2122"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/2122/hovercard">#2122</a>)</li>
<li><code>general</code>: Provide guidance on modeling lat/lon, x/y, etc
(<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2145"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/2145/hovercard">#2145</a>)</li>
<li><code>db</code>: Move <code>db.query.parameter.&lt;key&gt;</code>
from release_candidate back to development. (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2194"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/2194/hovercard">#2194</a>)</li>
<li><code>db</code>: Mark database semantic conventions as stable for
MariaDB, Microsoft SQL Server, MySQL, and PostgreSQL. (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2199"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/2199/hovercard">#2199</a>)</li>
<li><code>db</code>: Make <code>db.operation.name</code> required where
it's available, add recommendation for instrumentation point. (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2200"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/2200/hovercard">#2200</a>,
<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2098"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/2098/hovercard">#2098</a>)</li>
<li><code>db</code>: Add <code>db.stored_procedure.name</code> to the
general span conventions (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2205"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/2205/hovercard">#2205</a>)</li>
<li><code>db</code>: Add an option to generate
<code>db.query.summary</code> from operation name and target, remove it
from CosmosDB. (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2206"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/2206/hovercard">#2206</a>)</li>
<li><code>db</code>: Add <code>db.operation.name</code> and
<code>db.collection.name</code> to SQL for higher-level APIs (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2207"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/2207/hovercard">#2207</a>)</li>
<li><code>jvm</code>: Add <code>jvm.file_descriptor.count</code> as an
in-development metric to track the number of open file descriptors as
reported by the JVM. (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1838"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/1838/hovercard">#1838</a>)</li>
<li><code>jvm</code>: Add <code>jvm.gc.cause</code> to metric
<code>jvm.gc.duration</code> as an opt-in attribute to track gc cause.
(<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2065"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/2065/hovercard">#2065</a>)</li>
<li><code>process</code>: Add process.environment_variable. (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/672"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/672/hovercard">#672</a>)</li>
<li><code>app</code>: Defines two new click events for the app domain
(<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2070"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/2070/hovercard">#2070</a>)</li>
<li><code>code</code>: Mark <code>code.*</code> semantic conventions as
stable (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1377"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/1377/hovercard">#1377</a>)</li>
<li><code>k8s</code>: Introduce semantic conventions for k8s CronJob
labels and annotations (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2138"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/2138/hovercard">#2138</a>)</li>
<li><code>k8s</code>: Introduce semantic conventions for k8s DaemonSet
labels and annotations (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2136"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/2136/hovercard">#2136</a>)</li>
<li><code>k8s</code>: Introduce semantic conventions for k8s Deployment
labels and annotations (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2134"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/2134/hovercard">#2134</a>)</li>
<li><code>system</code>: Added entity association template rendering and
policies. (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1276"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/1276/hovercard">#1276</a>)</li>
<li><code>gen_ai</code>: Document <code>generate_content</code> as a
permissible value of <code>gen_ai.operation.name</code>. (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2048"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/2048/hovercard">#2048</a>)</li>
<li><code>k8s</code>: Introduce semantic conventions for k8s Job labels
and annotations (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2137"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/2137/hovercard">#2137</a>)</li>
<li><code>otel</code>: Adds SDK self-monitoring metrics for metric
processing (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2016"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/2016/hovercard">#2016</a>)</li>
<li><code>k8s</code>: Introduce semantic conventions for k8s Namespace
labels and annotations (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2131"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/2131/hovercard">#2131</a>)</li>
<li><code>k8s</code>: Introduce semantic conventions for k8s Node labels
and annotations (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2079"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/2079/hovercard">#2079</a>)</li>
<li><code>k8s</code>: Introduce semantic conventions for k8s ReplicaSet
labels and annotations (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2132"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/2132/hovercard">#2132</a>)</li>
<li><code>otel</code>: Adds SDK self-monitoring metric for exporter call
duration (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1906"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/1906/hovercard">#1906</a>)</li>
<li><code>k8s</code>: Introduce semantic conventions for k8s StatefulSet
labels and annotations (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2135"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/2135/hovercard">#2135</a>)</li>
</ul>
<h3>🧰 Bug fixes 🧰</h3>
<ul>
<li><code>gen-ai</code>: Removed irrelevant response attributes on GenAI
create agent span. (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1924"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/1924/hovercard">#1924</a>,
<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2116"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/2116/hovercard">#2116</a>)</li>
<li><code>vcs</code>: Fix typo in gitea name (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2057"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/2057/hovercard">#2057</a>)</li>
<li><code>gen-ai</code>: Add invoke_agent as a member of
gen_ai.operation.name (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2160"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/2160/hovercard">#2160</a>)</li>
<li><code>db</code>: Clarify <code>db.query.summary</code> for stored
procedures (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2218"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/2218/hovercard">#2218</a>)</li>
</ul>
2025-05-22 07:56:01 -07:00

658 lines
24 KiB
Go

// Code generated from semantic convention specification. DO NOT EDIT.
// Package httpconv provides types and functionality for OpenTelemetry semantic
// conventions in the "messaging" namespace.
package messagingconv
import (
"context"
"sync"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/noop"
)
var (
addOptPool = &sync.Pool{New: func() any { return &[]metric.AddOption{} }}
recOptPool = &sync.Pool{New: func() any { return &[]metric.RecordOption{} }}
)
// ErrorTypeAttr is an attribute conforming to the error.type semantic
// conventions. It represents the describes a class of error the operation ended
// with.
type ErrorTypeAttr string
var (
// ErrorTypeOther is a fallback error value to be used when the instrumentation
// doesn't define a custom value.
ErrorTypeOther ErrorTypeAttr = "_OTHER"
)
// OperationTypeAttr is an attribute conforming to the messaging.operation.type
// semantic conventions. It represents a string identifying the type of the
// messaging operation.
type OperationTypeAttr string
var (
// OperationTypeCreate is a message is created. "Create" spans always refer to a
// single message and are used to provide a unique creation context for messages
// in batch sending scenarios.
OperationTypeCreate OperationTypeAttr = "create"
// OperationTypeSend is the one or more messages are provided for sending to an
// intermediary. If a single message is sent, the context of the "Send" span can
// be used as the creation context and no "Create" span needs to be created.
OperationTypeSend OperationTypeAttr = "send"
// OperationTypeReceive is the one or more messages are requested by a consumer.
// This operation refers to pull-based scenarios, where consumers explicitly
// call methods of messaging SDKs to receive messages.
OperationTypeReceive OperationTypeAttr = "receive"
// OperationTypeProcess is the one or more messages are processed by a consumer.
OperationTypeProcess OperationTypeAttr = "process"
// OperationTypeSettle is the one or more messages are settled.
OperationTypeSettle OperationTypeAttr = "settle"
)
// SystemAttr is an attribute conforming to the messaging.system semantic
// conventions. It represents the messaging system as identified by the client
// instrumentation.
type SystemAttr string
var (
// SystemActiveMQ is the apache ActiveMQ.
SystemActiveMQ SystemAttr = "activemq"
// SystemAWSSQS is the amazon Simple Queue Service (SQS).
SystemAWSSQS SystemAttr = "aws_sqs"
// SystemEventGrid is the azure Event Grid.
SystemEventGrid SystemAttr = "eventgrid"
// SystemEventHubs is the azure Event Hubs.
SystemEventHubs SystemAttr = "eventhubs"
// SystemServiceBus is the azure Service Bus.
SystemServiceBus SystemAttr = "servicebus"
// SystemGCPPubSub is the google Cloud Pub/Sub.
SystemGCPPubSub SystemAttr = "gcp_pubsub"
// SystemJMS is the java Message Service.
SystemJMS SystemAttr = "jms"
// SystemKafka is the apache Kafka.
SystemKafka SystemAttr = "kafka"
// SystemRabbitMQ is the rabbitMQ.
SystemRabbitMQ SystemAttr = "rabbitmq"
// SystemRocketMQ is the apache RocketMQ.
SystemRocketMQ SystemAttr = "rocketmq"
// SystemPulsar is the apache Pulsar.
SystemPulsar SystemAttr = "pulsar"
)
// ClientConsumedMessages is an instrument used to record metric values
// conforming to the "messaging.client.consumed.messages" semantic conventions.
// It represents the number of messages that were delivered to the application.
type ClientConsumedMessages struct {
metric.Int64Counter
}
// NewClientConsumedMessages returns a new ClientConsumedMessages instrument.
func NewClientConsumedMessages(
m metric.Meter,
opt ...metric.Int64CounterOption,
) (ClientConsumedMessages, error) {
// Check if the meter is nil.
if m == nil {
return ClientConsumedMessages{noop.Int64Counter{}}, nil
}
i, err := m.Int64Counter(
"messaging.client.consumed.messages",
append([]metric.Int64CounterOption{
metric.WithDescription("Number of messages that were delivered to the application."),
metric.WithUnit("{message}"),
}, opt...)...,
)
if err != nil {
return ClientConsumedMessages{noop.Int64Counter{}}, err
}
return ClientConsumedMessages{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ClientConsumedMessages) Inst() metric.Int64Counter {
return m.Int64Counter
}
// Name returns the semantic convention name of the instrument.
func (ClientConsumedMessages) Name() string {
return "messaging.client.consumed.messages"
}
// Unit returns the semantic convention unit of the instrument
func (ClientConsumedMessages) Unit() string {
return "{message}"
}
// Description returns the semantic convention description of the instrument
func (ClientConsumedMessages) Description() string {
return "Number of messages that were delivered to the application."
}
// Add adds incr to the existing count.
//
// The operationName is the the system-specific name of the messaging operation.
//
// The system is the the messaging system as identified by the client
// instrumentation.
//
// All additional attrs passed are included in the recorded value.
//
// 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) Add(
ctx context.Context,
incr int64,
operationName string,
system SystemAttr,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
append(
attrs,
attribute.String("messaging.operation.name", operationName),
attribute.String("messaging.system", string(system)),
)...,
),
)
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.
func (ClientConsumedMessages) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
return attribute.String("error.type", string(val))
}
// AttrConsumerGroupName returns an optional attribute for the
// "messaging.consumer.group.name" semantic convention. It represents the name of
// the consumer group with which a consumer is associated.
func (ClientConsumedMessages) AttrConsumerGroupName(val string) attribute.KeyValue {
return attribute.String("messaging.consumer.group.name", val)
}
// AttrDestinationName returns an optional attribute for the
// "messaging.destination.name" semantic convention. It represents the message
// destination name.
func (ClientConsumedMessages) AttrDestinationName(val string) attribute.KeyValue {
return attribute.String("messaging.destination.name", val)
}
// AttrDestinationSubscriptionName returns an optional attribute for the
// "messaging.destination.subscription.name" semantic convention. It represents
// the name of the destination subscription from which a message is consumed.
func (ClientConsumedMessages) AttrDestinationSubscriptionName(val string) attribute.KeyValue {
return attribute.String("messaging.destination.subscription.name", val)
}
// AttrDestinationTemplate returns an optional attribute for the
// "messaging.destination.template" semantic convention. It represents the low
// cardinality representation of the messaging destination name.
func (ClientConsumedMessages) AttrDestinationTemplate(val string) attribute.KeyValue {
return attribute.String("messaging.destination.template", val)
}
// AttrServerAddress returns an optional attribute for the "server.address"
// semantic convention. It represents the server domain name if available without
// reverse DNS lookup; otherwise, IP address or Unix domain socket name.
func (ClientConsumedMessages) AttrServerAddress(val string) attribute.KeyValue {
return attribute.String("server.address", val)
}
// AttrDestinationPartitionID returns an optional attribute for the
// "messaging.destination.partition.id" semantic convention. It represents the
// identifier of the partition messages are sent to or received from, unique
// within the `messaging.destination.name`.
func (ClientConsumedMessages) AttrDestinationPartitionID(val string) attribute.KeyValue {
return attribute.String("messaging.destination.partition.id", val)
}
// AttrServerPort returns an optional attribute for the "server.port" semantic
// convention. It represents the server port number.
func (ClientConsumedMessages) AttrServerPort(val int) attribute.KeyValue {
return attribute.Int("server.port", val)
}
// ClientOperationDuration is an instrument used to record metric values
// conforming to the "messaging.client.operation.duration" semantic conventions.
// It represents the duration of messaging operation initiated by a producer or
// consumer client.
type ClientOperationDuration struct {
metric.Float64Histogram
}
// NewClientOperationDuration returns a new ClientOperationDuration instrument.
func NewClientOperationDuration(
m metric.Meter,
opt ...metric.Float64HistogramOption,
) (ClientOperationDuration, error) {
// Check if the meter is nil.
if m == nil {
return ClientOperationDuration{noop.Float64Histogram{}}, nil
}
i, err := m.Float64Histogram(
"messaging.client.operation.duration",
append([]metric.Float64HistogramOption{
metric.WithDescription("Duration of messaging operation initiated by a producer or consumer client."),
metric.WithUnit("s"),
}, opt...)...,
)
if err != nil {
return ClientOperationDuration{noop.Float64Histogram{}}, err
}
return ClientOperationDuration{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ClientOperationDuration) Inst() metric.Float64Histogram {
return m.Float64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ClientOperationDuration) Name() string {
return "messaging.client.operation.duration"
}
// Unit returns the semantic convention unit of the instrument
func (ClientOperationDuration) Unit() string {
return "s"
}
// Description returns the semantic convention description of the instrument
func (ClientOperationDuration) Description() string {
return "Duration of messaging operation initiated by a producer or consumer client."
}
// Record records val to the current distribution.
//
// The operationName is the the system-specific name of the messaging operation.
//
// The system is the the messaging system as identified by the client
// instrumentation.
//
// All additional attrs passed are included in the recorded value.
//
// This metric SHOULD NOT be used to report processing duration - processing
// duration is reported in `messaging.process.duration` metric.
func (m ClientOperationDuration) Record(
ctx context.Context,
val float64,
operationName string,
system SystemAttr,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
append(
attrs,
attribute.String("messaging.operation.name", operationName),
attribute.String("messaging.system", string(system)),
)...,
),
)
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.
func (ClientOperationDuration) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
return attribute.String("error.type", string(val))
}
// AttrConsumerGroupName returns an optional attribute for the
// "messaging.consumer.group.name" semantic convention. It represents the name of
// the consumer group with which a consumer is associated.
func (ClientOperationDuration) AttrConsumerGroupName(val string) attribute.KeyValue {
return attribute.String("messaging.consumer.group.name", val)
}
// AttrDestinationName returns an optional attribute for the
// "messaging.destination.name" semantic convention. It represents the message
// destination name.
func (ClientOperationDuration) AttrDestinationName(val string) attribute.KeyValue {
return attribute.String("messaging.destination.name", val)
}
// AttrDestinationSubscriptionName returns an optional attribute for the
// "messaging.destination.subscription.name" semantic convention. It represents
// the name of the destination subscription from which a message is consumed.
func (ClientOperationDuration) AttrDestinationSubscriptionName(val string) attribute.KeyValue {
return attribute.String("messaging.destination.subscription.name", val)
}
// AttrDestinationTemplate returns an optional attribute for the
// "messaging.destination.template" semantic convention. It represents the low
// cardinality representation of the messaging destination name.
func (ClientOperationDuration) AttrDestinationTemplate(val string) attribute.KeyValue {
return attribute.String("messaging.destination.template", val)
}
// AttrOperationType returns an optional attribute for the
// "messaging.operation.type" semantic convention. It represents a string
// identifying the type of the messaging operation.
func (ClientOperationDuration) AttrOperationType(val OperationTypeAttr) attribute.KeyValue {
return attribute.String("messaging.operation.type", string(val))
}
// AttrServerAddress returns an optional attribute for the "server.address"
// semantic convention. It represents the server domain name if available without
// reverse DNS lookup; otherwise, IP address or Unix domain socket name.
func (ClientOperationDuration) AttrServerAddress(val string) attribute.KeyValue {
return attribute.String("server.address", val)
}
// AttrDestinationPartitionID returns an optional attribute for the
// "messaging.destination.partition.id" semantic convention. It represents the
// identifier of the partition messages are sent to or received from, unique
// within the `messaging.destination.name`.
func (ClientOperationDuration) AttrDestinationPartitionID(val string) attribute.KeyValue {
return attribute.String("messaging.destination.partition.id", val)
}
// AttrServerPort returns an optional attribute for the "server.port" semantic
// convention. It represents the server port number.
func (ClientOperationDuration) AttrServerPort(val int) attribute.KeyValue {
return attribute.Int("server.port", val)
}
// ClientSentMessages is an instrument used to record metric values conforming to
// the "messaging.client.sent.messages" semantic conventions. It represents the
// number of messages producer attempted to send to the broker.
type ClientSentMessages struct {
metric.Int64Counter
}
// NewClientSentMessages returns a new ClientSentMessages instrument.
func NewClientSentMessages(
m metric.Meter,
opt ...metric.Int64CounterOption,
) (ClientSentMessages, error) {
// Check if the meter is nil.
if m == nil {
return ClientSentMessages{noop.Int64Counter{}}, nil
}
i, err := m.Int64Counter(
"messaging.client.sent.messages",
append([]metric.Int64CounterOption{
metric.WithDescription("Number of messages producer attempted to send to the broker."),
metric.WithUnit("{message}"),
}, opt...)...,
)
if err != nil {
return ClientSentMessages{noop.Int64Counter{}}, err
}
return ClientSentMessages{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ClientSentMessages) Inst() metric.Int64Counter {
return m.Int64Counter
}
// Name returns the semantic convention name of the instrument.
func (ClientSentMessages) Name() string {
return "messaging.client.sent.messages"
}
// Unit returns the semantic convention unit of the instrument
func (ClientSentMessages) Unit() string {
return "{message}"
}
// Description returns the semantic convention description of the instrument
func (ClientSentMessages) Description() string {
return "Number of messages producer attempted to send to the broker."
}
// Add adds incr to the existing count.
//
// The operationName is the the system-specific name of the messaging operation.
//
// The system is the the messaging system as identified by the client
// instrumentation.
//
// All additional attrs passed are included in the recorded value.
//
// This metric MUST NOT count messages that were created but haven't yet been
// sent.
func (m ClientSentMessages) Add(
ctx context.Context,
incr int64,
operationName string,
system SystemAttr,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
append(
attrs,
attribute.String("messaging.operation.name", operationName),
attribute.String("messaging.system", string(system)),
)...,
),
)
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.
func (ClientSentMessages) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
return attribute.String("error.type", string(val))
}
// AttrDestinationName returns an optional attribute for the
// "messaging.destination.name" semantic convention. It represents the message
// destination name.
func (ClientSentMessages) AttrDestinationName(val string) attribute.KeyValue {
return attribute.String("messaging.destination.name", val)
}
// AttrDestinationTemplate returns an optional attribute for the
// "messaging.destination.template" semantic convention. It represents the low
// cardinality representation of the messaging destination name.
func (ClientSentMessages) AttrDestinationTemplate(val string) attribute.KeyValue {
return attribute.String("messaging.destination.template", val)
}
// AttrServerAddress returns an optional attribute for the "server.address"
// semantic convention. It represents the server domain name if available without
// reverse DNS lookup; otherwise, IP address or Unix domain socket name.
func (ClientSentMessages) AttrServerAddress(val string) attribute.KeyValue {
return attribute.String("server.address", val)
}
// AttrDestinationPartitionID returns an optional attribute for the
// "messaging.destination.partition.id" semantic convention. It represents the
// identifier of the partition messages are sent to or received from, unique
// within the `messaging.destination.name`.
func (ClientSentMessages) AttrDestinationPartitionID(val string) attribute.KeyValue {
return attribute.String("messaging.destination.partition.id", val)
}
// AttrServerPort returns an optional attribute for the "server.port" semantic
// convention. It represents the server port number.
func (ClientSentMessages) AttrServerPort(val int) attribute.KeyValue {
return attribute.Int("server.port", val)
}
// ProcessDuration is an instrument used to record metric values conforming to
// the "messaging.process.duration" semantic conventions. It represents the
// duration of processing operation.
type ProcessDuration struct {
metric.Float64Histogram
}
// NewProcessDuration returns a new ProcessDuration instrument.
func NewProcessDuration(
m metric.Meter,
opt ...metric.Float64HistogramOption,
) (ProcessDuration, error) {
// Check if the meter is nil.
if m == nil {
return ProcessDuration{noop.Float64Histogram{}}, nil
}
i, err := m.Float64Histogram(
"messaging.process.duration",
append([]metric.Float64HistogramOption{
metric.WithDescription("Duration of processing operation."),
metric.WithUnit("s"),
}, opt...)...,
)
if err != nil {
return ProcessDuration{noop.Float64Histogram{}}, err
}
return ProcessDuration{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ProcessDuration) Inst() metric.Float64Histogram {
return m.Float64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ProcessDuration) Name() string {
return "messaging.process.duration"
}
// Unit returns the semantic convention unit of the instrument
func (ProcessDuration) Unit() string {
return "s"
}
// Description returns the semantic convention description of the instrument
func (ProcessDuration) Description() string {
return "Duration of processing operation."
}
// Record records val to the current distribution.
//
// The operationName is the the system-specific name of the messaging operation.
//
// The system is the the messaging system as identified by the client
// instrumentation.
//
// All additional attrs passed are included in the recorded value.
//
// This metric MUST be reported for operations with `messaging.operation.type`
// that matches `process`.
func (m ProcessDuration) Record(
ctx context.Context,
val float64,
operationName string,
system SystemAttr,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
append(
attrs,
attribute.String("messaging.operation.name", operationName),
attribute.String("messaging.system", string(system)),
)...,
),
)
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.
func (ProcessDuration) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
return attribute.String("error.type", string(val))
}
// AttrConsumerGroupName returns an optional attribute for the
// "messaging.consumer.group.name" semantic convention. It represents the name of
// the consumer group with which a consumer is associated.
func (ProcessDuration) AttrConsumerGroupName(val string) attribute.KeyValue {
return attribute.String("messaging.consumer.group.name", val)
}
// AttrDestinationName returns an optional attribute for the
// "messaging.destination.name" semantic convention. It represents the message
// destination name.
func (ProcessDuration) AttrDestinationName(val string) attribute.KeyValue {
return attribute.String("messaging.destination.name", val)
}
// AttrDestinationSubscriptionName returns an optional attribute for the
// "messaging.destination.subscription.name" semantic convention. It represents
// the name of the destination subscription from which a message is consumed.
func (ProcessDuration) AttrDestinationSubscriptionName(val string) attribute.KeyValue {
return attribute.String("messaging.destination.subscription.name", val)
}
// AttrDestinationTemplate returns an optional attribute for the
// "messaging.destination.template" semantic convention. It represents the low
// cardinality representation of the messaging destination name.
func (ProcessDuration) AttrDestinationTemplate(val string) attribute.KeyValue {
return attribute.String("messaging.destination.template", val)
}
// AttrServerAddress returns an optional attribute for the "server.address"
// semantic convention. It represents the server domain name if available without
// reverse DNS lookup; otherwise, IP address or Unix domain socket name.
func (ProcessDuration) AttrServerAddress(val string) attribute.KeyValue {
return attribute.String("server.address", val)
}
// AttrDestinationPartitionID returns an optional attribute for the
// "messaging.destination.partition.id" semantic convention. It represents the
// identifier of the partition messages are sent to or received from, unique
// within the `messaging.destination.name`.
func (ProcessDuration) AttrDestinationPartitionID(val string) attribute.KeyValue {
return attribute.String("messaging.destination.partition.id", val)
}
// AttrServerPort returns an optional attribute for the "server.port" semantic
// convention. It represents the server port number.
func (ProcessDuration) AttrServerPort(val int) attribute.KeyValue {
return attribute.Int("server.port", val)
}