You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-08-10 22:31:50 +02:00
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.<key></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>
This commit is contained in:
@@ -8,6 +8,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- The `go.opentelemetry.io/otel/semconv/v1.33.0` package.
|
||||
The package contains semantic conventions from the `v1.33.0` version of the OpenTelemetry Semantic Conventions.
|
||||
See the [migration documentation](./semconv/v1.33.0/MIGRATION.md) for information on how to upgrade from `go.opentelemetry.io/otel/semconv/v1.32.0.`(#6799)
|
||||
|
||||
<!-- Released section -->
|
||||
<!-- Don't change this section unless doing release -->
|
||||
|
||||
|
13
semconv/v1.33.0/MIGRATION.md
Normal file
13
semconv/v1.33.0/MIGRATION.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# Semantic Convention Changes
|
||||
|
||||
The `go.opentelemetry.io/otel/semconv/v1.33.0` package should be a drop-in replacement for `go.opentelemetry.io/otel/semconv/v1.32.0` with the following exceptions.
|
||||
|
||||
## Dropped deprecations
|
||||
|
||||
The following declarations have been deprecated in the [OpenTelemetry Semantic Conventions].
|
||||
Refer to the respective documentation in that repository for deprecation instructions for each type.
|
||||
|
||||
- `FeatureFlagEvaluationErrorMessage`
|
||||
- `FeatureFlagEvaluationErrorMessageKey`
|
||||
|
||||
[OpenTelemetry Semantic Conventions]: https://github.com/open-telemetry/semantic-conventions
|
3
semconv/v1.33.0/README.md
Normal file
3
semconv/v1.33.0/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Semconv v1.33.0
|
||||
|
||||
[](https://pkg.go.dev/go.opentelemetry.io/otel/semconv/v1.33.0)
|
13567
semconv/v1.33.0/attribute_group.go
Normal file
13567
semconv/v1.33.0/attribute_group.go
Normal file
File diff suppressed because it is too large
Load Diff
287
semconv/v1.33.0/azureconv/metric.go
Normal file
287
semconv/v1.33.0/azureconv/metric.go
Normal file
@@ -0,0 +1,287 @@
|
||||
// Code generated from semantic convention specification. DO NOT EDIT.
|
||||
|
||||
// Package httpconv provides types and functionality for OpenTelemetry semantic
|
||||
// conventions in the "azure" namespace.
|
||||
package azureconv
|
||||
|
||||
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{} }}
|
||||
)
|
||||
|
||||
// CosmosDBConsistencyLevelAttr is an attribute conforming to the
|
||||
// azure.cosmosdb.consistency.level semantic conventions. It represents the
|
||||
// account or request [consistency level].
|
||||
//
|
||||
// [consistency level]: https://learn.microsoft.com/azure/cosmos-db/consistency-levels
|
||||
type CosmosDBConsistencyLevelAttr string
|
||||
|
||||
var (
|
||||
// CosmosDBConsistencyLevelStrong is the none.
|
||||
CosmosDBConsistencyLevelStrong CosmosDBConsistencyLevelAttr = "Strong"
|
||||
// CosmosDBConsistencyLevelBoundedStaleness is the none.
|
||||
CosmosDBConsistencyLevelBoundedStaleness CosmosDBConsistencyLevelAttr = "BoundedStaleness"
|
||||
// CosmosDBConsistencyLevelSession is the none.
|
||||
CosmosDBConsistencyLevelSession CosmosDBConsistencyLevelAttr = "Session"
|
||||
// CosmosDBConsistencyLevelEventual is the none.
|
||||
CosmosDBConsistencyLevelEventual CosmosDBConsistencyLevelAttr = "Eventual"
|
||||
// CosmosDBConsistencyLevelConsistentPrefix is the none.
|
||||
CosmosDBConsistencyLevelConsistentPrefix CosmosDBConsistencyLevelAttr = "ConsistentPrefix"
|
||||
)
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// CosmosDBClientActiveInstanceCount is an instrument used to record metric
|
||||
// values conforming to the "azure.cosmosdb.client.active_instance.count"
|
||||
// semantic conventions. It represents the number of active client instances.
|
||||
type CosmosDBClientActiveInstanceCount struct {
|
||||
metric.Int64UpDownCounter
|
||||
}
|
||||
|
||||
// NewCosmosDBClientActiveInstanceCount returns a new
|
||||
// CosmosDBClientActiveInstanceCount instrument.
|
||||
func NewCosmosDBClientActiveInstanceCount(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64UpDownCounterOption,
|
||||
) (CosmosDBClientActiveInstanceCount, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return CosmosDBClientActiveInstanceCount{noop.Int64UpDownCounter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64UpDownCounter(
|
||||
"azure.cosmosdb.client.active_instance.count",
|
||||
append([]metric.Int64UpDownCounterOption{
|
||||
metric.WithDescription("Number of active client instances"),
|
||||
metric.WithUnit("{instance}"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return CosmosDBClientActiveInstanceCount{noop.Int64UpDownCounter{}}, err
|
||||
}
|
||||
return CosmosDBClientActiveInstanceCount{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m CosmosDBClientActiveInstanceCount) Inst() metric.Int64UpDownCounter {
|
||||
return m.Int64UpDownCounter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (CosmosDBClientActiveInstanceCount) Name() string {
|
||||
return "azure.cosmosdb.client.active_instance.count"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (CosmosDBClientActiveInstanceCount) Unit() string {
|
||||
return "{instance}"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (CosmosDBClientActiveInstanceCount) Description() string {
|
||||
return "Number of active client instances"
|
||||
}
|
||||
|
||||
// Add adds incr to the existing count.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m CosmosDBClientActiveInstanceCount) Add(
|
||||
ctx context.Context,
|
||||
incr int64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(
|
||||
*o,
|
||||
metric.WithAttributes(
|
||||
attrs...,
|
||||
),
|
||||
)
|
||||
|
||||
m.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 {
|
||||
return attribute.Int("server.port", val)
|
||||
}
|
||||
|
||||
// AttrServerAddress returns an optional attribute for the "server.address"
|
||||
// semantic convention. It represents the name of the database host.
|
||||
func (CosmosDBClientActiveInstanceCount) AttrServerAddress(val string) attribute.KeyValue {
|
||||
return attribute.String("server.address", val)
|
||||
}
|
||||
|
||||
// CosmosDBClientOperationRequestCharge is an instrument used to record metric
|
||||
// values conforming to the "azure.cosmosdb.client.operation.request_charge"
|
||||
// semantic conventions. It represents the [Request units] consumed by the
|
||||
// operation.
|
||||
//
|
||||
// [Request units]: https://learn.microsoft.com/azure/cosmos-db/request-units
|
||||
type CosmosDBClientOperationRequestCharge struct {
|
||||
metric.Int64Histogram
|
||||
}
|
||||
|
||||
// NewCosmosDBClientOperationRequestCharge returns a new
|
||||
// CosmosDBClientOperationRequestCharge instrument.
|
||||
func NewCosmosDBClientOperationRequestCharge(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64HistogramOption,
|
||||
) (CosmosDBClientOperationRequestCharge, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return CosmosDBClientOperationRequestCharge{noop.Int64Histogram{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Histogram(
|
||||
"azure.cosmosdb.client.operation.request_charge",
|
||||
append([]metric.Int64HistogramOption{
|
||||
metric.WithDescription("[Request units](https://learn.microsoft.com/azure/cosmos-db/request-units) consumed by the operation"),
|
||||
metric.WithUnit("{request_unit}"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return CosmosDBClientOperationRequestCharge{noop.Int64Histogram{}}, err
|
||||
}
|
||||
return CosmosDBClientOperationRequestCharge{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m CosmosDBClientOperationRequestCharge) Inst() metric.Int64Histogram {
|
||||
return m.Int64Histogram
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (CosmosDBClientOperationRequestCharge) Name() string {
|
||||
return "azure.cosmosdb.client.operation.request_charge"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (CosmosDBClientOperationRequestCharge) Unit() string {
|
||||
return "{request_unit}"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
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.
|
||||
//
|
||||
// The dbOperationName is the the name of the operation or command being
|
||||
// executed.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m CosmosDBClientOperationRequestCharge) Record(
|
||||
ctx context.Context,
|
||||
val int64,
|
||||
dbOperationName string,
|
||||
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("db.operation.name", dbOperationName),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
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].
|
||||
//
|
||||
// [consistency level]: https://learn.microsoft.com/azure/cosmos-db/consistency-levels
|
||||
func (CosmosDBClientOperationRequestCharge) AttrCosmosDBConsistencyLevel(val CosmosDBConsistencyLevelAttr) attribute.KeyValue {
|
||||
return attribute.String("azure.cosmosdb.consistency.level", string(val))
|
||||
}
|
||||
|
||||
// AttrCosmosDBResponseSubStatusCode returns an optional attribute for the
|
||||
// "azure.cosmosdb.response.sub_status_code" semantic convention. It represents
|
||||
// the cosmos DB sub status code.
|
||||
func (CosmosDBClientOperationRequestCharge) AttrCosmosDBResponseSubStatusCode(val int) attribute.KeyValue {
|
||||
return attribute.Int("azure.cosmosdb.response.sub_status_code", val)
|
||||
}
|
||||
|
||||
// AttrDBCollectionName returns an optional attribute for the
|
||||
// "db.collection.name" semantic convention. It represents the cosmos DB
|
||||
// container name.
|
||||
func (CosmosDBClientOperationRequestCharge) AttrDBCollectionName(val string) attribute.KeyValue {
|
||||
return attribute.String("db.collection.name", val)
|
||||
}
|
||||
|
||||
// AttrDBNamespace returns an optional attribute for the "db.namespace" semantic
|
||||
// convention. It represents the name of the database, fully qualified within the
|
||||
// server address and port.
|
||||
func (CosmosDBClientOperationRequestCharge) AttrDBNamespace(val string) attribute.KeyValue {
|
||||
return attribute.String("db.namespace", val)
|
||||
}
|
||||
|
||||
// AttrDBResponseStatusCode returns an optional attribute for the
|
||||
// "db.response.status_code" semantic convention. It represents the database
|
||||
// response status code.
|
||||
func (CosmosDBClientOperationRequestCharge) AttrDBResponseStatusCode(val string) attribute.KeyValue {
|
||||
return attribute.String("db.response.status_code", val)
|
||||
}
|
||||
|
||||
// AttrErrorType returns an optional attribute for the "error.type" semantic
|
||||
// convention. It represents the describes a class of error the operation ended
|
||||
// with.
|
||||
func (CosmosDBClientOperationRequestCharge) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
|
||||
return attribute.String("error.type", string(val))
|
||||
}
|
||||
|
||||
// AttrServerPort returns an optional attribute for the "server.port" semantic
|
||||
// convention. It represents the server port number.
|
||||
func (CosmosDBClientOperationRequestCharge) AttrServerPort(val int) attribute.KeyValue {
|
||||
return attribute.Int("server.port", val)
|
||||
}
|
||||
|
||||
// AttrCosmosDBOperationContactedRegions returns an optional attribute for the
|
||||
// "azure.cosmosdb.operation.contacted_regions" semantic convention. It
|
||||
// represents the list of regions contacted during operation in the order that
|
||||
// they were contacted. If there is more than one region listed, it indicates
|
||||
// that the operation was performed on multiple regions i.e. cross-regional call.
|
||||
func (CosmosDBClientOperationRequestCharge) AttrCosmosDBOperationContactedRegions(val ...string) attribute.KeyValue {
|
||||
return attribute.StringSlice("azure.cosmosdb.operation.contacted_regions", val)
|
||||
}
|
||||
|
||||
// AttrServerAddress returns an optional attribute for the "server.address"
|
||||
// semantic convention. It represents the name of the database host.
|
||||
func (CosmosDBClientOperationRequestCharge) AttrServerAddress(val string) attribute.KeyValue {
|
||||
return attribute.String("server.address", val)
|
||||
}
|
523
semconv/v1.33.0/cicdconv/metric.go
Normal file
523
semconv/v1.33.0/cicdconv/metric.go
Normal file
@@ -0,0 +1,523 @@
|
||||
// Code generated from semantic convention specification. DO NOT EDIT.
|
||||
|
||||
// Package httpconv provides types and functionality for OpenTelemetry semantic
|
||||
// conventions in the "cicd" namespace.
|
||||
package cicdconv
|
||||
|
||||
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{} }}
|
||||
)
|
||||
|
||||
// PipelineResultAttr is an attribute conforming to the cicd.pipeline.result
|
||||
// semantic conventions. It represents the result of a pipeline run.
|
||||
type PipelineResultAttr string
|
||||
|
||||
var (
|
||||
// PipelineResultSuccess is the pipeline run finished successfully.
|
||||
PipelineResultSuccess PipelineResultAttr = "success"
|
||||
// PipelineResultFailure is the pipeline run did not finish successfully, eg.
|
||||
// due to a compile error or a failing test. Such failures are usually detected
|
||||
// by non-zero exit codes of the tools executed in the pipeline run.
|
||||
PipelineResultFailure PipelineResultAttr = "failure"
|
||||
// PipelineResultError is the pipeline run failed due to an error in the CICD
|
||||
// system, eg. due to the worker being killed.
|
||||
PipelineResultError PipelineResultAttr = "error"
|
||||
// PipelineResultTimeout is a timeout caused the pipeline run to be interrupted.
|
||||
PipelineResultTimeout PipelineResultAttr = "timeout"
|
||||
// PipelineResultCancellation is the pipeline run was cancelled, eg. by a user
|
||||
// manually cancelling the pipeline run.
|
||||
PipelineResultCancellation PipelineResultAttr = "cancellation"
|
||||
// PipelineResultSkip is the pipeline run was skipped, eg. due to a precondition
|
||||
// not being met.
|
||||
PipelineResultSkip PipelineResultAttr = "skip"
|
||||
)
|
||||
|
||||
// PipelineRunStateAttr is an attribute conforming to the cicd.pipeline.run.state
|
||||
// semantic conventions. It represents the pipeline run goes through these states
|
||||
// during its lifecycle.
|
||||
type PipelineRunStateAttr string
|
||||
|
||||
var (
|
||||
// PipelineRunStatePending is the run pending state spans from the event
|
||||
// triggering the pipeline run until the execution of the run starts (eg. time
|
||||
// spent in a queue, provisioning agents, creating run resources).
|
||||
PipelineRunStatePending PipelineRunStateAttr = "pending"
|
||||
// PipelineRunStateExecuting is the executing state spans the execution of any
|
||||
// run tasks (eg. build, test).
|
||||
PipelineRunStateExecuting PipelineRunStateAttr = "executing"
|
||||
// PipelineRunStateFinalizing is the finalizing state spans from when the run
|
||||
// has finished executing (eg. cleanup of run resources).
|
||||
PipelineRunStateFinalizing PipelineRunStateAttr = "finalizing"
|
||||
)
|
||||
|
||||
// WorkerStateAttr is an attribute conforming to the cicd.worker.state semantic
|
||||
// conventions. It represents the state of a CICD worker / agent.
|
||||
type WorkerStateAttr string
|
||||
|
||||
var (
|
||||
// WorkerStateAvailable is the worker is not performing work for the CICD
|
||||
// system. It is available to the CICD system to perform work on (online /
|
||||
// idle).
|
||||
WorkerStateAvailable WorkerStateAttr = "available"
|
||||
// WorkerStateBusy is the worker is performing work for the CICD system.
|
||||
WorkerStateBusy WorkerStateAttr = "busy"
|
||||
// WorkerStateOffline is the worker is not available to the CICD system
|
||||
// (disconnected / down).
|
||||
WorkerStateOffline WorkerStateAttr = "offline"
|
||||
)
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// PipelineRunActive is an instrument used to record metric values conforming to
|
||||
// the "cicd.pipeline.run.active" semantic conventions. It represents the number
|
||||
// of pipeline runs currently active in the system by state.
|
||||
type PipelineRunActive struct {
|
||||
metric.Int64UpDownCounter
|
||||
}
|
||||
|
||||
// NewPipelineRunActive returns a new PipelineRunActive instrument.
|
||||
func NewPipelineRunActive(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64UpDownCounterOption,
|
||||
) (PipelineRunActive, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return PipelineRunActive{noop.Int64UpDownCounter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64UpDownCounter(
|
||||
"cicd.pipeline.run.active",
|
||||
append([]metric.Int64UpDownCounterOption{
|
||||
metric.WithDescription("The number of pipeline runs currently active in the system by state."),
|
||||
metric.WithUnit("{run}"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return PipelineRunActive{noop.Int64UpDownCounter{}}, err
|
||||
}
|
||||
return PipelineRunActive{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m PipelineRunActive) Inst() metric.Int64UpDownCounter {
|
||||
return m.Int64UpDownCounter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (PipelineRunActive) Name() string {
|
||||
return "cicd.pipeline.run.active"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (PipelineRunActive) Unit() string {
|
||||
return "{run}"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (PipelineRunActive) Description() string {
|
||||
return "The number of pipeline runs currently active in the system by state."
|
||||
}
|
||||
|
||||
// Add adds incr to the existing count.
|
||||
//
|
||||
// The pipelineName is the the human readable name of the pipeline within a CI/CD
|
||||
// system.
|
||||
//
|
||||
// The pipelineRunState is the the pipeline run goes through these states during
|
||||
// its lifecycle.
|
||||
func (m PipelineRunActive) Add(
|
||||
ctx context.Context,
|
||||
incr int64,
|
||||
pipelineName string,
|
||||
pipelineRunState PipelineRunStateAttr,
|
||||
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("cicd.pipeline.name", pipelineName),
|
||||
attribute.String("cicd.pipeline.run.state", string(pipelineRunState)),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
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.
|
||||
type PipelineRunDuration struct {
|
||||
metric.Float64Histogram
|
||||
}
|
||||
|
||||
// NewPipelineRunDuration returns a new PipelineRunDuration instrument.
|
||||
func NewPipelineRunDuration(
|
||||
m metric.Meter,
|
||||
opt ...metric.Float64HistogramOption,
|
||||
) (PipelineRunDuration, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return PipelineRunDuration{noop.Float64Histogram{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Float64Histogram(
|
||||
"cicd.pipeline.run.duration",
|
||||
append([]metric.Float64HistogramOption{
|
||||
metric.WithDescription("Duration of a pipeline run grouped by pipeline, state and result."),
|
||||
metric.WithUnit("s"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return PipelineRunDuration{noop.Float64Histogram{}}, err
|
||||
}
|
||||
return PipelineRunDuration{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m PipelineRunDuration) Inst() metric.Float64Histogram {
|
||||
return m.Float64Histogram
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (PipelineRunDuration) Name() string {
|
||||
return "cicd.pipeline.run.duration"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (PipelineRunDuration) Unit() string {
|
||||
return "s"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (PipelineRunDuration) Description() string {
|
||||
return "Duration of a pipeline run grouped by pipeline, state and result."
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// The pipelineName is the the human readable name of the pipeline within a CI/CD
|
||||
// system.
|
||||
//
|
||||
// The pipelineRunState is the the pipeline run goes through these states during
|
||||
// its lifecycle.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m PipelineRunDuration) Record(
|
||||
ctx context.Context,
|
||||
val float64,
|
||||
pipelineName string,
|
||||
pipelineRunState PipelineRunStateAttr,
|
||||
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("cicd.pipeline.name", pipelineName),
|
||||
attribute.String("cicd.pipeline.run.state", string(pipelineRunState)),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
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.
|
||||
func (PipelineRunDuration) AttrPipelineResult(val PipelineResultAttr) attribute.KeyValue {
|
||||
return attribute.String("cicd.pipeline.result", string(val))
|
||||
}
|
||||
|
||||
// AttrErrorType returns an optional attribute for the "error.type" semantic
|
||||
// convention. It represents the describes a class of error the operation ended
|
||||
// with.
|
||||
func (PipelineRunDuration) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
|
||||
return attribute.String("error.type", string(val))
|
||||
}
|
||||
|
||||
// PipelineRunErrors is an instrument used to record metric values conforming to
|
||||
// the "cicd.pipeline.run.errors" semantic conventions. It represents the number
|
||||
// of errors encountered in pipeline runs (eg. compile, test failures).
|
||||
type PipelineRunErrors struct {
|
||||
metric.Int64Counter
|
||||
}
|
||||
|
||||
// NewPipelineRunErrors returns a new PipelineRunErrors instrument.
|
||||
func NewPipelineRunErrors(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64CounterOption,
|
||||
) (PipelineRunErrors, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return PipelineRunErrors{noop.Int64Counter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Counter(
|
||||
"cicd.pipeline.run.errors",
|
||||
append([]metric.Int64CounterOption{
|
||||
metric.WithDescription("The number of errors encountered in pipeline runs (eg. compile, test failures)."),
|
||||
metric.WithUnit("{error}"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return PipelineRunErrors{noop.Int64Counter{}}, err
|
||||
}
|
||||
return PipelineRunErrors{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m PipelineRunErrors) Inst() metric.Int64Counter {
|
||||
return m.Int64Counter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (PipelineRunErrors) Name() string {
|
||||
return "cicd.pipeline.run.errors"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (PipelineRunErrors) Unit() string {
|
||||
return "{error}"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (PipelineRunErrors) Description() string {
|
||||
return "The number of errors encountered in pipeline runs (eg. compile, test failures)."
|
||||
}
|
||||
|
||||
// Add adds incr to the existing count.
|
||||
//
|
||||
// The pipelineName is the the human readable name of the pipeline within a CI/CD
|
||||
// system.
|
||||
//
|
||||
// The errorType is the describes a class of error the operation ended with.
|
||||
//
|
||||
// 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) Add(
|
||||
ctx context.Context,
|
||||
incr int64,
|
||||
pipelineName string,
|
||||
errorType ErrorTypeAttr,
|
||||
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("cicd.pipeline.name", pipelineName),
|
||||
attribute.String("error.type", string(errorType)),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
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).
|
||||
type SystemErrors struct {
|
||||
metric.Int64Counter
|
||||
}
|
||||
|
||||
// NewSystemErrors returns a new SystemErrors instrument.
|
||||
func NewSystemErrors(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64CounterOption,
|
||||
) (SystemErrors, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return SystemErrors{noop.Int64Counter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Counter(
|
||||
"cicd.system.errors",
|
||||
append([]metric.Int64CounterOption{
|
||||
metric.WithDescription("The number of errors in a component of the CICD system (eg. controller, scheduler, agent)."),
|
||||
metric.WithUnit("{error}"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return SystemErrors{noop.Int64Counter{}}, err
|
||||
}
|
||||
return SystemErrors{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m SystemErrors) Inst() metric.Int64Counter {
|
||||
return m.Int64Counter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (SystemErrors) Name() string {
|
||||
return "cicd.system.errors"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (SystemErrors) Unit() string {
|
||||
return "{error}"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
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.
|
||||
//
|
||||
// The systemComponent is the the name of a component of the CICD system.
|
||||
//
|
||||
// The errorType is the describes a class of error the operation ended with.
|
||||
//
|
||||
// Errors in pipeline run execution are explicitly excluded. Ie a test failure is
|
||||
// not counted in this metric.
|
||||
func (m SystemErrors) Add(
|
||||
ctx context.Context,
|
||||
incr int64,
|
||||
systemComponent string,
|
||||
errorType ErrorTypeAttr,
|
||||
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("cicd.system.component", systemComponent),
|
||||
attribute.String("error.type", string(errorType)),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
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.
|
||||
type WorkerCount struct {
|
||||
metric.Int64UpDownCounter
|
||||
}
|
||||
|
||||
// NewWorkerCount returns a new WorkerCount instrument.
|
||||
func NewWorkerCount(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64UpDownCounterOption,
|
||||
) (WorkerCount, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return WorkerCount{noop.Int64UpDownCounter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64UpDownCounter(
|
||||
"cicd.worker.count",
|
||||
append([]metric.Int64UpDownCounterOption{
|
||||
metric.WithDescription("The number of workers on the CICD system by state."),
|
||||
metric.WithUnit("{count}"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return WorkerCount{noop.Int64UpDownCounter{}}, err
|
||||
}
|
||||
return WorkerCount{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m WorkerCount) Inst() metric.Int64UpDownCounter {
|
||||
return m.Int64UpDownCounter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (WorkerCount) Name() string {
|
||||
return "cicd.worker.count"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (WorkerCount) Unit() string {
|
||||
return "{count}"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (WorkerCount) Description() string {
|
||||
return "The number of workers on the CICD system by state."
|
||||
}
|
||||
|
||||
// Add adds incr to the existing count.
|
||||
//
|
||||
// The workerState is the the state of a CICD worker / agent.
|
||||
func (m WorkerCount) Add(
|
||||
ctx context.Context,
|
||||
incr int64,
|
||||
workerState WorkerStateAttr,
|
||||
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("cicd.worker.state", string(workerState)),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Int64UpDownCounter.Add(ctx, incr, *o...)
|
||||
}
|
553
semconv/v1.33.0/containerconv/metric.go
Normal file
553
semconv/v1.33.0/containerconv/metric.go
Normal file
@@ -0,0 +1,553 @@
|
||||
// Code generated from semantic convention specification. DO NOT EDIT.
|
||||
|
||||
// Package httpconv provides types and functionality for OpenTelemetry semantic
|
||||
// conventions in the "container" namespace.
|
||||
package containerconv
|
||||
|
||||
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{} }}
|
||||
)
|
||||
|
||||
// CPUModeAttr is an attribute conforming to the cpu.mode semantic conventions.
|
||||
// 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,
|
||||
// *or only* data points with `mode` labels.
|
||||
type CPUModeAttr string
|
||||
|
||||
var (
|
||||
// CPUModeUser is the none.
|
||||
CPUModeUser CPUModeAttr = "user"
|
||||
// CPUModeSystem is the none.
|
||||
CPUModeSystem CPUModeAttr = "system"
|
||||
// CPUModeNice is the none.
|
||||
CPUModeNice CPUModeAttr = "nice"
|
||||
// CPUModeIdle is the none.
|
||||
CPUModeIdle CPUModeAttr = "idle"
|
||||
// CPUModeIOWait is the none.
|
||||
CPUModeIOWait CPUModeAttr = "iowait"
|
||||
// CPUModeInterrupt is the none.
|
||||
CPUModeInterrupt CPUModeAttr = "interrupt"
|
||||
// CPUModeSteal is the none.
|
||||
CPUModeSteal CPUModeAttr = "steal"
|
||||
// CPUModeKernel is the none.
|
||||
CPUModeKernel CPUModeAttr = "kernel"
|
||||
)
|
||||
|
||||
// DiskIODirectionAttr is an attribute conforming to the disk.io.direction
|
||||
// semantic conventions. It represents the disk IO operation direction.
|
||||
type DiskIODirectionAttr string
|
||||
|
||||
var (
|
||||
// DiskIODirectionRead is the none.
|
||||
DiskIODirectionRead DiskIODirectionAttr = "read"
|
||||
// DiskIODirectionWrite is the none.
|
||||
DiskIODirectionWrite DiskIODirectionAttr = "write"
|
||||
)
|
||||
|
||||
// NetworkIODirectionAttr is an attribute conforming to the network.io.direction
|
||||
// semantic conventions. It represents the network IO operation direction.
|
||||
type NetworkIODirectionAttr string
|
||||
|
||||
var (
|
||||
// NetworkIODirectionTransmit is the none.
|
||||
NetworkIODirectionTransmit NetworkIODirectionAttr = "transmit"
|
||||
// NetworkIODirectionReceive is the none.
|
||||
NetworkIODirectionReceive NetworkIODirectionAttr = "receive"
|
||||
)
|
||||
|
||||
// CPUTime is an instrument used to record metric values conforming to the
|
||||
// "container.cpu.time" semantic conventions. It represents the total CPU time
|
||||
// consumed.
|
||||
type CPUTime struct {
|
||||
metric.Float64Counter
|
||||
}
|
||||
|
||||
// NewCPUTime returns a new CPUTime instrument.
|
||||
func NewCPUTime(
|
||||
m metric.Meter,
|
||||
opt ...metric.Float64CounterOption,
|
||||
) (CPUTime, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return CPUTime{noop.Float64Counter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Float64Counter(
|
||||
"container.cpu.time",
|
||||
append([]metric.Float64CounterOption{
|
||||
metric.WithDescription("Total CPU time consumed"),
|
||||
metric.WithUnit("s"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return CPUTime{noop.Float64Counter{}}, err
|
||||
}
|
||||
return CPUTime{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m CPUTime) Inst() metric.Float64Counter {
|
||||
return m.Float64Counter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (CPUTime) Name() string {
|
||||
return "container.cpu.time"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (CPUTime) Unit() string {
|
||||
return "s"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (CPUTime) Description() string {
|
||||
return "Total CPU time consumed"
|
||||
}
|
||||
|
||||
// Add adds incr to the existing count.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
//
|
||||
// Total CPU time consumed by the specific container on all available CPU cores
|
||||
func (m CPUTime) Add(
|
||||
ctx context.Context,
|
||||
incr float64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(
|
||||
*o,
|
||||
metric.WithAttributes(
|
||||
attrs...,
|
||||
),
|
||||
)
|
||||
|
||||
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,
|
||||
// *or only* data points with `mode` labels.
|
||||
func (CPUTime) AttrCPUMode(val CPUModeAttr) attribute.KeyValue {
|
||||
return attribute.String("cpu.mode", string(val))
|
||||
}
|
||||
|
||||
// CPUUsage is an instrument used to record metric values conforming to the
|
||||
// "container.cpu.usage" semantic conventions. It represents the container's CPU
|
||||
// usage, measured in cpus. Range from 0 to the number of allocatable CPUs.
|
||||
type CPUUsage struct {
|
||||
metric.Int64Gauge
|
||||
}
|
||||
|
||||
// NewCPUUsage returns a new CPUUsage instrument.
|
||||
func NewCPUUsage(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64GaugeOption,
|
||||
) (CPUUsage, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return CPUUsage{noop.Int64Gauge{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Gauge(
|
||||
"container.cpu.usage",
|
||||
append([]metric.Int64GaugeOption{
|
||||
metric.WithDescription("Container's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs"),
|
||||
metric.WithUnit("{cpu}"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return CPUUsage{noop.Int64Gauge{}}, err
|
||||
}
|
||||
return CPUUsage{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m CPUUsage) Inst() metric.Int64Gauge {
|
||||
return m.Int64Gauge
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (CPUUsage) Name() string {
|
||||
return "container.cpu.usage"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (CPUUsage) Unit() string {
|
||||
return "{cpu}"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
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.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
//
|
||||
// CPU usage of the specific container on all available CPU cores, averaged over
|
||||
// the sample window
|
||||
func (m CPUUsage) Record(
|
||||
ctx context.Context,
|
||||
val int64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(
|
||||
*o,
|
||||
metric.WithAttributes(
|
||||
attrs...,
|
||||
),
|
||||
)
|
||||
|
||||
m.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,
|
||||
// *or only* data points with `mode` labels.
|
||||
func (CPUUsage) AttrCPUMode(val CPUModeAttr) attribute.KeyValue {
|
||||
return attribute.String("cpu.mode", string(val))
|
||||
}
|
||||
|
||||
// DiskIO is an instrument used to record metric values conforming to the
|
||||
// "container.disk.io" semantic conventions. It represents the disk bytes for the
|
||||
// container.
|
||||
type DiskIO struct {
|
||||
metric.Int64Counter
|
||||
}
|
||||
|
||||
// NewDiskIO returns a new DiskIO instrument.
|
||||
func NewDiskIO(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64CounterOption,
|
||||
) (DiskIO, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return DiskIO{noop.Int64Counter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Counter(
|
||||
"container.disk.io",
|
||||
append([]metric.Int64CounterOption{
|
||||
metric.WithDescription("Disk bytes for the container."),
|
||||
metric.WithUnit("By"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return DiskIO{noop.Int64Counter{}}, err
|
||||
}
|
||||
return DiskIO{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m DiskIO) Inst() metric.Int64Counter {
|
||||
return m.Int64Counter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (DiskIO) Name() string {
|
||||
return "container.disk.io"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (DiskIO) Unit() string {
|
||||
return "By"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (DiskIO) Description() string {
|
||||
return "Disk bytes for the container."
|
||||
}
|
||||
|
||||
// Add adds incr to the existing count.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
//
|
||||
// The total number of bytes read/written successfully (aggregated from all
|
||||
// disks).
|
||||
func (m DiskIO) Add(
|
||||
ctx context.Context,
|
||||
incr int64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(
|
||||
*o,
|
||||
metric.WithAttributes(
|
||||
attrs...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Int64Counter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// 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 {
|
||||
return attribute.String("disk.io.direction", string(val))
|
||||
}
|
||||
|
||||
// AttrSystemDevice returns an optional attribute for the "system.device"
|
||||
// semantic convention. It represents the device identifier.
|
||||
func (DiskIO) AttrSystemDevice(val string) attribute.KeyValue {
|
||||
return attribute.String("system.device", val)
|
||||
}
|
||||
|
||||
// MemoryUsage is an instrument used to record metric values conforming to the
|
||||
// "container.memory.usage" semantic conventions. It represents the memory usage
|
||||
// of the container.
|
||||
type MemoryUsage struct {
|
||||
metric.Int64Counter
|
||||
}
|
||||
|
||||
// NewMemoryUsage returns a new MemoryUsage instrument.
|
||||
func NewMemoryUsage(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64CounterOption,
|
||||
) (MemoryUsage, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return MemoryUsage{noop.Int64Counter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Counter(
|
||||
"container.memory.usage",
|
||||
append([]metric.Int64CounterOption{
|
||||
metric.WithDescription("Memory usage of the container."),
|
||||
metric.WithUnit("By"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return MemoryUsage{noop.Int64Counter{}}, err
|
||||
}
|
||||
return MemoryUsage{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m MemoryUsage) Inst() metric.Int64Counter {
|
||||
return m.Int64Counter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (MemoryUsage) Name() string {
|
||||
return "container.memory.usage"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (MemoryUsage) Unit() string {
|
||||
return "By"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (MemoryUsage) Description() string {
|
||||
return "Memory usage of the container."
|
||||
}
|
||||
|
||||
// Add adds incr to the existing count.
|
||||
//
|
||||
// Memory usage of the container.
|
||||
func (m MemoryUsage) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
|
||||
if len(attrs) == 0 {
|
||||
m.Int64Counter.Add(ctx, incr)
|
||||
return
|
||||
}
|
||||
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributes(attrs...))
|
||||
m.Int64Counter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// 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.
|
||||
type NetworkIO struct {
|
||||
metric.Int64Counter
|
||||
}
|
||||
|
||||
// NewNetworkIO returns a new NetworkIO instrument.
|
||||
func NewNetworkIO(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64CounterOption,
|
||||
) (NetworkIO, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return NetworkIO{noop.Int64Counter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Counter(
|
||||
"container.network.io",
|
||||
append([]metric.Int64CounterOption{
|
||||
metric.WithDescription("Network bytes for the container."),
|
||||
metric.WithUnit("By"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return NetworkIO{noop.Int64Counter{}}, err
|
||||
}
|
||||
return NetworkIO{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m NetworkIO) Inst() metric.Int64Counter {
|
||||
return m.Int64Counter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (NetworkIO) Name() string {
|
||||
return "container.network.io"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (NetworkIO) Unit() string {
|
||||
return "By"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (NetworkIO) Description() string {
|
||||
return "Network bytes for the container."
|
||||
}
|
||||
|
||||
// Add adds incr to the existing count.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
//
|
||||
// The number of bytes sent/received on all network interfaces by the container.
|
||||
func (m NetworkIO) Add(
|
||||
ctx context.Context,
|
||||
incr int64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(
|
||||
*o,
|
||||
metric.WithAttributes(
|
||||
attrs...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Int64Counter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// AttrNetworkInterfaceName returns an optional attribute for the
|
||||
// "network.interface.name" semantic convention. It represents the network
|
||||
// interface name.
|
||||
func (NetworkIO) AttrNetworkInterfaceName(val string) attribute.KeyValue {
|
||||
return attribute.String("network.interface.name", val)
|
||||
}
|
||||
|
||||
// AttrNetworkIODirection returns an optional attribute for the
|
||||
// "network.io.direction" semantic convention. It represents the network IO
|
||||
// operation direction.
|
||||
func (NetworkIO) AttrNetworkIODirection(val NetworkIODirectionAttr) attribute.KeyValue {
|
||||
return attribute.String("network.io.direction", string(val))
|
||||
}
|
||||
|
||||
// Uptime is an instrument used to record metric values conforming to the
|
||||
// "container.uptime" semantic conventions. It represents the time the container
|
||||
// has been running.
|
||||
type Uptime struct {
|
||||
metric.Float64Gauge
|
||||
}
|
||||
|
||||
// NewUptime returns a new Uptime instrument.
|
||||
func NewUptime(
|
||||
m metric.Meter,
|
||||
opt ...metric.Float64GaugeOption,
|
||||
) (Uptime, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return Uptime{noop.Float64Gauge{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Float64Gauge(
|
||||
"container.uptime",
|
||||
append([]metric.Float64GaugeOption{
|
||||
metric.WithDescription("The time the container has been running"),
|
||||
metric.WithUnit("s"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return Uptime{noop.Float64Gauge{}}, err
|
||||
}
|
||||
return Uptime{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m Uptime) Inst() metric.Float64Gauge {
|
||||
return m.Float64Gauge
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (Uptime) Name() string {
|
||||
return "container.uptime"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (Uptime) Unit() string {
|
||||
return "s"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (Uptime) Description() string {
|
||||
return "The time the container has been running"
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// 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) Record(ctx context.Context, val float64, attrs ...attribute.KeyValue) {
|
||||
if len(attrs) == 0 {
|
||||
m.Float64Gauge.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributes(attrs...))
|
||||
m.Float64Gauge.Record(ctx, val, *o...)
|
||||
}
|
271
semconv/v1.33.0/cpuconv/metric.go
Normal file
271
semconv/v1.33.0/cpuconv/metric.go
Normal file
@@ -0,0 +1,271 @@
|
||||
// Code generated from semantic convention specification. DO NOT EDIT.
|
||||
|
||||
// Package httpconv provides types and functionality for OpenTelemetry semantic
|
||||
// conventions in the "cpu" namespace.
|
||||
package cpuconv
|
||||
|
||||
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{} }}
|
||||
)
|
||||
|
||||
// ModeAttr is an attribute conforming to the cpu.mode semantic conventions. It
|
||||
// represents the mode of the CPU.
|
||||
type ModeAttr string
|
||||
|
||||
var (
|
||||
// ModeUser is the none.
|
||||
ModeUser ModeAttr = "user"
|
||||
// ModeSystem is the none.
|
||||
ModeSystem ModeAttr = "system"
|
||||
// ModeNice is the none.
|
||||
ModeNice ModeAttr = "nice"
|
||||
// ModeIdle is the none.
|
||||
ModeIdle ModeAttr = "idle"
|
||||
// ModeIOWait is the none.
|
||||
ModeIOWait ModeAttr = "iowait"
|
||||
// ModeInterrupt is the none.
|
||||
ModeInterrupt ModeAttr = "interrupt"
|
||||
// ModeSteal is the none.
|
||||
ModeSteal ModeAttr = "steal"
|
||||
// ModeKernel is the none.
|
||||
ModeKernel ModeAttr = "kernel"
|
||||
)
|
||||
|
||||
// Frequency is an instrument used to record metric values conforming to the
|
||||
// "cpu.frequency" semantic conventions. It represents the operating frequency of
|
||||
// the logical CPU in Hertz.
|
||||
type Frequency struct {
|
||||
metric.Int64Gauge
|
||||
}
|
||||
|
||||
// NewFrequency returns a new Frequency instrument.
|
||||
func NewFrequency(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64GaugeOption,
|
||||
) (Frequency, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return Frequency{noop.Int64Gauge{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Gauge(
|
||||
"cpu.frequency",
|
||||
append([]metric.Int64GaugeOption{
|
||||
metric.WithDescription("Operating frequency of the logical CPU in Hertz."),
|
||||
metric.WithUnit("Hz"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return Frequency{noop.Int64Gauge{}}, err
|
||||
}
|
||||
return Frequency{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m Frequency) Inst() metric.Int64Gauge {
|
||||
return m.Int64Gauge
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (Frequency) Name() string {
|
||||
return "cpu.frequency"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (Frequency) Unit() string {
|
||||
return "Hz"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (Frequency) Description() string {
|
||||
return "Operating frequency of the logical CPU in Hertz."
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m Frequency) Record(
|
||||
ctx context.Context,
|
||||
val int64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(
|
||||
*o,
|
||||
metric.WithAttributes(
|
||||
attrs...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Int64Gauge.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// AttrLogicalNumber returns an optional attribute for the "cpu.logical_number"
|
||||
// semantic convention. It represents the logical CPU number [0..n-1].
|
||||
func (Frequency) AttrLogicalNumber(val int) attribute.KeyValue {
|
||||
return attribute.Int("cpu.logical_number", val)
|
||||
}
|
||||
|
||||
// Time is an instrument used to record metric values conforming to the
|
||||
// "cpu.time" semantic conventions. It represents the seconds each logical CPU
|
||||
// spent on each mode.
|
||||
type Time struct {
|
||||
metric.Float64ObservableCounter
|
||||
}
|
||||
|
||||
// NewTime returns a new Time instrument.
|
||||
func NewTime(
|
||||
m metric.Meter,
|
||||
opt ...metric.Float64ObservableCounterOption,
|
||||
) (Time, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return Time{noop.Float64ObservableCounter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Float64ObservableCounter(
|
||||
"cpu.time",
|
||||
append([]metric.Float64ObservableCounterOption{
|
||||
metric.WithDescription("Seconds each logical CPU spent on each mode"),
|
||||
metric.WithUnit("s"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return Time{noop.Float64ObservableCounter{}}, err
|
||||
}
|
||||
return Time{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m Time) Inst() metric.Float64ObservableCounter {
|
||||
return m.Float64ObservableCounter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (Time) Name() string {
|
||||
return "cpu.time"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (Time) Unit() string {
|
||||
return "s"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (Time) Description() string {
|
||||
return "Seconds each logical CPU spent on each mode"
|
||||
}
|
||||
|
||||
// AttrLogicalNumber returns an optional attribute for the "cpu.logical_number"
|
||||
// semantic convention. It represents the logical CPU number [0..n-1].
|
||||
func (Time) AttrLogicalNumber(val int) attribute.KeyValue {
|
||||
return attribute.Int("cpu.logical_number", val)
|
||||
}
|
||||
|
||||
// AttrMode returns an optional attribute for the "cpu.mode" semantic convention.
|
||||
// It represents the mode of the CPU.
|
||||
func (Time) AttrMode(val ModeAttr) attribute.KeyValue {
|
||||
return attribute.String("cpu.mode", string(val))
|
||||
}
|
||||
|
||||
// Utilization is an instrument used to record metric values conforming to the
|
||||
// "cpu.utilization" semantic conventions. It represents the 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.
|
||||
type Utilization struct {
|
||||
metric.Int64Gauge
|
||||
}
|
||||
|
||||
// NewUtilization returns a new Utilization instrument.
|
||||
func NewUtilization(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64GaugeOption,
|
||||
) (Utilization, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return Utilization{noop.Int64Gauge{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Gauge(
|
||||
"cpu.utilization",
|
||||
append([]metric.Int64GaugeOption{
|
||||
metric.WithDescription("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."),
|
||||
metric.WithUnit("1"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return Utilization{noop.Int64Gauge{}}, err
|
||||
}
|
||||
return Utilization{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m Utilization) Inst() metric.Int64Gauge {
|
||||
return m.Int64Gauge
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (Utilization) Name() string {
|
||||
return "cpu.utilization"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (Utilization) Unit() string {
|
||||
return "1"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (Utilization) 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.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m Utilization) Record(
|
||||
ctx context.Context,
|
||||
val int64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(
|
||||
*o,
|
||||
metric.WithAttributes(
|
||||
attrs...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Int64Gauge.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// AttrLogicalNumber returns an optional attribute for the "cpu.logical_number"
|
||||
// semantic convention. It represents the logical CPU number [0..n-1].
|
||||
func (Utilization) AttrLogicalNumber(val int) attribute.KeyValue {
|
||||
return attribute.Int("cpu.logical_number", val)
|
||||
}
|
||||
|
||||
// AttrMode returns an optional attribute for the "cpu.mode" semantic convention.
|
||||
// It represents the mode of the CPU.
|
||||
func (Utilization) AttrMode(val ModeAttr) attribute.KeyValue {
|
||||
return attribute.String("cpu.mode", string(val))
|
||||
}
|
1328
semconv/v1.33.0/dbconv/metric.go
Normal file
1328
semconv/v1.33.0/dbconv/metric.go
Normal file
File diff suppressed because it is too large
Load Diff
115
semconv/v1.33.0/dnsconv/metric.go
Normal file
115
semconv/v1.33.0/dnsconv/metric.go
Normal file
@@ -0,0 +1,115 @@
|
||||
// Code generated from semantic convention specification. DO NOT EDIT.
|
||||
|
||||
// Package httpconv provides types and functionality for OpenTelemetry semantic
|
||||
// conventions in the "dns" namespace.
|
||||
package dnsconv
|
||||
|
||||
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 the error the DNS lookup failed 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"
|
||||
)
|
||||
|
||||
// LookupDuration is an instrument used to record metric values conforming to the
|
||||
// "dns.lookup.duration" semantic conventions. It represents the measures the
|
||||
// time taken to perform a DNS lookup.
|
||||
type LookupDuration struct {
|
||||
metric.Float64Histogram
|
||||
}
|
||||
|
||||
// NewLookupDuration returns a new LookupDuration instrument.
|
||||
func NewLookupDuration(
|
||||
m metric.Meter,
|
||||
opt ...metric.Float64HistogramOption,
|
||||
) (LookupDuration, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return LookupDuration{noop.Float64Histogram{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Float64Histogram(
|
||||
"dns.lookup.duration",
|
||||
append([]metric.Float64HistogramOption{
|
||||
metric.WithDescription("Measures the time taken to perform a DNS lookup."),
|
||||
metric.WithUnit("s"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return LookupDuration{noop.Float64Histogram{}}, err
|
||||
}
|
||||
return LookupDuration{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m LookupDuration) Inst() metric.Float64Histogram {
|
||||
return m.Float64Histogram
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (LookupDuration) Name() string {
|
||||
return "dns.lookup.duration"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (LookupDuration) Unit() string {
|
||||
return "s"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (LookupDuration) Description() string {
|
||||
return "Measures the time taken to perform a DNS lookup."
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// The questionName is the the name being queried.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m LookupDuration) Record(
|
||||
ctx context.Context,
|
||||
val float64,
|
||||
questionName string,
|
||||
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("dns.question.name", questionName),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
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 {
|
||||
return attribute.String("error.type", string(val))
|
||||
}
|
9
semconv/v1.33.0/doc.go
Normal file
9
semconv/v1.33.0/doc.go
Normal file
@@ -0,0 +1,9 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Package semconv implements OpenTelemetry semantic conventions.
|
||||
//
|
||||
// OpenTelemetry semantic conventions are agreed standardized naming
|
||||
// patterns for OpenTelemetry things. This package represents the v1.33.0
|
||||
// version of the OpenTelemetry semantic conventions.
|
||||
package semconv // import "go.opentelemetry.io/otel/semconv/v1.33.0"
|
9
semconv/v1.33.0/exception.go
Normal file
9
semconv/v1.33.0/exception.go
Normal file
@@ -0,0 +1,9 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package semconv // import "go.opentelemetry.io/otel/semconv/v1.33.0"
|
||||
|
||||
const (
|
||||
// ExceptionEventName is the name of the Span event representing an exception.
|
||||
ExceptionEventName = "exception"
|
||||
)
|
768
semconv/v1.33.0/faasconv/metric.go
Normal file
768
semconv/v1.33.0/faasconv/metric.go
Normal file
@@ -0,0 +1,768 @@
|
||||
// Code generated from semantic convention specification. DO NOT EDIT.
|
||||
|
||||
// Package httpconv provides types and functionality for OpenTelemetry semantic
|
||||
// conventions in the "faas" namespace.
|
||||
package faasconv
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/noop"
|
||||
)
|
||||
|
||||
var (
|
||||
addOptPool = &sync.Pool{New: func() any { return &[]metric.AddOption{} }}
|
||||
recOptPool = &sync.Pool{New: func() any { return &[]metric.RecordOption{} }}
|
||||
)
|
||||
|
||||
// TriggerAttr is an attribute conforming to the faas.trigger semantic
|
||||
// conventions. It represents the type of the trigger which caused this function
|
||||
// invocation.
|
||||
type TriggerAttr string
|
||||
|
||||
var (
|
||||
// TriggerDatasource is a response to some data source operation such as a
|
||||
// database or filesystem read/write.
|
||||
TriggerDatasource TriggerAttr = "datasource"
|
||||
// TriggerHTTP is the to provide an answer to an inbound HTTP request.
|
||||
TriggerHTTP TriggerAttr = "http"
|
||||
// TriggerPubSub is a function is set to be executed when messages are sent to a
|
||||
// messaging system.
|
||||
TriggerPubSub TriggerAttr = "pubsub"
|
||||
// TriggerTimer is a function is scheduled to be executed regularly.
|
||||
TriggerTimer TriggerAttr = "timer"
|
||||
// TriggerOther is the if none of the others apply.
|
||||
TriggerOther TriggerAttr = "other"
|
||||
)
|
||||
|
||||
// Coldstarts is an instrument used to record metric values conforming to the
|
||||
// "faas.coldstarts" semantic conventions. It represents the number of invocation
|
||||
// cold starts.
|
||||
type Coldstarts struct {
|
||||
metric.Int64Counter
|
||||
}
|
||||
|
||||
// NewColdstarts returns a new Coldstarts instrument.
|
||||
func NewColdstarts(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64CounterOption,
|
||||
) (Coldstarts, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return Coldstarts{noop.Int64Counter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Counter(
|
||||
"faas.coldstarts",
|
||||
append([]metric.Int64CounterOption{
|
||||
metric.WithDescription("Number of invocation cold starts"),
|
||||
metric.WithUnit("{coldstart}"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return Coldstarts{noop.Int64Counter{}}, err
|
||||
}
|
||||
return Coldstarts{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m Coldstarts) Inst() metric.Int64Counter {
|
||||
return m.Int64Counter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (Coldstarts) Name() string {
|
||||
return "faas.coldstarts"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (Coldstarts) Unit() string {
|
||||
return "{coldstart}"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (Coldstarts) Description() string {
|
||||
return "Number of invocation cold starts"
|
||||
}
|
||||
|
||||
// Add adds incr to the existing count.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m Coldstarts) Add(
|
||||
ctx context.Context,
|
||||
incr int64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(
|
||||
*o,
|
||||
metric.WithAttributes(
|
||||
attrs...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Int64Counter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
|
||||
// convention. It represents the type of the trigger which caused this function
|
||||
// invocation.
|
||||
func (Coldstarts) AttrTrigger(val TriggerAttr) attribute.KeyValue {
|
||||
return attribute.String("faas.trigger", string(val))
|
||||
}
|
||||
|
||||
// CPUUsage is an instrument used to record metric values conforming to the
|
||||
// "faas.cpu_usage" semantic conventions. It represents the distribution of CPU
|
||||
// usage per invocation.
|
||||
type CPUUsage struct {
|
||||
metric.Float64Histogram
|
||||
}
|
||||
|
||||
// NewCPUUsage returns a new CPUUsage instrument.
|
||||
func NewCPUUsage(
|
||||
m metric.Meter,
|
||||
opt ...metric.Float64HistogramOption,
|
||||
) (CPUUsage, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return CPUUsage{noop.Float64Histogram{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Float64Histogram(
|
||||
"faas.cpu_usage",
|
||||
append([]metric.Float64HistogramOption{
|
||||
metric.WithDescription("Distribution of CPU usage per invocation"),
|
||||
metric.WithUnit("s"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return CPUUsage{noop.Float64Histogram{}}, err
|
||||
}
|
||||
return CPUUsage{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m CPUUsage) Inst() metric.Float64Histogram {
|
||||
return m.Float64Histogram
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (CPUUsage) Name() string {
|
||||
return "faas.cpu_usage"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (CPUUsage) Unit() string {
|
||||
return "s"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (CPUUsage) Description() string {
|
||||
return "Distribution of CPU usage per invocation"
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m CPUUsage) Record(
|
||||
ctx context.Context,
|
||||
val float64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(
|
||||
*o,
|
||||
metric.WithAttributes(
|
||||
attrs...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Float64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
|
||||
// convention. It represents the type of the trigger which caused this function
|
||||
// invocation.
|
||||
func (CPUUsage) AttrTrigger(val TriggerAttr) attribute.KeyValue {
|
||||
return attribute.String("faas.trigger", string(val))
|
||||
}
|
||||
|
||||
// Errors is an instrument used to record metric values conforming to the
|
||||
// "faas.errors" semantic conventions. It represents the number of invocation
|
||||
// errors.
|
||||
type Errors struct {
|
||||
metric.Int64Counter
|
||||
}
|
||||
|
||||
// NewErrors returns a new Errors instrument.
|
||||
func NewErrors(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64CounterOption,
|
||||
) (Errors, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return Errors{noop.Int64Counter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Counter(
|
||||
"faas.errors",
|
||||
append([]metric.Int64CounterOption{
|
||||
metric.WithDescription("Number of invocation errors"),
|
||||
metric.WithUnit("{error}"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return Errors{noop.Int64Counter{}}, err
|
||||
}
|
||||
return Errors{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m Errors) Inst() metric.Int64Counter {
|
||||
return m.Int64Counter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (Errors) Name() string {
|
||||
return "faas.errors"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (Errors) Unit() string {
|
||||
return "{error}"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (Errors) Description() string {
|
||||
return "Number of invocation errors"
|
||||
}
|
||||
|
||||
// Add adds incr to the existing count.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m Errors) Add(
|
||||
ctx context.Context,
|
||||
incr int64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(
|
||||
*o,
|
||||
metric.WithAttributes(
|
||||
attrs...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Int64Counter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
|
||||
// convention. It represents the type of the trigger which caused this function
|
||||
// invocation.
|
||||
func (Errors) AttrTrigger(val TriggerAttr) attribute.KeyValue {
|
||||
return attribute.String("faas.trigger", string(val))
|
||||
}
|
||||
|
||||
// InitDuration is an instrument used to record metric values conforming to the
|
||||
// "faas.init_duration" semantic conventions. It represents the measures the
|
||||
// duration of the function's initialization, such as a cold start.
|
||||
type InitDuration struct {
|
||||
metric.Float64Histogram
|
||||
}
|
||||
|
||||
// NewInitDuration returns a new InitDuration instrument.
|
||||
func NewInitDuration(
|
||||
m metric.Meter,
|
||||
opt ...metric.Float64HistogramOption,
|
||||
) (InitDuration, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return InitDuration{noop.Float64Histogram{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Float64Histogram(
|
||||
"faas.init_duration",
|
||||
append([]metric.Float64HistogramOption{
|
||||
metric.WithDescription("Measures the duration of the function's initialization, such as a cold start"),
|
||||
metric.WithUnit("s"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return InitDuration{noop.Float64Histogram{}}, err
|
||||
}
|
||||
return InitDuration{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m InitDuration) Inst() metric.Float64Histogram {
|
||||
return m.Float64Histogram
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (InitDuration) Name() string {
|
||||
return "faas.init_duration"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (InitDuration) Unit() string {
|
||||
return "s"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (InitDuration) Description() string {
|
||||
return "Measures the duration of the function's initialization, such as a cold start"
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m InitDuration) Record(
|
||||
ctx context.Context,
|
||||
val float64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(
|
||||
*o,
|
||||
metric.WithAttributes(
|
||||
attrs...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Float64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
|
||||
// convention. It represents the type of the trigger which caused this function
|
||||
// invocation.
|
||||
func (InitDuration) AttrTrigger(val TriggerAttr) attribute.KeyValue {
|
||||
return attribute.String("faas.trigger", string(val))
|
||||
}
|
||||
|
||||
// Invocations is an instrument used to record metric values conforming to the
|
||||
// "faas.invocations" semantic conventions. It represents the number of
|
||||
// successful invocations.
|
||||
type Invocations struct {
|
||||
metric.Int64Counter
|
||||
}
|
||||
|
||||
// NewInvocations returns a new Invocations instrument.
|
||||
func NewInvocations(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64CounterOption,
|
||||
) (Invocations, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return Invocations{noop.Int64Counter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Counter(
|
||||
"faas.invocations",
|
||||
append([]metric.Int64CounterOption{
|
||||
metric.WithDescription("Number of successful invocations"),
|
||||
metric.WithUnit("{invocation}"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return Invocations{noop.Int64Counter{}}, err
|
||||
}
|
||||
return Invocations{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m Invocations) Inst() metric.Int64Counter {
|
||||
return m.Int64Counter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (Invocations) Name() string {
|
||||
return "faas.invocations"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (Invocations) Unit() string {
|
||||
return "{invocation}"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (Invocations) Description() string {
|
||||
return "Number of successful invocations"
|
||||
}
|
||||
|
||||
// Add adds incr to the existing count.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m Invocations) Add(
|
||||
ctx context.Context,
|
||||
incr int64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(
|
||||
*o,
|
||||
metric.WithAttributes(
|
||||
attrs...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Int64Counter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
|
||||
// convention. It represents the type of the trigger which caused this function
|
||||
// invocation.
|
||||
func (Invocations) AttrTrigger(val TriggerAttr) attribute.KeyValue {
|
||||
return attribute.String("faas.trigger", string(val))
|
||||
}
|
||||
|
||||
// InvokeDuration is an instrument used to record metric values conforming to the
|
||||
// "faas.invoke_duration" semantic conventions. It represents the measures the
|
||||
// duration of the function's logic execution.
|
||||
type InvokeDuration struct {
|
||||
metric.Float64Histogram
|
||||
}
|
||||
|
||||
// NewInvokeDuration returns a new InvokeDuration instrument.
|
||||
func NewInvokeDuration(
|
||||
m metric.Meter,
|
||||
opt ...metric.Float64HistogramOption,
|
||||
) (InvokeDuration, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return InvokeDuration{noop.Float64Histogram{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Float64Histogram(
|
||||
"faas.invoke_duration",
|
||||
append([]metric.Float64HistogramOption{
|
||||
metric.WithDescription("Measures the duration of the function's logic execution"),
|
||||
metric.WithUnit("s"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return InvokeDuration{noop.Float64Histogram{}}, err
|
||||
}
|
||||
return InvokeDuration{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m InvokeDuration) Inst() metric.Float64Histogram {
|
||||
return m.Float64Histogram
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (InvokeDuration) Name() string {
|
||||
return "faas.invoke_duration"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (InvokeDuration) Unit() string {
|
||||
return "s"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (InvokeDuration) Description() string {
|
||||
return "Measures the duration of the function's logic execution"
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m InvokeDuration) Record(
|
||||
ctx context.Context,
|
||||
val float64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(
|
||||
*o,
|
||||
metric.WithAttributes(
|
||||
attrs...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Float64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
|
||||
// convention. It represents the type of the trigger which caused this function
|
||||
// invocation.
|
||||
func (InvokeDuration) AttrTrigger(val TriggerAttr) attribute.KeyValue {
|
||||
return attribute.String("faas.trigger", string(val))
|
||||
}
|
||||
|
||||
// MemUsage is an instrument used to record metric values conforming to the
|
||||
// "faas.mem_usage" semantic conventions. It represents the distribution of max
|
||||
// memory usage per invocation.
|
||||
type MemUsage struct {
|
||||
metric.Int64Histogram
|
||||
}
|
||||
|
||||
// NewMemUsage returns a new MemUsage instrument.
|
||||
func NewMemUsage(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64HistogramOption,
|
||||
) (MemUsage, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return MemUsage{noop.Int64Histogram{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Histogram(
|
||||
"faas.mem_usage",
|
||||
append([]metric.Int64HistogramOption{
|
||||
metric.WithDescription("Distribution of max memory usage per invocation"),
|
||||
metric.WithUnit("By"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return MemUsage{noop.Int64Histogram{}}, err
|
||||
}
|
||||
return MemUsage{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m MemUsage) Inst() metric.Int64Histogram {
|
||||
return m.Int64Histogram
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (MemUsage) Name() string {
|
||||
return "faas.mem_usage"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (MemUsage) Unit() string {
|
||||
return "By"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (MemUsage) Description() string {
|
||||
return "Distribution of max memory usage per invocation"
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m MemUsage) Record(
|
||||
ctx context.Context,
|
||||
val int64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(
|
||||
*o,
|
||||
metric.WithAttributes(
|
||||
attrs...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Int64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
|
||||
// convention. It represents the type of the trigger which caused this function
|
||||
// invocation.
|
||||
func (MemUsage) AttrTrigger(val TriggerAttr) attribute.KeyValue {
|
||||
return attribute.String("faas.trigger", string(val))
|
||||
}
|
||||
|
||||
// NetIO is an instrument used to record metric values conforming to the
|
||||
// "faas.net_io" semantic conventions. It represents the distribution of net I/O
|
||||
// usage per invocation.
|
||||
type NetIO struct {
|
||||
metric.Int64Histogram
|
||||
}
|
||||
|
||||
// NewNetIO returns a new NetIO instrument.
|
||||
func NewNetIO(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64HistogramOption,
|
||||
) (NetIO, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return NetIO{noop.Int64Histogram{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Histogram(
|
||||
"faas.net_io",
|
||||
append([]metric.Int64HistogramOption{
|
||||
metric.WithDescription("Distribution of net I/O usage per invocation"),
|
||||
metric.WithUnit("By"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return NetIO{noop.Int64Histogram{}}, err
|
||||
}
|
||||
return NetIO{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m NetIO) Inst() metric.Int64Histogram {
|
||||
return m.Int64Histogram
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (NetIO) Name() string {
|
||||
return "faas.net_io"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (NetIO) Unit() string {
|
||||
return "By"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (NetIO) Description() string {
|
||||
return "Distribution of net I/O usage per invocation"
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m NetIO) Record(
|
||||
ctx context.Context,
|
||||
val int64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(
|
||||
*o,
|
||||
metric.WithAttributes(
|
||||
attrs...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Int64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
|
||||
// convention. It represents the type of the trigger which caused this function
|
||||
// invocation.
|
||||
func (NetIO) AttrTrigger(val TriggerAttr) attribute.KeyValue {
|
||||
return attribute.String("faas.trigger", string(val))
|
||||
}
|
||||
|
||||
// Timeouts is an instrument used to record metric values conforming to the
|
||||
// "faas.timeouts" semantic conventions. It represents the number of invocation
|
||||
// timeouts.
|
||||
type Timeouts struct {
|
||||
metric.Int64Counter
|
||||
}
|
||||
|
||||
// NewTimeouts returns a new Timeouts instrument.
|
||||
func NewTimeouts(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64CounterOption,
|
||||
) (Timeouts, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return Timeouts{noop.Int64Counter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Counter(
|
||||
"faas.timeouts",
|
||||
append([]metric.Int64CounterOption{
|
||||
metric.WithDescription("Number of invocation timeouts"),
|
||||
metric.WithUnit("{timeout}"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return Timeouts{noop.Int64Counter{}}, err
|
||||
}
|
||||
return Timeouts{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m Timeouts) Inst() metric.Int64Counter {
|
||||
return m.Int64Counter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (Timeouts) Name() string {
|
||||
return "faas.timeouts"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (Timeouts) Unit() string {
|
||||
return "{timeout}"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (Timeouts) Description() string {
|
||||
return "Number of invocation timeouts"
|
||||
}
|
||||
|
||||
// Add adds incr to the existing count.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m Timeouts) Add(
|
||||
ctx context.Context,
|
||||
incr int64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(
|
||||
*o,
|
||||
metric.WithAttributes(
|
||||
attrs...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Int64Counter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
|
||||
// convention. It represents the type of the trigger which caused this function
|
||||
// invocation.
|
||||
func (Timeouts) AttrTrigger(val TriggerAttr) attribute.KeyValue {
|
||||
return attribute.String("faas.trigger", string(val))
|
||||
}
|
687
semconv/v1.33.0/genaiconv/metric.go
Normal file
687
semconv/v1.33.0/genaiconv/metric.go
Normal file
@@ -0,0 +1,687 @@
|
||||
// Code generated from semantic convention specification. DO NOT EDIT.
|
||||
|
||||
// Package httpconv provides types and functionality for OpenTelemetry semantic
|
||||
// conventions in the "gen_ai" namespace.
|
||||
package genaiconv
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
// OperationNameAttr is an attribute conforming to the gen_ai.operation.name
|
||||
// semantic conventions. It represents the name of the operation being performed.
|
||||
type OperationNameAttr string
|
||||
|
||||
var (
|
||||
// OperationNameChat is the chat completion operation such as [OpenAI Chat API]
|
||||
// .
|
||||
//
|
||||
// [OpenAI Chat API]: https://platform.openai.com/docs/api-reference/chat
|
||||
OperationNameChat OperationNameAttr = "chat"
|
||||
// OperationNameGenerateContent is the multimodal content generation operation
|
||||
// such as [Gemini Generate Content].
|
||||
//
|
||||
// [Gemini Generate Content]: https://ai.google.dev/api/generate-content
|
||||
OperationNameGenerateContent OperationNameAttr = "generate_content"
|
||||
// OperationNameTextCompletion is the text completions operation such as
|
||||
// [OpenAI Completions API (Legacy)].
|
||||
//
|
||||
// [OpenAI Completions API (Legacy)]: https://platform.openai.com/docs/api-reference/completions
|
||||
OperationNameTextCompletion OperationNameAttr = "text_completion"
|
||||
// OperationNameEmbeddings is the embeddings operation such as
|
||||
// [OpenAI Create embeddings API].
|
||||
//
|
||||
// [OpenAI Create embeddings API]: https://platform.openai.com/docs/api-reference/embeddings/create
|
||||
OperationNameEmbeddings OperationNameAttr = "embeddings"
|
||||
// OperationNameCreateAgent is the create GenAI agent.
|
||||
OperationNameCreateAgent OperationNameAttr = "create_agent"
|
||||
// OperationNameInvokeAgent is the invoke GenAI agent.
|
||||
OperationNameInvokeAgent OperationNameAttr = "invoke_agent"
|
||||
// OperationNameExecuteTool is the execute a tool.
|
||||
OperationNameExecuteTool OperationNameAttr = "execute_tool"
|
||||
)
|
||||
|
||||
// SystemAttr is an attribute conforming to the gen_ai.system semantic
|
||||
// conventions. It represents the Generative AI product as identified by the
|
||||
// client or server instrumentation.
|
||||
type SystemAttr string
|
||||
|
||||
var (
|
||||
// SystemOpenAI is the openAI.
|
||||
SystemOpenAI SystemAttr = "openai"
|
||||
// SystemGCPGenAI is the any Google generative AI endpoint.
|
||||
SystemGCPGenAI SystemAttr = "gcp.gen_ai"
|
||||
// SystemGCPVertexAI is the vertex AI.
|
||||
SystemGCPVertexAI SystemAttr = "gcp.vertex_ai"
|
||||
// SystemGCPGemini is the gemini.
|
||||
SystemGCPGemini SystemAttr = "gcp.gemini"
|
||||
// SystemAnthropic is the anthropic.
|
||||
SystemAnthropic SystemAttr = "anthropic"
|
||||
// SystemCohere is the cohere.
|
||||
SystemCohere SystemAttr = "cohere"
|
||||
// SystemAzAIInference is the azure AI Inference.
|
||||
SystemAzAIInference SystemAttr = "az.ai.inference"
|
||||
// SystemAzAIOpenAI is the azure OpenAI.
|
||||
SystemAzAIOpenAI SystemAttr = "az.ai.openai"
|
||||
// SystemIBMWatsonxAI is the IBM Watsonx AI.
|
||||
SystemIBMWatsonxAI SystemAttr = "ibm.watsonx.ai"
|
||||
// SystemAWSBedrock is the AWS Bedrock.
|
||||
SystemAWSBedrock SystemAttr = "aws.bedrock"
|
||||
// SystemPerplexity is the perplexity.
|
||||
SystemPerplexity SystemAttr = "perplexity"
|
||||
// SystemXai is the xAI.
|
||||
SystemXai SystemAttr = "xai"
|
||||
// SystemDeepseek is the deepSeek.
|
||||
SystemDeepseek SystemAttr = "deepseek"
|
||||
// SystemGroq is the groq.
|
||||
SystemGroq SystemAttr = "groq"
|
||||
// SystemMistralAI is the mistral AI.
|
||||
SystemMistralAI SystemAttr = "mistral_ai"
|
||||
)
|
||||
|
||||
// TokenTypeAttr is an attribute conforming to the gen_ai.token.type semantic
|
||||
// conventions. It represents the type of token being counted.
|
||||
type TokenTypeAttr string
|
||||
|
||||
var (
|
||||
// TokenTypeInput is the input tokens (prompt, input, etc.).
|
||||
TokenTypeInput TokenTypeAttr = "input"
|
||||
// TokenTypeOutput is the output tokens (completion, response, etc.).
|
||||
TokenTypeOutput TokenTypeAttr = "output"
|
||||
)
|
||||
|
||||
// ClientOperationDuration is an instrument used to record metric values
|
||||
// conforming to the "gen_ai.client.operation.duration" semantic conventions. It
|
||||
// represents the genAI operation duration.
|
||||
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(
|
||||
"gen_ai.client.operation.duration",
|
||||
append([]metric.Float64HistogramOption{
|
||||
metric.WithDescription("GenAI operation duration"),
|
||||
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 "gen_ai.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 "GenAI operation duration"
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// The operationName is the the name of the operation being performed.
|
||||
//
|
||||
// The system is the the Generative AI product as identified by the client or
|
||||
// server instrumentation.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m ClientOperationDuration) Record(
|
||||
ctx context.Context,
|
||||
val float64,
|
||||
operationName OperationNameAttr,
|
||||
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("gen_ai.operation.name", string(operationName)),
|
||||
attribute.String("gen_ai.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))
|
||||
}
|
||||
|
||||
// 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.
|
||||
func (ClientOperationDuration) AttrRequestModel(val string) attribute.KeyValue {
|
||||
return attribute.String("gen_ai.request.model", val)
|
||||
}
|
||||
|
||||
// AttrServerPort returns an optional attribute for the "server.port" semantic
|
||||
// convention. It represents the genAI server port.
|
||||
func (ClientOperationDuration) AttrServerPort(val int) attribute.KeyValue {
|
||||
return attribute.Int("server.port", val)
|
||||
}
|
||||
|
||||
// AttrResponseModel returns an optional attribute for the
|
||||
// "gen_ai.response.model" semantic convention. It represents the name of the
|
||||
// model that generated the response.
|
||||
func (ClientOperationDuration) AttrResponseModel(val string) attribute.KeyValue {
|
||||
return attribute.String("gen_ai.response.model", val)
|
||||
}
|
||||
|
||||
// AttrServerAddress returns an optional attribute for the "server.address"
|
||||
// semantic convention. It represents the genAI server address.
|
||||
func (ClientOperationDuration) AttrServerAddress(val string) attribute.KeyValue {
|
||||
return attribute.String("server.address", val)
|
||||
}
|
||||
|
||||
// ClientTokenUsage is an instrument used to record metric values conforming to
|
||||
// the "gen_ai.client.token.usage" semantic conventions. It represents the
|
||||
// measures number of input and output tokens used.
|
||||
type ClientTokenUsage struct {
|
||||
metric.Int64Histogram
|
||||
}
|
||||
|
||||
// NewClientTokenUsage returns a new ClientTokenUsage instrument.
|
||||
func NewClientTokenUsage(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64HistogramOption,
|
||||
) (ClientTokenUsage, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return ClientTokenUsage{noop.Int64Histogram{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Histogram(
|
||||
"gen_ai.client.token.usage",
|
||||
append([]metric.Int64HistogramOption{
|
||||
metric.WithDescription("Measures number of input and output tokens used"),
|
||||
metric.WithUnit("{token}"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return ClientTokenUsage{noop.Int64Histogram{}}, err
|
||||
}
|
||||
return ClientTokenUsage{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m ClientTokenUsage) Inst() metric.Int64Histogram {
|
||||
return m.Int64Histogram
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (ClientTokenUsage) Name() string {
|
||||
return "gen_ai.client.token.usage"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (ClientTokenUsage) Unit() string {
|
||||
return "{token}"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (ClientTokenUsage) Description() string {
|
||||
return "Measures number of input and output tokens used"
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// The operationName is the the name of the operation being performed.
|
||||
//
|
||||
// The system is the the Generative AI product as identified by the client or
|
||||
// server instrumentation.
|
||||
//
|
||||
// The tokenType is the the type of token being counted.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m ClientTokenUsage) Record(
|
||||
ctx context.Context,
|
||||
val int64,
|
||||
operationName OperationNameAttr,
|
||||
system SystemAttr,
|
||||
tokenType TokenTypeAttr,
|
||||
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("gen_ai.operation.name", string(operationName)),
|
||||
attribute.String("gen_ai.system", string(system)),
|
||||
attribute.String("gen_ai.token.type", string(tokenType)),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
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.
|
||||
func (ClientTokenUsage) AttrRequestModel(val string) attribute.KeyValue {
|
||||
return attribute.String("gen_ai.request.model", val)
|
||||
}
|
||||
|
||||
// AttrServerPort returns an optional attribute for the "server.port" semantic
|
||||
// convention. It represents the genAI server port.
|
||||
func (ClientTokenUsage) AttrServerPort(val int) attribute.KeyValue {
|
||||
return attribute.Int("server.port", val)
|
||||
}
|
||||
|
||||
// AttrResponseModel returns an optional attribute for the
|
||||
// "gen_ai.response.model" semantic convention. It represents the name of the
|
||||
// model that generated the response.
|
||||
func (ClientTokenUsage) AttrResponseModel(val string) attribute.KeyValue {
|
||||
return attribute.String("gen_ai.response.model", val)
|
||||
}
|
||||
|
||||
// AttrServerAddress returns an optional attribute for the "server.address"
|
||||
// semantic convention. It represents the genAI server address.
|
||||
func (ClientTokenUsage) AttrServerAddress(val string) attribute.KeyValue {
|
||||
return attribute.String("server.address", val)
|
||||
}
|
||||
|
||||
// ServerRequestDuration is an instrument used to record metric values conforming
|
||||
// to the "gen_ai.server.request.duration" semantic conventions. It represents
|
||||
// the generative AI server request duration such as time-to-last byte or last
|
||||
// output token.
|
||||
type ServerRequestDuration struct {
|
||||
metric.Float64Histogram
|
||||
}
|
||||
|
||||
// NewServerRequestDuration returns a new ServerRequestDuration instrument.
|
||||
func NewServerRequestDuration(
|
||||
m metric.Meter,
|
||||
opt ...metric.Float64HistogramOption,
|
||||
) (ServerRequestDuration, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return ServerRequestDuration{noop.Float64Histogram{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Float64Histogram(
|
||||
"gen_ai.server.request.duration",
|
||||
append([]metric.Float64HistogramOption{
|
||||
metric.WithDescription("Generative AI server request duration such as time-to-last byte or last output token"),
|
||||
metric.WithUnit("s"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return ServerRequestDuration{noop.Float64Histogram{}}, err
|
||||
}
|
||||
return ServerRequestDuration{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m ServerRequestDuration) Inst() metric.Float64Histogram {
|
||||
return m.Float64Histogram
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (ServerRequestDuration) Name() string {
|
||||
return "gen_ai.server.request.duration"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (ServerRequestDuration) Unit() string {
|
||||
return "s"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
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.
|
||||
//
|
||||
// The operationName is the the name of the operation being performed.
|
||||
//
|
||||
// The system is the the Generative AI product as identified by the client or
|
||||
// server instrumentation.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m ServerRequestDuration) Record(
|
||||
ctx context.Context,
|
||||
val float64,
|
||||
operationName OperationNameAttr,
|
||||
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("gen_ai.operation.name", string(operationName)),
|
||||
attribute.String("gen_ai.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 (ServerRequestDuration) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
|
||||
return attribute.String("error.type", string(val))
|
||||
}
|
||||
|
||||
// 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.
|
||||
func (ServerRequestDuration) AttrRequestModel(val string) attribute.KeyValue {
|
||||
return attribute.String("gen_ai.request.model", val)
|
||||
}
|
||||
|
||||
// AttrServerPort returns an optional attribute for the "server.port" semantic
|
||||
// convention. It represents the genAI server port.
|
||||
func (ServerRequestDuration) AttrServerPort(val int) attribute.KeyValue {
|
||||
return attribute.Int("server.port", val)
|
||||
}
|
||||
|
||||
// AttrResponseModel returns an optional attribute for the
|
||||
// "gen_ai.response.model" semantic convention. It represents the name of the
|
||||
// model that generated the response.
|
||||
func (ServerRequestDuration) AttrResponseModel(val string) attribute.KeyValue {
|
||||
return attribute.String("gen_ai.response.model", val)
|
||||
}
|
||||
|
||||
// AttrServerAddress returns an optional attribute for the "server.address"
|
||||
// semantic convention. It represents the genAI server address.
|
||||
func (ServerRequestDuration) AttrServerAddress(val string) attribute.KeyValue {
|
||||
return attribute.String("server.address", val)
|
||||
}
|
||||
|
||||
// ServerTimePerOutputToken is an instrument used to record metric values
|
||||
// conforming to the "gen_ai.server.time_per_output_token" semantic conventions.
|
||||
// It represents the time per output token generated after the first token for
|
||||
// successful responses.
|
||||
type ServerTimePerOutputToken struct {
|
||||
metric.Float64Histogram
|
||||
}
|
||||
|
||||
// NewServerTimePerOutputToken returns a new ServerTimePerOutputToken instrument.
|
||||
func NewServerTimePerOutputToken(
|
||||
m metric.Meter,
|
||||
opt ...metric.Float64HistogramOption,
|
||||
) (ServerTimePerOutputToken, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return ServerTimePerOutputToken{noop.Float64Histogram{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Float64Histogram(
|
||||
"gen_ai.server.time_per_output_token",
|
||||
append([]metric.Float64HistogramOption{
|
||||
metric.WithDescription("Time per output token generated after the first token for successful responses"),
|
||||
metric.WithUnit("s"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return ServerTimePerOutputToken{noop.Float64Histogram{}}, err
|
||||
}
|
||||
return ServerTimePerOutputToken{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m ServerTimePerOutputToken) Inst() metric.Float64Histogram {
|
||||
return m.Float64Histogram
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (ServerTimePerOutputToken) Name() string {
|
||||
return "gen_ai.server.time_per_output_token"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (ServerTimePerOutputToken) Unit() string {
|
||||
return "s"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (ServerTimePerOutputToken) Description() string {
|
||||
return "Time per output token generated after the first token for successful responses"
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// The operationName is the the name of the operation being performed.
|
||||
//
|
||||
// The system is the the Generative AI product as identified by the client or
|
||||
// server instrumentation.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m ServerTimePerOutputToken) Record(
|
||||
ctx context.Context,
|
||||
val float64,
|
||||
operationName OperationNameAttr,
|
||||
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("gen_ai.operation.name", string(operationName)),
|
||||
attribute.String("gen_ai.system", string(system)),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
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.
|
||||
func (ServerTimePerOutputToken) AttrRequestModel(val string) attribute.KeyValue {
|
||||
return attribute.String("gen_ai.request.model", val)
|
||||
}
|
||||
|
||||
// AttrServerPort returns an optional attribute for the "server.port" semantic
|
||||
// convention. It represents the genAI server port.
|
||||
func (ServerTimePerOutputToken) AttrServerPort(val int) attribute.KeyValue {
|
||||
return attribute.Int("server.port", val)
|
||||
}
|
||||
|
||||
// AttrResponseModel returns an optional attribute for the
|
||||
// "gen_ai.response.model" semantic convention. It represents the name of the
|
||||
// model that generated the response.
|
||||
func (ServerTimePerOutputToken) AttrResponseModel(val string) attribute.KeyValue {
|
||||
return attribute.String("gen_ai.response.model", val)
|
||||
}
|
||||
|
||||
// AttrServerAddress returns an optional attribute for the "server.address"
|
||||
// semantic convention. It represents the genAI server address.
|
||||
func (ServerTimePerOutputToken) AttrServerAddress(val string) attribute.KeyValue {
|
||||
return attribute.String("server.address", val)
|
||||
}
|
||||
|
||||
// ServerTimeToFirstToken is an instrument used to record metric values
|
||||
// conforming to the "gen_ai.server.time_to_first_token" semantic conventions. It
|
||||
// represents the time to generate first token for successful responses.
|
||||
type ServerTimeToFirstToken struct {
|
||||
metric.Float64Histogram
|
||||
}
|
||||
|
||||
// NewServerTimeToFirstToken returns a new ServerTimeToFirstToken instrument.
|
||||
func NewServerTimeToFirstToken(
|
||||
m metric.Meter,
|
||||
opt ...metric.Float64HistogramOption,
|
||||
) (ServerTimeToFirstToken, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return ServerTimeToFirstToken{noop.Float64Histogram{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Float64Histogram(
|
||||
"gen_ai.server.time_to_first_token",
|
||||
append([]metric.Float64HistogramOption{
|
||||
metric.WithDescription("Time to generate first token for successful responses"),
|
||||
metric.WithUnit("s"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return ServerTimeToFirstToken{noop.Float64Histogram{}}, err
|
||||
}
|
||||
return ServerTimeToFirstToken{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m ServerTimeToFirstToken) Inst() metric.Float64Histogram {
|
||||
return m.Float64Histogram
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (ServerTimeToFirstToken) Name() string {
|
||||
return "gen_ai.server.time_to_first_token"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (ServerTimeToFirstToken) Unit() string {
|
||||
return "s"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (ServerTimeToFirstToken) Description() string {
|
||||
return "Time to generate first token for successful responses"
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// The operationName is the the name of the operation being performed.
|
||||
//
|
||||
// The system is the the Generative AI product as identified by the client or
|
||||
// server instrumentation.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m ServerTimeToFirstToken) Record(
|
||||
ctx context.Context,
|
||||
val float64,
|
||||
operationName OperationNameAttr,
|
||||
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("gen_ai.operation.name", string(operationName)),
|
||||
attribute.String("gen_ai.system", string(system)),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
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.
|
||||
func (ServerTimeToFirstToken) AttrRequestModel(val string) attribute.KeyValue {
|
||||
return attribute.String("gen_ai.request.model", val)
|
||||
}
|
||||
|
||||
// AttrServerPort returns an optional attribute for the "server.port" semantic
|
||||
// convention. It represents the genAI server port.
|
||||
func (ServerTimeToFirstToken) AttrServerPort(val int) attribute.KeyValue {
|
||||
return attribute.Int("server.port", val)
|
||||
}
|
||||
|
||||
// AttrResponseModel returns an optional attribute for the
|
||||
// "gen_ai.response.model" semantic convention. It represents the name of the
|
||||
// model that generated the response.
|
||||
func (ServerTimeToFirstToken) AttrResponseModel(val string) attribute.KeyValue {
|
||||
return attribute.String("gen_ai.response.model", val)
|
||||
}
|
||||
|
||||
// AttrServerAddress returns an optional attribute for the "server.address"
|
||||
// semantic convention. It represents the genAI server address.
|
||||
func (ServerTimeToFirstToken) AttrServerAddress(val string) attribute.KeyValue {
|
||||
return attribute.String("server.address", val)
|
||||
}
|
508
semconv/v1.33.0/goconv/metric.go
Normal file
508
semconv/v1.33.0/goconv/metric.go
Normal file
@@ -0,0 +1,508 @@
|
||||
// Code generated from semantic convention specification. DO NOT EDIT.
|
||||
|
||||
// Package httpconv provides types and functionality for OpenTelemetry semantic
|
||||
// conventions in the "go" namespace.
|
||||
package goconv
|
||||
|
||||
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{} }}
|
||||
)
|
||||
|
||||
// MemoryTypeAttr is an attribute conforming to the go.memory.type semantic
|
||||
// conventions. It represents the type of memory.
|
||||
type MemoryTypeAttr string
|
||||
|
||||
var (
|
||||
// MemoryTypeStack is the memory allocated from the heap that is reserved for
|
||||
// stack space, whether or not it is currently in-use.
|
||||
MemoryTypeStack MemoryTypeAttr = "stack"
|
||||
// MemoryTypeOther is the memory used by the Go runtime, excluding other
|
||||
// categories of memory usage described in this enumeration.
|
||||
MemoryTypeOther MemoryTypeAttr = "other"
|
||||
)
|
||||
|
||||
// ConfigGogc is an instrument used to record metric values conforming to the
|
||||
// "go.config.gogc" semantic conventions. It represents the heap size target
|
||||
// percentage configured by the user, otherwise 100.
|
||||
type ConfigGogc struct {
|
||||
metric.Int64ObservableUpDownCounter
|
||||
}
|
||||
|
||||
// NewConfigGogc returns a new ConfigGogc instrument.
|
||||
func NewConfigGogc(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64ObservableUpDownCounterOption,
|
||||
) (ConfigGogc, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return ConfigGogc{noop.Int64ObservableUpDownCounter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64ObservableUpDownCounter(
|
||||
"go.config.gogc",
|
||||
append([]metric.Int64ObservableUpDownCounterOption{
|
||||
metric.WithDescription("Heap size target percentage configured by the user, otherwise 100."),
|
||||
metric.WithUnit("%"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return ConfigGogc{noop.Int64ObservableUpDownCounter{}}, err
|
||||
}
|
||||
return ConfigGogc{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m ConfigGogc) Inst() metric.Int64ObservableUpDownCounter {
|
||||
return m.Int64ObservableUpDownCounter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (ConfigGogc) Name() string {
|
||||
return "go.config.gogc"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (ConfigGogc) Unit() string {
|
||||
return "%"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (ConfigGogc) Description() string {
|
||||
return "Heap size target percentage configured by the user, otherwise 100."
|
||||
}
|
||||
|
||||
// GoroutineCount is an instrument used to record metric values conforming to the
|
||||
// "go.goroutine.count" semantic conventions. It represents the count of live
|
||||
// goroutines.
|
||||
type GoroutineCount struct {
|
||||
metric.Int64ObservableUpDownCounter
|
||||
}
|
||||
|
||||
// NewGoroutineCount returns a new GoroutineCount instrument.
|
||||
func NewGoroutineCount(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64ObservableUpDownCounterOption,
|
||||
) (GoroutineCount, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return GoroutineCount{noop.Int64ObservableUpDownCounter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64ObservableUpDownCounter(
|
||||
"go.goroutine.count",
|
||||
append([]metric.Int64ObservableUpDownCounterOption{
|
||||
metric.WithDescription("Count of live goroutines."),
|
||||
metric.WithUnit("{goroutine}"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return GoroutineCount{noop.Int64ObservableUpDownCounter{}}, err
|
||||
}
|
||||
return GoroutineCount{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m GoroutineCount) Inst() metric.Int64ObservableUpDownCounter {
|
||||
return m.Int64ObservableUpDownCounter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (GoroutineCount) Name() string {
|
||||
return "go.goroutine.count"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (GoroutineCount) Unit() string {
|
||||
return "{goroutine}"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (GoroutineCount) Description() string {
|
||||
return "Count of live goroutines."
|
||||
}
|
||||
|
||||
// MemoryAllocated is an instrument used to record metric values conforming to
|
||||
// the "go.memory.allocated" semantic conventions. It represents the memory
|
||||
// allocated to the heap by the application.
|
||||
type MemoryAllocated struct {
|
||||
metric.Int64ObservableCounter
|
||||
}
|
||||
|
||||
// NewMemoryAllocated returns a new MemoryAllocated instrument.
|
||||
func NewMemoryAllocated(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64ObservableCounterOption,
|
||||
) (MemoryAllocated, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return MemoryAllocated{noop.Int64ObservableCounter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64ObservableCounter(
|
||||
"go.memory.allocated",
|
||||
append([]metric.Int64ObservableCounterOption{
|
||||
metric.WithDescription("Memory allocated to the heap by the application."),
|
||||
metric.WithUnit("By"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return MemoryAllocated{noop.Int64ObservableCounter{}}, err
|
||||
}
|
||||
return MemoryAllocated{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m MemoryAllocated) Inst() metric.Int64ObservableCounter {
|
||||
return m.Int64ObservableCounter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (MemoryAllocated) Name() string {
|
||||
return "go.memory.allocated"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (MemoryAllocated) Unit() string {
|
||||
return "By"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (MemoryAllocated) Description() string {
|
||||
return "Memory allocated to the heap by the application."
|
||||
}
|
||||
|
||||
// MemoryAllocations is an instrument used to record metric values conforming to
|
||||
// the "go.memory.allocations" semantic conventions. It represents the count of
|
||||
// allocations to the heap by the application.
|
||||
type MemoryAllocations struct {
|
||||
metric.Int64ObservableCounter
|
||||
}
|
||||
|
||||
// NewMemoryAllocations returns a new MemoryAllocations instrument.
|
||||
func NewMemoryAllocations(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64ObservableCounterOption,
|
||||
) (MemoryAllocations, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return MemoryAllocations{noop.Int64ObservableCounter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64ObservableCounter(
|
||||
"go.memory.allocations",
|
||||
append([]metric.Int64ObservableCounterOption{
|
||||
metric.WithDescription("Count of allocations to the heap by the application."),
|
||||
metric.WithUnit("{allocation}"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return MemoryAllocations{noop.Int64ObservableCounter{}}, err
|
||||
}
|
||||
return MemoryAllocations{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m MemoryAllocations) Inst() metric.Int64ObservableCounter {
|
||||
return m.Int64ObservableCounter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (MemoryAllocations) Name() string {
|
||||
return "go.memory.allocations"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (MemoryAllocations) Unit() string {
|
||||
return "{allocation}"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (MemoryAllocations) Description() string {
|
||||
return "Count of allocations to the heap by the application."
|
||||
}
|
||||
|
||||
// MemoryGCGoal is an instrument used to record metric values conforming to the
|
||||
// "go.memory.gc.goal" semantic conventions. It represents the heap size target
|
||||
// for the end of the GC cycle.
|
||||
type MemoryGCGoal struct {
|
||||
metric.Int64ObservableUpDownCounter
|
||||
}
|
||||
|
||||
// NewMemoryGCGoal returns a new MemoryGCGoal instrument.
|
||||
func NewMemoryGCGoal(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64ObservableUpDownCounterOption,
|
||||
) (MemoryGCGoal, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return MemoryGCGoal{noop.Int64ObservableUpDownCounter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64ObservableUpDownCounter(
|
||||
"go.memory.gc.goal",
|
||||
append([]metric.Int64ObservableUpDownCounterOption{
|
||||
metric.WithDescription("Heap size target for the end of the GC cycle."),
|
||||
metric.WithUnit("By"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return MemoryGCGoal{noop.Int64ObservableUpDownCounter{}}, err
|
||||
}
|
||||
return MemoryGCGoal{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m MemoryGCGoal) Inst() metric.Int64ObservableUpDownCounter {
|
||||
return m.Int64ObservableUpDownCounter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (MemoryGCGoal) Name() string {
|
||||
return "go.memory.gc.goal"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (MemoryGCGoal) Unit() string {
|
||||
return "By"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (MemoryGCGoal) Description() string {
|
||||
return "Heap size target for the end of the GC cycle."
|
||||
}
|
||||
|
||||
// MemoryLimit is an instrument used to record metric values conforming to the
|
||||
// "go.memory.limit" semantic conventions. It represents the go runtime memory
|
||||
// limit configured by the user, if a limit exists.
|
||||
type MemoryLimit struct {
|
||||
metric.Int64ObservableUpDownCounter
|
||||
}
|
||||
|
||||
// NewMemoryLimit returns a new MemoryLimit instrument.
|
||||
func NewMemoryLimit(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64ObservableUpDownCounterOption,
|
||||
) (MemoryLimit, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return MemoryLimit{noop.Int64ObservableUpDownCounter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64ObservableUpDownCounter(
|
||||
"go.memory.limit",
|
||||
append([]metric.Int64ObservableUpDownCounterOption{
|
||||
metric.WithDescription("Go runtime memory limit configured by the user, if a limit exists."),
|
||||
metric.WithUnit("By"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return MemoryLimit{noop.Int64ObservableUpDownCounter{}}, err
|
||||
}
|
||||
return MemoryLimit{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m MemoryLimit) Inst() metric.Int64ObservableUpDownCounter {
|
||||
return m.Int64ObservableUpDownCounter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (MemoryLimit) Name() string {
|
||||
return "go.memory.limit"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (MemoryLimit) Unit() string {
|
||||
return "By"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (MemoryLimit) Description() string {
|
||||
return "Go runtime memory limit configured by the user, if a limit exists."
|
||||
}
|
||||
|
||||
// MemoryUsed is an instrument used to record metric values conforming to the
|
||||
// "go.memory.used" semantic conventions. It represents the memory used by the Go
|
||||
// runtime.
|
||||
type MemoryUsed struct {
|
||||
metric.Int64ObservableCounter
|
||||
}
|
||||
|
||||
// NewMemoryUsed returns a new MemoryUsed instrument.
|
||||
func NewMemoryUsed(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64ObservableCounterOption,
|
||||
) (MemoryUsed, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return MemoryUsed{noop.Int64ObservableCounter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64ObservableCounter(
|
||||
"go.memory.used",
|
||||
append([]metric.Int64ObservableCounterOption{
|
||||
metric.WithDescription("Memory used by the Go runtime."),
|
||||
metric.WithUnit("By"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return MemoryUsed{noop.Int64ObservableCounter{}}, err
|
||||
}
|
||||
return MemoryUsed{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m MemoryUsed) Inst() metric.Int64ObservableCounter {
|
||||
return m.Int64ObservableCounter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (MemoryUsed) Name() string {
|
||||
return "go.memory.used"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (MemoryUsed) Unit() string {
|
||||
return "By"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (MemoryUsed) Description() string {
|
||||
return "Memory used by the Go runtime."
|
||||
}
|
||||
|
||||
// AttrMemoryType returns an optional attribute for the "go.memory.type" semantic
|
||||
// convention. It represents the type of memory.
|
||||
func (MemoryUsed) AttrMemoryType(val MemoryTypeAttr) attribute.KeyValue {
|
||||
return attribute.String("go.memory.type", string(val))
|
||||
}
|
||||
|
||||
// ProcessorLimit is an instrument used to record metric values conforming to the
|
||||
// "go.processor.limit" semantic conventions. It represents the number of OS
|
||||
// threads that can execute user-level Go code simultaneously.
|
||||
type ProcessorLimit struct {
|
||||
metric.Int64ObservableUpDownCounter
|
||||
}
|
||||
|
||||
// NewProcessorLimit returns a new ProcessorLimit instrument.
|
||||
func NewProcessorLimit(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64ObservableUpDownCounterOption,
|
||||
) (ProcessorLimit, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return ProcessorLimit{noop.Int64ObservableUpDownCounter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64ObservableUpDownCounter(
|
||||
"go.processor.limit",
|
||||
append([]metric.Int64ObservableUpDownCounterOption{
|
||||
metric.WithDescription("The number of OS threads that can execute user-level Go code simultaneously."),
|
||||
metric.WithUnit("{thread}"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return ProcessorLimit{noop.Int64ObservableUpDownCounter{}}, err
|
||||
}
|
||||
return ProcessorLimit{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m ProcessorLimit) Inst() metric.Int64ObservableUpDownCounter {
|
||||
return m.Int64ObservableUpDownCounter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (ProcessorLimit) Name() string {
|
||||
return "go.processor.limit"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (ProcessorLimit) Unit() string {
|
||||
return "{thread}"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (ProcessorLimit) Description() string {
|
||||
return "The number of OS threads that can execute user-level Go code simultaneously."
|
||||
}
|
||||
|
||||
// ScheduleDuration is an instrument used to record metric values conforming to
|
||||
// the "go.schedule.duration" semantic conventions. It represents the time
|
||||
// goroutines have spent in the scheduler in a runnable state before actually
|
||||
// running.
|
||||
type ScheduleDuration struct {
|
||||
metric.Float64Histogram
|
||||
}
|
||||
|
||||
// NewScheduleDuration returns a new ScheduleDuration instrument.
|
||||
func NewScheduleDuration(
|
||||
m metric.Meter,
|
||||
opt ...metric.Float64HistogramOption,
|
||||
) (ScheduleDuration, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return ScheduleDuration{noop.Float64Histogram{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Float64Histogram(
|
||||
"go.schedule.duration",
|
||||
append([]metric.Float64HistogramOption{
|
||||
metric.WithDescription("The time goroutines have spent in the scheduler in a runnable state before actually running."),
|
||||
metric.WithUnit("s"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return ScheduleDuration{noop.Float64Histogram{}}, err
|
||||
}
|
||||
return ScheduleDuration{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m ScheduleDuration) Inst() metric.Float64Histogram {
|
||||
return m.Float64Histogram
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (ScheduleDuration) Name() string {
|
||||
return "go.schedule.duration"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (ScheduleDuration) Unit() string {
|
||||
return "s"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
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.
|
||||
//
|
||||
// Computed from `/sched/latencies:seconds`. Bucket boundaries are provided by
|
||||
// the runtime, and are subject to change.
|
||||
func (m ScheduleDuration) Record(ctx context.Context, val float64, attrs ...attribute.KeyValue) {
|
||||
if len(attrs) == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributes(attrs...))
|
||||
m.Float64Histogram.Record(ctx, val, *o...)
|
||||
}
|
1418
semconv/v1.33.0/httpconv/metric.go
Normal file
1418
semconv/v1.33.0/httpconv/metric.go
Normal file
File diff suppressed because it is too large
Load Diff
876
semconv/v1.33.0/hwconv/metric.go
Normal file
876
semconv/v1.33.0/hwconv/metric.go
Normal file
@@ -0,0 +1,876 @@
|
||||
// Code generated from semantic convention specification. DO NOT EDIT.
|
||||
|
||||
// Package httpconv provides types and functionality for OpenTelemetry semantic
|
||||
// conventions in the "hw" namespace.
|
||||
package hwconv
|
||||
|
||||
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 type of error encountered by the component.
|
||||
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"
|
||||
)
|
||||
|
||||
// StateAttr is an attribute conforming to the hw.state semantic conventions. It
|
||||
// represents the current state of the component.
|
||||
type StateAttr string
|
||||
|
||||
var (
|
||||
// StateOk is the ok.
|
||||
StateOk StateAttr = "ok"
|
||||
// StateDegraded is the degraded.
|
||||
StateDegraded StateAttr = "degraded"
|
||||
// StateFailed is the failed.
|
||||
StateFailed StateAttr = "failed"
|
||||
)
|
||||
|
||||
// TypeAttr is an attribute conforming to the hw.type semantic conventions. It
|
||||
// represents the type of the component.
|
||||
type TypeAttr string
|
||||
|
||||
var (
|
||||
// TypeBattery is the battery.
|
||||
TypeBattery TypeAttr = "battery"
|
||||
// TypeCPU is the CPU.
|
||||
TypeCPU TypeAttr = "cpu"
|
||||
// TypeDiskController is the disk controller.
|
||||
TypeDiskController TypeAttr = "disk_controller"
|
||||
// TypeEnclosure is the enclosure.
|
||||
TypeEnclosure TypeAttr = "enclosure"
|
||||
// TypeFan is the fan.
|
||||
TypeFan TypeAttr = "fan"
|
||||
// TypeGpu is the GPU.
|
||||
TypeGpu TypeAttr = "gpu"
|
||||
// TypeLogicalDisk is the logical disk.
|
||||
TypeLogicalDisk TypeAttr = "logical_disk"
|
||||
// TypeMemory is the memory.
|
||||
TypeMemory TypeAttr = "memory"
|
||||
// TypeNetwork is the network.
|
||||
TypeNetwork TypeAttr = "network"
|
||||
// TypePhysicalDisk is the physical disk.
|
||||
TypePhysicalDisk TypeAttr = "physical_disk"
|
||||
// TypePowerSupply is the power supply.
|
||||
TypePowerSupply TypeAttr = "power_supply"
|
||||
// TypeTapeDrive is the tape drive.
|
||||
TypeTapeDrive TypeAttr = "tape_drive"
|
||||
// TypeTemperature is the temperature.
|
||||
TypeTemperature TypeAttr = "temperature"
|
||||
// TypeVoltage is the voltage.
|
||||
TypeVoltage TypeAttr = "voltage"
|
||||
)
|
||||
|
||||
// Energy is an instrument used to record metric values conforming to the
|
||||
// "hw.energy" semantic conventions. It represents the energy consumed by the
|
||||
// component.
|
||||
type Energy struct {
|
||||
metric.Int64Counter
|
||||
}
|
||||
|
||||
// NewEnergy returns a new Energy instrument.
|
||||
func NewEnergy(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64CounterOption,
|
||||
) (Energy, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return Energy{noop.Int64Counter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Counter(
|
||||
"hw.energy",
|
||||
append([]metric.Int64CounterOption{
|
||||
metric.WithDescription("Energy consumed by the component"),
|
||||
metric.WithUnit("J"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return Energy{noop.Int64Counter{}}, err
|
||||
}
|
||||
return Energy{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m Energy) Inst() metric.Int64Counter {
|
||||
return m.Int64Counter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (Energy) Name() string {
|
||||
return "hw.energy"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (Energy) Unit() string {
|
||||
return "J"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (Energy) Description() string {
|
||||
return "Energy consumed by the component"
|
||||
}
|
||||
|
||||
// Add adds incr to the existing count.
|
||||
//
|
||||
// The id is the an identifier for the hardware component, unique within the
|
||||
// monitored host
|
||||
//
|
||||
// The hwType is the type of the component
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m Energy) Add(
|
||||
ctx context.Context,
|
||||
incr int64,
|
||||
id string,
|
||||
hwType TypeAttr,
|
||||
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("hw.id", id),
|
||||
attribute.String("hw.type", string(hwType)),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
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 {
|
||||
return attribute.String("hw.name", val)
|
||||
}
|
||||
|
||||
// AttrParent returns an optional attribute for the "hw.parent" semantic
|
||||
// convention. It represents the unique identifier of the parent component
|
||||
// (typically the `hw.id` attribute of the enclosure, or disk controller).
|
||||
func (Energy) AttrParent(val string) attribute.KeyValue {
|
||||
return attribute.String("hw.parent", val)
|
||||
}
|
||||
|
||||
// Errors is an instrument used to record metric values conforming to the
|
||||
// "hw.errors" semantic conventions. It represents the number of errors
|
||||
// encountered by the component.
|
||||
type Errors struct {
|
||||
metric.Int64Counter
|
||||
}
|
||||
|
||||
// NewErrors returns a new Errors instrument.
|
||||
func NewErrors(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64CounterOption,
|
||||
) (Errors, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return Errors{noop.Int64Counter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Counter(
|
||||
"hw.errors",
|
||||
append([]metric.Int64CounterOption{
|
||||
metric.WithDescription("Number of errors encountered by the component"),
|
||||
metric.WithUnit("{error}"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return Errors{noop.Int64Counter{}}, err
|
||||
}
|
||||
return Errors{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m Errors) Inst() metric.Int64Counter {
|
||||
return m.Int64Counter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (Errors) Name() string {
|
||||
return "hw.errors"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (Errors) Unit() string {
|
||||
return "{error}"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (Errors) Description() string {
|
||||
return "Number of errors encountered by the component"
|
||||
}
|
||||
|
||||
// Add adds incr to the existing count.
|
||||
//
|
||||
// The id is the an identifier for the hardware component, unique within the
|
||||
// monitored host
|
||||
//
|
||||
// The hwType is the type of the component
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m Errors) Add(
|
||||
ctx context.Context,
|
||||
incr int64,
|
||||
id string,
|
||||
hwType TypeAttr,
|
||||
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("hw.id", id),
|
||||
attribute.String("hw.type", string(hwType)),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
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 {
|
||||
return attribute.String("error.type", string(val))
|
||||
}
|
||||
|
||||
// AttrName returns an optional attribute for the "hw.name" semantic convention.
|
||||
// It represents an easily-recognizable name for the hardware component.
|
||||
func (Errors) AttrName(val string) attribute.KeyValue {
|
||||
return attribute.String("hw.name", val)
|
||||
}
|
||||
|
||||
// AttrParent returns an optional attribute for the "hw.parent" semantic
|
||||
// convention. It represents the unique identifier of the parent component
|
||||
// (typically the `hw.id` attribute of the enclosure, or disk controller).
|
||||
func (Errors) AttrParent(val string) attribute.KeyValue {
|
||||
return attribute.String("hw.parent", val)
|
||||
}
|
||||
|
||||
// HostAmbientTemperature is an instrument used to record metric values
|
||||
// conforming to the "hw.host.ambient_temperature" semantic conventions. It
|
||||
// represents the ambient (external) temperature of the physical host.
|
||||
type HostAmbientTemperature struct {
|
||||
metric.Int64Gauge
|
||||
}
|
||||
|
||||
// NewHostAmbientTemperature returns a new HostAmbientTemperature instrument.
|
||||
func NewHostAmbientTemperature(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64GaugeOption,
|
||||
) (HostAmbientTemperature, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return HostAmbientTemperature{noop.Int64Gauge{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Gauge(
|
||||
"hw.host.ambient_temperature",
|
||||
append([]metric.Int64GaugeOption{
|
||||
metric.WithDescription("Ambient (external) temperature of the physical host"),
|
||||
metric.WithUnit("Cel"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return HostAmbientTemperature{noop.Int64Gauge{}}, err
|
||||
}
|
||||
return HostAmbientTemperature{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m HostAmbientTemperature) Inst() metric.Int64Gauge {
|
||||
return m.Int64Gauge
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (HostAmbientTemperature) Name() string {
|
||||
return "hw.host.ambient_temperature"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (HostAmbientTemperature) Unit() string {
|
||||
return "Cel"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (HostAmbientTemperature) Description() string {
|
||||
return "Ambient (external) temperature of the physical host"
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// The id is the an identifier for the hardware component, unique within the
|
||||
// monitored host
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m HostAmbientTemperature) Record(
|
||||
ctx context.Context,
|
||||
val int64,
|
||||
id string,
|
||||
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("hw.id", id),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
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 {
|
||||
return attribute.String("hw.name", val)
|
||||
}
|
||||
|
||||
// AttrParent returns an optional attribute for the "hw.parent" semantic
|
||||
// convention. It represents the unique identifier of the parent component
|
||||
// (typically the `hw.id` attribute of the enclosure, or disk controller).
|
||||
func (HostAmbientTemperature) AttrParent(val string) attribute.KeyValue {
|
||||
return attribute.String("hw.parent", val)
|
||||
}
|
||||
|
||||
// HostEnergy is an instrument used to record metric values conforming to the
|
||||
// "hw.host.energy" semantic conventions. It represents the total energy consumed
|
||||
// by the entire physical host, in joules.
|
||||
type HostEnergy struct {
|
||||
metric.Int64Counter
|
||||
}
|
||||
|
||||
// NewHostEnergy returns a new HostEnergy instrument.
|
||||
func NewHostEnergy(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64CounterOption,
|
||||
) (HostEnergy, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return HostEnergy{noop.Int64Counter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Counter(
|
||||
"hw.host.energy",
|
||||
append([]metric.Int64CounterOption{
|
||||
metric.WithDescription("Total energy consumed by the entire physical host, in joules"),
|
||||
metric.WithUnit("J"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return HostEnergy{noop.Int64Counter{}}, err
|
||||
}
|
||||
return HostEnergy{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m HostEnergy) Inst() metric.Int64Counter {
|
||||
return m.Int64Counter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (HostEnergy) Name() string {
|
||||
return "hw.host.energy"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (HostEnergy) Unit() string {
|
||||
return "J"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (HostEnergy) Description() string {
|
||||
return "Total energy consumed by the entire physical host, in joules"
|
||||
}
|
||||
|
||||
// Add adds incr to the existing count.
|
||||
//
|
||||
// The id is the an identifier for the hardware component, unique within the
|
||||
// monitored host
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
//
|
||||
// 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) Add(
|
||||
ctx context.Context,
|
||||
incr int64,
|
||||
id string,
|
||||
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("hw.id", id),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
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 {
|
||||
return attribute.String("hw.name", val)
|
||||
}
|
||||
|
||||
// AttrParent returns an optional attribute for the "hw.parent" semantic
|
||||
// convention. It represents the unique identifier of the parent component
|
||||
// (typically the `hw.id` attribute of the enclosure, or disk controller).
|
||||
func (HostEnergy) AttrParent(val string) attribute.KeyValue {
|
||||
return attribute.String("hw.parent", val)
|
||||
}
|
||||
|
||||
// HostHeatingMargin is an instrument used to record metric values conforming to
|
||||
// the "hw.host.heating_margin" semantic conventions. It represents the 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.
|
||||
type HostHeatingMargin struct {
|
||||
metric.Int64Gauge
|
||||
}
|
||||
|
||||
// NewHostHeatingMargin returns a new HostHeatingMargin instrument.
|
||||
func NewHostHeatingMargin(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64GaugeOption,
|
||||
) (HostHeatingMargin, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return HostHeatingMargin{noop.Int64Gauge{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Gauge(
|
||||
"hw.host.heating_margin",
|
||||
append([]metric.Int64GaugeOption{
|
||||
metric.WithDescription("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"),
|
||||
metric.WithUnit("Cel"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return HostHeatingMargin{noop.Int64Gauge{}}, err
|
||||
}
|
||||
return HostHeatingMargin{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m HostHeatingMargin) Inst() metric.Int64Gauge {
|
||||
return m.Int64Gauge
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (HostHeatingMargin) Name() string {
|
||||
return "hw.host.heating_margin"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (HostHeatingMargin) Unit() string {
|
||||
return "Cel"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
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.
|
||||
//
|
||||
// The id is the an identifier for the hardware component, unique within the
|
||||
// monitored host
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m HostHeatingMargin) Record(
|
||||
ctx context.Context,
|
||||
val int64,
|
||||
id string,
|
||||
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("hw.id", id),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
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 {
|
||||
return attribute.String("hw.name", val)
|
||||
}
|
||||
|
||||
// AttrParent returns an optional attribute for the "hw.parent" semantic
|
||||
// convention. It represents the unique identifier of the parent component
|
||||
// (typically the `hw.id` attribute of the enclosure, or disk controller).
|
||||
func (HostHeatingMargin) AttrParent(val string) attribute.KeyValue {
|
||||
return attribute.String("hw.parent", val)
|
||||
}
|
||||
|
||||
// HostPower is an instrument used to record metric values conforming to the
|
||||
// "hw.host.power" semantic conventions. It represents the instantaneous power
|
||||
// consumed by the entire physical host in Watts (`hw.host.energy` is preferred).
|
||||
type HostPower struct {
|
||||
metric.Int64Gauge
|
||||
}
|
||||
|
||||
// NewHostPower returns a new HostPower instrument.
|
||||
func NewHostPower(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64GaugeOption,
|
||||
) (HostPower, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return HostPower{noop.Int64Gauge{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Gauge(
|
||||
"hw.host.power",
|
||||
append([]metric.Int64GaugeOption{
|
||||
metric.WithDescription("Instantaneous power consumed by the entire physical host in Watts (`hw.host.energy` is preferred)"),
|
||||
metric.WithUnit("W"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return HostPower{noop.Int64Gauge{}}, err
|
||||
}
|
||||
return HostPower{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m HostPower) Inst() metric.Int64Gauge {
|
||||
return m.Int64Gauge
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (HostPower) Name() string {
|
||||
return "hw.host.power"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (HostPower) Unit() string {
|
||||
return "W"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
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.
|
||||
//
|
||||
// The id is the an identifier for the hardware component, unique within the
|
||||
// monitored host
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
//
|
||||
// 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) Record(
|
||||
ctx context.Context,
|
||||
val int64,
|
||||
id string,
|
||||
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("hw.id", id),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
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 {
|
||||
return attribute.String("hw.name", val)
|
||||
}
|
||||
|
||||
// AttrParent returns an optional attribute for the "hw.parent" semantic
|
||||
// convention. It represents the unique identifier of the parent component
|
||||
// (typically the `hw.id` attribute of the enclosure, or disk controller).
|
||||
func (HostPower) AttrParent(val string) attribute.KeyValue {
|
||||
return attribute.String("hw.parent", val)
|
||||
}
|
||||
|
||||
// Power is an instrument used to record metric values conforming to the
|
||||
// "hw.power" semantic conventions. It represents the instantaneous power
|
||||
// consumed by the component.
|
||||
type Power struct {
|
||||
metric.Int64Gauge
|
||||
}
|
||||
|
||||
// NewPower returns a new Power instrument.
|
||||
func NewPower(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64GaugeOption,
|
||||
) (Power, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return Power{noop.Int64Gauge{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Gauge(
|
||||
"hw.power",
|
||||
append([]metric.Int64GaugeOption{
|
||||
metric.WithDescription("Instantaneous power consumed by the component"),
|
||||
metric.WithUnit("W"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return Power{noop.Int64Gauge{}}, err
|
||||
}
|
||||
return Power{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m Power) Inst() metric.Int64Gauge {
|
||||
return m.Int64Gauge
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (Power) Name() string {
|
||||
return "hw.power"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (Power) Unit() string {
|
||||
return "W"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (Power) Description() string {
|
||||
return "Instantaneous power consumed by the component"
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// The id is the an identifier for the hardware component, unique within the
|
||||
// monitored host
|
||||
//
|
||||
// The hwType is the type of the component
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
//
|
||||
// It is recommended to report `hw.energy` instead of `hw.power` when possible.
|
||||
func (m Power) Record(
|
||||
ctx context.Context,
|
||||
val int64,
|
||||
id string,
|
||||
hwType TypeAttr,
|
||||
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("hw.id", id),
|
||||
attribute.String("hw.type", string(hwType)),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
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 {
|
||||
return attribute.String("hw.name", val)
|
||||
}
|
||||
|
||||
// AttrParent returns an optional attribute for the "hw.parent" semantic
|
||||
// convention. It represents the unique identifier of the parent component
|
||||
// (typically the `hw.id` attribute of the enclosure, or disk controller).
|
||||
func (Power) AttrParent(val string) attribute.KeyValue {
|
||||
return attribute.String("hw.parent", val)
|
||||
}
|
||||
|
||||
// Status is an instrument used to record metric values conforming to the
|
||||
// "hw.status" semantic conventions. It represents the operational status: `1`
|
||||
// (true) or `0` (false) for each of the possible states.
|
||||
type Status struct {
|
||||
metric.Int64UpDownCounter
|
||||
}
|
||||
|
||||
// NewStatus returns a new Status instrument.
|
||||
func NewStatus(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64UpDownCounterOption,
|
||||
) (Status, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return Status{noop.Int64UpDownCounter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64UpDownCounter(
|
||||
"hw.status",
|
||||
append([]metric.Int64UpDownCounterOption{
|
||||
metric.WithDescription("Operational status: `1` (true) or `0` (false) for each of the possible states"),
|
||||
metric.WithUnit("1"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return Status{noop.Int64UpDownCounter{}}, err
|
||||
}
|
||||
return Status{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m Status) Inst() metric.Int64UpDownCounter {
|
||||
return m.Int64UpDownCounter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (Status) Name() string {
|
||||
return "hw.status"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (Status) Unit() string {
|
||||
return "1"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
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.
|
||||
//
|
||||
// The id is the an identifier for the hardware component, unique within the
|
||||
// monitored host
|
||||
//
|
||||
// The state is the the current state of the component
|
||||
//
|
||||
// The hwType is the type of the component
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
//
|
||||
// `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) Add(
|
||||
ctx context.Context,
|
||||
incr int64,
|
||||
id string,
|
||||
state StateAttr,
|
||||
hwType TypeAttr,
|
||||
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("hw.id", id),
|
||||
attribute.String("hw.state", string(state)),
|
||||
attribute.String("hw.type", string(hwType)),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
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 {
|
||||
return attribute.String("hw.name", val)
|
||||
}
|
||||
|
||||
// AttrParent returns an optional attribute for the "hw.parent" semantic
|
||||
// convention. It represents the unique identifier of the parent component
|
||||
// (typically the `hw.id` attribute of the enclosure, or disk controller).
|
||||
func (Status) AttrParent(val string) attribute.KeyValue {
|
||||
return attribute.String("hw.parent", val)
|
||||
}
|
2876
semconv/v1.33.0/k8sconv/metric.go
Normal file
2876
semconv/v1.33.0/k8sconv/metric.go
Normal file
File diff suppressed because it is too large
Load Diff
658
semconv/v1.33.0/messagingconv/metric.go
Normal file
658
semconv/v1.33.0/messagingconv/metric.go
Normal file
@@ -0,0 +1,658 @@
|
||||
// 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)
|
||||
}
|
1857
semconv/v1.33.0/otelconv/metric.go
Normal file
1857
semconv/v1.33.0/otelconv/metric.go
Normal file
File diff suppressed because it is too large
Load Diff
893
semconv/v1.33.0/processconv/metric.go
Normal file
893
semconv/v1.33.0/processconv/metric.go
Normal file
@@ -0,0 +1,893 @@
|
||||
// Code generated from semantic convention specification. DO NOT EDIT.
|
||||
|
||||
// Package httpconv provides types and functionality for OpenTelemetry semantic
|
||||
// conventions in the "process" namespace.
|
||||
package processconv
|
||||
|
||||
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{} }}
|
||||
)
|
||||
|
||||
// CPUModeAttr is an attribute conforming to the cpu.mode semantic conventions.
|
||||
// It represents a process SHOULD be characterized *either* by data points with
|
||||
// no `mode` labels, *or only* data points with `mode` labels.
|
||||
type CPUModeAttr string
|
||||
|
||||
var (
|
||||
// CPUModeUser is the none.
|
||||
CPUModeUser CPUModeAttr = "user"
|
||||
// CPUModeSystem is the none.
|
||||
CPUModeSystem CPUModeAttr = "system"
|
||||
// CPUModeNice is the none.
|
||||
CPUModeNice CPUModeAttr = "nice"
|
||||
// CPUModeIdle is the none.
|
||||
CPUModeIdle CPUModeAttr = "idle"
|
||||
// CPUModeIOWait is the none.
|
||||
CPUModeIOWait CPUModeAttr = "iowait"
|
||||
// CPUModeInterrupt is the none.
|
||||
CPUModeInterrupt CPUModeAttr = "interrupt"
|
||||
// CPUModeSteal is the none.
|
||||
CPUModeSteal CPUModeAttr = "steal"
|
||||
// CPUModeKernel is the none.
|
||||
CPUModeKernel CPUModeAttr = "kernel"
|
||||
)
|
||||
|
||||
// DiskIODirectionAttr is an attribute conforming to the disk.io.direction
|
||||
// semantic conventions. It represents the disk IO operation direction.
|
||||
type DiskIODirectionAttr string
|
||||
|
||||
var (
|
||||
// DiskIODirectionRead is the none.
|
||||
DiskIODirectionRead DiskIODirectionAttr = "read"
|
||||
// DiskIODirectionWrite is the none.
|
||||
DiskIODirectionWrite DiskIODirectionAttr = "write"
|
||||
)
|
||||
|
||||
// NetworkIODirectionAttr is an attribute conforming to the network.io.direction
|
||||
// semantic conventions. It represents the network IO operation direction.
|
||||
type NetworkIODirectionAttr string
|
||||
|
||||
var (
|
||||
// NetworkIODirectionTransmit is the none.
|
||||
NetworkIODirectionTransmit NetworkIODirectionAttr = "transmit"
|
||||
// NetworkIODirectionReceive is the none.
|
||||
NetworkIODirectionReceive NetworkIODirectionAttr = "receive"
|
||||
)
|
||||
|
||||
// ContextSwitchTypeAttr is an attribute conforming to the
|
||||
// process.context_switch_type semantic conventions. It represents the specifies
|
||||
// whether the context switches for this data point were voluntary or
|
||||
// involuntary.
|
||||
type ContextSwitchTypeAttr string
|
||||
|
||||
var (
|
||||
// ContextSwitchTypeVoluntary is the none.
|
||||
ContextSwitchTypeVoluntary ContextSwitchTypeAttr = "voluntary"
|
||||
// ContextSwitchTypeInvoluntary is the none.
|
||||
ContextSwitchTypeInvoluntary ContextSwitchTypeAttr = "involuntary"
|
||||
)
|
||||
|
||||
// PagingFaultTypeAttr is an attribute conforming to the
|
||||
// process.paging.fault_type semantic conventions. It represents the type of page
|
||||
// fault for this data point. Type `major` is for major/hard page faults, and
|
||||
// `minor` is for minor/soft page faults.
|
||||
type PagingFaultTypeAttr string
|
||||
|
||||
var (
|
||||
// PagingFaultTypeMajor is the none.
|
||||
PagingFaultTypeMajor PagingFaultTypeAttr = "major"
|
||||
// PagingFaultTypeMinor is the none.
|
||||
PagingFaultTypeMinor PagingFaultTypeAttr = "minor"
|
||||
)
|
||||
|
||||
// ContextSwitches is an instrument used to record metric values conforming to
|
||||
// the "process.context_switches" semantic conventions. It represents the number
|
||||
// of times the process has been context switched.
|
||||
type ContextSwitches struct {
|
||||
metric.Int64Counter
|
||||
}
|
||||
|
||||
// NewContextSwitches returns a new ContextSwitches instrument.
|
||||
func NewContextSwitches(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64CounterOption,
|
||||
) (ContextSwitches, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return ContextSwitches{noop.Int64Counter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Counter(
|
||||
"process.context_switches",
|
||||
append([]metric.Int64CounterOption{
|
||||
metric.WithDescription("Number of times the process has been context switched."),
|
||||
metric.WithUnit("{context_switch}"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return ContextSwitches{noop.Int64Counter{}}, err
|
||||
}
|
||||
return ContextSwitches{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m ContextSwitches) Inst() metric.Int64Counter {
|
||||
return m.Int64Counter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (ContextSwitches) Name() string {
|
||||
return "process.context_switches"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (ContextSwitches) Unit() string {
|
||||
return "{context_switch}"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (ContextSwitches) Description() string {
|
||||
return "Number of times the process has been context switched."
|
||||
}
|
||||
|
||||
// Add adds incr to the existing count.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m ContextSwitches) Add(
|
||||
ctx context.Context,
|
||||
incr int64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(
|
||||
*o,
|
||||
metric.WithAttributes(
|
||||
attrs...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Int64Counter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// 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
|
||||
// involuntary.
|
||||
func (ContextSwitches) AttrContextSwitchType(val ContextSwitchTypeAttr) attribute.KeyValue {
|
||||
return attribute.String("process.context_switch_type", string(val))
|
||||
}
|
||||
|
||||
// CPUTime is an instrument used to record metric values conforming to the
|
||||
// "process.cpu.time" semantic conventions. It represents the total CPU seconds
|
||||
// broken down by different states.
|
||||
type CPUTime struct {
|
||||
metric.Float64ObservableCounter
|
||||
}
|
||||
|
||||
// NewCPUTime returns a new CPUTime instrument.
|
||||
func NewCPUTime(
|
||||
m metric.Meter,
|
||||
opt ...metric.Float64ObservableCounterOption,
|
||||
) (CPUTime, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return CPUTime{noop.Float64ObservableCounter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Float64ObservableCounter(
|
||||
"process.cpu.time",
|
||||
append([]metric.Float64ObservableCounterOption{
|
||||
metric.WithDescription("Total CPU seconds broken down by different states."),
|
||||
metric.WithUnit("s"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return CPUTime{noop.Float64ObservableCounter{}}, err
|
||||
}
|
||||
return CPUTime{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m CPUTime) Inst() metric.Float64ObservableCounter {
|
||||
return m.Float64ObservableCounter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (CPUTime) Name() string {
|
||||
return "process.cpu.time"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (CPUTime) Unit() string {
|
||||
return "s"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (CPUTime) Description() string {
|
||||
return "Total CPU seconds broken down by different states."
|
||||
}
|
||||
|
||||
// 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.
|
||||
func (CPUTime) AttrCPUMode(val CPUModeAttr) attribute.KeyValue {
|
||||
return attribute.String("cpu.mode", string(val))
|
||||
}
|
||||
|
||||
// CPUUtilization is an instrument used to record metric values conforming to the
|
||||
// "process.cpu.utilization" semantic conventions. It represents the difference
|
||||
// in process.cpu.time since the last measurement, divided by the elapsed time
|
||||
// and number of CPUs available to the process.
|
||||
type CPUUtilization struct {
|
||||
metric.Int64Gauge
|
||||
}
|
||||
|
||||
// NewCPUUtilization returns a new CPUUtilization instrument.
|
||||
func NewCPUUtilization(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64GaugeOption,
|
||||
) (CPUUtilization, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return CPUUtilization{noop.Int64Gauge{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Gauge(
|
||||
"process.cpu.utilization",
|
||||
append([]metric.Int64GaugeOption{
|
||||
metric.WithDescription("Difference in process.cpu.time since the last measurement, divided by the elapsed time and number of CPUs available to the process."),
|
||||
metric.WithUnit("1"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return CPUUtilization{noop.Int64Gauge{}}, err
|
||||
}
|
||||
return CPUUtilization{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m CPUUtilization) Inst() metric.Int64Gauge {
|
||||
return m.Int64Gauge
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (CPUUtilization) Name() string {
|
||||
return "process.cpu.utilization"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (CPUUtilization) Unit() string {
|
||||
return "1"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
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.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m CPUUtilization) Record(
|
||||
ctx context.Context,
|
||||
val int64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(
|
||||
*o,
|
||||
metric.WithAttributes(
|
||||
attrs...,
|
||||
),
|
||||
)
|
||||
|
||||
m.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.
|
||||
func (CPUUtilization) AttrCPUMode(val CPUModeAttr) attribute.KeyValue {
|
||||
return attribute.String("cpu.mode", string(val))
|
||||
}
|
||||
|
||||
// DiskIO is an instrument used to record metric values conforming to the
|
||||
// "process.disk.io" semantic conventions. It represents the disk bytes
|
||||
// transferred.
|
||||
type DiskIO struct {
|
||||
metric.Int64Counter
|
||||
}
|
||||
|
||||
// NewDiskIO returns a new DiskIO instrument.
|
||||
func NewDiskIO(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64CounterOption,
|
||||
) (DiskIO, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return DiskIO{noop.Int64Counter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Counter(
|
||||
"process.disk.io",
|
||||
append([]metric.Int64CounterOption{
|
||||
metric.WithDescription("Disk bytes transferred."),
|
||||
metric.WithUnit("By"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return DiskIO{noop.Int64Counter{}}, err
|
||||
}
|
||||
return DiskIO{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m DiskIO) Inst() metric.Int64Counter {
|
||||
return m.Int64Counter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (DiskIO) Name() string {
|
||||
return "process.disk.io"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (DiskIO) Unit() string {
|
||||
return "By"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (DiskIO) Description() string {
|
||||
return "Disk bytes transferred."
|
||||
}
|
||||
|
||||
// Add adds incr to the existing count.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m DiskIO) Add(
|
||||
ctx context.Context,
|
||||
incr int64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(
|
||||
*o,
|
||||
metric.WithAttributes(
|
||||
attrs...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Int64Counter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// 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 {
|
||||
return attribute.String("disk.io.direction", string(val))
|
||||
}
|
||||
|
||||
// MemoryUsage is an instrument used to record metric values conforming to the
|
||||
// "process.memory.usage" semantic conventions. It represents the amount of
|
||||
// physical memory in use.
|
||||
type MemoryUsage struct {
|
||||
metric.Int64UpDownCounter
|
||||
}
|
||||
|
||||
// NewMemoryUsage returns a new MemoryUsage instrument.
|
||||
func NewMemoryUsage(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64UpDownCounterOption,
|
||||
) (MemoryUsage, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return MemoryUsage{noop.Int64UpDownCounter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64UpDownCounter(
|
||||
"process.memory.usage",
|
||||
append([]metric.Int64UpDownCounterOption{
|
||||
metric.WithDescription("The amount of physical memory in use."),
|
||||
metric.WithUnit("By"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return MemoryUsage{noop.Int64UpDownCounter{}}, err
|
||||
}
|
||||
return MemoryUsage{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m MemoryUsage) Inst() metric.Int64UpDownCounter {
|
||||
return m.Int64UpDownCounter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (MemoryUsage) Name() string {
|
||||
return "process.memory.usage"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (MemoryUsage) Unit() string {
|
||||
return "By"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (MemoryUsage) Description() string {
|
||||
return "The amount of physical memory in use."
|
||||
}
|
||||
|
||||
// Add adds incr to the existing count.
|
||||
func (m MemoryUsage) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
|
||||
if len(attrs) == 0 {
|
||||
m.Int64UpDownCounter.Add(ctx, incr)
|
||||
return
|
||||
}
|
||||
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributes(attrs...))
|
||||
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.
|
||||
type MemoryVirtual struct {
|
||||
metric.Int64UpDownCounter
|
||||
}
|
||||
|
||||
// NewMemoryVirtual returns a new MemoryVirtual instrument.
|
||||
func NewMemoryVirtual(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64UpDownCounterOption,
|
||||
) (MemoryVirtual, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return MemoryVirtual{noop.Int64UpDownCounter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64UpDownCounter(
|
||||
"process.memory.virtual",
|
||||
append([]metric.Int64UpDownCounterOption{
|
||||
metric.WithDescription("The amount of committed virtual memory."),
|
||||
metric.WithUnit("By"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return MemoryVirtual{noop.Int64UpDownCounter{}}, err
|
||||
}
|
||||
return MemoryVirtual{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m MemoryVirtual) Inst() metric.Int64UpDownCounter {
|
||||
return m.Int64UpDownCounter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (MemoryVirtual) Name() string {
|
||||
return "process.memory.virtual"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (MemoryVirtual) Unit() string {
|
||||
return "By"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (MemoryVirtual) Description() string {
|
||||
return "The amount of committed virtual memory."
|
||||
}
|
||||
|
||||
// Add adds incr to the existing count.
|
||||
func (m MemoryVirtual) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
|
||||
if len(attrs) == 0 {
|
||||
m.Int64UpDownCounter.Add(ctx, incr)
|
||||
return
|
||||
}
|
||||
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributes(attrs...))
|
||||
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.
|
||||
type NetworkIO struct {
|
||||
metric.Int64Counter
|
||||
}
|
||||
|
||||
// NewNetworkIO returns a new NetworkIO instrument.
|
||||
func NewNetworkIO(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64CounterOption,
|
||||
) (NetworkIO, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return NetworkIO{noop.Int64Counter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Counter(
|
||||
"process.network.io",
|
||||
append([]metric.Int64CounterOption{
|
||||
metric.WithDescription("Network bytes transferred."),
|
||||
metric.WithUnit("By"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return NetworkIO{noop.Int64Counter{}}, err
|
||||
}
|
||||
return NetworkIO{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m NetworkIO) Inst() metric.Int64Counter {
|
||||
return m.Int64Counter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (NetworkIO) Name() string {
|
||||
return "process.network.io"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (NetworkIO) Unit() string {
|
||||
return "By"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (NetworkIO) Description() string {
|
||||
return "Network bytes transferred."
|
||||
}
|
||||
|
||||
// Add adds incr to the existing count.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m NetworkIO) Add(
|
||||
ctx context.Context,
|
||||
incr int64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(
|
||||
*o,
|
||||
metric.WithAttributes(
|
||||
attrs...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Int64Counter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// AttrNetworkIODirection returns an optional attribute for the
|
||||
// "network.io.direction" semantic convention. It represents the network IO
|
||||
// operation direction.
|
||||
func (NetworkIO) AttrNetworkIODirection(val NetworkIODirectionAttr) attribute.KeyValue {
|
||||
return attribute.String("network.io.direction", string(val))
|
||||
}
|
||||
|
||||
// OpenFileDescriptorCount is an instrument used to record metric values
|
||||
// conforming to the "process.open_file_descriptor.count" semantic conventions.
|
||||
// It represents the number of file descriptors in use by the process.
|
||||
type OpenFileDescriptorCount struct {
|
||||
metric.Int64UpDownCounter
|
||||
}
|
||||
|
||||
// NewOpenFileDescriptorCount returns a new OpenFileDescriptorCount instrument.
|
||||
func NewOpenFileDescriptorCount(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64UpDownCounterOption,
|
||||
) (OpenFileDescriptorCount, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return OpenFileDescriptorCount{noop.Int64UpDownCounter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64UpDownCounter(
|
||||
"process.open_file_descriptor.count",
|
||||
append([]metric.Int64UpDownCounterOption{
|
||||
metric.WithDescription("Number of file descriptors in use by the process."),
|
||||
metric.WithUnit("{file_descriptor}"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return OpenFileDescriptorCount{noop.Int64UpDownCounter{}}, err
|
||||
}
|
||||
return OpenFileDescriptorCount{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m OpenFileDescriptorCount) Inst() metric.Int64UpDownCounter {
|
||||
return m.Int64UpDownCounter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (OpenFileDescriptorCount) Name() string {
|
||||
return "process.open_file_descriptor.count"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (OpenFileDescriptorCount) Unit() string {
|
||||
return "{file_descriptor}"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (OpenFileDescriptorCount) Description() string {
|
||||
return "Number of file descriptors in use by the process."
|
||||
}
|
||||
|
||||
// Add adds incr to the existing count.
|
||||
func (m OpenFileDescriptorCount) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
|
||||
if len(attrs) == 0 {
|
||||
m.Int64UpDownCounter.Add(ctx, incr)
|
||||
return
|
||||
}
|
||||
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributes(attrs...))
|
||||
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.
|
||||
type PagingFaults struct {
|
||||
metric.Int64Counter
|
||||
}
|
||||
|
||||
// NewPagingFaults returns a new PagingFaults instrument.
|
||||
func NewPagingFaults(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64CounterOption,
|
||||
) (PagingFaults, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return PagingFaults{noop.Int64Counter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Counter(
|
||||
"process.paging.faults",
|
||||
append([]metric.Int64CounterOption{
|
||||
metric.WithDescription("Number of page faults the process has made."),
|
||||
metric.WithUnit("{fault}"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return PagingFaults{noop.Int64Counter{}}, err
|
||||
}
|
||||
return PagingFaults{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m PagingFaults) Inst() metric.Int64Counter {
|
||||
return m.Int64Counter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (PagingFaults) Name() string {
|
||||
return "process.paging.faults"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (PagingFaults) Unit() string {
|
||||
return "{fault}"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (PagingFaults) Description() string {
|
||||
return "Number of page faults the process has made."
|
||||
}
|
||||
|
||||
// Add adds incr to the existing count.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m PagingFaults) Add(
|
||||
ctx context.Context,
|
||||
incr int64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(
|
||||
*o,
|
||||
metric.WithAttributes(
|
||||
attrs...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Int64Counter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// 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,
|
||||
// and `minor` is for minor/soft page faults.
|
||||
func (PagingFaults) AttrPagingFaultType(val PagingFaultTypeAttr) attribute.KeyValue {
|
||||
return attribute.String("process.paging.fault_type", string(val))
|
||||
}
|
||||
|
||||
// ThreadCount is an instrument used to record metric values conforming to the
|
||||
// "process.thread.count" semantic conventions. It represents the process threads
|
||||
// count.
|
||||
type ThreadCount struct {
|
||||
metric.Int64UpDownCounter
|
||||
}
|
||||
|
||||
// NewThreadCount returns a new ThreadCount instrument.
|
||||
func NewThreadCount(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64UpDownCounterOption,
|
||||
) (ThreadCount, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return ThreadCount{noop.Int64UpDownCounter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64UpDownCounter(
|
||||
"process.thread.count",
|
||||
append([]metric.Int64UpDownCounterOption{
|
||||
metric.WithDescription("Process threads count."),
|
||||
metric.WithUnit("{thread}"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return ThreadCount{noop.Int64UpDownCounter{}}, err
|
||||
}
|
||||
return ThreadCount{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m ThreadCount) Inst() metric.Int64UpDownCounter {
|
||||
return m.Int64UpDownCounter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (ThreadCount) Name() string {
|
||||
return "process.thread.count"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (ThreadCount) Unit() string {
|
||||
return "{thread}"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (ThreadCount) Description() string {
|
||||
return "Process threads count."
|
||||
}
|
||||
|
||||
// Add adds incr to the existing count.
|
||||
func (m ThreadCount) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
|
||||
if len(attrs) == 0 {
|
||||
m.Int64UpDownCounter.Add(ctx, incr)
|
||||
return
|
||||
}
|
||||
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributes(attrs...))
|
||||
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.
|
||||
type Uptime struct {
|
||||
metric.Float64Gauge
|
||||
}
|
||||
|
||||
// NewUptime returns a new Uptime instrument.
|
||||
func NewUptime(
|
||||
m metric.Meter,
|
||||
opt ...metric.Float64GaugeOption,
|
||||
) (Uptime, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return Uptime{noop.Float64Gauge{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Float64Gauge(
|
||||
"process.uptime",
|
||||
append([]metric.Float64GaugeOption{
|
||||
metric.WithDescription("The time the process has been running."),
|
||||
metric.WithUnit("s"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return Uptime{noop.Float64Gauge{}}, err
|
||||
}
|
||||
return Uptime{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m Uptime) Inst() metric.Float64Gauge {
|
||||
return m.Float64Gauge
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (Uptime) Name() string {
|
||||
return "process.uptime"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (Uptime) Unit() string {
|
||||
return "s"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (Uptime) Description() string {
|
||||
return "The time the process has been running."
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// 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) Record(ctx context.Context, val float64, attrs ...attribute.KeyValue) {
|
||||
if len(attrs) == 0 {
|
||||
m.Float64Gauge.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributes(attrs...))
|
||||
m.Float64Gauge.Record(ctx, val, *o...)
|
||||
}
|
713
semconv/v1.33.0/rpcconv/metric.go
Normal file
713
semconv/v1.33.0/rpcconv/metric.go
Normal file
@@ -0,0 +1,713 @@
|
||||
// Code generated from semantic convention specification. DO NOT EDIT.
|
||||
|
||||
// Package httpconv provides types and functionality for OpenTelemetry semantic
|
||||
// conventions in the "rpc" namespace.
|
||||
package rpcconv
|
||||
|
||||
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{} }}
|
||||
)
|
||||
|
||||
// ClientDuration is an instrument used to record metric values conforming to the
|
||||
// "rpc.client.duration" semantic conventions. It represents the measures the
|
||||
// duration of outbound RPC.
|
||||
type ClientDuration struct {
|
||||
metric.Float64Histogram
|
||||
}
|
||||
|
||||
// NewClientDuration returns a new ClientDuration instrument.
|
||||
func NewClientDuration(
|
||||
m metric.Meter,
|
||||
opt ...metric.Float64HistogramOption,
|
||||
) (ClientDuration, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return ClientDuration{noop.Float64Histogram{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Float64Histogram(
|
||||
"rpc.client.duration",
|
||||
append([]metric.Float64HistogramOption{
|
||||
metric.WithDescription("Measures the duration of outbound RPC."),
|
||||
metric.WithUnit("ms"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return ClientDuration{noop.Float64Histogram{}}, err
|
||||
}
|
||||
return ClientDuration{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m ClientDuration) Inst() metric.Float64Histogram {
|
||||
return m.Float64Histogram
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (ClientDuration) Name() string {
|
||||
return "rpc.client.duration"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (ClientDuration) Unit() string {
|
||||
return "ms"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (ClientDuration) Description() string {
|
||||
return "Measures the duration of outbound RPC."
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// 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) Record(ctx context.Context, val float64, attrs ...attribute.KeyValue) {
|
||||
if len(attrs) == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributes(attrs...))
|
||||
m.Float64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// 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).
|
||||
type ClientRequestSize struct {
|
||||
metric.Int64Histogram
|
||||
}
|
||||
|
||||
// NewClientRequestSize returns a new ClientRequestSize instrument.
|
||||
func NewClientRequestSize(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64HistogramOption,
|
||||
) (ClientRequestSize, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return ClientRequestSize{noop.Int64Histogram{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Histogram(
|
||||
"rpc.client.request.size",
|
||||
append([]metric.Int64HistogramOption{
|
||||
metric.WithDescription("Measures the size of RPC request messages (uncompressed)."),
|
||||
metric.WithUnit("By"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return ClientRequestSize{noop.Int64Histogram{}}, err
|
||||
}
|
||||
return ClientRequestSize{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m ClientRequestSize) Inst() metric.Int64Histogram {
|
||||
return m.Int64Histogram
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (ClientRequestSize) Name() string {
|
||||
return "rpc.client.request.size"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (ClientRequestSize) Unit() string {
|
||||
return "By"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (ClientRequestSize) Description() string {
|
||||
return "Measures the size of RPC request messages (uncompressed)."
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// **Streaming**: Recorded per message in a streaming batch
|
||||
func (m ClientRequestSize) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
|
||||
if len(attrs) == 0 {
|
||||
m.Int64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributes(attrs...))
|
||||
m.Int64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// 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.
|
||||
type ClientRequestsPerRPC struct {
|
||||
metric.Int64Histogram
|
||||
}
|
||||
|
||||
// NewClientRequestsPerRPC returns a new ClientRequestsPerRPC instrument.
|
||||
func NewClientRequestsPerRPC(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64HistogramOption,
|
||||
) (ClientRequestsPerRPC, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return ClientRequestsPerRPC{noop.Int64Histogram{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Histogram(
|
||||
"rpc.client.requests_per_rpc",
|
||||
append([]metric.Int64HistogramOption{
|
||||
metric.WithDescription("Measures the number of messages received per RPC."),
|
||||
metric.WithUnit("{count}"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return ClientRequestsPerRPC{noop.Int64Histogram{}}, err
|
||||
}
|
||||
return ClientRequestsPerRPC{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m ClientRequestsPerRPC) Inst() metric.Int64Histogram {
|
||||
return m.Int64Histogram
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (ClientRequestsPerRPC) Name() string {
|
||||
return "rpc.client.requests_per_rpc"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (ClientRequestsPerRPC) Unit() string {
|
||||
return "{count}"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (ClientRequestsPerRPC) Description() string {
|
||||
return "Measures the number of messages received per RPC."
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// Should be 1 for all non-streaming RPCs.
|
||||
//
|
||||
// **Streaming**: This metric is required for server and client streaming RPCs
|
||||
func (m ClientRequestsPerRPC) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
|
||||
if len(attrs) == 0 {
|
||||
m.Int64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributes(attrs...))
|
||||
m.Int64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// 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).
|
||||
type ClientResponseSize struct {
|
||||
metric.Int64Histogram
|
||||
}
|
||||
|
||||
// NewClientResponseSize returns a new ClientResponseSize instrument.
|
||||
func NewClientResponseSize(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64HistogramOption,
|
||||
) (ClientResponseSize, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return ClientResponseSize{noop.Int64Histogram{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Histogram(
|
||||
"rpc.client.response.size",
|
||||
append([]metric.Int64HistogramOption{
|
||||
metric.WithDescription("Measures the size of RPC response messages (uncompressed)."),
|
||||
metric.WithUnit("By"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return ClientResponseSize{noop.Int64Histogram{}}, err
|
||||
}
|
||||
return ClientResponseSize{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m ClientResponseSize) Inst() metric.Int64Histogram {
|
||||
return m.Int64Histogram
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (ClientResponseSize) Name() string {
|
||||
return "rpc.client.response.size"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (ClientResponseSize) Unit() string {
|
||||
return "By"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (ClientResponseSize) Description() string {
|
||||
return "Measures the size of RPC response messages (uncompressed)."
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// **Streaming**: Recorded per response in a streaming batch
|
||||
func (m ClientResponseSize) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
|
||||
if len(attrs) == 0 {
|
||||
m.Int64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributes(attrs...))
|
||||
m.Int64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// 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.
|
||||
type ClientResponsesPerRPC struct {
|
||||
metric.Int64Histogram
|
||||
}
|
||||
|
||||
// NewClientResponsesPerRPC returns a new ClientResponsesPerRPC instrument.
|
||||
func NewClientResponsesPerRPC(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64HistogramOption,
|
||||
) (ClientResponsesPerRPC, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return ClientResponsesPerRPC{noop.Int64Histogram{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Histogram(
|
||||
"rpc.client.responses_per_rpc",
|
||||
append([]metric.Int64HistogramOption{
|
||||
metric.WithDescription("Measures the number of messages sent per RPC."),
|
||||
metric.WithUnit("{count}"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return ClientResponsesPerRPC{noop.Int64Histogram{}}, err
|
||||
}
|
||||
return ClientResponsesPerRPC{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m ClientResponsesPerRPC) Inst() metric.Int64Histogram {
|
||||
return m.Int64Histogram
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (ClientResponsesPerRPC) Name() string {
|
||||
return "rpc.client.responses_per_rpc"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (ClientResponsesPerRPC) Unit() string {
|
||||
return "{count}"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (ClientResponsesPerRPC) Description() string {
|
||||
return "Measures the number of messages sent per RPC."
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// Should be 1 for all non-streaming RPCs.
|
||||
//
|
||||
// **Streaming**: This metric is required for server and client streaming RPCs
|
||||
func (m ClientResponsesPerRPC) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
|
||||
if len(attrs) == 0 {
|
||||
m.Int64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributes(attrs...))
|
||||
m.Int64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// 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.
|
||||
type ServerDuration struct {
|
||||
metric.Float64Histogram
|
||||
}
|
||||
|
||||
// NewServerDuration returns a new ServerDuration instrument.
|
||||
func NewServerDuration(
|
||||
m metric.Meter,
|
||||
opt ...metric.Float64HistogramOption,
|
||||
) (ServerDuration, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return ServerDuration{noop.Float64Histogram{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Float64Histogram(
|
||||
"rpc.server.duration",
|
||||
append([]metric.Float64HistogramOption{
|
||||
metric.WithDescription("Measures the duration of inbound RPC."),
|
||||
metric.WithUnit("ms"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return ServerDuration{noop.Float64Histogram{}}, err
|
||||
}
|
||||
return ServerDuration{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m ServerDuration) Inst() metric.Float64Histogram {
|
||||
return m.Float64Histogram
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (ServerDuration) Name() string {
|
||||
return "rpc.server.duration"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (ServerDuration) Unit() string {
|
||||
return "ms"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (ServerDuration) Description() string {
|
||||
return "Measures the duration of inbound RPC."
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// 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) Record(ctx context.Context, val float64, attrs ...attribute.KeyValue) {
|
||||
if len(attrs) == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributes(attrs...))
|
||||
m.Float64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// 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).
|
||||
type ServerRequestSize struct {
|
||||
metric.Int64Histogram
|
||||
}
|
||||
|
||||
// NewServerRequestSize returns a new ServerRequestSize instrument.
|
||||
func NewServerRequestSize(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64HistogramOption,
|
||||
) (ServerRequestSize, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return ServerRequestSize{noop.Int64Histogram{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Histogram(
|
||||
"rpc.server.request.size",
|
||||
append([]metric.Int64HistogramOption{
|
||||
metric.WithDescription("Measures the size of RPC request messages (uncompressed)."),
|
||||
metric.WithUnit("By"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return ServerRequestSize{noop.Int64Histogram{}}, err
|
||||
}
|
||||
return ServerRequestSize{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m ServerRequestSize) Inst() metric.Int64Histogram {
|
||||
return m.Int64Histogram
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (ServerRequestSize) Name() string {
|
||||
return "rpc.server.request.size"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (ServerRequestSize) Unit() string {
|
||||
return "By"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (ServerRequestSize) Description() string {
|
||||
return "Measures the size of RPC request messages (uncompressed)."
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// **Streaming**: Recorded per message in a streaming batch
|
||||
func (m ServerRequestSize) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
|
||||
if len(attrs) == 0 {
|
||||
m.Int64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributes(attrs...))
|
||||
m.Int64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// 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.
|
||||
type ServerRequestsPerRPC struct {
|
||||
metric.Int64Histogram
|
||||
}
|
||||
|
||||
// NewServerRequestsPerRPC returns a new ServerRequestsPerRPC instrument.
|
||||
func NewServerRequestsPerRPC(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64HistogramOption,
|
||||
) (ServerRequestsPerRPC, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return ServerRequestsPerRPC{noop.Int64Histogram{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Histogram(
|
||||
"rpc.server.requests_per_rpc",
|
||||
append([]metric.Int64HistogramOption{
|
||||
metric.WithDescription("Measures the number of messages received per RPC."),
|
||||
metric.WithUnit("{count}"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return ServerRequestsPerRPC{noop.Int64Histogram{}}, err
|
||||
}
|
||||
return ServerRequestsPerRPC{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m ServerRequestsPerRPC) Inst() metric.Int64Histogram {
|
||||
return m.Int64Histogram
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (ServerRequestsPerRPC) Name() string {
|
||||
return "rpc.server.requests_per_rpc"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (ServerRequestsPerRPC) Unit() string {
|
||||
return "{count}"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (ServerRequestsPerRPC) Description() string {
|
||||
return "Measures the number of messages received per RPC."
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// Should be 1 for all non-streaming RPCs.
|
||||
//
|
||||
// **Streaming** : This metric is required for server and client streaming RPCs
|
||||
func (m ServerRequestsPerRPC) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
|
||||
if len(attrs) == 0 {
|
||||
m.Int64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributes(attrs...))
|
||||
m.Int64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// 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).
|
||||
type ServerResponseSize struct {
|
||||
metric.Int64Histogram
|
||||
}
|
||||
|
||||
// NewServerResponseSize returns a new ServerResponseSize instrument.
|
||||
func NewServerResponseSize(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64HistogramOption,
|
||||
) (ServerResponseSize, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return ServerResponseSize{noop.Int64Histogram{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Histogram(
|
||||
"rpc.server.response.size",
|
||||
append([]metric.Int64HistogramOption{
|
||||
metric.WithDescription("Measures the size of RPC response messages (uncompressed)."),
|
||||
metric.WithUnit("By"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return ServerResponseSize{noop.Int64Histogram{}}, err
|
||||
}
|
||||
return ServerResponseSize{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m ServerResponseSize) Inst() metric.Int64Histogram {
|
||||
return m.Int64Histogram
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (ServerResponseSize) Name() string {
|
||||
return "rpc.server.response.size"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (ServerResponseSize) Unit() string {
|
||||
return "By"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (ServerResponseSize) Description() string {
|
||||
return "Measures the size of RPC response messages (uncompressed)."
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// **Streaming**: Recorded per response in a streaming batch
|
||||
func (m ServerResponseSize) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
|
||||
if len(attrs) == 0 {
|
||||
m.Int64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributes(attrs...))
|
||||
m.Int64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// 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.
|
||||
type ServerResponsesPerRPC struct {
|
||||
metric.Int64Histogram
|
||||
}
|
||||
|
||||
// NewServerResponsesPerRPC returns a new ServerResponsesPerRPC instrument.
|
||||
func NewServerResponsesPerRPC(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64HistogramOption,
|
||||
) (ServerResponsesPerRPC, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return ServerResponsesPerRPC{noop.Int64Histogram{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64Histogram(
|
||||
"rpc.server.responses_per_rpc",
|
||||
append([]metric.Int64HistogramOption{
|
||||
metric.WithDescription("Measures the number of messages sent per RPC."),
|
||||
metric.WithUnit("{count}"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return ServerResponsesPerRPC{noop.Int64Histogram{}}, err
|
||||
}
|
||||
return ServerResponsesPerRPC{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m ServerResponsesPerRPC) Inst() metric.Int64Histogram {
|
||||
return m.Int64Histogram
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (ServerResponsesPerRPC) Name() string {
|
||||
return "rpc.server.responses_per_rpc"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (ServerResponsesPerRPC) Unit() string {
|
||||
return "{count}"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (ServerResponsesPerRPC) Description() string {
|
||||
return "Measures the number of messages sent per RPC."
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// Should be 1 for all non-streaming RPCs.
|
||||
//
|
||||
// **Streaming**: This metric is required for server and client streaming RPCs
|
||||
func (m ServerResponsesPerRPC) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
|
||||
if len(attrs) == 0 {
|
||||
m.Int64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributes(attrs...))
|
||||
m.Int64Histogram.Record(ctx, val, *o...)
|
||||
}
|
9
semconv/v1.33.0/schema.go
Normal file
9
semconv/v1.33.0/schema.go
Normal file
@@ -0,0 +1,9 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package semconv // import "go.opentelemetry.io/otel/semconv/v1.33.0"
|
||||
|
||||
// SchemaURL is the schema URL that matches the version of the semantic conventions
|
||||
// that this package defines. Semconv packages starting from v1.4.0 must declare
|
||||
// non-empty schema URL in the form https://opentelemetry.io/schemas/<version>
|
||||
const SchemaURL = "https://opentelemetry.io/schemas/1.33.0"
|
233
semconv/v1.33.0/signalrconv/metric.go
Normal file
233
semconv/v1.33.0/signalrconv/metric.go
Normal file
@@ -0,0 +1,233 @@
|
||||
// Code generated from semantic convention specification. DO NOT EDIT.
|
||||
|
||||
// Package httpconv provides types and functionality for OpenTelemetry semantic
|
||||
// conventions in the "signalr" namespace.
|
||||
package signalrconv
|
||||
|
||||
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{} }}
|
||||
)
|
||||
|
||||
// ConnectionStatusAttr is an attribute conforming to the
|
||||
// signalr.connection.status semantic conventions. It represents the signalR HTTP
|
||||
// connection closure status.
|
||||
type ConnectionStatusAttr string
|
||||
|
||||
var (
|
||||
// ConnectionStatusNormalClosure is the connection was closed normally.
|
||||
ConnectionStatusNormalClosure ConnectionStatusAttr = "normal_closure"
|
||||
// ConnectionStatusTimeout is the connection was closed due to a timeout.
|
||||
ConnectionStatusTimeout ConnectionStatusAttr = "timeout"
|
||||
// ConnectionStatusAppShutdown is the connection was closed because the app is
|
||||
// shutting down.
|
||||
ConnectionStatusAppShutdown ConnectionStatusAttr = "app_shutdown"
|
||||
)
|
||||
|
||||
// TransportAttr is an attribute conforming to the signalr.transport semantic
|
||||
// conventions. It represents the [SignalR transport type].
|
||||
//
|
||||
// [SignalR transport type]: https://github.com/dotnet/aspnetcore/blob/main/src/SignalR/docs/specs/TransportProtocols.md
|
||||
type TransportAttr string
|
||||
|
||||
var (
|
||||
// TransportServerSentEvents is the serverSentEvents protocol.
|
||||
TransportServerSentEvents TransportAttr = "server_sent_events"
|
||||
// TransportLongPolling is the longPolling protocol.
|
||||
TransportLongPolling TransportAttr = "long_polling"
|
||||
// TransportWebSockets is the webSockets protocol.
|
||||
TransportWebSockets TransportAttr = "web_sockets"
|
||||
)
|
||||
|
||||
// ServerActiveConnections is an instrument used to record metric values
|
||||
// conforming to the "signalr.server.active_connections" semantic conventions. It
|
||||
// represents the number of connections that are currently active on the server.
|
||||
type ServerActiveConnections struct {
|
||||
metric.Int64UpDownCounter
|
||||
}
|
||||
|
||||
// NewServerActiveConnections returns a new ServerActiveConnections instrument.
|
||||
func NewServerActiveConnections(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64UpDownCounterOption,
|
||||
) (ServerActiveConnections, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return ServerActiveConnections{noop.Int64UpDownCounter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64UpDownCounter(
|
||||
"signalr.server.active_connections",
|
||||
append([]metric.Int64UpDownCounterOption{
|
||||
metric.WithDescription("Number of connections that are currently active on the server."),
|
||||
metric.WithUnit("{connection}"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return ServerActiveConnections{noop.Int64UpDownCounter{}}, err
|
||||
}
|
||||
return ServerActiveConnections{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m ServerActiveConnections) Inst() metric.Int64UpDownCounter {
|
||||
return m.Int64UpDownCounter
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (ServerActiveConnections) Name() string {
|
||||
return "signalr.server.active_connections"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (ServerActiveConnections) Unit() string {
|
||||
return "{connection}"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (ServerActiveConnections) Description() string {
|
||||
return "Number of connections that are currently active on the server."
|
||||
}
|
||||
|
||||
// Add adds incr to the existing count.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
//
|
||||
// Meter name: `Microsoft.AspNetCore.Http.Connections`; Added in: ASP.NET Core
|
||||
// 8.0
|
||||
func (m ServerActiveConnections) Add(
|
||||
ctx context.Context,
|
||||
incr int64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(
|
||||
*o,
|
||||
metric.WithAttributes(
|
||||
attrs...,
|
||||
),
|
||||
)
|
||||
|
||||
m.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.
|
||||
func (ServerActiveConnections) AttrConnectionStatus(val ConnectionStatusAttr) attribute.KeyValue {
|
||||
return attribute.String("signalr.connection.status", string(val))
|
||||
}
|
||||
|
||||
// AttrTransport returns an optional attribute for the "signalr.transport"
|
||||
// semantic convention. It represents the [SignalR transport type].
|
||||
//
|
||||
// [SignalR transport type]: https://github.com/dotnet/aspnetcore/blob/main/src/SignalR/docs/specs/TransportProtocols.md
|
||||
func (ServerActiveConnections) AttrTransport(val TransportAttr) attribute.KeyValue {
|
||||
return attribute.String("signalr.transport", string(val))
|
||||
}
|
||||
|
||||
// ServerConnectionDuration is an instrument used to record metric values
|
||||
// conforming to the "signalr.server.connection.duration" semantic conventions.
|
||||
// It represents the duration of connections on the server.
|
||||
type ServerConnectionDuration struct {
|
||||
metric.Float64Histogram
|
||||
}
|
||||
|
||||
// NewServerConnectionDuration returns a new ServerConnectionDuration instrument.
|
||||
func NewServerConnectionDuration(
|
||||
m metric.Meter,
|
||||
opt ...metric.Float64HistogramOption,
|
||||
) (ServerConnectionDuration, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return ServerConnectionDuration{noop.Float64Histogram{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Float64Histogram(
|
||||
"signalr.server.connection.duration",
|
||||
append([]metric.Float64HistogramOption{
|
||||
metric.WithDescription("The duration of connections on the server."),
|
||||
metric.WithUnit("s"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return ServerConnectionDuration{noop.Float64Histogram{}}, err
|
||||
}
|
||||
return ServerConnectionDuration{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m ServerConnectionDuration) Inst() metric.Float64Histogram {
|
||||
return m.Float64Histogram
|
||||
}
|
||||
|
||||
// Name returns the semantic convention name of the instrument.
|
||||
func (ServerConnectionDuration) Name() string {
|
||||
return "signalr.server.connection.duration"
|
||||
}
|
||||
|
||||
// Unit returns the semantic convention unit of the instrument
|
||||
func (ServerConnectionDuration) Unit() string {
|
||||
return "s"
|
||||
}
|
||||
|
||||
// Description returns the semantic convention description of the instrument
|
||||
func (ServerConnectionDuration) Description() string {
|
||||
return "The duration of connections on the server."
|
||||
}
|
||||
|
||||
// Record records val to the current distribution.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
//
|
||||
// Meter name: `Microsoft.AspNetCore.Http.Connections`; Added in: ASP.NET Core
|
||||
// 8.0
|
||||
func (m ServerConnectionDuration) Record(
|
||||
ctx context.Context,
|
||||
val float64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(
|
||||
*o,
|
||||
metric.WithAttributes(
|
||||
attrs...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Float64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// AttrConnectionStatus returns an optional attribute for the
|
||||
// "signalr.connection.status" semantic convention. It represents the signalR
|
||||
// HTTP connection closure status.
|
||||
func (ServerConnectionDuration) AttrConnectionStatus(val ConnectionStatusAttr) attribute.KeyValue {
|
||||
return attribute.String("signalr.connection.status", string(val))
|
||||
}
|
||||
|
||||
// AttrTransport returns an optional attribute for the "signalr.transport"
|
||||
// semantic convention. It represents the [SignalR transport type].
|
||||
//
|
||||
// [SignalR transport type]: https://github.com/dotnet/aspnetcore/blob/main/src/SignalR/docs/specs/TransportProtocols.md
|
||||
func (ServerConnectionDuration) AttrTransport(val TransportAttr) attribute.KeyValue {
|
||||
return attribute.String("signalr.transport", string(val))
|
||||
}
|
2559
semconv/v1.33.0/systemconv/metric.go
Normal file
2559
semconv/v1.33.0/systemconv/metric.go
Normal file
File diff suppressed because it is too large
Load Diff
1364
semconv/v1.33.0/vcsconv/metric.go
Normal file
1364
semconv/v1.33.0/vcsconv/metric.go
Normal file
File diff suppressed because it is too large
Load Diff
@@ -52,6 +52,7 @@ text_maps:
|
||||
string: String
|
||||
string[]: StringSlice
|
||||
int: Int
|
||||
int64: Int64
|
||||
int[]: IntSlice
|
||||
double: Float64
|
||||
double[]: FloatSlice
|
||||
|
Reference in New Issue
Block a user