You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2026-06-03 18:35:08 +02:00
5e212ba8c6
Resolve #7030 This generation fixes the following: - The `semconv/weaver.yaml` file is moved to the `semconv/templates/registry/go` to [fix the generation](https://github.com/open-telemetry/opentelemetry-go/issues/7030#issuecomment-3074916061). - Deprecated enum `var`s are no longer generate. - The deprecation of the previous `OSTypeZOS` (`z_os`) conflicts with the replacement (`zos`). - This matches all other generations where deprecated types are not generated and the migration docs identify users need to upgrade when upgrading packages. - Fix metric description rendering to handle multi-line metric descriptions. - Fix filter of deprecated metrics in weaver configuration (see https://github.com/open-telemetry/weaver/issues/847). The release notes for v1.35.0 are included as we do not plan to add a package for that release and it includes breaking changes being released here (i.e. `az.namespace` and `az.service_request_id`) ## [`v1.36.0` semantic convention release notes](https://github.com/open-telemetry/semantic-conventions/releases/tag/v1.36.0) <div data-pjax="true" data-test-selector="body-content" data-view-component="true" class="markdown-body my-3"><h3>🚩 Deprecations 🚩</h3> <ul> <li><code>os</code>: Adds the 'deprecated:' tag/attribute to the <code>z_os</code> enum value of <code>os.type</code>. This value was recently deprecated in v1.35.0. (<a href="https://github.com/open-telemetry/semantic-conventions/issues/2479" data-hovercard-type="pull_request" data-hovercard-url="/open-telemetry/semantic-conventions/pull/2479/hovercard" aria-keyshortcuts="Alt+ArrowUp">#2479</a>)</li> </ul> <h3>💡 Enhancements 💡</h3> <ul> <li><code>otel</code>: Replaces <code>otel.sdk.span.ended</code> with <code>otel.sdk.span.started</code> and allow differentiation based on the parent span origin (<a href="https://github.com/open-telemetry/semantic-conventions/issues/2431" data-hovercard-type="pull_request" data-hovercard-url="/open-telemetry/semantic-conventions/pull/2431/hovercard" aria-keyshortcuts="Alt+ArrowUp">#2431</a>)</li> <li><code>db</code>: Add database context propagation via <code>SET CONTEXT_INFO</code> for SQL Server (<a href="https://github.com/open-telemetry/semantic-conventions/issues/2162" data-hovercard-type="issue" data-hovercard-url="/open-telemetry/semantic-conventions/issues/2162/hovercard" aria-keyshortcuts="Alt+ArrowUp">#2162</a>)</li> <li><code>entities</code>: Adds support for Entity registry and Entity stabilization policies. (<a href="https://github.com/open-telemetry/semantic-conventions/issues/2246" data-hovercard-type="issue" data-hovercard-url="/open-telemetry/semantic-conventions/issues/2246/hovercard" aria-keyshortcuts="Alt+ArrowUp">#2246</a>)</li> </ul> <h3>🧰 Bug fixes 🧰</h3> <ul> <li><code>cloud</code>: Exclude deprecated Azure members from code generation on the <code>cloud.platform</code> attribute (<a href="https://github.com/open-telemetry/semantic-conventions/issues/2477" data-hovercard-type="pull_request" data-hovercard-url="/open-telemetry/semantic-conventions/pull/2477/hovercard" aria-keyshortcuts="Alt+ArrowUp">#2477</a>, <a href="https://github.com/open-telemetry/semantic-conventions/issues/2455" data-hovercard-type="issue" data-hovercard-url="/open-telemetry/semantic-conventions/issues/2455/hovercard" aria-keyshortcuts="Alt+ArrowUp">#2455</a>)</li> </ul> ## [`v1.35.0` semantic convention release notes](https://github.com/open-telemetry/semantic-conventions/releases/tag/v1.35.0) <div data-pjax="true" data-test-selector="body-content" data-view-component="true" class="markdown-body my-3"><h3>🛑 Breaking changes 🛑</h3> <ul> <li> <p><code>azure</code>: Align azure events, attributes, and enum members with general naming guidelines. (<a href="https://github.com/open-telemetry/semantic-conventions/issues/608" data-hovercard-type="issue" data-hovercard-url="/open-telemetry/semantic-conventions/issues/608/hovercard" aria-keyshortcuts="Alt+ArrowUp">#608</a>, <a href="https://github.com/open-telemetry/semantic-conventions/issues/1708" data-hovercard-type="pull_request" data-hovercard-url="/open-telemetry/semantic-conventions/pull/1708/hovercard" aria-keyshortcuts="Alt+ArrowUp">#1708</a>, <a href="https://github.com/open-telemetry/semantic-conventions/issues/1698" data-hovercard-type="pull_request" data-hovercard-url="/open-telemetry/semantic-conventions/pull/1698/hovercard" aria-keyshortcuts="Alt+ArrowUp">#1698</a>)</p> <ul> <li>Renamed attributes: <ul> <li><code>az.service_request_id</code> to <code>azure.service.request.id</code></li> <li><code>az.namespace</code> to <code>azure.resource_provider.namespace</code></li> </ul> </li> <li>Renamed events: <ul> <li><code>az.resource.log</code> to <code>azure.resource.log</code></li> </ul> </li> <li>Renamed enum members: <ul> <li><code>az.ai.inference</code> to <code>azure.ai.inference</code> (on <code>gen_ai.system</code>)</li> <li><code>az.ai.openai</code> to <code>azure.ai.openai</code> (on <code>gen_ai.system</code>)</li> <li><code>azure_aks</code> to <code>azure.aks</code> (on <code>cloud.platform</code>)</li> <li><code>azure_app_service</code> to <code>azure.app_service</code> (on <code>cloud.platform</code>)</li> <li><code>azure_container_apps</code> to <code>azure.container_apps</code> (on <code>cloud.platform</code>)</li> <li><code>azure_container_instances</code> to <code>azure.container_instances</code> (on <code>cloud.platform</code>)</li> <li><code>azure_functions</code> to <code>azure.functions</code> (on <code>cloud.platform</code>)</li> <li><code>azure_openshift</code> to <code>azure.open_shift</code> (on <code>cloud.platform</code>)</li> <li><code>azure_vm</code> to <code>azure.vm</code> (on <code>cloud.platform</code>)</li> </ul> </li> </ul> </li> <li> <p><code>system</code>: Revert the change that moved <code>system.cpu.*</code> to <code>cpu.*</code>. The 3 affected metrics are back in <code>system.cpu.*</code>. (<a href="https://github.com/open-telemetry/semantic-conventions/issues/1873" data-hovercard-type="issue" data-hovercard-url="/open-telemetry/semantic-conventions/issues/1873/hovercard" aria-keyshortcuts="Alt+ArrowUp">#1873</a>)</p> </li> <li> <p><code>system</code>: Changes system.network.connections to system.network.connection.count (<a href="https://github.com/open-telemetry/semantic-conventions/issues/1800" data-hovercard-type="issue" data-hovercard-url="/open-telemetry/semantic-conventions/issues/1800/hovercard" aria-keyshortcuts="Alt+ArrowUp">#1800</a>)</p> </li> <li> <p><code>k8s</code>: Change instrument type for .limit/.request container metrics from gauge to updowncounter (<a href="https://github.com/open-telemetry/semantic-conventions/issues/2354" data-hovercard-type="pull_request" data-hovercard-url="/open-telemetry/semantic-conventions/pull/2354/hovercard" aria-keyshortcuts="Alt+ArrowUp">#2354</a>)</p> </li> </ul> <h3>🚩 Deprecations 🚩</h3> <ul> <li><code>os</code>: Deprecate os.type='z_os' and replace with os.type='zos' (<a href="https://github.com/open-telemetry/semantic-conventions/issues/1687" data-hovercard-type="issue" data-hovercard-url="/open-telemetry/semantic-conventions/issues/1687/hovercard" aria-keyshortcuts="Alt+ArrowUp">#1687</a>)</li> </ul> <h3>🚀 New components 🚀</h3> <ul> <li><code>mainframe, zos</code>: Add initial semantic conventions for mainframes (<a href="https://github.com/open-telemetry/semantic-conventions/issues/1687" data-hovercard-type="issue" data-hovercard-url="/open-telemetry/semantic-conventions/issues/1687/hovercard" aria-keyshortcuts="Alt+ArrowUp">#1687</a>)</li> </ul> <h3>💡 Enhancements 💡</h3> <ul> <li> <p><code>dotnet</code>: Define .NET-specific network spans for DNS resolution, TLS handshake, and socket connections, along with HTTP-level spans to (optionally) record relationships between HTTP requests and connections.<br> (<a href="https://github.com/open-telemetry/semantic-conventions/issues/1192" data-hovercard-type="pull_request" data-hovercard-url="/open-telemetry/semantic-conventions/pull/1192/hovercard" aria-keyshortcuts="Alt+ArrowUp">#1192</a>)</p> </li> <li> <p><code>k8s</code>: Add <code>k8s.node.allocatable.cpu</code>, <code>k8s.node.allocatable.ephemeral_storage</code>, <code>k8s.node.allocatable.memory</code>, <code>k8s.node.allocatable.pods</code> metrics (<a href="https://github.com/open-telemetry/semantic-conventions/issues/2243" data-hovercard-type="issue" data-hovercard-url="/open-telemetry/semantic-conventions/issues/2243/hovercard" aria-keyshortcuts="Alt+ArrowUp">#2243</a>)</p> </li> <li> <p><code>k8s</code>: Add k8s.container.restart.count metric (<a href="https://github.com/open-telemetry/semantic-conventions/issues/2191" data-hovercard-type="pull_request" data-hovercard-url="/open-telemetry/semantic-conventions/pull/2191/hovercard" aria-keyshortcuts="Alt+ArrowUp">#2191</a>)</p> </li> <li> <p><code>k8s</code>: Add K8s container resource related metrics (<a href="https://github.com/open-telemetry/semantic-conventions/issues/2074" data-hovercard-type="issue" data-hovercard-url="/open-telemetry/semantic-conventions/issues/2074/hovercard" aria-keyshortcuts="Alt+ArrowUp">#2074</a>)</p> </li> <li> <p><code>k8s</code>: Add k8s.container.ready metric (<a href="https://github.com/open-telemetry/semantic-conventions/issues/2074" data-hovercard-type="issue" data-hovercard-url="/open-telemetry/semantic-conventions/issues/2074/hovercard" aria-keyshortcuts="Alt+ArrowUp">#2074</a>)</p> </li> <li> <p><code>k8s</code>: Add k8s.node.condition metric (<a href="https://github.com/open-telemetry/semantic-conventions/issues/2077" data-hovercard-type="issue" data-hovercard-url="/open-telemetry/semantic-conventions/issues/2077/hovercard" aria-keyshortcuts="Alt+ArrowUp">#2077</a>)</p> </li> <li> <p><code>k8s</code>: Add k8s resource quota metrics (<a href="https://github.com/open-telemetry/semantic-conventions/issues/2076" data-hovercard-type="issue" data-hovercard-url="/open-telemetry/semantic-conventions/issues/2076/hovercard" aria-keyshortcuts="Alt+ArrowUp">#2076</a>)</p> </li> <li> <p><code>events</code>: Update general event guidance to allow complex attributes on events and use them instead of the body fields.<br> (<a href="https://github.com/open-telemetry/semantic-conventions/issues/1651" data-hovercard-type="issue" data-hovercard-url="/open-telemetry/semantic-conventions/issues/1651/hovercard" aria-keyshortcuts="Alt+ArrowUp">#1651</a>, <a href="https://github.com/open-telemetry/semantic-conventions/issues/1669" data-hovercard-type="issue" data-hovercard-url="/open-telemetry/semantic-conventions/issues/1669/hovercard" aria-keyshortcuts="Alt+ArrowUp">#1669</a>)</p> </li> <li> <p><code>k8s</code>: Add k8s.container.status.state and k8s.container.status.reason metrics (<a href="https://github.com/open-telemetry/semantic-conventions/issues/1672" data-hovercard-type="issue" data-hovercard-url="/open-telemetry/semantic-conventions/issues/1672/hovercard" aria-keyshortcuts="Alt+ArrowUp">#1672</a>)</p> </li> <li> <p><code>feature_flags</code>: Mark feature flag semantic convention as release candidate. (<a href="https://github.com/open-telemetry/semantic-conventions/issues/2277" data-hovercard-type="pull_request" data-hovercard-url="/open-telemetry/semantic-conventions/pull/2277/hovercard" aria-keyshortcuts="Alt+ArrowUp">#2277</a>)</p> </li> <li> <p><code>k8s</code>: Add new resource attributes for <code>k8s.hpa</code> to capture the <code>scaleTargetRef</code> fields (<a href="https://github.com/open-telemetry/semantic-conventions/issues/2008" data-hovercard-type="issue" data-hovercard-url="/open-telemetry/semantic-conventions/issues/2008/hovercard" aria-keyshortcuts="Alt+ArrowUp">#2008</a>)<br> Adds below attributes to the <code>k8s.hpa</code> resource:</p> <ul> <li><code>k8s.hpa.scaletargetref.kind</code></li> <li><code>k8s.hpa.scaletargetref.name</code></li> <li><code>k8s.hpa.scaletargetref.api_version</code></li> </ul> </li> <li> <p><code>k8s</code>: Adds metrics and attributes to track k8s HPA's metric target values for CPU resources. (<a href="https://github.com/open-telemetry/semantic-conventions/issues/2182" data-hovercard-type="issue" data-hovercard-url="/open-telemetry/semantic-conventions/issues/2182/hovercard" aria-keyshortcuts="Alt+ArrowUp">#2182</a>)<br> Below metrics are introduced to provide insight into HPA scaling configuration for CPU.</p> <ul> <li><code>k8s.hpa.metric.target.cpu.value</code></li> <li><code>k8s.hpa.metric.target.cpu.average_value</code></li> <li><code>k8s.hpa.metric.target.cpu.average_utilization</code></li> </ul> </li> <li> <p><code>k8s</code>: Explains the rationale behind the Kubernetes resource naming convention. (<a href="https://github.com/open-telemetry/semantic-conventions/issues/2245" data-hovercard-type="issue" data-hovercard-url="/open-telemetry/semantic-conventions/issues/2245/hovercard" aria-keyshortcuts="Alt+ArrowUp">#2245</a>)</p> </li> <li> <p><code>all</code>: Adds modelling guide for resource and entity. (<a href="https://github.com/open-telemetry/semantic-conventions/issues/2246" data-hovercard-type="issue" data-hovercard-url="/open-telemetry/semantic-conventions/issues/2246/hovercard" aria-keyshortcuts="Alt+ArrowUp">#2246</a>)</p> </li> <li> <p><code>service</code>: Adds stability policies for Entity groups. (<a href="https://github.com/open-telemetry/semantic-conventions/issues/2378" data-hovercard-type="pull_request" data-hovercard-url="/open-telemetry/semantic-conventions/pull/2378/hovercard" aria-keyshortcuts="Alt+ArrowUp">#2378</a>)<br> Entity groups now require <code>role</code> to be filled for attributes.</p> </li> <li> <p><code>otel</code>: Specifies component.type values for Zipkin and Prometheus exporters (<a href="https://github.com/open-telemetry/semantic-conventions/issues/2229" data-hovercard-type="pull_request" data-hovercard-url="/open-telemetry/semantic-conventions/pull/2229/hovercard" aria-keyshortcuts="Alt+ArrowUp">#2229</a>)</p> </li> </ul> <h3>🧰 Bug fixes 🧰</h3> <ul> <li><code>otel</code>: Removes <code>otel.scope</code> entity. (<a href="https://github.com/open-telemetry/semantic-conventions/issues/2310" data-hovercard-type="pull_request" data-hovercard-url="/open-telemetry/semantic-conventions/pull/2310/hovercard" aria-keyshortcuts="Alt+ArrowUp">#2310</a>)</li> </ul>
523 lines
16 KiB
Go
523 lines
16 KiB
Go
// Code generated from semantic convention specification. DO NOT EDIT.
|
|
|
|
// Package httpconv provides types and functionality for OpenTelemetry semantic
|
|
// conventions in the "cicd" namespace.
|
|
package cicdconv
|
|
|
|
import (
|
|
"context"
|
|
"sync"
|
|
|
|
"go.opentelemetry.io/otel/attribute"
|
|
"go.opentelemetry.io/otel/metric"
|
|
"go.opentelemetry.io/otel/metric/noop"
|
|
)
|
|
|
|
var (
|
|
addOptPool = &sync.Pool{New: func() any { return &[]metric.AddOption{} }}
|
|
recOptPool = &sync.Pool{New: func() any { return &[]metric.RecordOption{} }}
|
|
)
|
|
|
|
// PipelineResultAttr is an attribute conforming to the cicd.pipeline.result
|
|
// semantic conventions. It represents the result of a pipeline run.
|
|
type PipelineResultAttr string
|
|
|
|
var (
|
|
// PipelineResultSuccess is the pipeline run finished successfully.
|
|
PipelineResultSuccess PipelineResultAttr = "success"
|
|
// PipelineResultFailure is the pipeline run did not finish successfully, eg.
|
|
// due to a compile error or a failing test. Such failures are usually detected
|
|
// by non-zero exit codes of the tools executed in the pipeline run.
|
|
PipelineResultFailure PipelineResultAttr = "failure"
|
|
// PipelineResultError is the pipeline run failed due to an error in the CICD
|
|
// system, eg. due to the worker being killed.
|
|
PipelineResultError PipelineResultAttr = "error"
|
|
// PipelineResultTimeout is a timeout caused the pipeline run to be interrupted.
|
|
PipelineResultTimeout PipelineResultAttr = "timeout"
|
|
// PipelineResultCancellation is the pipeline run was cancelled, eg. by a user
|
|
// manually cancelling the pipeline run.
|
|
PipelineResultCancellation PipelineResultAttr = "cancellation"
|
|
// PipelineResultSkip is the pipeline run was skipped, eg. due to a precondition
|
|
// not being met.
|
|
PipelineResultSkip PipelineResultAttr = "skip"
|
|
)
|
|
|
|
// PipelineRunStateAttr is an attribute conforming to the cicd.pipeline.run.state
|
|
// semantic conventions. It represents the pipeline run goes through these states
|
|
// during its lifecycle.
|
|
type PipelineRunStateAttr string
|
|
|
|
var (
|
|
// PipelineRunStatePending is the run pending state spans from the event
|
|
// triggering the pipeline run until the execution of the run starts (eg. time
|
|
// spent in a queue, provisioning agents, creating run resources).
|
|
PipelineRunStatePending PipelineRunStateAttr = "pending"
|
|
// PipelineRunStateExecuting is the executing state spans the execution of any
|
|
// run tasks (eg. build, test).
|
|
PipelineRunStateExecuting PipelineRunStateAttr = "executing"
|
|
// PipelineRunStateFinalizing is the finalizing state spans from when the run
|
|
// has finished executing (eg. cleanup of run resources).
|
|
PipelineRunStateFinalizing PipelineRunStateAttr = "finalizing"
|
|
)
|
|
|
|
// WorkerStateAttr is an attribute conforming to the cicd.worker.state semantic
|
|
// conventions. It represents the state of a CICD worker / agent.
|
|
type WorkerStateAttr string
|
|
|
|
var (
|
|
// WorkerStateAvailable is the worker is not performing work for the CICD
|
|
// system. It is available to the CICD system to perform work on (online /
|
|
// idle).
|
|
WorkerStateAvailable WorkerStateAttr = "available"
|
|
// WorkerStateBusy is the worker is performing work for the CICD system.
|
|
WorkerStateBusy WorkerStateAttr = "busy"
|
|
// WorkerStateOffline is the worker is not available to the CICD system
|
|
// (disconnected / down).
|
|
WorkerStateOffline WorkerStateAttr = "offline"
|
|
)
|
|
|
|
// ErrorTypeAttr is an attribute conforming to the error.type semantic
|
|
// conventions. It represents the describes a class of error the operation ended
|
|
// with.
|
|
type ErrorTypeAttr string
|
|
|
|
var (
|
|
// ErrorTypeOther is a fallback error value to be used when the instrumentation
|
|
// doesn't define a custom value.
|
|
ErrorTypeOther ErrorTypeAttr = "_OTHER"
|
|
)
|
|
|
|
// PipelineRunActive is an instrument used to record metric values conforming to
|
|
// the "cicd.pipeline.run.active" semantic conventions. It represents the number
|
|
// of pipeline runs currently active in the system by state.
|
|
type PipelineRunActive struct {
|
|
metric.Int64UpDownCounter
|
|
}
|
|
|
|
// NewPipelineRunActive returns a new PipelineRunActive instrument.
|
|
func NewPipelineRunActive(
|
|
m metric.Meter,
|
|
opt ...metric.Int64UpDownCounterOption,
|
|
) (PipelineRunActive, error) {
|
|
// Check if the meter is nil.
|
|
if m == nil {
|
|
return PipelineRunActive{noop.Int64UpDownCounter{}}, nil
|
|
}
|
|
|
|
i, err := m.Int64UpDownCounter(
|
|
"cicd.pipeline.run.active",
|
|
append([]metric.Int64UpDownCounterOption{
|
|
metric.WithDescription("The number of pipeline runs currently active in the system by state."),
|
|
metric.WithUnit("{run}"),
|
|
}, opt...)...,
|
|
)
|
|
if err != nil {
|
|
return PipelineRunActive{noop.Int64UpDownCounter{}}, err
|
|
}
|
|
return PipelineRunActive{i}, nil
|
|
}
|
|
|
|
// Inst returns the underlying metric instrument.
|
|
func (m PipelineRunActive) Inst() metric.Int64UpDownCounter {
|
|
return m.Int64UpDownCounter
|
|
}
|
|
|
|
// Name returns the semantic convention name of the instrument.
|
|
func (PipelineRunActive) Name() string {
|
|
return "cicd.pipeline.run.active"
|
|
}
|
|
|
|
// Unit returns the semantic convention unit of the instrument
|
|
func (PipelineRunActive) Unit() string {
|
|
return "{run}"
|
|
}
|
|
|
|
// Description returns the semantic convention description of the instrument
|
|
func (PipelineRunActive) Description() string {
|
|
return "The number of pipeline runs currently active in the system by state."
|
|
}
|
|
|
|
// Add adds incr to the existing count.
|
|
//
|
|
// The pipelineName is the the human readable name of the pipeline within a CI/CD
|
|
// system.
|
|
//
|
|
// The pipelineRunState is the the pipeline run goes through these states during
|
|
// its lifecycle.
|
|
func (m PipelineRunActive) Add(
|
|
ctx context.Context,
|
|
incr int64,
|
|
pipelineName string,
|
|
pipelineRunState PipelineRunStateAttr,
|
|
attrs ...attribute.KeyValue,
|
|
) {
|
|
o := addOptPool.Get().(*[]metric.AddOption)
|
|
defer func() {
|
|
*o = (*o)[:0]
|
|
addOptPool.Put(o)
|
|
}()
|
|
|
|
*o = append(
|
|
*o,
|
|
metric.WithAttributes(
|
|
append(
|
|
attrs,
|
|
attribute.String("cicd.pipeline.name", pipelineName),
|
|
attribute.String("cicd.pipeline.run.state", string(pipelineRunState)),
|
|
)...,
|
|
),
|
|
)
|
|
|
|
m.Int64UpDownCounter.Add(ctx, incr, *o...)
|
|
}
|
|
|
|
// PipelineRunDuration is an instrument used to record metric values conforming
|
|
// to the "cicd.pipeline.run.duration" semantic conventions. It represents the
|
|
// duration of a pipeline run grouped by pipeline, state and result.
|
|
type PipelineRunDuration struct {
|
|
metric.Float64Histogram
|
|
}
|
|
|
|
// NewPipelineRunDuration returns a new PipelineRunDuration instrument.
|
|
func NewPipelineRunDuration(
|
|
m metric.Meter,
|
|
opt ...metric.Float64HistogramOption,
|
|
) (PipelineRunDuration, error) {
|
|
// Check if the meter is nil.
|
|
if m == nil {
|
|
return PipelineRunDuration{noop.Float64Histogram{}}, nil
|
|
}
|
|
|
|
i, err := m.Float64Histogram(
|
|
"cicd.pipeline.run.duration",
|
|
append([]metric.Float64HistogramOption{
|
|
metric.WithDescription("Duration of a pipeline run grouped by pipeline, state and result."),
|
|
metric.WithUnit("s"),
|
|
}, opt...)...,
|
|
)
|
|
if err != nil {
|
|
return PipelineRunDuration{noop.Float64Histogram{}}, err
|
|
}
|
|
return PipelineRunDuration{i}, nil
|
|
}
|
|
|
|
// Inst returns the underlying metric instrument.
|
|
func (m PipelineRunDuration) Inst() metric.Float64Histogram {
|
|
return m.Float64Histogram
|
|
}
|
|
|
|
// Name returns the semantic convention name of the instrument.
|
|
func (PipelineRunDuration) Name() string {
|
|
return "cicd.pipeline.run.duration"
|
|
}
|
|
|
|
// Unit returns the semantic convention unit of the instrument
|
|
func (PipelineRunDuration) Unit() string {
|
|
return "s"
|
|
}
|
|
|
|
// Description returns the semantic convention description of the instrument
|
|
func (PipelineRunDuration) Description() string {
|
|
return "Duration of a pipeline run grouped by pipeline, state and result."
|
|
}
|
|
|
|
// Record records val to the current distribution.
|
|
//
|
|
// The pipelineName is the the human readable name of the pipeline within a CI/CD
|
|
// system.
|
|
//
|
|
// The pipelineRunState is the the pipeline run goes through these states during
|
|
// its lifecycle.
|
|
//
|
|
// All additional attrs passed are included in the recorded value.
|
|
func (m PipelineRunDuration) Record(
|
|
ctx context.Context,
|
|
val float64,
|
|
pipelineName string,
|
|
pipelineRunState PipelineRunStateAttr,
|
|
attrs ...attribute.KeyValue,
|
|
) {
|
|
o := recOptPool.Get().(*[]metric.RecordOption)
|
|
defer func() {
|
|
*o = (*o)[:0]
|
|
recOptPool.Put(o)
|
|
}()
|
|
|
|
*o = append(
|
|
*o,
|
|
metric.WithAttributes(
|
|
append(
|
|
attrs,
|
|
attribute.String("cicd.pipeline.name", pipelineName),
|
|
attribute.String("cicd.pipeline.run.state", string(pipelineRunState)),
|
|
)...,
|
|
),
|
|
)
|
|
|
|
m.Float64Histogram.Record(ctx, val, *o...)
|
|
}
|
|
|
|
// AttrPipelineResult returns an optional attribute for the
|
|
// "cicd.pipeline.result" semantic convention. It represents the result of a
|
|
// pipeline run.
|
|
func (PipelineRunDuration) AttrPipelineResult(val PipelineResultAttr) attribute.KeyValue {
|
|
return attribute.String("cicd.pipeline.result", string(val))
|
|
}
|
|
|
|
// AttrErrorType returns an optional attribute for the "error.type" semantic
|
|
// convention. It represents the describes a class of error the operation ended
|
|
// with.
|
|
func (PipelineRunDuration) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
|
|
return attribute.String("error.type", string(val))
|
|
}
|
|
|
|
// PipelineRunErrors is an instrument used to record metric values conforming to
|
|
// the "cicd.pipeline.run.errors" semantic conventions. It represents the number
|
|
// of errors encountered in pipeline runs (eg. compile, test failures).
|
|
type PipelineRunErrors struct {
|
|
metric.Int64Counter
|
|
}
|
|
|
|
// NewPipelineRunErrors returns a new PipelineRunErrors instrument.
|
|
func NewPipelineRunErrors(
|
|
m metric.Meter,
|
|
opt ...metric.Int64CounterOption,
|
|
) (PipelineRunErrors, error) {
|
|
// Check if the meter is nil.
|
|
if m == nil {
|
|
return PipelineRunErrors{noop.Int64Counter{}}, nil
|
|
}
|
|
|
|
i, err := m.Int64Counter(
|
|
"cicd.pipeline.run.errors",
|
|
append([]metric.Int64CounterOption{
|
|
metric.WithDescription("The number of errors encountered in pipeline runs (eg. compile, test failures)."),
|
|
metric.WithUnit("{error}"),
|
|
}, opt...)...,
|
|
)
|
|
if err != nil {
|
|
return PipelineRunErrors{noop.Int64Counter{}}, err
|
|
}
|
|
return PipelineRunErrors{i}, nil
|
|
}
|
|
|
|
// Inst returns the underlying metric instrument.
|
|
func (m PipelineRunErrors) Inst() metric.Int64Counter {
|
|
return m.Int64Counter
|
|
}
|
|
|
|
// Name returns the semantic convention name of the instrument.
|
|
func (PipelineRunErrors) Name() string {
|
|
return "cicd.pipeline.run.errors"
|
|
}
|
|
|
|
// Unit returns the semantic convention unit of the instrument
|
|
func (PipelineRunErrors) Unit() string {
|
|
return "{error}"
|
|
}
|
|
|
|
// Description returns the semantic convention description of the instrument
|
|
func (PipelineRunErrors) Description() string {
|
|
return "The number of errors encountered in pipeline runs (eg. compile, test failures)."
|
|
}
|
|
|
|
// Add adds incr to the existing count.
|
|
//
|
|
// The pipelineName is the the human readable name of the pipeline within a CI/CD
|
|
// system.
|
|
//
|
|
// The errorType is the describes a class of error the operation ended with.
|
|
//
|
|
// There might be errors in a pipeline run that are non fatal (eg. they are
|
|
// suppressed) or in a parallel stage multiple stages could have a fatal error.
|
|
// This means that this error count might not be the same as the count of metric
|
|
// `cicd.pipeline.run.duration` with run result `failure`.
|
|
func (m PipelineRunErrors) Add(
|
|
ctx context.Context,
|
|
incr int64,
|
|
pipelineName string,
|
|
errorType ErrorTypeAttr,
|
|
attrs ...attribute.KeyValue,
|
|
) {
|
|
o := addOptPool.Get().(*[]metric.AddOption)
|
|
defer func() {
|
|
*o = (*o)[:0]
|
|
addOptPool.Put(o)
|
|
}()
|
|
|
|
*o = append(
|
|
*o,
|
|
metric.WithAttributes(
|
|
append(
|
|
attrs,
|
|
attribute.String("cicd.pipeline.name", pipelineName),
|
|
attribute.String("error.type", string(errorType)),
|
|
)...,
|
|
),
|
|
)
|
|
|
|
m.Int64Counter.Add(ctx, incr, *o...)
|
|
}
|
|
|
|
// SystemErrors is an instrument used to record metric values conforming to the
|
|
// "cicd.system.errors" semantic conventions. It represents the number of errors
|
|
// in a component of the CICD system (eg. controller, scheduler, agent).
|
|
type SystemErrors struct {
|
|
metric.Int64Counter
|
|
}
|
|
|
|
// NewSystemErrors returns a new SystemErrors instrument.
|
|
func NewSystemErrors(
|
|
m metric.Meter,
|
|
opt ...metric.Int64CounterOption,
|
|
) (SystemErrors, error) {
|
|
// Check if the meter is nil.
|
|
if m == nil {
|
|
return SystemErrors{noop.Int64Counter{}}, nil
|
|
}
|
|
|
|
i, err := m.Int64Counter(
|
|
"cicd.system.errors",
|
|
append([]metric.Int64CounterOption{
|
|
metric.WithDescription("The number of errors in a component of the CICD system (eg. controller, scheduler, agent)."),
|
|
metric.WithUnit("{error}"),
|
|
}, opt...)...,
|
|
)
|
|
if err != nil {
|
|
return SystemErrors{noop.Int64Counter{}}, err
|
|
}
|
|
return SystemErrors{i}, nil
|
|
}
|
|
|
|
// Inst returns the underlying metric instrument.
|
|
func (m SystemErrors) Inst() metric.Int64Counter {
|
|
return m.Int64Counter
|
|
}
|
|
|
|
// Name returns the semantic convention name of the instrument.
|
|
func (SystemErrors) Name() string {
|
|
return "cicd.system.errors"
|
|
}
|
|
|
|
// Unit returns the semantic convention unit of the instrument
|
|
func (SystemErrors) Unit() string {
|
|
return "{error}"
|
|
}
|
|
|
|
// Description returns the semantic convention description of the instrument
|
|
func (SystemErrors) Description() string {
|
|
return "The number of errors in a component of the CICD system (eg. controller, scheduler, agent)."
|
|
}
|
|
|
|
// Add adds incr to the existing count.
|
|
//
|
|
// The systemComponent is the the name of a component of the CICD system.
|
|
//
|
|
// The errorType is the describes a class of error the operation ended with.
|
|
//
|
|
// Errors in pipeline run execution are explicitly excluded. Ie a test failure is
|
|
// not counted in this metric.
|
|
func (m SystemErrors) Add(
|
|
ctx context.Context,
|
|
incr int64,
|
|
systemComponent string,
|
|
errorType ErrorTypeAttr,
|
|
attrs ...attribute.KeyValue,
|
|
) {
|
|
o := addOptPool.Get().(*[]metric.AddOption)
|
|
defer func() {
|
|
*o = (*o)[:0]
|
|
addOptPool.Put(o)
|
|
}()
|
|
|
|
*o = append(
|
|
*o,
|
|
metric.WithAttributes(
|
|
append(
|
|
attrs,
|
|
attribute.String("cicd.system.component", systemComponent),
|
|
attribute.String("error.type", string(errorType)),
|
|
)...,
|
|
),
|
|
)
|
|
|
|
m.Int64Counter.Add(ctx, incr, *o...)
|
|
}
|
|
|
|
// WorkerCount is an instrument used to record metric values conforming to the
|
|
// "cicd.worker.count" semantic conventions. It represents the number of workers
|
|
// on the CICD system by state.
|
|
type WorkerCount struct {
|
|
metric.Int64UpDownCounter
|
|
}
|
|
|
|
// NewWorkerCount returns a new WorkerCount instrument.
|
|
func NewWorkerCount(
|
|
m metric.Meter,
|
|
opt ...metric.Int64UpDownCounterOption,
|
|
) (WorkerCount, error) {
|
|
// Check if the meter is nil.
|
|
if m == nil {
|
|
return WorkerCount{noop.Int64UpDownCounter{}}, nil
|
|
}
|
|
|
|
i, err := m.Int64UpDownCounter(
|
|
"cicd.worker.count",
|
|
append([]metric.Int64UpDownCounterOption{
|
|
metric.WithDescription("The number of workers on the CICD system by state."),
|
|
metric.WithUnit("{count}"),
|
|
}, opt...)...,
|
|
)
|
|
if err != nil {
|
|
return WorkerCount{noop.Int64UpDownCounter{}}, err
|
|
}
|
|
return WorkerCount{i}, nil
|
|
}
|
|
|
|
// Inst returns the underlying metric instrument.
|
|
func (m WorkerCount) Inst() metric.Int64UpDownCounter {
|
|
return m.Int64UpDownCounter
|
|
}
|
|
|
|
// Name returns the semantic convention name of the instrument.
|
|
func (WorkerCount) Name() string {
|
|
return "cicd.worker.count"
|
|
}
|
|
|
|
// Unit returns the semantic convention unit of the instrument
|
|
func (WorkerCount) Unit() string {
|
|
return "{count}"
|
|
}
|
|
|
|
// Description returns the semantic convention description of the instrument
|
|
func (WorkerCount) Description() string {
|
|
return "The number of workers on the CICD system by state."
|
|
}
|
|
|
|
// Add adds incr to the existing count.
|
|
//
|
|
// The workerState is the the state of a CICD worker / agent.
|
|
func (m WorkerCount) Add(
|
|
ctx context.Context,
|
|
incr int64,
|
|
workerState WorkerStateAttr,
|
|
attrs ...attribute.KeyValue,
|
|
) {
|
|
o := addOptPool.Get().(*[]metric.AddOption)
|
|
defer func() {
|
|
*o = (*o)[:0]
|
|
addOptPool.Put(o)
|
|
}()
|
|
|
|
*o = append(
|
|
*o,
|
|
metric.WithAttributes(
|
|
append(
|
|
attrs,
|
|
attribute.String("cicd.worker.state", string(workerState)),
|
|
)...,
|
|
),
|
|
)
|
|
|
|
m.Int64UpDownCounter.Add(ctx, incr, *o...)
|
|
} |