You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-11-29 23:07:45 +02:00
@@ -57,6 +57,9 @@ The next release will require at least [Go 1.24].
|
||||
- Add experimental self-observability trace exporter metrics in `go.opentelemetry.io/otel/exporters/stdout/stdouttrace`.
|
||||
Check the `go.opentelemetry.io/otel/exporters/stdout/stdouttrace/internal/x` package documentation for more information. (#7133)
|
||||
- Support testing of [Go 1.25]. (#7187)
|
||||
- The `go.opentelemetry.io/otel/semconv/v1.37.0` package.
|
||||
The package contains semantic conventions from the `v1.37.0` version of the OpenTelemetry Semantic Conventions.
|
||||
See the [migration documentation](./semconv/v1.37.0/MIGRATION.md) for information on how to upgrade from `go.opentelemetry.io/otel/semconv/v1.36.0.`(#7254)
|
||||
|
||||
### Changed
|
||||
|
||||
|
||||
41
semconv/v1.37.0/MIGRATION.md
Normal file
41
semconv/v1.37.0/MIGRATION.md
Normal file
@@ -0,0 +1,41 @@
|
||||
<!-- Generated. DO NOT MODIFY. -->
|
||||
# Migration from v1.36.0 to v1.37.0
|
||||
|
||||
The `go.opentelemetry.io/otel/semconv/v1.37.0` package should be a drop-in replacement for `go.opentelemetry.io/otel/semconv/v1.36.0` with the following exceptions.
|
||||
|
||||
## Removed
|
||||
|
||||
The following declarations have been removed.
|
||||
Refer to the [OpenTelemetry Semantic Conventions documentation] for deprecation instructions.
|
||||
|
||||
If the type is not listed in the documentation as deprecated, it has been removed in this version due to lack of applicability or use.
|
||||
If you use any of these non-deprecated declarations in your Go application, please [open an issue] describing your use-case.
|
||||
|
||||
- `ContainerRuntime`
|
||||
- `ContainerRuntimeKey`
|
||||
- `GenAIOpenAIRequestServiceTierAuto`
|
||||
- `GenAIOpenAIRequestServiceTierDefault`
|
||||
- `GenAIOpenAIRequestServiceTierKey`
|
||||
- `GenAIOpenAIResponseServiceTier`
|
||||
- `GenAIOpenAIResponseServiceTierKey`
|
||||
- `GenAIOpenAIResponseSystemFingerprint`
|
||||
- `GenAIOpenAIResponseSystemFingerprintKey`
|
||||
- `GenAISystemAWSBedrock`
|
||||
- `GenAISystemAnthropic`
|
||||
- `GenAISystemAzureAIInference`
|
||||
- `GenAISystemAzureAIOpenAI`
|
||||
- `GenAISystemCohere`
|
||||
- `GenAISystemDeepseek`
|
||||
- `GenAISystemGCPGemini`
|
||||
- `GenAISystemGCPGenAI`
|
||||
- `GenAISystemGCPVertexAI`
|
||||
- `GenAISystemGroq`
|
||||
- `GenAISystemIBMWatsonxAI`
|
||||
- `GenAISystemKey`
|
||||
- `GenAISystemMistralAI`
|
||||
- `GenAISystemOpenAI`
|
||||
- `GenAISystemPerplexity`
|
||||
- `GenAISystemXai`
|
||||
|
||||
[OpenTelemetry Semantic Conventions documentation]: https://github.com/open-telemetry/semantic-conventions
|
||||
[open an issue]: https://github.com/open-telemetry/opentelemetry-go/issues/new?template=Blank+issue
|
||||
3
semconv/v1.37.0/README.md
Normal file
3
semconv/v1.37.0/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Semconv v1.37.0
|
||||
|
||||
[](https://pkg.go.dev/go.opentelemetry.io/otel/semconv/v1.37.0)
|
||||
15193
semconv/v1.37.0/attribute_group.go
Normal file
15193
semconv/v1.37.0/attribute_group.go
Normal file
File diff suppressed because it is too large
Load Diff
333
semconv/v1.37.0/azureconv/metric.go
Normal file
333
semconv/v1.37.0/azureconv/metric.go
Normal file
@@ -0,0 +1,333 @@
|
||||
// Code generated from semantic convention specification. DO NOT EDIT.
|
||||
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// 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 strong.
|
||||
CosmosDBConsistencyLevelStrong CosmosDBConsistencyLevelAttr = "Strong"
|
||||
// CosmosDBConsistencyLevelBoundedStaleness is the bounded Staleness.
|
||||
CosmosDBConsistencyLevelBoundedStaleness CosmosDBConsistencyLevelAttr = "BoundedStaleness"
|
||||
// CosmosDBConsistencyLevelSession is the session.
|
||||
CosmosDBConsistencyLevelSession CosmosDBConsistencyLevelAttr = "Session"
|
||||
// CosmosDBConsistencyLevelEventual is the eventual.
|
||||
CosmosDBConsistencyLevelEventual CosmosDBConsistencyLevelAttr = "Eventual"
|
||||
// CosmosDBConsistencyLevelConsistentPrefix is the consistent Prefix.
|
||||
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 for attrs.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m CosmosDBClientActiveInstanceCount) 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...)
|
||||
}
|
||||
|
||||
// AddSet adds incr to the existing count for set.
|
||||
func (m CosmosDBClientActiveInstanceCount) AddSet(ctx context.Context, incr int64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Int64UpDownCounter.Add(ctx, incr)
|
||||
return
|
||||
}
|
||||
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Int64UpDownCounter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// AttrServerPort returns an optional attribute for the "server.port" semantic
|
||||
// convention. It represents the server port number.
|
||||
func (CosmosDBClientActiveInstanceCount) AttrServerPort(val int) attribute.KeyValue {
|
||||
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 for attrs.
|
||||
//
|
||||
// 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,
|
||||
) {
|
||||
if len(attrs) == 0 {
|
||||
m.Int64Histogram.Record(ctx, val)
|
||||
return
|
||||
}
|
||||
|
||||
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...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
func (m CosmosDBClientOperationRequestCharge) RecordSet(ctx context.Context, val int64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Int64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Int64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// AttrCosmosDBConsistencyLevel returns an optional attribute for the
|
||||
// "azure.cosmosdb.consistency.level" semantic convention. It represents the
|
||||
// account or request [consistency level].
|
||||
//
|
||||
// [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)
|
||||
}
|
||||
643
semconv/v1.37.0/cicdconv/metric.go
Normal file
643
semconv/v1.37.0/cicdconv/metric.go
Normal file
@@ -0,0 +1,643 @@
|
||||
// Code generated from semantic convention specification. DO NOT EDIT.
|
||||
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// 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 for attrs.
|
||||
//
|
||||
// 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,
|
||||
) {
|
||||
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(
|
||||
append(
|
||||
attrs,
|
||||
attribute.String("cicd.pipeline.name", pipelineName),
|
||||
attribute.String("cicd.pipeline.run.state", string(pipelineRunState)),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Int64UpDownCounter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// AddSet adds incr to the existing count for set.
|
||||
func (m PipelineRunActive) AddSet(ctx context.Context, incr int64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Int64UpDownCounter.Add(ctx, incr)
|
||||
return
|
||||
}
|
||||
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Int64UpDownCounter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// PipelineRunDuration is an instrument used to record metric values conforming
|
||||
// to the "cicd.pipeline.run.duration" semantic conventions. It represents the
|
||||
// duration of a pipeline run grouped by pipeline, state and result.
|
||||
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 for attrs.
|
||||
//
|
||||
// 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,
|
||||
) {
|
||||
if len(attrs) == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
return
|
||||
}
|
||||
|
||||
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...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
func (m PipelineRunDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Float64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// AttrPipelineResult returns an optional attribute for the
|
||||
// "cicd.pipeline.result" semantic convention. It represents the result of a
|
||||
// pipeline run.
|
||||
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 for attrs.
|
||||
//
|
||||
// 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,
|
||||
) {
|
||||
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(
|
||||
append(
|
||||
attrs,
|
||||
attribute.String("cicd.pipeline.name", pipelineName),
|
||||
attribute.String("error.type", string(errorType)),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Int64Counter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// AddSet adds incr to the existing count for set.
|
||||
//
|
||||
// There might be errors in a pipeline run that are non fatal (eg. they are
|
||||
// suppressed) or in a parallel stage multiple stages could have a fatal error.
|
||||
// This means that this error count might not be the same as the count of metric
|
||||
// `cicd.pipeline.run.duration` with run result `failure`.
|
||||
func (m PipelineRunErrors) AddSet(ctx context.Context, incr int64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Int64Counter.Add(ctx, incr)
|
||||
return
|
||||
}
|
||||
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Int64Counter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// SystemErrors is an instrument used to record metric values conforming to the
|
||||
// "cicd.system.errors" semantic conventions. It represents the number of errors
|
||||
// in a component of the CICD system (eg. controller, scheduler, agent).
|
||||
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 for attrs.
|
||||
//
|
||||
// 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,
|
||||
) {
|
||||
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(
|
||||
append(
|
||||
attrs,
|
||||
attribute.String("cicd.system.component", systemComponent),
|
||||
attribute.String("error.type", string(errorType)),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Int64Counter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// AddSet adds incr to the existing count for set.
|
||||
//
|
||||
// Errors in pipeline run execution are explicitly excluded. Ie a test failure is
|
||||
// not counted in this metric.
|
||||
func (m SystemErrors) AddSet(ctx context.Context, incr int64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Int64Counter.Add(ctx, incr)
|
||||
return
|
||||
}
|
||||
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Int64Counter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// WorkerCount is an instrument used to record metric values conforming to the
|
||||
// "cicd.worker.count" semantic conventions. It represents the number of workers
|
||||
// on the CICD system by state.
|
||||
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 for attrs.
|
||||
//
|
||||
// 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,
|
||||
) {
|
||||
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(
|
||||
append(
|
||||
attrs,
|
||||
attribute.String("cicd.worker.state", string(workerState)),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Int64UpDownCounter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// AddSet adds incr to the existing count for set.
|
||||
func (m WorkerCount) AddSet(ctx context.Context, incr int64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Int64UpDownCounter.Add(ctx, incr)
|
||||
return
|
||||
}
|
||||
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Int64UpDownCounter.Add(ctx, incr, *o...)
|
||||
}
|
||||
1000
semconv/v1.37.0/containerconv/metric.go
Normal file
1000
semconv/v1.37.0/containerconv/metric.go
Normal file
File diff suppressed because it is too large
Load Diff
1542
semconv/v1.37.0/dbconv/metric.go
Normal file
1542
semconv/v1.37.0/dbconv/metric.go
Normal file
File diff suppressed because it is too large
Load Diff
139
semconv/v1.37.0/dnsconv/metric.go
Normal file
139
semconv/v1.37.0/dnsconv/metric.go
Normal file
@@ -0,0 +1,139 @@
|
||||
// Code generated from semantic convention specification. DO NOT EDIT.
|
||||
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// 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 for attrs.
|
||||
//
|
||||
// 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,
|
||||
) {
|
||||
if len(attrs) == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
return
|
||||
}
|
||||
|
||||
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...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
func (m LookupDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Float64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// AttrErrorType returns an optional attribute for the "error.type" semantic
|
||||
// convention. It represents the describes the error the DNS lookup failed with.
|
||||
func (LookupDuration) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
|
||||
return attribute.String("error.type", string(val))
|
||||
}
|
||||
9
semconv/v1.37.0/doc.go
Normal file
9
semconv/v1.37.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.37.0
|
||||
// version of the OpenTelemetry semantic conventions.
|
||||
package semconv // import "go.opentelemetry.io/otel/semconv/v1.37.0"
|
||||
31
semconv/v1.37.0/error_type.go
Normal file
31
semconv/v1.37.0/error_type.go
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package semconv // import "go.opentelemetry.io/otel/semconv/v1.37.0"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
)
|
||||
|
||||
// ErrorType returns an [attribute.KeyValue] identifying the error type of err.
|
||||
func ErrorType(err error) attribute.KeyValue {
|
||||
if err == nil {
|
||||
return ErrorTypeOther
|
||||
}
|
||||
t := reflect.TypeOf(err)
|
||||
var value string
|
||||
if t.PkgPath() == "" && t.Name() == "" {
|
||||
// Likely a builtin type.
|
||||
value = t.String()
|
||||
} else {
|
||||
value = fmt.Sprintf("%s.%s", t.PkgPath(), t.Name())
|
||||
}
|
||||
|
||||
if value == "" {
|
||||
return ErrorTypeOther
|
||||
}
|
||||
return ErrorTypeKey.String(value)
|
||||
}
|
||||
59
semconv/v1.37.0/error_type_test.go
Normal file
59
semconv/v1.37.0/error_type_test.go
Normal file
@@ -0,0 +1,59 @@
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package semconv // import "go.opentelemetry.io/otel/semconv/v1.37.0"
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
)
|
||||
|
||||
type CustomError struct{}
|
||||
|
||||
func (CustomError) Error() string {
|
||||
return "custom error"
|
||||
}
|
||||
|
||||
func TestErrorType(t *testing.T) {
|
||||
customErr := CustomError{}
|
||||
builtinErr := errors.New("something went wrong")
|
||||
var nilErr error
|
||||
|
||||
wantCustomType := reflect.TypeOf(customErr)
|
||||
wantCustomStr := fmt.Sprintf("%s.%s", wantCustomType.PkgPath(), wantCustomType.Name())
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
err error
|
||||
want attribute.KeyValue
|
||||
}{
|
||||
{
|
||||
name: "BuiltinError",
|
||||
err: builtinErr,
|
||||
want: attribute.String("error.type", "*errors.errorString"),
|
||||
},
|
||||
{
|
||||
name: "CustomError",
|
||||
err: customErr,
|
||||
want: attribute.String("error.type", wantCustomStr),
|
||||
},
|
||||
{
|
||||
name: "NilError",
|
||||
err: nilErr,
|
||||
want: ErrorTypeOther,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := ErrorType(tt.err)
|
||||
if got != tt.want {
|
||||
t.Errorf("ErrorType(%v) = %v, want %v", tt.err, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
9
semconv/v1.37.0/exception.go
Normal file
9
semconv/v1.37.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.37.0"
|
||||
|
||||
const (
|
||||
// ExceptionEventName is the name of the Span event representing an exception.
|
||||
ExceptionEventName = "exception"
|
||||
)
|
||||
964
semconv/v1.37.0/faasconv/metric.go
Normal file
964
semconv/v1.37.0/faasconv/metric.go
Normal file
@@ -0,0 +1,964 @@
|
||||
// Code generated from semantic convention specification. DO NOT EDIT.
|
||||
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// 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 for attrs.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m Coldstarts) 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...)
|
||||
}
|
||||
|
||||
// AddSet adds incr to the existing count for set.
|
||||
func (m Coldstarts) AddSet(ctx context.Context, incr int64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Int64Counter.Add(ctx, incr)
|
||||
return
|
||||
}
|
||||
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Int64Counter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
|
||||
// convention. It represents the type of the trigger which caused this function
|
||||
// invocation.
|
||||
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 for attrs.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m CPUUsage) Record(
|
||||
ctx context.Context,
|
||||
val float64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
if len(attrs) == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
return
|
||||
}
|
||||
|
||||
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...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
func (m CPUUsage) RecordSet(ctx context.Context, val float64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Float64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
|
||||
// convention. It represents the type of the trigger which caused this function
|
||||
// invocation.
|
||||
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 for attrs.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m Errors) 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...)
|
||||
}
|
||||
|
||||
// AddSet adds incr to the existing count for set.
|
||||
func (m Errors) AddSet(ctx context.Context, incr int64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Int64Counter.Add(ctx, incr)
|
||||
return
|
||||
}
|
||||
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Int64Counter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
|
||||
// convention. It represents the type of the trigger which caused this function
|
||||
// invocation.
|
||||
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 for attrs.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m InitDuration) Record(
|
||||
ctx context.Context,
|
||||
val float64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
if len(attrs) == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
return
|
||||
}
|
||||
|
||||
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...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
func (m InitDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Float64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
|
||||
// convention. It represents the type of the trigger which caused this function
|
||||
// invocation.
|
||||
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 for attrs.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m Invocations) 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...)
|
||||
}
|
||||
|
||||
// AddSet adds incr to the existing count for set.
|
||||
func (m Invocations) AddSet(ctx context.Context, incr int64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Int64Counter.Add(ctx, incr)
|
||||
return
|
||||
}
|
||||
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Int64Counter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
|
||||
// convention. It represents the type of the trigger which caused this function
|
||||
// invocation.
|
||||
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 for attrs.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m InvokeDuration) Record(
|
||||
ctx context.Context,
|
||||
val float64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
if len(attrs) == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
return
|
||||
}
|
||||
|
||||
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...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
func (m InvokeDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Float64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
|
||||
// convention. It represents the type of the trigger which caused this function
|
||||
// invocation.
|
||||
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 for attrs.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m MemUsage) Record(
|
||||
ctx context.Context,
|
||||
val int64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
if len(attrs) == 0 {
|
||||
m.Int64Histogram.Record(ctx, val)
|
||||
return
|
||||
}
|
||||
|
||||
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...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
func (m MemUsage) RecordSet(ctx context.Context, val int64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Int64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Int64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
|
||||
// convention. It represents the type of the trigger which caused this function
|
||||
// invocation.
|
||||
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 for attrs.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m NetIO) Record(
|
||||
ctx context.Context,
|
||||
val int64,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
if len(attrs) == 0 {
|
||||
m.Int64Histogram.Record(ctx, val)
|
||||
return
|
||||
}
|
||||
|
||||
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...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
func (m NetIO) RecordSet(ctx context.Context, val int64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Int64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Int64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
|
||||
// convention. It represents the type of the trigger which caused this function
|
||||
// invocation.
|
||||
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 for attrs.
|
||||
//
|
||||
// All additional attrs passed are included in the recorded value.
|
||||
func (m Timeouts) 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...)
|
||||
}
|
||||
|
||||
// AddSet adds incr to the existing count for set.
|
||||
func (m Timeouts) AddSet(ctx context.Context, incr int64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Int64Counter.Add(ctx, incr)
|
||||
return
|
||||
}
|
||||
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Int64Counter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
|
||||
// convention. It represents the type of the trigger which caused this function
|
||||
// invocation.
|
||||
func (Timeouts) AttrTrigger(val TriggerAttr) attribute.KeyValue {
|
||||
return attribute.String("faas.trigger", string(val))
|
||||
}
|
||||
821
semconv/v1.37.0/genaiconv/metric.go
Normal file
821
semconv/v1.37.0/genaiconv/metric.go
Normal file
@@ -0,0 +1,821 @@
|
||||
// Code generated from semantic convention specification. DO NOT EDIT.
|
||||
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// ProviderNameAttr is an attribute conforming to the gen_ai.provider.name
|
||||
// semantic conventions. It represents the Generative AI provider as identified
|
||||
// by the client or server instrumentation.
|
||||
type ProviderNameAttr string
|
||||
|
||||
var (
|
||||
// ProviderNameOpenAI is the [OpenAI].
|
||||
//
|
||||
// [OpenAI]: https://openai.com/
|
||||
ProviderNameOpenAI ProviderNameAttr = "openai"
|
||||
// ProviderNameGCPGenAI is the any Google generative AI endpoint.
|
||||
ProviderNameGCPGenAI ProviderNameAttr = "gcp.gen_ai"
|
||||
// ProviderNameGCPVertexAI is the [Vertex AI].
|
||||
//
|
||||
// [Vertex AI]: https://cloud.google.com/vertex-ai
|
||||
ProviderNameGCPVertexAI ProviderNameAttr = "gcp.vertex_ai"
|
||||
// ProviderNameGCPGemini is the [Gemini].
|
||||
//
|
||||
// [Gemini]: https://cloud.google.com/products/gemini
|
||||
ProviderNameGCPGemini ProviderNameAttr = "gcp.gemini"
|
||||
// ProviderNameAnthropic is the [Anthropic].
|
||||
//
|
||||
// [Anthropic]: https://www.anthropic.com/
|
||||
ProviderNameAnthropic ProviderNameAttr = "anthropic"
|
||||
// ProviderNameCohere is the [Cohere].
|
||||
//
|
||||
// [Cohere]: https://cohere.com/
|
||||
ProviderNameCohere ProviderNameAttr = "cohere"
|
||||
// ProviderNameAzureAIInference is the azure AI Inference.
|
||||
ProviderNameAzureAIInference ProviderNameAttr = "azure.ai.inference"
|
||||
// ProviderNameAzureAIOpenAI is the [Azure OpenAI].
|
||||
//
|
||||
// [Azure OpenAI]: https://azure.microsoft.com/products/ai-services/openai-service/
|
||||
ProviderNameAzureAIOpenAI ProviderNameAttr = "azure.ai.openai"
|
||||
// ProviderNameIBMWatsonxAI is the [IBM Watsonx AI].
|
||||
//
|
||||
// [IBM Watsonx AI]: https://www.ibm.com/products/watsonx-ai
|
||||
ProviderNameIBMWatsonxAI ProviderNameAttr = "ibm.watsonx.ai"
|
||||
// ProviderNameAWSBedrock is the [AWS Bedrock].
|
||||
//
|
||||
// [AWS Bedrock]: https://aws.amazon.com/bedrock
|
||||
ProviderNameAWSBedrock ProviderNameAttr = "aws.bedrock"
|
||||
// ProviderNamePerplexity is the [Perplexity].
|
||||
//
|
||||
// [Perplexity]: https://www.perplexity.ai/
|
||||
ProviderNamePerplexity ProviderNameAttr = "perplexity"
|
||||
// ProviderNameXAI is the [xAI].
|
||||
//
|
||||
// [xAI]: https://x.ai/
|
||||
ProviderNameXAI ProviderNameAttr = "x_ai"
|
||||
// ProviderNameDeepseek is the [DeepSeek].
|
||||
//
|
||||
// [DeepSeek]: https://www.deepseek.com/
|
||||
ProviderNameDeepseek ProviderNameAttr = "deepseek"
|
||||
// ProviderNameGroq is the [Groq].
|
||||
//
|
||||
// [Groq]: https://groq.com/
|
||||
ProviderNameGroq ProviderNameAttr = "groq"
|
||||
// ProviderNameMistralAI is the [Mistral AI].
|
||||
//
|
||||
// [Mistral AI]: https://mistral.ai/
|
||||
ProviderNameMistralAI ProviderNameAttr = "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 for attrs.
|
||||
//
|
||||
// The operationName is the the name of the operation being performed.
|
||||
//
|
||||
// The providerName is the the Generative AI provider 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,
|
||||
providerName ProviderNameAttr,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
if len(attrs) == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
return
|
||||
}
|
||||
|
||||
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.provider.name", string(providerName)),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Float64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
func (m ClientOperationDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Float64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// AttrErrorType returns an optional attribute for the "error.type" semantic
|
||||
// convention. It represents the describes a class of error the operation ended
|
||||
// with.
|
||||
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 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("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 "Number of input and output tokens used."
|
||||
}
|
||||
|
||||
// Record records val to the current distribution for attrs.
|
||||
//
|
||||
// The operationName is the the name of the operation being performed.
|
||||
//
|
||||
// The providerName is the the Generative AI provider 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,
|
||||
providerName ProviderNameAttr,
|
||||
tokenType TokenTypeAttr,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
if len(attrs) == 0 {
|
||||
m.Int64Histogram.Record(ctx, val)
|
||||
return
|
||||
}
|
||||
|
||||
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.provider.name", string(providerName)),
|
||||
attribute.String("gen_ai.token.type", string(tokenType)),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Int64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
func (m ClientTokenUsage) RecordSet(ctx context.Context, val int64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Int64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Int64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// AttrRequestModel returns an optional attribute for the "gen_ai.request.model"
|
||||
// semantic convention. It represents the name of the GenAI model a request is
|
||||
// being made to.
|
||||
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 for attrs.
|
||||
//
|
||||
// The operationName is the the name of the operation being performed.
|
||||
//
|
||||
// The providerName is the the Generative AI provider 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,
|
||||
providerName ProviderNameAttr,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
if len(attrs) == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
return
|
||||
}
|
||||
|
||||
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.provider.name", string(providerName)),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Float64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
func (m ServerRequestDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Float64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// AttrErrorType returns an optional attribute for the "error.type" semantic
|
||||
// convention. It represents the describes a class of error the operation ended
|
||||
// with.
|
||||
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 for attrs.
|
||||
//
|
||||
// The operationName is the the name of the operation being performed.
|
||||
//
|
||||
// The providerName is the the Generative AI provider 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,
|
||||
providerName ProviderNameAttr,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
if len(attrs) == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
return
|
||||
}
|
||||
|
||||
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.provider.name", string(providerName)),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Float64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
func (m ServerTimePerOutputToken) RecordSet(ctx context.Context, val float64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Float64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// AttrRequestModel returns an optional attribute for the "gen_ai.request.model"
|
||||
// semantic convention. It represents the name of the GenAI model a request is
|
||||
// being made to.
|
||||
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 for attrs.
|
||||
//
|
||||
// The operationName is the the name of the operation being performed.
|
||||
//
|
||||
// The providerName is the the Generative AI provider 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,
|
||||
providerName ProviderNameAttr,
|
||||
attrs ...attribute.KeyValue,
|
||||
) {
|
||||
if len(attrs) == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
return
|
||||
}
|
||||
|
||||
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.provider.name", string(providerName)),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Float64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
func (m ServerTimeToFirstToken) RecordSet(ctx context.Context, val float64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Float64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// AttrRequestModel returns an optional attribute for the "gen_ai.request.model"
|
||||
// semantic convention. It represents the name of the GenAI model a request is
|
||||
// being made to.
|
||||
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)
|
||||
}
|
||||
531
semconv/v1.37.0/goconv/metric.go
Normal file
531
semconv/v1.37.0/goconv/metric.go
Normal file
@@ -0,0 +1,531 @@
|
||||
// Code generated from semantic convention specification. DO NOT EDIT.
|
||||
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// 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.Int64ObservableUpDownCounter
|
||||
}
|
||||
|
||||
// NewMemoryUsed returns a new MemoryUsed instrument.
|
||||
func NewMemoryUsed(
|
||||
m metric.Meter,
|
||||
opt ...metric.Int64ObservableUpDownCounterOption,
|
||||
) (MemoryUsed, error) {
|
||||
// Check if the meter is nil.
|
||||
if m == nil {
|
||||
return MemoryUsed{noop.Int64ObservableUpDownCounter{}}, nil
|
||||
}
|
||||
|
||||
i, err := m.Int64ObservableUpDownCounter(
|
||||
"go.memory.used",
|
||||
append([]metric.Int64ObservableUpDownCounterOption{
|
||||
metric.WithDescription("Memory used by the Go runtime."),
|
||||
metric.WithUnit("By"),
|
||||
}, opt...)...,
|
||||
)
|
||||
if err != nil {
|
||||
return MemoryUsed{noop.Int64ObservableUpDownCounter{}}, err
|
||||
}
|
||||
return MemoryUsed{i}, nil
|
||||
}
|
||||
|
||||
// Inst returns the underlying metric instrument.
|
||||
func (m MemoryUsed) Inst() metric.Int64ObservableUpDownCounter {
|
||||
return m.Int64ObservableUpDownCounter
|
||||
}
|
||||
|
||||
// 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 for attrs.
|
||||
//
|
||||
// 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)
|
||||
return
|
||||
}
|
||||
|
||||
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...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
//
|
||||
// Computed from `/sched/latencies:seconds`. Bucket boundaries are provided by
|
||||
// the runtime, and are subject to change.
|
||||
func (m ScheduleDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Float64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
1641
semconv/v1.37.0/httpconv/metric.go
Normal file
1641
semconv/v1.37.0/httpconv/metric.go
Normal file
File diff suppressed because it is too large
Load Diff
5939
semconv/v1.37.0/hwconv/metric.go
Normal file
5939
semconv/v1.37.0/hwconv/metric.go
Normal file
File diff suppressed because it is too large
Load Diff
9195
semconv/v1.37.0/k8sconv/metric.go
Normal file
9195
semconv/v1.37.0/k8sconv/metric.go
Normal file
File diff suppressed because it is too large
Load Diff
765
semconv/v1.37.0/messagingconv/metric.go
Normal file
765
semconv/v1.37.0/messagingconv/metric.go
Normal file
@@ -0,0 +1,765 @@
|
||||
// Code generated from semantic convention specification. DO NOT EDIT.
|
||||
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// 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"
|
||||
// SystemAWSSNS is the amazon Simple Notification Service (SNS).
|
||||
SystemAWSSNS SystemAttr = "aws.sns"
|
||||
// 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 for attrs.
|
||||
//
|
||||
// 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,
|
||||
) {
|
||||
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(
|
||||
append(
|
||||
attrs,
|
||||
attribute.String("messaging.operation.name", operationName),
|
||||
attribute.String("messaging.system", string(system)),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Int64Counter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// AddSet adds incr to the existing count for set.
|
||||
//
|
||||
// Records the number of messages pulled from the broker or number of messages
|
||||
// dispatched to the application in push-based scenarios.
|
||||
// The metric SHOULD be reported once per message delivery. For example, if
|
||||
// receiving and processing operations are both instrumented for a single message
|
||||
// delivery, this counter is incremented when the message is received and not
|
||||
// reported when it is processed.
|
||||
func (m ClientConsumedMessages) AddSet(ctx context.Context, incr int64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Int64Counter.Add(ctx, incr)
|
||||
return
|
||||
}
|
||||
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Int64Counter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// AttrErrorType returns an optional attribute for the "error.type" semantic
|
||||
// convention. It represents the describes a class of error the operation ended
|
||||
// with.
|
||||
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 for attrs.
|
||||
//
|
||||
// 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,
|
||||
) {
|
||||
if len(attrs) == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
return
|
||||
}
|
||||
|
||||
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...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
//
|
||||
// This metric SHOULD NOT be used to report processing duration - processing
|
||||
// duration is reported in `messaging.process.duration` metric.
|
||||
func (m ClientOperationDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Float64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// AttrErrorType returns an optional attribute for the "error.type" semantic
|
||||
// convention. It represents the describes a class of error the operation ended
|
||||
// with.
|
||||
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 for attrs.
|
||||
//
|
||||
// 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,
|
||||
) {
|
||||
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(
|
||||
append(
|
||||
attrs,
|
||||
attribute.String("messaging.operation.name", operationName),
|
||||
attribute.String("messaging.system", string(system)),
|
||||
)...,
|
||||
),
|
||||
)
|
||||
|
||||
m.Int64Counter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// AddSet adds incr to the existing count for set.
|
||||
//
|
||||
// This metric MUST NOT count messages that were created but haven't yet been
|
||||
// sent.
|
||||
func (m ClientSentMessages) AddSet(ctx context.Context, incr int64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Int64Counter.Add(ctx, incr)
|
||||
return
|
||||
}
|
||||
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Int64Counter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// AttrErrorType returns an optional attribute for the "error.type" semantic
|
||||
// convention. It represents the describes a class of error the operation ended
|
||||
// with.
|
||||
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 for attrs.
|
||||
//
|
||||
// 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,
|
||||
) {
|
||||
if len(attrs) == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
return
|
||||
}
|
||||
|
||||
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...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
//
|
||||
// This metric MUST be reported for operations with `messaging.operation.type`
|
||||
// that matches `process`.
|
||||
func (m ProcessDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Float64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// AttrErrorType returns an optional attribute for the "error.type" semantic
|
||||
// convention. It represents the describes a class of error the operation ended
|
||||
// with.
|
||||
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)
|
||||
}
|
||||
2126
semconv/v1.37.0/otelconv/metric.go
Normal file
2126
semconv/v1.37.0/otelconv/metric.go
Normal file
File diff suppressed because it is too large
Load Diff
1101
semconv/v1.37.0/processconv/metric.go
Normal file
1101
semconv/v1.37.0/processconv/metric.go
Normal file
File diff suppressed because it is too large
Load Diff
920
semconv/v1.37.0/rpcconv/metric.go
Normal file
920
semconv/v1.37.0/rpcconv/metric.go
Normal file
@@ -0,0 +1,920 @@
|
||||
// Code generated from semantic convention specification. DO NOT EDIT.
|
||||
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// 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 for attrs.
|
||||
//
|
||||
// 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)
|
||||
return
|
||||
}
|
||||
|
||||
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...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
//
|
||||
// While streaming RPCs may record this metric as start-of-batch
|
||||
// to end-of-batch, it's hard to interpret in practice.
|
||||
//
|
||||
// **Streaming**: N/A.
|
||||
func (m ClientDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Float64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// ClientRequestSize is an instrument used to record metric values conforming to
|
||||
// the "rpc.client.request.size" semantic conventions. It represents the measures
|
||||
// the size of RPC request messages (uncompressed).
|
||||
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 for attrs.
|
||||
//
|
||||
// **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)
|
||||
return
|
||||
}
|
||||
|
||||
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...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
//
|
||||
// **Streaming**: Recorded per message in a streaming batch
|
||||
func (m ClientRequestSize) RecordSet(ctx context.Context, val int64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Int64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Int64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// ClientRequestsPerRPC is an instrument used to record metric values conforming
|
||||
// to the "rpc.client.requests_per_rpc" semantic conventions. It represents the
|
||||
// measures the number of messages received per RPC.
|
||||
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 for attrs.
|
||||
//
|
||||
// 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)
|
||||
return
|
||||
}
|
||||
|
||||
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...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
//
|
||||
// Should be 1 for all non-streaming RPCs.
|
||||
//
|
||||
// **Streaming**: This metric is required for server and client streaming RPCs
|
||||
func (m ClientRequestsPerRPC) RecordSet(ctx context.Context, val int64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Int64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Int64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// ClientResponseSize is an instrument used to record metric values conforming to
|
||||
// the "rpc.client.response.size" semantic conventions. It represents the
|
||||
// measures the size of RPC response messages (uncompressed).
|
||||
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 for attrs.
|
||||
//
|
||||
// **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)
|
||||
return
|
||||
}
|
||||
|
||||
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...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
//
|
||||
// **Streaming**: Recorded per response in a streaming batch
|
||||
func (m ClientResponseSize) RecordSet(ctx context.Context, val int64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Int64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Int64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// ClientResponsesPerRPC is an instrument used to record metric values conforming
|
||||
// to the "rpc.client.responses_per_rpc" semantic conventions. It represents the
|
||||
// measures the number of messages sent per RPC.
|
||||
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 for attrs.
|
||||
//
|
||||
// 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)
|
||||
return
|
||||
}
|
||||
|
||||
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...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
//
|
||||
// Should be 1 for all non-streaming RPCs.
|
||||
//
|
||||
// **Streaming**: This metric is required for server and client streaming RPCs
|
||||
func (m ClientResponsesPerRPC) RecordSet(ctx context.Context, val int64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Int64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Int64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// ServerDuration is an instrument used to record metric values conforming to the
|
||||
// "rpc.server.duration" semantic conventions. It represents the measures the
|
||||
// duration of inbound RPC.
|
||||
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 for attrs.
|
||||
//
|
||||
// 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)
|
||||
return
|
||||
}
|
||||
|
||||
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...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
//
|
||||
// While streaming RPCs may record this metric as start-of-batch
|
||||
// to end-of-batch, it's hard to interpret in practice.
|
||||
//
|
||||
// **Streaming**: N/A.
|
||||
func (m ServerDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Float64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// ServerRequestSize is an instrument used to record metric values conforming to
|
||||
// the "rpc.server.request.size" semantic conventions. It represents the measures
|
||||
// the size of RPC request messages (uncompressed).
|
||||
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 for attrs.
|
||||
//
|
||||
// **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)
|
||||
return
|
||||
}
|
||||
|
||||
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...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
//
|
||||
// **Streaming**: Recorded per message in a streaming batch
|
||||
func (m ServerRequestSize) RecordSet(ctx context.Context, val int64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Int64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Int64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// ServerRequestsPerRPC is an instrument used to record metric values conforming
|
||||
// to the "rpc.server.requests_per_rpc" semantic conventions. It represents the
|
||||
// measures the number of messages received per RPC.
|
||||
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 for attrs.
|
||||
//
|
||||
// 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)
|
||||
return
|
||||
}
|
||||
|
||||
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...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
//
|
||||
// Should be 1 for all non-streaming RPCs.
|
||||
//
|
||||
// **Streaming** : This metric is required for server and client streaming RPCs
|
||||
func (m ServerRequestsPerRPC) RecordSet(ctx context.Context, val int64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Int64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Int64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// ServerResponseSize is an instrument used to record metric values conforming to
|
||||
// the "rpc.server.response.size" semantic conventions. It represents the
|
||||
// measures the size of RPC response messages (uncompressed).
|
||||
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 for attrs.
|
||||
//
|
||||
// **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)
|
||||
return
|
||||
}
|
||||
|
||||
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...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
//
|
||||
// **Streaming**: Recorded per response in a streaming batch
|
||||
func (m ServerResponseSize) RecordSet(ctx context.Context, val int64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Int64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Int64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// ServerResponsesPerRPC is an instrument used to record metric values conforming
|
||||
// to the "rpc.server.responses_per_rpc" semantic conventions. It represents the
|
||||
// measures the number of messages sent per RPC.
|
||||
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 for attrs.
|
||||
//
|
||||
// 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)
|
||||
return
|
||||
}
|
||||
|
||||
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...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
//
|
||||
// Should be 1 for all non-streaming RPCs.
|
||||
//
|
||||
// **Streaming**: This metric is required for server and client streaming RPCs
|
||||
func (m ServerResponsesPerRPC) RecordSet(ctx context.Context, val int64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Int64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Int64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
9
semconv/v1.37.0/schema.go
Normal file
9
semconv/v1.37.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.37.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.37.0"
|
||||
285
semconv/v1.37.0/signalrconv/metric.go
Normal file
285
semconv/v1.37.0/signalrconv/metric.go
Normal file
@@ -0,0 +1,285 @@
|
||||
// Code generated from semantic convention specification. DO NOT EDIT.
|
||||
|
||||
// Copyright The OpenTelemetry Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// 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 for attrs.
|
||||
//
|
||||
// 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,
|
||||
) {
|
||||
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...)
|
||||
}
|
||||
|
||||
// AddSet adds incr to the existing count for set.
|
||||
//
|
||||
// Meter name: `Microsoft.AspNetCore.Http.Connections`; Added in: ASP.NET Core
|
||||
// 8.0
|
||||
func (m ServerActiveConnections) AddSet(ctx context.Context, incr int64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Int64UpDownCounter.Add(ctx, incr)
|
||||
return
|
||||
}
|
||||
|
||||
o := addOptPool.Get().(*[]metric.AddOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
addOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Int64UpDownCounter.Add(ctx, incr, *o...)
|
||||
}
|
||||
|
||||
// AttrConnectionStatus returns an optional attribute for the
|
||||
// "signalr.connection.status" semantic convention. It represents the signalR
|
||||
// HTTP connection closure status.
|
||||
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 for attrs.
|
||||
//
|
||||
// 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,
|
||||
) {
|
||||
if len(attrs) == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
return
|
||||
}
|
||||
|
||||
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...)
|
||||
}
|
||||
|
||||
// RecordSet records val to the current distribution for set.
|
||||
//
|
||||
// Meter name: `Microsoft.AspNetCore.Http.Connections`; Added in: ASP.NET Core
|
||||
// 8.0
|
||||
func (m ServerConnectionDuration) RecordSet(ctx context.Context, val float64, set attribute.Set) {
|
||||
if set.Len() == 0 {
|
||||
m.Float64Histogram.Record(ctx, val)
|
||||
}
|
||||
|
||||
o := recOptPool.Get().(*[]metric.RecordOption)
|
||||
defer func() {
|
||||
*o = (*o)[:0]
|
||||
recOptPool.Put(o)
|
||||
}()
|
||||
|
||||
*o = append(*o, metric.WithAttributeSet(set))
|
||||
m.Float64Histogram.Record(ctx, val, *o...)
|
||||
}
|
||||
|
||||
// AttrConnectionStatus returns an optional attribute for the
|
||||
// "signalr.connection.status" semantic convention. It represents the signalR
|
||||
// HTTP connection closure status.
|
||||
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))
|
||||
}
|
||||
3556
semconv/v1.37.0/systemconv/metric.go
Normal file
3556
semconv/v1.37.0/systemconv/metric.go
Normal file
File diff suppressed because it is too large
Load Diff
1592
semconv/v1.37.0/vcsconv/metric.go
Normal file
1592
semconv/v1.37.0/vcsconv/metric.go
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user