1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-08-10 22:31:50 +02:00

Add semconv/v1.32.0 (#6782)

- Add the new metric API package structure prototyped in
https://github.com/MrAlias/semconv-go

  Prototypes of new metric API use:
   - https://github.com/MrAlias/opentelemetry-go-contrib/pull/6136
   - https://github.com/MrAlias/opentelemetry-go-contrib/pull/6135
   - https://github.com/MrAlias/opentelemetry-go-contrib/pull/6134
- Generate `semconv/v1.32.0`
- Drop the `kestrel` metric namespace as this is a Java specific
technology

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

<div data-pjax="true" data-test-selector="body-content"
data-view-component="true" class="markdown-body my-3"><p>📣 This release
is the second release candidate for the Database Semantic Conventions,
with <strong>db conventions stability planned to be declared in the
subsequent release</strong>.</p>
<h3>🛑 Breaking changes 🛑</h3>
<ul>
<li><code>device</code>: Change the definition of <code>device.id</code>
and make it opt-in. (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1874"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/1874/hovercard">#1874</a>,
<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1951"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/1951/hovercard">#1951</a>)</li>
<li><code>feature_flag</code>: Rename <code>evaluation</code> to
<code>result</code> for feature flag evaluation result attributes (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1989"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/1989/hovercard">#1989</a>)</li>
</ul>
<h3>🚀 New components 🚀</h3>
<ul>
<li><code>app</code>: Create <code>app.installation.id</code> attribute
(<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1874"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/1874/hovercard">#1874</a>,
<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1897"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/1897/hovercard">#1897</a>)</li>
<li><code>cpython</code>: Add CPython runtime garbage collector metrics
(<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1930"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/1930/hovercard">#1930</a>)</li>
</ul>
<h3>💡 Enhancements 💡</h3>
<ul>
<li><code>vcs</code>: Add owner and provider name to VCS attribute
registry (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1452"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/1452/hovercard">#1452</a>)</li>
<li><code>vcs</code>: Remove fallback value for VCS provider name
attribute (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2020"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/2020/hovercard">#2020</a>)</li>
<li><code>db</code>: Truncate <code>db.query.summary</code> to 255
characters if parsed from the query (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1978"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/1978/hovercard">#1978</a>)</li>
<li><code>db</code>: Normalize spaces in <code>db.operation.name</code>
(if any) (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2028"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/2028/hovercard">#2028</a>)</li>
<li><code>db</code>: <code>db.operation.parameter.&lt;key&gt;</code>
should not be captured for batch operations (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2026"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/2026/hovercard">#2026</a>)</li>
<li><code>db</code>: Add <code>db.stored_procedure.name</code> (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1491"
data-hovercard-type="issue"
data-hovercard-url="/open-telemetry/semantic-conventions/issues/1491/hovercard">#1491</a>)</li>
<li><code>gcp</code>: Adds GCP AppHub labels for resource. (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2006"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/2006/hovercard">#2006</a>)</li>
<li><code>error</code>: Add <code>error.message</code> property for
human-readable error message on events. (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1992"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/1992/hovercard">#1992</a>)</li>
<li><code>profile</code>: Extend the list of known frame types with a
value for Go and Rust (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/2003"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/2003/hovercard">#2003</a>)</li>
<li><code>otel</code>: Adds SDK self-monitoring metrics for log
processing (<a
href="https://github.com/open-telemetry/semantic-conventions/issues/1921"
data-hovercard-type="pull_request"
data-hovercard-url="/open-telemetry/semantic-conventions/pull/1921/hovercard">#1921</a>)</li>
</ul>
This commit is contained in:
Tyler Yahn
2025-05-20 10:33:50 -07:00
committed by GitHub
parent fe523bd15a
commit 2d4c9dc115
30 changed files with 32585 additions and 49 deletions

View File

@@ -22,6 +22,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Add `Values` method to `HeaderCarrier` to implement the new `ValuesGetter` interface in `go.opentelemetry.io/otel/propagation`. (#5973)
- Update `Baggage` in `go.opentelemetry.io/otel/propagation` to retrieve multiple values for a key when the carrier implements `ValuesGetter`. (#5973)
- Add `AssertEqual` function in `go.opentelemetry.io/otel/log/logtest`. (#6662)
- The `go.opentelemetry.io/otel/semconv/v1.32.0` package.
The package contains semantic conventions from the `v1.32.0` version of the OpenTelemetry Semantic Conventions.
See the [migration documentation](./semconv/v1.32.0/MIGRATION.md) for information on how to upgrade from `go.opentelemetry.io/otel/semconv/v1.31.0`(#6782)
- Add `Transform` option in `go.opentelemetry.io/otel/log/logtest`. (#6794)
### Removed

View File

@@ -13,7 +13,16 @@
{%- endfor -%}
{%- endmacro -%}
{%- macro to_go_name(fqn) -%}
{%- macro to_go_name(fqn="", pkg="") -%}
{%- if pkg != "" -%}
{%- set n = pkg | length -%}
{%- if pkg == fqn[:n] -%}
{%- set fqn = fqn[n:] -%}
{%- if fqn[0] == "." or fqn[0] == "." -%}
{%- set fqn = fqn[1:] -%}
{%- endif -%}
{%- endif -%}
{%- endif -%}
{{ repl(smart_title_case(fqn | replace(" ", "") | replace("_", ".") | acronym)) }}
{%- endmacro -%}
@@ -49,26 +58,30 @@ Examples: {{ attr.examples | trim("[]") }}
{%- endfor -%}
{%- endmacro -%}
{%- macro it_reps(brief) -%}
{%- macro prefix_brief(brief, prefix="") -%}
{%- set norms = [
"MUST", "REQUIRED", "SHALL",
"SHOULD", "RECOMMENDED",
"MAY", "OPTIONAL"
"MUST", "REQUIRED", "SHALL",
"SHOULD", "RECOMMENDED",
"MAY", "OPTIONAL"
] -%}
{%- set brief = brief | trim() | trim(".") -%}
{%- set brief = brief | trim() -%}
{%- if first_word(brief) is in norms -%}
It {{ brief }}.
{%- else -%}
It represents {% if brief[:2] == "A " or brief[:3] == "An " or brief[:4] == "The " -%}
{{ lower_first(brief) }}.
{{ prefix }} {% if brief[:2] == "A " or brief[:3] == "An " or brief[:4] == "The " -%}
{{ lower_first(brief) | trim(".") }}.
{%- else -%}
the {{ lower_first(brief) }}.
the {{ lower_first(brief) | trim(".") }}.
{%- endif -%}
{%- endif -%}
{%- endmacro -%}
{%- macro keydoc(attr) -%}
{{ to_go_name(attr.name) }}Key is the attribute Key conforming to the "{{ attr.name }}" semantic conventions. {{ it_reps(attr.brief) }}
{%- macro it_reps(brief) -%}
{{ prefix_brief(brief, "It represents") }}
{%- endmacro -%}
{%- macro keydoc(attr, pkg="") -%}
{{ to_go_name(attr.name, pkg) }}Key is the attribute Key conforming to the "{{ attr.name }}" semantic conventions. {{ it_reps(attr.brief) }}
{% if attr is enum -%}
Type: Enum
@@ -82,7 +95,7 @@ Stability: {{ attr.stability | title }}
{{ deprecated_doc(attr) }}
{%- endmacro -%}
{%- macro generate_consts(group) -%}
{%- macro generate_consts(group, pkg="") -%}
{#- TODO: generate with group docs (i.e group by registry namespace) #}
{{ ["Namespace: " ~ group.root_namespace] | comment(format="go") }}
@@ -91,26 +104,26 @@ const (
{#- TODO: Handle template attributes. #}
{%- if not attribute.type is template_type %}
{{ keydoc(attribute) | comment(format="go_1tab") }}
{{to_go_name(attribute.name)}}Key = attribute.Key("{{attribute.name}}")
{{to_go_name(attribute.name, pkg=pkg)}}Key = attribute.Key("{{attribute.name}}")
{% endif -%}
{%- endfor -%}
)
{%- endmacro -%}
{%- macro generate_funcs(group) -%}
{%- macro generate_funcs(group, pkg="") -%}
{%- for attribute in group.attributes if not attribute is enum %}
{#- TODO: Handle template attributes. #}
{%- if not attribute.type is template_type %}
{{ [to_go_name(attribute.name) ~ " returns an attribute KeyValue conforming to the \"" ~ attribute.name ~ "\" semantic conventions. " ~ it_reps(attribute.brief) ] | comment(format="go") }}
func {{to_go_name(attribute.name)}}(val {{attribute.type | instantiated_type | map_text("attribute_type_value")}}) attribute.KeyValue {
return {{to_go_name(attribute.name)}}Key.{{attribute.type | instantiated_type | map_text("attribute_type_method")}}(val)
{{ [to_go_name(attribute.name, pkg) ~ " returns an attribute KeyValue conforming to the \"" ~ attribute.name ~ "\" semantic conventions. " ~ it_reps(attribute.brief) ] | comment(format="go") }}
func {{to_go_name(attribute.name, pkg)}}(val {{attribute.type | instantiated_type | map_text("attribute_type_value")}}) attribute.KeyValue {
return {{to_go_name(attribute.name, pkg)}}Key.{{attribute.type | instantiated_type | map_text("attribute_type_method")}}(val)
}
{%- endif %}
{%- endfor %}
{%- endmacro -%}
{%- macro generate_vars(group) -%}
{%- macro generate_vars(group, pkg="") -%}
{#- Render values for enums #}
{%- for attribute in group.attributes %}
{%- if attribute is enum %}
@@ -123,17 +136,47 @@ var (
{%- else %}
{{ [value.brief or value.id, "Stability: " ~ value.stability] | comment(format="go_1tab") }}
{%- endif %}
{{to_go_name(attribute.name ~ "." ~ value.id)}} = {{ to_go_name(attribute.name) }}Key.{{attribute.type | instantiated_type | map_text("attribute_type_method")}}({{ value.value | print_member_value }})
{{to_go_name(attribute.name ~ "." ~ value.id, pkg=pkg)}} = {{ to_go_name(attribute.name, pkg=pkg) }}Key.{{attribute.type | instantiated_type | map_text("attribute_type_method")}}({{ value.value | print_member_value }})
{%- endfor %}
)
{%- endif %}
{%- endfor %}
{%- endmacro -%}
{%- macro metric_keydoc(metric) -%}
{%- macro metric_keydoc(metric, pkg="") -%}
{%- if not metric.brief -%}
{{ to_go_name(metric.metric_name) }} is the metric conforming to the "{{ metric.metric_name}}" semantic conventions.
{{ to_go_name(metric.metric_name, pkg=pkg) }} is the metric conforming to the "{{ metric.metric_name}}" semantic conventions.
{%- else -%}
{{ to_go_name(metric.metric_name) }} is the metric conforming to the "{{ metric.metric_name}}" semantic conventions. {{ it_reps(metric.brief)|trim(".") }}.
{{ to_go_name(metric.metric_name, pkg=pkg) }} is the metric conforming to the "{{ metric.metric_name}}" semantic conventions. {{ it_reps(metric.brief)|trim(".") }}.
{%- endif %}
{%- endmacro -%}
{%- macro metric_typedoc(metric, pkg="") -%}
{%- if not metric.brief -%}
{{ to_go_name(metric.metric_name, pkg=pkg) }} is an instrument used to record metric values conforming to the "{{ metric.metric_name}}" semantic conventions.
{%- else -%}
{{ to_go_name(metric.metric_name, pkg=pkg) }} is an instrument used to record metric values conforming to the "{{ metric.metric_name}}" semantic conventions. {{ it_reps(metric.brief)|trim(".") }}.
{%- endif %}
{%- endmacro -%}
{%- macro member_type(member) %}
{%- if member.value is string %}string{%- endif %}
{%- if member.value is boolean %}bool{%- endif %}
{%- if member.value is int %}int64{%- endif %}
{%- if member.value is float %}float64{%- endif %}
{%- endmacro %}
{%- macro attr_type(attribute) %}
{%- if attribute.type is mapping %}
{{- member_type(attribute.type.members[0]) }}
{%- elif attribute.type == "template[boolean]" %}boolean
{%- elif attribute.type == "template[int]" %}int
{%- elif attribute.type == "template[double]" %}double
{%- elif attribute.type == "template[string]" %}string
{%- elif attribute.type == "template[boolean[]]" %}boolean[]
{%- elif attribute.type == "template[int[]]" %}int[]
{%- elif attribute.type == "template[double[]]" %}double[]
{%- elif attribute.type == "template[string[]]" %}string[]
{%- else %}{{ attribute.type | trim }}
{%- endif %}
{%- endmacro %}

220
semconv/instrument.j2 Normal file
View File

@@ -0,0 +1,220 @@
{% import 'helpers.j2' as h -%}
{%- macro instrument_default(metric) -%}
{%- set ns = namespace(value="Int64", inst="unknown") -%}
{%- set divisible = ["s", "ms"] -%}
{%- if metric.unit is in divisible -%}
{%- set ns.value="Float64" -%}
{%- endif -%}
{%- if metric.instrument == "counter" -%}
{%- set ns.inst="Counter" -%}
{%- elif metric.instrument == "updowncounter" -%}
{%- set ns.inst="UpDownCounter" -%}
{%- elif metric.instrument == "gauge" -%}
{%- set ns.inst="Gauge" -%}
{%- elif metric.instrument == "histogram" -%}
{%- set ns.inst="Histogram" -%}
{%- endif -%}
{{ ns.value ~ ns.inst }}
{%- endmacro -%}
{%- macro instrument(metric) -%}
{{ metric.metric_name | map_text("instrument", instrument_default(metric)) }}
{%- endmacro -%}
{%- macro value_type(metric) -%}
{%- if instrument(metric)[:7] == "Float64" -%}
Float64
{%- else -%}
Int64
{%- endif -%}
{%- endmacro -%}
{%- macro param_name(raw="", pkg="") -%}
{%- set reserved = [
"type", "break", "default", "func", "interface", "select", "case", "defer",
"go", "map", "struct", "chan", "else", "goto", "const", "fallthrough", "if",
"range", "type", "continue", "for", "import", "return", "var",
]-%}
{%- set name = raw -%}
{%- if pkg != "" -%}
{%- set n = pkg | length -%}
{%- if pkg == name[:n] -%}
{%- set name = name[n:] -%}
{%- if name[0] == "." or name[0] == "." -%}
{%- set name = name[1:] -%}
{%- endif -%}
{%- endif -%}
{%- endif -%}
{%- if name | lower is in reserved -%}
{{ raw | camel_case }}
{%- else -%}
{{ name | camel_case }}
{%- endif -%}
{%- endmacro -%}
{%- macro params_docs(attrs, pkg="") -%}
{%- set ns = namespace(output='') -%}
{%- for attr in attrs | required | attribute_sort -%}
{%- set ns.output = ns.output ~ "\n\nThe " ~ param_name(attr.name, pkg) ~ " is the " ~ h.lower_first(attr.brief) -%}
{%- endfor -%}
{%- if attrs | not_required | length > 0 -%}
{%- set ns.output = ns.output ~ "\n\nAll additional attrs passed are included in the recorded value." -%}
{%- endif -%}
{%- if ns.output != "" -%}
//
{{ ns.output | comment }}
{%- endif -%}
{%- endmacro -%}
{%- macro param(attr, pkg="") -%}
{%- if attr.type is mapping -%}
{{ param_name(attr.name, pkg) }} {{ h.to_go_name(attr.name, pkg) }}Attr,
{%- else -%}
{{ param_name(attr.name, pkg) }} {{ attr.type | map_text("attribute_type_value")}},
{%- endif -%}
{%- endmacro -%}
{%- macro params(attrs, type="", pkg="", prefix="") -%}
{%- for attr in attrs | required | attribute_sort -%}
{{ prefix ~ param(attr, pkg) }}
{% endfor -%}
{{ prefix ~ "attrs ...attribute.KeyValue," }}
{%- endmacro -%}
{%- macro to_attribute(attr, pkg="") -%}
{%- if attr.type is mapping -%}
attribute.{{ h.attr_type(attr) | map_text("attribute_type_method")}}("{{ attr.name }}", {{ h.member_type(attr.type.members[0]) }}({{ param_name(attr.name, pkg) }})),
{%- else -%}
attribute.{{ attr.type | map_text("attribute_type_method")}}("{{ attr.name }}", {{ param_name(attr.name, pkg) }}),
{%- endif -%}
{%- endmacro -%}
{%- macro with_attributes_opt(attrs, pkg="", prefix="") -%}
{%- if attrs | length > 0 -%}
{{ prefix }}metric.WithAttributes(
{%- if attrs | required | length > 0 %}
{{ prefix }} append(
{{ prefix }} attrs,
{%- for attr in attrs | required | attribute_sort %}
{{ prefix }} {{ to_attribute(attr, pkg) }}
{%- endfor %}
{{ prefix }} )...,
{%- else %}
{{ prefix }} attrs...,
{%- endif %}
{{ prefix }}),
{%- endif -%}
{%- endmacro -%}
{%- macro add_method_with_optional(metric, inst, pkg="") -%}
{%- set name = h.to_go_name(metric.metric_name, pkg) -%}
{%- set req_attr = metric.attributes | required | attribute_sort -%}
func (m {{ name }}) Add(
ctx context.Context,
incr {{ value_type(metric) | lower }},
{{ params(metric.attributes, pkg=pkg, prefix="\t") }}
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
{{ with_attributes_opt(metric.attributes, pkg=pkg, prefix="\t\t") }}
)
m.{{ inst }}.Add(ctx, incr, *o...)
}
{%- endmacro -%}
{%- macro add_method(metric, inst, pkg="") -%}
// Add adds incr to the existing count.
{%- if metric.attributes | length > 0 %}
{{ params_docs(metric.attributes, pkg=pkg) }}
{%- if metric.note is defined %}
//
{{ metric.note | comment }}
{%- endif %}
{{ add_method_with_optional(metric, inst, pkg) }}
{%- else %}
{%- if metric.note is defined %}
//
{{ metric.note | comment }}
{%- endif %}
func (m {{ h.to_go_name(metric.metric_name, pkg) }}) Add(ctx context.Context, incr {{ value_type(metric) | lower }}, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.{{ inst }}.Add(ctx, incr)
return
}
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.{{ inst }}.Add(ctx, incr, *o...)
}
{%- endif -%}
{%- endmacro -%}
{%- macro record_method_with_optional(metric, inst, pkg="") -%}
{%- set name = h.to_go_name(metric.metric_name, pkg) -%}
{%- set req_attr = metric.attributes | required | attribute_sort -%}
func (m {{ name }}) Record(
ctx context.Context,
val {{ value_type(metric) | lower }},
{{ params(metric.attributes, pkg=pkg, prefix="\t") }}
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
{{ with_attributes_opt(metric.attributes, pkg=pkg, prefix="\t\t") }}
)
m.{{ inst }}.Record(ctx, val, *o...)
}
{%- endmacro -%}
{%- macro record_method(metric, inst, pkg="") -%}
// Record records val to the current distribution.
{%- if metric.attributes | length > 0 %}
{{ params_docs(metric.attributes, pkg=pkg) }}
{%- if metric.note is defined %}
//
{{ metric.note | comment }}
{%- endif %}
{{ record_method_with_optional(metric, inst, pkg) }}
{%- else %}
{%- set name = h.to_go_name(metric.metric_name, pkg) -%}
{%- if metric.note is defined %}
//
{{ metric.note | comment }}
{%- endif %}
func (m {{ name }}) Record(ctx context.Context, val {{ value_type(metric) | lower }}, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.{{ inst }}.Record(ctx, val)
}
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.{{ inst }}.Record(ctx, val, *o...)
}
{%- endif -%}
{%- endmacro -%}

View File

@@ -1,27 +1,116 @@
{% import 'helpers.j2' as h -%}
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
{% import 'instrument.j2' as i -%}
// Code generated from semantic convention specification. DO NOT EDIT.
package semconv // import "go.opentelemetry.io/otel/semconv/{{params.tag}}"
// Package httpconv provides types and functionality for OpenTelemetry semantic
// conventions in the "{{ ctx.root_namespace }}" namespace.
package {{ ctx.root_namespace | camel_case | lower }}conv
const (
{%- for metric in ctx if not metric.deprecated %}
{{ h.metric_keydoc(metric) | comment(indent=2) }}
// Instrument: {{ metric.instrument }}
// Unit: {{ metric.unit }}
// Stability: {{ metric.stability }}
{%- if metric is deprecated %}
// Deprecated: {{ metric.deprecated }}
{%- endif %}
{%- if not metric.brief %}
// NOTE: The description (brief) for this metric is not defined in the semantic-conventions repository.
{%- endif %}
{{ h.to_go_name(metric.metric_name) }}Name = "{{ metric.metric_name }}"
{{ h.to_go_name(metric.metric_name) }}Unit = "{{ metric.unit }}"
{%- if metric.brief %}
{{ h.to_go_name(metric.metric_name) }}Description = "{{ metric.brief | trim }}"
{%- endif %}
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{} }}
)
{%- for attr in ctx.metrics | map(attribute="attributes") | flatten | selectattr("type", "mapping") | unique(attribute="name") | sort(attribute="name") %}
{%- set name = h.to_go_name(attr.name, ctx.root_namespace) %}
{{ [ name ~ "Attr is an attribute conforming to the " ~ attr.name ~ " semantic conventions. " ~ h.it_reps(attr.brief) ] | comment }}
type {{ name }}Attr {{ h.member_type(attr.type.members[0]) }}
var (
{%- for m in attr.type.members if not m.deprecated %}
{%- set m_name = name ~ h.to_go_name(m.id, ctx.root_namespace) %}
{{ h.prefix_brief(m.brief, m_name ~ " is ") | comment(format="go_1tab") }}
{{ m_name }} {{ name }}Attr = {% if attr.type.members[0].value is string -%}
"{{ m.value }}"
{%- else -%}
{{ m.value }}
{%- endif -%}
{%- endfor %}
)
{%- endfor %}
{%- for metric in ctx.metrics if not metric.deprecated %}
{%- set metric_name = h.to_go_name(metric.metric_name, ctx.root_namespace) %}
{%- set metric_inst = metric.metric_name | map_text("instrument", i.instrument_default(metric)) %}
{{ h.metric_typedoc(metric, ctx.root_namespace) | comment | trim }}
type {{ metric_name }} struct {
metric.{{ metric_inst }}
}
{{ ["New" ~ metric_name ~ " returns a new " ~ metric_name ~ " instrument."] | comment }}
func New{{ metric_name }}(
m metric.Meter,
opt ...metric.{{ metric_inst}}Option,
) ({{ metric_name }}, error) {
// Check if the meter is nil.
if m == nil {
return {{metric_name}}{noop.{{ metric_inst }}{}}, nil
}
i, err := m.{{ metric_inst }}(
"{{metric.metric_name}}",
append([]metric.{{ metric_inst }}Option{
metric.WithDescription("{{metric.brief | trim}}"),
metric.WithUnit("{{metric.unit}}"),
}, opt...)...,
)
if err != nil {
return {{metric_name}}{noop.{{ metric_inst }}{}}, err
}
return {{ metric_name }}{i}, nil
}
// Inst returns the underlying metric instrument.
func (m {{ metric_name }}) Inst() metric.{{ metric_inst }} {
return m.{{ metric_inst }}
}
// Name returns the semantic convention name of the instrument.
func ({{ metric_name }}) Name() string {
return "{{ metric.metric_name }}"
}
// Unit returns the semantic convention unit of the instrument
func ({{ metric_name }}) Unit() string {
return "{{ metric.unit }}"
}
{%- if metric.brief %}
// Description returns the semantic convention description of the instrument
func ({{ metric_name }}) Description() string {
return "{{ metric.brief | trim }}"
}
{%- endif %}
{%- if "Observable" is in metric_inst %}
{%- elif metric.instrument == "counter" or metric.instrument == "updowncounter" %}
{{ i.add_method(metric, metric_inst, ctx.root_namespace) }}
{%- elif metric.instrument == "histogram" or metric.instrument == "gauge" %}
{{ i.record_method(metric, metric_inst, ctx.root_namespace) }}
{%- endif %}
{%- for attr in metric.attributes | not_required | attribute_sort %}
{%- set name = h.to_go_name(attr.name, ctx.root_namespace) %}
{{ [ "Attr" ~ name ~ " returns an optional attribute for the \"" ~ attr.name ~ "\" semantic convention. " ~ h.it_reps(attr.brief) ] | comment }}
{%- if attr.type is mapping %}
func ({{ metric_name}}) Attr{{name}}(val {{ name }}Attr) attribute.KeyValue {
return attribute.{{ h.attr_type(attr) | map_text("attribute_type_method")}}("{{ attr.name }}", {{ h.member_type(attr.type.members[0]) }}(val))
}
{%- else %}
func ({{ metric_name}}) Attr{{name}}(val {{ attr.type | map_text("attribute_type_value")}}) attribute.KeyValue {
return attribute.{{ h.attr_type(attr) | map_text("attribute_type_method")}}("{{ attr.name }}", val)
}
{%- endif %}
{%- endfor %}
{%- endfor %}

View File

@@ -0,0 +1,801 @@
# Semantic Convention Changes
The `go.opentelemetry.io/otel/semconv/v1.32.0` package should be a drop-in replacement for `go.opentelemetry.io/otel/semconv/v1.31.0` with the following exceptions.
## Metric packaging
All metric instrument names, descriptions, and units have been moved into dedicated packages scoped by a namespace.
Each package contains metric instrument types designed for convenience.
Existing uses of `go.opentelemetry.io/otel/semconv/v1.31.0` can migrate to using these new purpose built instruments.
Additionally, the static `Name`, `Description`, and `Unit` methods of instruments can be used to retrieve the name, description, and unit of the instrument similar to what was provided before.
Below are the new packages and the respective declarations they replace.
- `go.opentelemetry.io/otel/semconv/v1.32.0/azureconv`
- `AzureCosmosDBClientActiveInstanceCountDescription`
- `AzureCosmosDBClientActiveInstanceCountName`
- `AzureCosmosDBClientActiveInstanceCountUnit`
- `AzureCosmosDBClientOperationRequestChargeDescription`
- `AzureCosmosDBClientOperationRequestChargeName`
- `AzureCosmosDBClientOperationRequestChargeUnit`
- `go.opentelemetry.io/otel/semconv/v1.32.0/cicdconv`
- `CICDPipelineRunActiveDescription`
- `CICDPipelineRunActiveName`
- `CICDPipelineRunActiveUnit`
- `CICDPipelineRunDurationDescription`
- `CICDPipelineRunDurationName`
- `CICDPipelineRunDurationUnit`
- `CICDPipelineRunErrorsDescription`
- `CICDPipelineRunErrorsName`
- `CICDPipelineRunErrorsUnit`
- `CICDSystemErrorsDescription`
- `CICDSystemErrorsName`
- `CICDSystemErrorsUnit`
- `CICDWorkerCountDescription`
- `CICDWorkerCountName`
- `CICDWorkerCountUnit`
- `go.opentelemetry.io/otel/semconv/v1.32.0/containerconv`
- `ContainerCPUTimeDescription`
- `ContainerCPUTimeName`
- `ContainerCPUTimeUnit`
- `ContainerCPUUsageDescription`
- `ContainerCPUUsageName`
- `ContainerCPUUsageUnit`
- `ContainerDiskIoDescription`
- `ContainerDiskIoName`
- `ContainerDiskIoUnit`
- `ContainerMemoryUsageDescription`
- `ContainerMemoryUsageName`
- `ContainerMemoryUsageUnit`
- `ContainerNetworkIoDescription`
- `ContainerNetworkIoName`
- `ContainerNetworkIoUnit`
- `ContainerUptimeDescription`
- `ContainerUptimeName`
- `ContainerUptimeUnit`
- `go.opentelemetry.io/otel/semconv/v1.32.0/cpuconv`
- `CPUFrequencyDescription`
- `CPUFrequencyName`
- `CPUFrequencyUnit`
- `CPUTimeDescription`
- `CPUTimeName`
- `CPUTimeUnit`
- `CPUUtilizationDescription`
- `CPUUtilizationName`
- `CPUUtilizationUnit`
- `go.opentelemetry.io/otel/semconv/v1.32.0/dbconv`
- `DBClientConnectionCountDescription`
- `DBClientConnectionCountName`
- `DBClientConnectionCountUnit`
- `DBClientConnectionCreateTimeDescription`
- `DBClientConnectionCreateTimeName`
- `DBClientConnectionCreateTimeUnit`
- `DBClientConnectionIdleMaxDescription`
- `DBClientConnectionIdleMaxName`
- `DBClientConnectionIdleMaxUnit`
- `DBClientConnectionIdleMinDescription`
- `DBClientConnectionIdleMinName`
- `DBClientConnectionIdleMinUnit`
- `DBClientConnectionMaxDescription`
- `DBClientConnectionMaxName`
- `DBClientConnectionMaxUnit`
- `DBClientConnectionPendingRequestsDescription`
- `DBClientConnectionPendingRequestsName`
- `DBClientConnectionPendingRequestsUnit`
- `DBClientConnectionTimeoutsDescription`
- `DBClientConnectionTimeoutsName`
- `DBClientConnectionTimeoutsUnit`
- `DBClientConnectionUseTimeDescription`
- `DBClientConnectionUseTimeName`
- `DBClientConnectionUseTimeUnit`
- `DBClientConnectionWaitTimeDescription`
- `DBClientConnectionWaitTimeName`
- `DBClientConnectionWaitTimeUnit`
- `DBClientOperationDurationDescription`
- `DBClientOperationDurationName`
- `DBClientOperationDurationUnit`
- `DBClientResponseReturnedRowsDescription`
- `DBClientResponseReturnedRowsName`
- `DBClientResponseReturnedRowsUnit`
- `go.opentelemetry.io/otel/semconv/v1.32.0/dnsconv`
- `DNSLookupDurationDescription`
- `DNSLookupDurationName`
- `DNSLookupDurationUnit`
- `go.opentelemetry.io/otel/semconv/v1.32.0/faasconv`
- `FaaSCPUUsageDescription`
- `FaaSCPUUsageName`
- `FaaSCPUUsageUnit`
- `FaaSColdstartsDescription`
- `FaaSColdstartsName`
- `FaaSColdstartsUnit`
- `FaaSErrorsDescription`
- `FaaSErrorsName`
- `FaaSErrorsUnit`
- `FaaSInitDurationDescription`
- `FaaSInitDurationName`
- `FaaSInitDurationUnit`
- `FaaSInvocationsDescription`
- `FaaSInvocationsName`
- `FaaSInvocationsUnit`
- `FaaSInvokeDurationDescription`
- `FaaSInvokeDurationName`
- `FaaSInvokeDurationUnit`
- `FaaSMemUsageDescription`
- `FaaSMemUsageName`
- `FaaSMemUsageUnit`
- `FaaSNetIoDescription`
- `FaaSNetIoName`
- `FaaSNetIoUnit`
- `FaaSTimeoutsDescription`
- `FaaSTimeoutsName`
- `FaaSTimeoutsUnit`
- `go.opentelemetry.io/otel/semconv/v1.32.0/genaiconv`
- `GenAIClientOperationDurationDescription`
- `GenAIClientOperationDurationName`
- `GenAIClientOperationDurationUnit`
- `GenAIClientTokenUsageDescription`
- `GenAIClientTokenUsageName`
- `GenAIClientTokenUsageUnit`
- `GenAIServerRequestDurationDescription`
- `GenAIServerRequestDurationName`
- `GenAIServerRequestDurationUnit`
- `GenAIServerTimePerOutputTokenDescription`
- `GenAIServerTimePerOutputTokenName`
- `GenAIServerTimePerOutputTokenUnit`
- `GenAIServerTimeToFirstTokenDescription`
- `GenAIServerTimeToFirstTokenName`
- `GenAIServerTimeToFirstTokenUnit`
- `go.opentelemetry.io/otel/semconv/v1.32.0/goconv`
- `GoConfigGogcDescription`
- `GoConfigGogcName`
- `GoConfigGogcUnit`
- `GoGoroutineCountDescription`
- `GoGoroutineCountName`
- `GoGoroutineCountUnit`
- `GoMemoryAllocatedDescription`
- `GoMemoryAllocatedName`
- `GoMemoryAllocatedUnit`
- `GoMemoryAllocationsDescription`
- `GoMemoryAllocationsName`
- `GoMemoryAllocationsUnit`
- `GoMemoryGCGoalDescription`
- `GoMemoryGCGoalName`
- `GoMemoryGCGoalUnit`
- `GoMemoryLimitDescription`
- `GoMemoryLimitName`
- `GoMemoryLimitUnit`
- `GoMemoryUsedDescription`
- `GoMemoryUsedName`
- `GoMemoryUsedUnit`
- `GoProcessorLimitDescription`
- `GoProcessorLimitName`
- `GoProcessorLimitUnit`
- `GoScheduleDurationDescription`
- `GoScheduleDurationName`
- `GoScheduleDurationUnit`
- `go.opentelemetry.io/otel/semconv/v1.32.0/httpconv`
- `HTTPClientActiveRequestsDescription`
- `HTTPClientActiveRequestsName`
- `HTTPClientActiveRequestsUnit`
- `HTTPClientConnectionDurationDescription`
- `HTTPClientConnectionDurationName`
- `HTTPClientConnectionDurationUnit`
- `HTTPClientOpenConnectionsDescription`
- `HTTPClientOpenConnectionsName`
- `HTTPClientOpenConnectionsUnit`
- `HTTPClientRequestBodySizeDescription`
- `HTTPClientRequestBodySizeName`
- `HTTPClientRequestBodySizeUnit`
- `HTTPClientRequestDurationDescription`
- `HTTPClientRequestDurationName`
- `HTTPClientRequestDurationUnit`
- `HTTPClientResponseBodySizeDescription`
- `HTTPClientResponseBodySizeName`
- `HTTPClientResponseBodySizeUnit`
- `HTTPServerActiveRequestsDescription`
- `HTTPServerActiveRequestsName`
- `HTTPServerActiveRequestsUnit`
- `HTTPServerRequestBodySizeDescription`
- `HTTPServerRequestBodySizeName`
- `HTTPServerRequestBodySizeUnit`
- `HTTPServerRequestDurationDescription`
- `HTTPServerRequestDurationName`
- `HTTPServerRequestDurationUnit`
- `HTTPServerResponseBodySizeDescription`
- `HTTPServerResponseBodySizeName`
- `HTTPServerResponseBodySizeUnit`
- `go.opentelemetry.io/otel/semconv/v1.32.0/hwconv`
- `HwEnergyDescription`
- `HwEnergyName`
- `HwEnergyUnit`
- `HwErrorsDescription`
- `HwErrorsName`
- `HwErrorsUnit`
- `HwHostAmbientTemperatureDescription`
- `HwHostAmbientTemperatureName`
- `HwHostAmbientTemperatureUnit`
- `HwHostEnergyDescription`
- `HwHostEnergyName`
- `HwHostEnergyUnit`
- `HwHostHeatingMarginDescription`
- `HwHostHeatingMarginName`
- `HwHostHeatingMarginUnit`
- `HwHostPowerDescription`
- `HwHostPowerName`
- `HwHostPowerUnit`
- `HwPowerDescription`
- `HwPowerName`
- `HwPowerUnit`
- `HwStatusDescription`
- `HwStatusName`
- `HwStatusUnit`
- `go.opentelemetry.io/otel/semconv/v1.32.0/k8sconv`
- `K8SCronJobActiveJobsDescription`
- `K8SCronJobActiveJobsName`
- `K8SCronJobActiveJobsUnit`
- `K8SDaemonSetCurrentScheduledNodesDescription`
- `K8SDaemonSetCurrentScheduledNodesName`
- `K8SDaemonSetCurrentScheduledNodesUnit`
- `K8SDaemonSetDesiredScheduledNodesDescription`
- `K8SDaemonSetDesiredScheduledNodesName`
- `K8SDaemonSetDesiredScheduledNodesUnit`
- `K8SDaemonSetMisscheduledNodesDescription`
- `K8SDaemonSetMisscheduledNodesName`
- `K8SDaemonSetMisscheduledNodesUnit`
- `K8SDaemonSetReadyNodesDescription`
- `K8SDaemonSetReadyNodesName`
- `K8SDaemonSetReadyNodesUnit`
- `K8SDeploymentAvailablePodsDescription`
- `K8SDeploymentAvailablePodsName`
- `K8SDeploymentAvailablePodsUnit`
- `K8SDeploymentDesiredPodsDescription`
- `K8SDeploymentDesiredPodsName`
- `K8SDeploymentDesiredPodsUnit`
- `K8SHpaCurrentPodsDescription`
- `K8SHpaCurrentPodsName`
- `K8SHpaCurrentPodsUnit`
- `K8SHpaDesiredPodsDescription`
- `K8SHpaDesiredPodsName`
- `K8SHpaDesiredPodsUnit`
- `K8SHpaMaxPodsDescription`
- `K8SHpaMaxPodsName`
- `K8SHpaMaxPodsUnit`
- `K8SHpaMinPodsDescription`
- `K8SHpaMinPodsName`
- `K8SHpaMinPodsUnit`
- `K8SJobActivePodsDescription`
- `K8SJobActivePodsName`
- `K8SJobActivePodsUnit`
- `K8SJobDesiredSuccessfulPodsDescription`
- `K8SJobDesiredSuccessfulPodsName`
- `K8SJobDesiredSuccessfulPodsUnit`
- `K8SJobFailedPodsDescription`
- `K8SJobFailedPodsName`
- `K8SJobFailedPodsUnit`
- `K8SJobMaxParallelPodsDescription`
- `K8SJobMaxParallelPodsName`
- `K8SJobMaxParallelPodsUnit`
- `K8SJobSuccessfulPodsDescription`
- `K8SJobSuccessfulPodsName`
- `K8SJobSuccessfulPodsUnit`
- `K8SNamespacePhaseDescription`
- `K8SNamespacePhaseName`
- `K8SNamespacePhaseUnit`
- `K8SNodeCPUTimeDescription`
- `K8SNodeCPUTimeName`
- `K8SNodeCPUTimeUnit`
- `K8SNodeCPUUsageDescription`
- `K8SNodeCPUUsageName`
- `K8SNodeCPUUsageUnit`
- `K8SNodeMemoryUsageDescription`
- `K8SNodeMemoryUsageName`
- `K8SNodeMemoryUsageUnit`
- `K8SNodeNetworkErrorsDescription`
- `K8SNodeNetworkErrorsName`
- `K8SNodeNetworkErrorsUnit`
- `K8SNodeNetworkIoDescription`
- `K8SNodeNetworkIoName`
- `K8SNodeNetworkIoUnit`
- `K8SNodeUptimeDescription`
- `K8SNodeUptimeName`
- `K8SNodeUptimeUnit`
- `K8SPodCPUTimeDescription`
- `K8SPodCPUTimeName`
- `K8SPodCPUTimeUnit`
- `K8SPodCPUUsageDescription`
- `K8SPodCPUUsageName`
- `K8SPodCPUUsageUnit`
- `K8SPodMemoryUsageDescription`
- `K8SPodMemoryUsageName`
- `K8SPodMemoryUsageUnit`
- `K8SPodNetworkErrorsDescription`
- `K8SPodNetworkErrorsName`
- `K8SPodNetworkErrorsUnit`
- `K8SPodNetworkIoDescription`
- `K8SPodNetworkIoName`
- `K8SPodNetworkIoUnit`
- `K8SPodUptimeDescription`
- `K8SPodUptimeName`
- `K8SPodUptimeUnit`
- `K8SReplicaSetAvailablePodsDescription`
- `K8SReplicaSetAvailablePodsName`
- `K8SReplicaSetAvailablePodsUnit`
- `K8SReplicaSetDesiredPodsDescription`
- `K8SReplicaSetDesiredPodsName`
- `K8SReplicaSetDesiredPodsUnit`
- `K8SReplicationControllerAvailablePodsDescription`
- `K8SReplicationControllerAvailablePodsName`
- `K8SReplicationControllerAvailablePodsUnit`
- `K8SReplicationControllerDesiredPodsDescription`
- `K8SReplicationControllerDesiredPodsName`
- `K8SReplicationControllerDesiredPodsUnit`
- `K8SStatefulSetCurrentPodsDescription`
- `K8SStatefulSetCurrentPodsName`
- `K8SStatefulSetCurrentPodsUnit`
- `K8SStatefulSetDesiredPodsDescription`
- `K8SStatefulSetDesiredPodsName`
- `K8SStatefulSetDesiredPodsUnit`
- `K8SStatefulSetReadyPodsDescription`
- `K8SStatefulSetReadyPodsName`
- `K8SStatefulSetReadyPodsUnit`
- `K8SStatefulSetUpdatedPodsDescription`
- `K8SStatefulSetUpdatedPodsName`
- `K8SStatefulSetUpdatedPodsUnit`
- `go.opentelemetry.io/otel/semconv/v1.32.0/messagingconv`
- `MessagingClientConsumedMessagesDescription`
- `MessagingClientConsumedMessagesName`
- `MessagingClientConsumedMessagesUnit`
- `MessagingClientOperationDurationDescription`
- `MessagingClientOperationDurationName`
- `MessagingClientOperationDurationUnit`
- `MessagingClientSentMessagesDescription`
- `MessagingClientSentMessagesName`
- `MessagingClientSentMessagesUnit`
- `MessagingProcessDurationDescription`
- `MessagingProcessDurationName`
- `MessagingProcessDurationUnit`
- `go.opentelemetry.io/otel/semconv/v1.32.0/otelconv`
- `OTelSDKExporterSpanExportedCountDescription`
- `OTelSDKExporterSpanExportedCountName`
- `OTelSDKExporterSpanExportedCountUnit`
- `OTelSDKExporterSpanInflightCountDescription`
- `OTelSDKExporterSpanInflightCountName`
- `OTelSDKExporterSpanInflightCountUnit`
- `OTelSDKProcessorSpanProcessedCountDescription`
- `OTelSDKProcessorSpanProcessedCountName`
- `OTelSDKProcessorSpanProcessedCountUnit`
- `OTelSDKProcessorSpanQueueCapacityDescription`
- `OTelSDKProcessorSpanQueueCapacityName`
- `OTelSDKProcessorSpanQueueCapacityUnit`
- `OTelSDKProcessorSpanQueueSizeDescription`
- `OTelSDKProcessorSpanQueueSizeName`
- `OTelSDKProcessorSpanQueueSizeUnit`
- `OTelSDKSpanEndedCountDescription`
- `OTelSDKSpanEndedCountName`
- `OTelSDKSpanEndedCountUnit`
- `OTelSDKSpanLiveCountDescription`
- `OTelSDKSpanLiveCountName`
- `OTelSDKSpanLiveCountUnit`
- `go.opentelemetry.io/otel/semconv/v1.32.0/processconv`
- `ProcessCPUTimeDescription`
- `ProcessCPUTimeName`
- `ProcessCPUTimeUnit`
- `ProcessCPUUtilizationDescription`
- `ProcessCPUUtilizationName`
- `ProcessCPUUtilizationUnit`
- `ProcessContextSwitchesDescription`
- `ProcessContextSwitchesName`
- `ProcessContextSwitchesUnit`
- `ProcessDiskIoDescription`
- `ProcessDiskIoName`
- `ProcessDiskIoUnit`
- `ProcessMemoryUsageDescription`
- `ProcessMemoryUsageName`
- `ProcessMemoryUsageUnit`
- `ProcessMemoryVirtualDescription`
- `ProcessMemoryVirtualName`
- `ProcessMemoryVirtualUnit`
- `ProcessNetworkIoDescription`
- `ProcessNetworkIoName`
- `ProcessNetworkIoUnit`
- `ProcessOpenFileDescriptorCountDescription`
- `ProcessOpenFileDescriptorCountName`
- `ProcessOpenFileDescriptorCountUnit`
- `ProcessPagingFaultsDescription`
- `ProcessPagingFaultsName`
- `ProcessPagingFaultsUnit`
- `ProcessThreadCountDescription`
- `ProcessThreadCountName`
- `ProcessThreadCountUnit`
- `ProcessUptimeDescription`
- `ProcessUptimeName`
- `ProcessUptimeUnit`
- `go.opentelemetry.io/otel/semconv/v1.32.0/rpcconv`
- `RPCClientDurationDescription`
- `RPCClientDurationName`
- `RPCClientDurationUnit`
- `RPCClientRequestSizeDescription`
- `RPCClientRequestSizeName`
- `RPCClientRequestSizeUnit`
- `RPCClientRequestsPerRPCDescription`
- `RPCClientRequestsPerRPCName`
- `RPCClientRequestsPerRPCUnit`
- `RPCClientResponseSizeDescription`
- `RPCClientResponseSizeName`
- `RPCClientResponseSizeUnit`
- `RPCClientResponsesPerRPCDescription`
- `RPCClientResponsesPerRPCName`
- `RPCClientResponsesPerRPCUnit`
- `RPCServerDurationDescription`
- `RPCServerDurationName`
- `RPCServerDurationUnit`
- `RPCServerRequestSizeDescription`
- `RPCServerRequestSizeName`
- `RPCServerRequestSizeUnit`
- `RPCServerRequestsPerRPCDescription`
- `RPCServerRequestsPerRPCName`
- `RPCServerRequestsPerRPCUnit`
- `RPCServerResponseSizeDescription`
- `RPCServerResponseSizeName`
- `RPCServerResponseSizeUnit`
- `RPCServerResponsesPerRPCDescription`
- `RPCServerResponsesPerRPCName`
- `RPCServerResponsesPerRPCUnit`
- `go.opentelemetry.io/otel/semconv/v1.32.0/signalrconv`
- `SignalrServerActiveConnectionsDescription`
- `SignalrServerActiveConnectionsName`
- `SignalrServerActiveConnectionsUnit`
- `SignalrServerConnectionDurationDescription`
- `SignalrServerConnectionDurationName`
- `SignalrServerConnectionDurationUnit`
- `go.opentelemetry.io/otel/semconv/v1.32.0/systemconv`
- `SystemCPULogicalCountDescription`
- `SystemCPULogicalCountName`
- `SystemCPULogicalCountUnit`
- `SystemCPUPhysicalCountDescription`
- `SystemCPUPhysicalCountName`
- `SystemCPUPhysicalCountUnit`
- `SystemDiskIoName`
- `SystemDiskIoTimeDescription`
- `SystemDiskIoTimeName`
- `SystemDiskIoTimeUnit`
- `SystemDiskIoUnit`
- `SystemDiskLimitDescription`
- `SystemDiskLimitName`
- `SystemDiskLimitUnit`
- `SystemDiskMergedName`
- `SystemDiskMergedUnit`
- `SystemDiskOperationTimeDescription`
- `SystemDiskOperationTimeName`
- `SystemDiskOperationTimeUnit`
- `SystemDiskOperationsName`
- `SystemDiskOperationsUnit`
- `SystemFilesystemLimitDescription`
- `SystemFilesystemLimitName`
- `SystemFilesystemLimitUnit`
- `SystemFilesystemUsageDescription`
- `SystemFilesystemUsageName`
- `SystemFilesystemUsageUnit`
- `SystemFilesystemUtilizationName`
- `SystemFilesystemUtilizationUnit`
- `SystemLinuxMemoryAvailableDescription`
- `SystemLinuxMemoryAvailableName`
- `SystemLinuxMemoryAvailableUnit`
- `SystemLinuxMemorySlabUsageDescription`
- `SystemLinuxMemorySlabUsageName`
- `SystemLinuxMemorySlabUsageUnit`
- `SystemMemoryLimitDescription`
- `SystemMemoryLimitName`
- `SystemMemoryLimitUnit`
- `SystemMemorySharedDescription`
- `SystemMemorySharedName`
- `SystemMemorySharedUnit`
- `SystemMemoryUsageDescription`
- `SystemMemoryUsageName`
- `SystemMemoryUsageUnit`
- `SystemMemoryUtilizationName`
- `SystemMemoryUtilizationUnit`
- `SystemNetworkConnectionsName`
- `SystemNetworkConnectionsUnit`
- `SystemNetworkDroppedDescription`
- `SystemNetworkDroppedName`
- `SystemNetworkDroppedUnit`
- `SystemNetworkErrorsDescription`
- `SystemNetworkErrorsName`
- `SystemNetworkErrorsUnit`
- `SystemNetworkIoName`
- `SystemNetworkIoUnit`
- `SystemNetworkPacketsName`
- `SystemNetworkPacketsUnit`
- `SystemPagingFaultsName`
- `SystemPagingFaultsUnit`
- `SystemPagingOperationsName`
- `SystemPagingOperationsUnit`
- `SystemPagingUsageDescription`
- `SystemPagingUsageName`
- `SystemPagingUsageUnit`
- `SystemPagingUtilizationName`
- `SystemPagingUtilizationUnit`
- `SystemProcessCountDescription`
- `SystemProcessCountName`
- `SystemProcessCountUnit`
- `SystemProcessCreatedDescription`
- `SystemProcessCreatedName`
- `SystemProcessCreatedUnit`
- `SystemUptimeDescription`
- `SystemUptimeName`
- `SystemUptimeUnit`
- `go.opentelemetry.io/otel/semconv/v1.32.0/vcsconv`
- `VCSChangeCountDescription`
- `VCSChangeCountName`
- `VCSChangeCountUnit`
- `VCSChangeDurationDescription`
- `VCSChangeDurationName`
- `VCSChangeDurationUnit`
- `VCSChangeTimeToApprovalDescription`
- `VCSChangeTimeToApprovalName`
- `VCSChangeTimeToApprovalUnit`
- `VCSChangeTimeToMergeDescription`
- `VCSChangeTimeToMergeName`
- `VCSChangeTimeToMergeUnit`
- `VCSContributorCountDescription`
- `VCSContributorCountName`
- `VCSContributorCountUnit`
- `VCSRefCountDescription`
- `VCSRefCountName`
- `VCSRefCountUnit`
- `VCSRefLinesDeltaDescription`
- `VCSRefLinesDeltaName`
- `VCSRefLinesDeltaUnit`
- `VCSRefRevisionsDeltaDescription`
- `VCSRefRevisionsDeltaName`
- `VCSRefRevisionsDeltaUnit`
- `VCSRefTimeDescription`
- `VCSRefTimeName`
- `VCSRefTimeUnit`
- `VCSRepositoryCountDescription`
- `VCSRepositoryCountName`
- `VCSRepositoryCountUnit`
Note the following declarations from the `kestrel` namespace have been dropped.
- `KestrelActiveConnectionsDescription`
- `KestrelActiveConnectionsName`
- `KestrelActiveConnectionsUnit`
- `KestrelActiveTLSHandshakesDescription`
- `KestrelActiveTLSHandshakesName`
- `KestrelActiveTLSHandshakesUnit`
- `KestrelConnectionDurationDescription`
- `KestrelConnectionDurationName`
- `KestrelConnectionDurationUnit`
- `KestrelQueuedConnectionsDescription`
- `KestrelQueuedConnectionsName`
- `KestrelQueuedConnectionsUnit`
- `KestrelQueuedRequestsDescription`
- `KestrelQueuedRequestsName`
- `KestrelQueuedRequestsUnit`
- `KestrelRejectedConnectionsDescription`
- `KestrelRejectedConnectionsName`
- `KestrelRejectedConnectionsUnit`
- `KestrelTLSHandshakeDurationDescription`
- `KestrelTLSHandshakeDurationName`
- `KestrelTLSHandshakeDurationUnit`
- `KestrelUpgradedConnectionsDescription`
- `KestrelUpgradedConnectionsName`
- `KestrelUpgradedConnectionsUnit`
If you use any of these declarations in your Go application, please [open an issue] describing your use-case.
## Dropped deprecations
The following declarations have been deprecated in the [OpenTelemetry Semantic Conventions].
Refer to the respective documentation in that repository for deprecation instructions for each type.
- `FeatureFlagEvaluationReasonCached`
- `FeatureFlagEvaluationReasonDefault`
- `FeatureFlagEvaluationReasonDisabled`
- `FeatureFlagEvaluationReasonError`
- `FeatureFlagEvaluationReasonKey`
- `FeatureFlagEvaluationReasonSplit`
- `FeatureFlagEvaluationReasonStale`
- `FeatureFlagEvaluationReasonStatic`
- `FeatureFlagEvaluationReasonTargetingMatch`
- `FeatureFlagEvaluationReasonUnknown`
- `FeatureFlagVariant`
- `FeatureFlagVariantKey`
### Renames
The following renames have been introduced to better match Go and industry naming standards.
Be sure to update any use from `go.opentelemetry.io/otel/semconv/v1.31.0` with the equivalent in `go.opentelemetry.io/otel/semconv/v1.32.0`.
| `v1.31.0` | `v1.32.0` |
| --- | --- |
| `CPUModeIowait` | `CPUModeIOWait` |
| `CloudPlatformAWSOpenshift` | `CloudPlatformAWSOpenShift` |
| `CloudPlatformAlibabaCloudFc` | `CloudPlatformAlibabaCloudFC` |
| `CloudPlatformAlibabaCloudOpenshift` | `CloudPlatformAlibabaCloudOpenShift` |
| `CloudPlatformAzureOpenshift` | `CloudPlatformAzureOpenShift` |
| `CloudPlatformGCPOpenshift` | `CloudPlatformGCPOpenShift` |
| `CloudPlatformIbmCloudOpenshift` | `CloudPlatformIBMCloudOpenShift` |
| `CloudPlatformOracleCloudOke` | `CloudPlatformOracleCloudOKE` |
| `CloudPlatformTencentCloudCvm` | `CloudPlatformTencentCloudCVM` |
| `CloudPlatformTencentCloudScf` | `CloudPlatformTencentCloudSCF` |
| `CloudProviderIbmCloud` | `CloudProviderIBMCloud` |
| `CloudeventsEventID` | `CloudEventsEventID` |
| `CloudeventsEventIDKey` | `CloudEventsEventIDKey` |
| `CloudeventsEventSource` | `CloudEventsEventSource` |
| `CloudeventsEventSourceKey` | `CloudEventsEventSourceKey` |
| `CloudeventsEventSpecVersion` | `CloudEventsEventSpecVersion` |
| `CloudeventsEventSpecVersionKey` | `CloudEventsEventSpecVersionKey` |
| `CloudeventsEventSubject` | `CloudEventsEventSubject` |
| `CloudeventsEventSubjectKey` | `CloudEventsEventSubjectKey` |
| `CloudeventsEventType` | `CloudEventsEventType` |
| `CloudeventsEventTypeKey` | `CloudEventsEventTypeKey` |
| `CloudfoundryAppID` | `CloudFoundryAppID` |
| `CloudfoundryAppIDKey` | `CloudFoundryAppIDKey` |
| `CloudfoundryAppInstanceID` | `CloudFoundryAppInstanceID` |
| `CloudfoundryAppInstanceIDKey` | `CloudFoundryAppInstanceIDKey` |
| `CloudfoundryAppName` | `CloudFoundryAppName` |
| `CloudfoundryAppNameKey` | `CloudFoundryAppNameKey` |
| `CloudfoundryOrgID` | `CloudFoundryOrgID` |
| `CloudfoundryOrgIDKey` | `CloudFoundryOrgIDKey` |
| `CloudfoundryOrgName` | `CloudFoundryOrgName` |
| `CloudfoundryOrgNameKey` | `CloudFoundryOrgNameKey` |
| `CloudfoundryProcessID` | `CloudFoundryProcessID` |
| `CloudfoundryProcessIDKey` | `CloudFoundryProcessIDKey` |
| `CloudfoundryProcessType` | `CloudFoundryProcessType` |
| `CloudfoundryProcessTypeKey` | `CloudFoundryProcessTypeKey` |
| `CloudfoundrySpaceID` | `CloudFoundrySpaceID` |
| `CloudfoundrySpaceIDKey` | `CloudFoundrySpaceIDKey` |
| `CloudfoundrySpaceName` | `CloudFoundrySpaceName` |
| `CloudfoundrySpaceNameKey` | `CloudFoundrySpaceNameKey` |
| `CloudfoundrySystemID` | `CloudFoundrySystemID` |
| `CloudfoundrySystemIDKey` | `CloudFoundrySystemIDKey` |
| `CloudfoundrySystemInstanceID` | `CloudFoundrySystemInstanceID` |
| `CloudfoundrySystemInstanceIDKey` | `CloudFoundrySystemInstanceIDKey` |
| `ContainerCsiPluginName` | `ContainerCSIPluginName` |
| `ContainerCsiPluginNameKey` | `ContainerCSIPluginNameKey` |
| `ContainerCsiVolumeID` | `ContainerCSIVolumeID` |
| `ContainerCsiVolumeIDKey` | `ContainerCSIVolumeIDKey` |
| `DBSystemNameClickhouse` | `DBSystemNameClickHouse` |
| `DBSystemNameCockroachdb` | `DBSystemNameCockroachDB` |
| `DBSystemNameFirebirdsql` | `DBSystemNameFirebirdSQL` |
| `DBSystemNameIbmDb2` | `DBSystemNameIBMDB2` |
| `DBSystemNameIbmInformix` | `DBSystemNameIBMInformix` |
| `DBSystemNameIbmNetezza` | `DBSystemNameIBMNetezza` |
| `DBSystemNameInfluxdb` | `DBSystemNameInfluxDB` |
| `DBSystemNameOpensearch` | `DBSystemNameOpenSearch` |
| `DBSystemNameSapHana` | `DBSystemNameSAPHANA` |
| `DBSystemNameSapMaxDB` | `DBSystemNameSAPMaxDB` |
| `DBSystemNameSqlite` | `DBSystemNameSQLite` |
| `DiskIoDirectionKey` | `DiskIODirectionKey` |
| `DiskIoDirectionRead` | `DiskIODirectionRead` |
| `DiskIoDirectionWrite` | `DiskIODirectionWrite` |
| `FaaSTriggerPubsub` | `FaaSTriggerPubSub` |
| `GCPGceInstanceHostname` | `GCPGCEInstanceHostname` |
| `GCPGceInstanceHostnameKey` | `GCPGCEInstanceHostnameKey` |
| `GCPGceInstanceName` | `GCPGCEInstanceName` |
| `GCPGceInstanceNameKey` | `GCPGCEInstanceNameKey` |
| `GenAIOpenaiRequestServiceTierAuto` | `GenAIOpenAIRequestServiceTierAuto` |
| `GenAIOpenaiRequestServiceTierDefault` | `GenAIOpenAIRequestServiceTierDefault` |
| `GenAIOpenaiRequestServiceTierKey` | `GenAIOpenAIRequestServiceTierKey` |
| `GenAIOpenaiResponseServiceTier` | `GenAIOpenAIResponseServiceTier` |
| `GenAIOpenaiResponseServiceTierKey` | `GenAIOpenAIResponseServiceTierKey` |
| `GenAIOpenaiResponseSystemFingerprint` | `GenAIOpenAIResponseSystemFingerprint` |
| `GenAIOpenaiResponseSystemFingerprintKey` | `GenAIOpenAIResponseSystemFingerprintKey` |
| `GenAISystemAzAIOpenai` | `GenAISystemAzAIOpenAI` |
| `GenAISystemIbmWatsonxAI` | `GenAISystemIBMWatsonxAI` |
| `GenAISystemOpenai` | `GenAISystemOpenAI` |
| `GeoCountryIsoCode` | `GeoCountryISOCode` |
| `GeoCountryIsoCodeKey` | `GeoCountryISOCodeKey` |
| `GeoRegionIsoCode` | `GeoRegionISOCode` |
| `GeoRegionIsoCodeKey` | `GeoRegionISOCodeKey` |
| `GraphqlDocument` | `GraphQLDocument` |
| `GraphqlDocumentKey` | `GraphQLDocumentKey` |
| `GraphqlOperationName` | `GraphQLOperationName` |
| `GraphqlOperationNameKey` | `GraphQLOperationNameKey` |
| `GraphqlOperationTypeKey` | `GraphQLOperationTypeKey` |
| `GraphqlOperationTypeMutation` | `GraphQLOperationTypeMutation` |
| `GraphqlOperationTypeQuery` | `GraphQLOperationTypeQuery` |
| `GraphqlOperationTypeSubscription` | `GraphQLOperationTypeSubscription` |
| `IosAppStateActive` | `IOSAppStateActive` |
| `IosAppStateBackground` | `IOSAppStateBackground` |
| `IosAppStateForeground` | `IOSAppStateForeground` |
| `IosAppStateInactive` | `IOSAppStateInactive` |
| `IosAppStateKey` | `IOSAppStateKey` |
| `IosAppStateTerminate` | `IOSAppStateTerminate` |
| `K8SHpaName` | `K8SHPAName` |
| `K8SHpaNameKey` | `K8SHPANameKey` |
| `K8SHpaUID` | `K8SHPAUID` |
| `K8SHpaUIDKey` | `K8SHPAUIDKey` |
| `MessagingEventhubsMessageEnqueuedTime` | `MessagingEventHubsMessageEnqueuedTime` |
| `MessagingEventhubsMessageEnqueuedTimeKey` | `MessagingEventHubsMessageEnqueuedTimeKey` |
| `MessagingGCPPubsubMessageAckDeadline` | `MessagingGCPPubSubMessageAckDeadline` |
| `MessagingGCPPubsubMessageAckDeadlineKey` | `MessagingGCPPubSubMessageAckDeadlineKey` |
| `MessagingGCPPubsubMessageAckID` | `MessagingGCPPubSubMessageAckID` |
| `MessagingGCPPubsubMessageAckIDKey` | `MessagingGCPPubSubMessageAckIDKey` |
| `MessagingGCPPubsubMessageDeliveryAttempt` | `MessagingGCPPubSubMessageDeliveryAttempt` |
| `MessagingGCPPubsubMessageDeliveryAttemptKey` | `MessagingGCPPubSubMessageDeliveryAttemptKey` |
| `MessagingGCPPubsubMessageOrderingKey` | `MessagingGCPPubSubMessageOrderingKey` |
| `MessagingGCPPubsubMessageOrderingKeyKey` | `MessagingGCPPubSubMessageOrderingKeyKey` |
| `MessagingRabbitmqDestinationRoutingKey` | `MessagingRabbitMQDestinationRoutingKey` |
| `MessagingRabbitmqDestinationRoutingKeyKey` | `MessagingRabbitMQDestinationRoutingKeyKey` |
| `MessagingRabbitmqMessageDeliveryTag` | `MessagingRabbitMQMessageDeliveryTag` |
| `MessagingRabbitmqMessageDeliveryTagKey` | `MessagingRabbitMQMessageDeliveryTagKey` |
| `MessagingRocketmqConsumptionModelBroadcasting` | `MessagingRocketMQConsumptionModelBroadcasting` |
| `MessagingRocketmqConsumptionModelClustering` | `MessagingRocketMQConsumptionModelClustering` |
| `MessagingRocketmqConsumptionModelKey` | `MessagingRocketMQConsumptionModelKey` |
| `MessagingRocketmqMessageDelayTimeLevel` | `MessagingRocketMQMessageDelayTimeLevel` |
| `MessagingRocketmqMessageDelayTimeLevelKey` | `MessagingRocketMQMessageDelayTimeLevelKey` |
| `MessagingRocketmqMessageDeliveryTimestamp` | `MessagingRocketMQMessageDeliveryTimestamp` |
| `MessagingRocketmqMessageDeliveryTimestampKey` | `MessagingRocketMQMessageDeliveryTimestampKey` |
| `MessagingRocketmqMessageGroup` | `MessagingRocketMQMessageGroup` |
| `MessagingRocketmqMessageGroupKey` | `MessagingRocketMQMessageGroupKey` |
| `MessagingRocketmqMessageKeys` | `MessagingRocketMQMessageKeys` |
| `MessagingRocketmqMessageKeysKey` | `MessagingRocketMQMessageKeysKey` |
| `MessagingRocketmqMessageTag` | `MessagingRocketMQMessageTag` |
| `MessagingRocketmqMessageTagKey` | `MessagingRocketMQMessageTagKey` |
| `MessagingRocketmqMessageTypeDelay` | `MessagingRocketMQMessageTypeDelay` |
| `MessagingRocketmqMessageTypeFifo` | `MessagingRocketMQMessageTypeFifo` |
| `MessagingRocketmqMessageTypeKey` | `MessagingRocketMQMessageTypeKey` |
| `MessagingRocketmqMessageTypeNormal` | `MessagingRocketMQMessageTypeNormal` |
| `MessagingRocketmqMessageTypeTransaction` | `MessagingRocketMQMessageTypeTransaction` |
| `MessagingRocketmqNamespace` | `MessagingRocketMQNamespace` |
| `MessagingRocketmqNamespaceKey` | `MessagingRocketMQNamespaceKey` |
| `MessagingServicebusDispositionStatusAbandon` | `MessagingServiceBusDispositionStatusAbandon` |
| `MessagingServicebusDispositionStatusComplete` | `MessagingServiceBusDispositionStatusComplete` |
| `MessagingServicebusDispositionStatusDeadLetter` | `MessagingServiceBusDispositionStatusDeadLetter` |
| `MessagingServicebusDispositionStatusDefer` | `MessagingServiceBusDispositionStatusDefer` |
| `MessagingServicebusDispositionStatusKey` | `MessagingServiceBusDispositionStatusKey` |
| `MessagingServicebusMessageDeliveryCount` | `MessagingServiceBusMessageDeliveryCount` |
| `MessagingServicebusMessageDeliveryCountKey` | `MessagingServiceBusMessageDeliveryCountKey` |
| `MessagingServicebusMessageEnqueuedTime` | `MessagingServiceBusMessageEnqueuedTime` |
| `MessagingServicebusMessageEnqueuedTimeKey` | `MessagingServiceBusMessageEnqueuedTimeKey` |
| `MessagingSystemAWSSqs` | `MessagingSystemAWSSQS` |
| `MessagingSystemActivemq` | `MessagingSystemActiveMQ` |
| `MessagingSystemEventgrid` | `MessagingSystemEventGrid` |
| `MessagingSystemEventhubs` | `MessagingSystemEventHubs` |
| `MessagingSystemGCPPubsub` | `MessagingSystemGCPPubSub` |
| `MessagingSystemJms` | `MessagingSystemJMS` |
| `MessagingSystemRabbitmq` | `MessagingSystemRabbitMQ` |
| `MessagingSystemRocketmq` | `MessagingSystemRocketMQ` |
| `MessagingSystemServicebus` | `MessagingSystemServiceBus` |
| `NetworkCarrierIcc` | `NetworkCarrierICC` |
| `NetworkCarrierIccKey` | `NetworkCarrierICCKey` |
| `NetworkCarrierMcc` | `NetworkCarrierMCC` |
| `NetworkCarrierMccKey` | `NetworkCarrierMCCKey` |
| `NetworkCarrierMnc` | `NetworkCarrierMNC` |
| `NetworkCarrierMncKey` | `NetworkCarrierMNCKey` |
| `NetworkIoDirectionKey` | `NetworkIODirectionKey` |
| `NetworkIoDirectionReceive` | `NetworkIODirectionReceive` |
| `NetworkIoDirectionTransmit` | `NetworkIODirectionTransmit` |
| `NetworkTypeIpv4` | `NetworkTypeIPv4` |
| `NetworkTypeIpv6` | `NetworkTypeIPv6` |
| `OciManifestDigest` | `OCIManifestDigest` |
| `OciManifestDigestKey` | `OCIManifestDigestKey` |
| `OpentracingRefTypeChildOf` | `OpenTracingRefTypeChildOf` |
| `OpentracingRefTypeFollowsFrom` | `OpenTracingRefTypeFollowsFrom` |
| `OpentracingRefTypeKey` | `OpenTracingRefTypeKey` |
| `ProcessExecutableBuildIDGnu` | `ProcessExecutableBuildIDGNU` |
| `ProcessExecutableBuildIDGnuKey` | `ProcessExecutableBuildIDGNUKey` |
| `RPCJsonrpcErrorCode` | `RPCJSONRPCErrorCode` |
| `RPCJsonrpcErrorCodeKey` | `RPCJSONRPCErrorCodeKey` |
| `RPCJsonrpcErrorMessage` | `RPCJSONRPCErrorMessage` |
| `RPCJsonrpcErrorMessageKey` | `RPCJSONRPCErrorMessageKey` |
| `RPCJsonrpcRequestID` | `RPCJSONRPCRequestID` |
| `RPCJsonrpcRequestIDKey` | `RPCJSONRPCRequestIDKey` |
| `RPCJsonrpcVersion` | `RPCJSONRPCVersion` |
| `RPCJsonrpcVersionKey` | `RPCJSONRPCVersionKey` |
| `SignalrConnectionStatusAppShutdown` | `SignalRConnectionStatusAppShutdown` |
| `SignalrConnectionStatusKey` | `SignalRConnectionStatusKey` |
| `SignalrConnectionStatusNormalClosure` | `SignalRConnectionStatusNormalClosure` |
| `SignalrConnectionStatusTimeout` | `SignalRConnectionStatusTimeout` |
| `SignalrTransportKey` | `SignalRTransportKey` |
| `SignalrTransportLongPolling` | `SignalRTransportLongPolling` |
| `SignalrTransportServerSentEvents` | `SignalRTransportServerSentEvents` |
| `SignalrTransportWebSockets` | `SignalRTransportWebSockets` |
| `TelemetrySDKLanguageWebjs` | `TelemetrySDKLanguageWebJS` |
[OpenTelemetry Semantic Conventions]: https://github.com/open-telemetry/semantic-conventions
[open an issue]: https://github.com/open-telemetry/opentelemetry-go/issues/new?template=Blank+issue

View File

@@ -0,0 +1,3 @@
# Semconv v1.32.0
[![PkgGoDev](https://pkg.go.dev/badge/go.opentelemetry.io/otel/semconv/v1.32.0)](https://pkg.go.dev/go.opentelemetry.io/otel/semconv/v1.32.0)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,287 @@
// Code generated from semantic convention specification. DO NOT EDIT.
// Package httpconv provides types and functionality for OpenTelemetry semantic
// conventions in the "azure" namespace.
package azureconv
import (
"context"
"sync"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/noop"
)
var (
addOptPool = &sync.Pool{New: func() any { return &[]metric.AddOption{} }}
recOptPool = &sync.Pool{New: func() any { return &[]metric.RecordOption{} }}
)
// CosmosDBConsistencyLevelAttr is an attribute conforming to the
// azure.cosmosdb.consistency.level semantic conventions. It represents the
// account or request [consistency level].
//
// [consistency level]: https://learn.microsoft.com/azure/cosmos-db/consistency-levels
type CosmosDBConsistencyLevelAttr string
var (
// CosmosDBConsistencyLevelStrong is the none.
CosmosDBConsistencyLevelStrong CosmosDBConsistencyLevelAttr = "Strong"
// CosmosDBConsistencyLevelBoundedStaleness is the none.
CosmosDBConsistencyLevelBoundedStaleness CosmosDBConsistencyLevelAttr = "BoundedStaleness"
// CosmosDBConsistencyLevelSession is the none.
CosmosDBConsistencyLevelSession CosmosDBConsistencyLevelAttr = "Session"
// CosmosDBConsistencyLevelEventual is the none.
CosmosDBConsistencyLevelEventual CosmosDBConsistencyLevelAttr = "Eventual"
// CosmosDBConsistencyLevelConsistentPrefix is the none.
CosmosDBConsistencyLevelConsistentPrefix CosmosDBConsistencyLevelAttr = "ConsistentPrefix"
)
// ErrorTypeAttr is an attribute conforming to the error.type semantic
// conventions. It represents the describes a class of error the operation ended
// with.
type ErrorTypeAttr string
var (
// ErrorTypeOther is a fallback error value to be used when the instrumentation
// doesn't define a custom value.
ErrorTypeOther ErrorTypeAttr = "_OTHER"
)
// CosmosDBClientActiveInstanceCount is an instrument used to record metric
// values conforming to the "azure.cosmosdb.client.active_instance.count"
// semantic conventions. It represents the number of active client instances.
type CosmosDBClientActiveInstanceCount struct {
metric.Int64UpDownCounter
}
// NewCosmosDBClientActiveInstanceCount returns a new
// CosmosDBClientActiveInstanceCount instrument.
func NewCosmosDBClientActiveInstanceCount(
m metric.Meter,
opt ...metric.Int64UpDownCounterOption,
) (CosmosDBClientActiveInstanceCount, error) {
// Check if the meter is nil.
if m == nil {
return CosmosDBClientActiveInstanceCount{noop.Int64UpDownCounter{}}, nil
}
i, err := m.Int64UpDownCounter(
"azure.cosmosdb.client.active_instance.count",
append([]metric.Int64UpDownCounterOption{
metric.WithDescription("Number of active client instances"),
metric.WithUnit("{instance}"),
}, opt...)...,
)
if err != nil {
return CosmosDBClientActiveInstanceCount{noop.Int64UpDownCounter{}}, err
}
return CosmosDBClientActiveInstanceCount{i}, nil
}
// Inst returns the underlying metric instrument.
func (m CosmosDBClientActiveInstanceCount) Inst() metric.Int64UpDownCounter {
return m.Int64UpDownCounter
}
// Name returns the semantic convention name of the instrument.
func (CosmosDBClientActiveInstanceCount) Name() string {
return "azure.cosmosdb.client.active_instance.count"
}
// Unit returns the semantic convention unit of the instrument
func (CosmosDBClientActiveInstanceCount) Unit() string {
return "{instance}"
}
// Description returns the semantic convention description of the instrument
func (CosmosDBClientActiveInstanceCount) Description() string {
return "Number of active client instances"
}
// Add adds incr to the existing count.
//
// All additional attrs passed are included in the recorded value.
func (m CosmosDBClientActiveInstanceCount) Add(
ctx context.Context,
incr int64,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Int64UpDownCounter.Add(ctx, incr, *o...)
}
// AttrServerPort returns an optional attribute for the "server.port" semantic
// convention. It represents the server port number.
func (CosmosDBClientActiveInstanceCount) AttrServerPort(val int) attribute.KeyValue {
return attribute.Int("server.port", val)
}
// AttrServerAddress returns an optional attribute for the "server.address"
// semantic convention. It represents the name of the database host.
func (CosmosDBClientActiveInstanceCount) AttrServerAddress(val string) attribute.KeyValue {
return attribute.String("server.address", val)
}
// CosmosDBClientOperationRequestCharge is an instrument used to record metric
// values conforming to the "azure.cosmosdb.client.operation.request_charge"
// semantic conventions. It represents the [Request units] consumed by the
// operation.
//
// [Request units]: https://learn.microsoft.com/azure/cosmos-db/request-units
type CosmosDBClientOperationRequestCharge struct {
metric.Int64Histogram
}
// NewCosmosDBClientOperationRequestCharge returns a new
// CosmosDBClientOperationRequestCharge instrument.
func NewCosmosDBClientOperationRequestCharge(
m metric.Meter,
opt ...metric.Int64HistogramOption,
) (CosmosDBClientOperationRequestCharge, error) {
// Check if the meter is nil.
if m == nil {
return CosmosDBClientOperationRequestCharge{noop.Int64Histogram{}}, nil
}
i, err := m.Int64Histogram(
"azure.cosmosdb.client.operation.request_charge",
append([]metric.Int64HistogramOption{
metric.WithDescription("[Request units](https://learn.microsoft.com/azure/cosmos-db/request-units) consumed by the operation"),
metric.WithUnit("{request_unit}"),
}, opt...)...,
)
if err != nil {
return CosmosDBClientOperationRequestCharge{noop.Int64Histogram{}}, err
}
return CosmosDBClientOperationRequestCharge{i}, nil
}
// Inst returns the underlying metric instrument.
func (m CosmosDBClientOperationRequestCharge) Inst() metric.Int64Histogram {
return m.Int64Histogram
}
// Name returns the semantic convention name of the instrument.
func (CosmosDBClientOperationRequestCharge) Name() string {
return "azure.cosmosdb.client.operation.request_charge"
}
// Unit returns the semantic convention unit of the instrument
func (CosmosDBClientOperationRequestCharge) Unit() string {
return "{request_unit}"
}
// Description returns the semantic convention description of the instrument
func (CosmosDBClientOperationRequestCharge) Description() string {
return "[Request units](https://learn.microsoft.com/azure/cosmos-db/request-units) consumed by the operation"
}
// Record records val to the current distribution.
//
// All additional attrs passed are included in the recorded value.
func (m CosmosDBClientOperationRequestCharge) Record(
ctx context.Context,
val int64,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Int64Histogram.Record(ctx, val, *o...)
}
// 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)
}
// AttrDBOperationName returns an optional attribute for the "db.operation.name"
// semantic convention. It represents the name of the operation or command being
// executed.
func (CosmosDBClientOperationRequestCharge) AttrDBOperationName(val string) attribute.KeyValue {
return attribute.String("db.operation.name", 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)
}

View File

@@ -0,0 +1,523 @@
// Code generated from semantic convention specification. DO NOT EDIT.
// Package httpconv provides types and functionality for OpenTelemetry semantic
// conventions in the "cicd" namespace.
package cicdconv
import (
"context"
"sync"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/noop"
)
var (
addOptPool = &sync.Pool{New: func() any { return &[]metric.AddOption{} }}
recOptPool = &sync.Pool{New: func() any { return &[]metric.RecordOption{} }}
)
// PipelineResultAttr is an attribute conforming to the cicd.pipeline.result
// semantic conventions. It represents the result of a pipeline run.
type PipelineResultAttr string
var (
// PipelineResultSuccess is the pipeline run finished successfully.
PipelineResultSuccess PipelineResultAttr = "success"
// PipelineResultFailure is the pipeline run did not finish successfully, eg.
// due to a compile error or a failing test. Such failures are usually detected
// by non-zero exit codes of the tools executed in the pipeline run.
PipelineResultFailure PipelineResultAttr = "failure"
// PipelineResultError is the pipeline run failed due to an error in the CICD
// system, eg. due to the worker being killed.
PipelineResultError PipelineResultAttr = "error"
// PipelineResultTimeout is a timeout caused the pipeline run to be interrupted.
PipelineResultTimeout PipelineResultAttr = "timeout"
// PipelineResultCancellation is the pipeline run was cancelled, eg. by a user
// manually cancelling the pipeline run.
PipelineResultCancellation PipelineResultAttr = "cancellation"
// PipelineResultSkip is the pipeline run was skipped, eg. due to a precondition
// not being met.
PipelineResultSkip PipelineResultAttr = "skip"
)
// PipelineRunStateAttr is an attribute conforming to the cicd.pipeline.run.state
// semantic conventions. It represents the pipeline run goes through these states
// during its lifecycle.
type PipelineRunStateAttr string
var (
// PipelineRunStatePending is the run pending state spans from the event
// triggering the pipeline run until the execution of the run starts (eg. time
// spent in a queue, provisioning agents, creating run resources).
PipelineRunStatePending PipelineRunStateAttr = "pending"
// PipelineRunStateExecuting is the executing state spans the execution of any
// run tasks (eg. build, test).
PipelineRunStateExecuting PipelineRunStateAttr = "executing"
// PipelineRunStateFinalizing is the finalizing state spans from when the run
// has finished executing (eg. cleanup of run resources).
PipelineRunStateFinalizing PipelineRunStateAttr = "finalizing"
)
// WorkerStateAttr is an attribute conforming to the cicd.worker.state semantic
// conventions. It represents the state of a CICD worker / agent.
type WorkerStateAttr string
var (
// WorkerStateAvailable is the worker is not performing work for the CICD
// system. It is available to the CICD system to perform work on (online /
// idle).
WorkerStateAvailable WorkerStateAttr = "available"
// WorkerStateBusy is the worker is performing work for the CICD system.
WorkerStateBusy WorkerStateAttr = "busy"
// WorkerStateOffline is the worker is not available to the CICD system
// (disconnected / down).
WorkerStateOffline WorkerStateAttr = "offline"
)
// ErrorTypeAttr is an attribute conforming to the error.type semantic
// conventions. It represents the describes a class of error the operation ended
// with.
type ErrorTypeAttr string
var (
// ErrorTypeOther is a fallback error value to be used when the instrumentation
// doesn't define a custom value.
ErrorTypeOther ErrorTypeAttr = "_OTHER"
)
// PipelineRunActive is an instrument used to record metric values conforming to
// the "cicd.pipeline.run.active" semantic conventions. It represents the number
// of pipeline runs currently active in the system by state.
type PipelineRunActive struct {
metric.Int64UpDownCounter
}
// NewPipelineRunActive returns a new PipelineRunActive instrument.
func NewPipelineRunActive(
m metric.Meter,
opt ...metric.Int64UpDownCounterOption,
) (PipelineRunActive, error) {
// Check if the meter is nil.
if m == nil {
return PipelineRunActive{noop.Int64UpDownCounter{}}, nil
}
i, err := m.Int64UpDownCounter(
"cicd.pipeline.run.active",
append([]metric.Int64UpDownCounterOption{
metric.WithDescription("The number of pipeline runs currently active in the system by state."),
metric.WithUnit("{run}"),
}, opt...)...,
)
if err != nil {
return PipelineRunActive{noop.Int64UpDownCounter{}}, err
}
return PipelineRunActive{i}, nil
}
// Inst returns the underlying metric instrument.
func (m PipelineRunActive) Inst() metric.Int64UpDownCounter {
return m.Int64UpDownCounter
}
// Name returns the semantic convention name of the instrument.
func (PipelineRunActive) Name() string {
return "cicd.pipeline.run.active"
}
// Unit returns the semantic convention unit of the instrument
func (PipelineRunActive) Unit() string {
return "{run}"
}
// Description returns the semantic convention description of the instrument
func (PipelineRunActive) Description() string {
return "The number of pipeline runs currently active in the system by state."
}
// Add adds incr to the existing count.
//
// The pipelineName is the the human readable name of the pipeline within a CI/CD
// system.
//
// The pipelineRunState is the the pipeline run goes through these states during
// its lifecycle.
func (m PipelineRunActive) Add(
ctx context.Context,
incr int64,
pipelineName string,
pipelineRunState PipelineRunStateAttr,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
append(
attrs,
attribute.String("cicd.pipeline.name", pipelineName),
attribute.String("cicd.pipeline.run.state", string(pipelineRunState)),
)...,
),
)
m.Int64UpDownCounter.Add(ctx, incr, *o...)
}
// PipelineRunDuration is an instrument used to record metric values conforming
// to the "cicd.pipeline.run.duration" semantic conventions. It represents the
// duration of a pipeline run grouped by pipeline, state and result.
type PipelineRunDuration struct {
metric.Float64Histogram
}
// NewPipelineRunDuration returns a new PipelineRunDuration instrument.
func NewPipelineRunDuration(
m metric.Meter,
opt ...metric.Float64HistogramOption,
) (PipelineRunDuration, error) {
// Check if the meter is nil.
if m == nil {
return PipelineRunDuration{noop.Float64Histogram{}}, nil
}
i, err := m.Float64Histogram(
"cicd.pipeline.run.duration",
append([]metric.Float64HistogramOption{
metric.WithDescription("Duration of a pipeline run grouped by pipeline, state and result."),
metric.WithUnit("s"),
}, opt...)...,
)
if err != nil {
return PipelineRunDuration{noop.Float64Histogram{}}, err
}
return PipelineRunDuration{i}, nil
}
// Inst returns the underlying metric instrument.
func (m PipelineRunDuration) Inst() metric.Float64Histogram {
return m.Float64Histogram
}
// Name returns the semantic convention name of the instrument.
func (PipelineRunDuration) Name() string {
return "cicd.pipeline.run.duration"
}
// Unit returns the semantic convention unit of the instrument
func (PipelineRunDuration) Unit() string {
return "s"
}
// Description returns the semantic convention description of the instrument
func (PipelineRunDuration) Description() string {
return "Duration of a pipeline run grouped by pipeline, state and result."
}
// Record records val to the current distribution.
//
// The pipelineName is the the human readable name of the pipeline within a CI/CD
// system.
//
// The pipelineRunState is the the pipeline run goes through these states during
// its lifecycle.
//
// All additional attrs passed are included in the recorded value.
func (m PipelineRunDuration) Record(
ctx context.Context,
val float64,
pipelineName string,
pipelineRunState PipelineRunStateAttr,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
append(
attrs,
attribute.String("cicd.pipeline.name", pipelineName),
attribute.String("cicd.pipeline.run.state", string(pipelineRunState)),
)...,
),
)
m.Float64Histogram.Record(ctx, val, *o...)
}
// AttrPipelineResult returns an optional attribute for the
// "cicd.pipeline.result" semantic convention. It represents the result of a
// pipeline run.
func (PipelineRunDuration) AttrPipelineResult(val PipelineResultAttr) attribute.KeyValue {
return attribute.String("cicd.pipeline.result", string(val))
}
// AttrErrorType returns an optional attribute for the "error.type" semantic
// convention. It represents the describes a class of error the operation ended
// with.
func (PipelineRunDuration) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
return attribute.String("error.type", string(val))
}
// PipelineRunErrors is an instrument used to record metric values conforming to
// the "cicd.pipeline.run.errors" semantic conventions. It represents the number
// of errors encountered in pipeline runs (eg. compile, test failures).
type PipelineRunErrors struct {
metric.Int64Counter
}
// NewPipelineRunErrors returns a new PipelineRunErrors instrument.
func NewPipelineRunErrors(
m metric.Meter,
opt ...metric.Int64CounterOption,
) (PipelineRunErrors, error) {
// Check if the meter is nil.
if m == nil {
return PipelineRunErrors{noop.Int64Counter{}}, nil
}
i, err := m.Int64Counter(
"cicd.pipeline.run.errors",
append([]metric.Int64CounterOption{
metric.WithDescription("The number of errors encountered in pipeline runs (eg. compile, test failures)."),
metric.WithUnit("{error}"),
}, opt...)...,
)
if err != nil {
return PipelineRunErrors{noop.Int64Counter{}}, err
}
return PipelineRunErrors{i}, nil
}
// Inst returns the underlying metric instrument.
func (m PipelineRunErrors) Inst() metric.Int64Counter {
return m.Int64Counter
}
// Name returns the semantic convention name of the instrument.
func (PipelineRunErrors) Name() string {
return "cicd.pipeline.run.errors"
}
// Unit returns the semantic convention unit of the instrument
func (PipelineRunErrors) Unit() string {
return "{error}"
}
// Description returns the semantic convention description of the instrument
func (PipelineRunErrors) Description() string {
return "The number of errors encountered in pipeline runs (eg. compile, test failures)."
}
// Add adds incr to the existing count.
//
// The pipelineName is the the human readable name of the pipeline within a CI/CD
// system.
//
// The errorType is the describes a class of error the operation ended with.
//
// There might be errors in a pipeline run that are non fatal (eg. they are
// suppressed) or in a parallel stage multiple stages could have a fatal error.
// This means that this error count might not be the same as the count of metric
// `cicd.pipeline.run.duration` with run result `failure`.
func (m PipelineRunErrors) Add(
ctx context.Context,
incr int64,
pipelineName string,
errorType ErrorTypeAttr,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
append(
attrs,
attribute.String("cicd.pipeline.name", pipelineName),
attribute.String("error.type", string(errorType)),
)...,
),
)
m.Int64Counter.Add(ctx, incr, *o...)
}
// SystemErrors is an instrument used to record metric values conforming to the
// "cicd.system.errors" semantic conventions. It represents the number of errors
// in a component of the CICD system (eg. controller, scheduler, agent).
type SystemErrors struct {
metric.Int64Counter
}
// NewSystemErrors returns a new SystemErrors instrument.
func NewSystemErrors(
m metric.Meter,
opt ...metric.Int64CounterOption,
) (SystemErrors, error) {
// Check if the meter is nil.
if m == nil {
return SystemErrors{noop.Int64Counter{}}, nil
}
i, err := m.Int64Counter(
"cicd.system.errors",
append([]metric.Int64CounterOption{
metric.WithDescription("The number of errors in a component of the CICD system (eg. controller, scheduler, agent)."),
metric.WithUnit("{error}"),
}, opt...)...,
)
if err != nil {
return SystemErrors{noop.Int64Counter{}}, err
}
return SystemErrors{i}, nil
}
// Inst returns the underlying metric instrument.
func (m SystemErrors) Inst() metric.Int64Counter {
return m.Int64Counter
}
// Name returns the semantic convention name of the instrument.
func (SystemErrors) Name() string {
return "cicd.system.errors"
}
// Unit returns the semantic convention unit of the instrument
func (SystemErrors) Unit() string {
return "{error}"
}
// Description returns the semantic convention description of the instrument
func (SystemErrors) Description() string {
return "The number of errors in a component of the CICD system (eg. controller, scheduler, agent)."
}
// Add adds incr to the existing count.
//
// The systemComponent is the the name of a component of the CICD system.
//
// The errorType is the describes a class of error the operation ended with.
//
// Errors in pipeline run execution are explicitly excluded. Ie a test failure is
// not counted in this metric.
func (m SystemErrors) Add(
ctx context.Context,
incr int64,
systemComponent string,
errorType ErrorTypeAttr,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
append(
attrs,
attribute.String("cicd.system.component", systemComponent),
attribute.String("error.type", string(errorType)),
)...,
),
)
m.Int64Counter.Add(ctx, incr, *o...)
}
// WorkerCount is an instrument used to record metric values conforming to the
// "cicd.worker.count" semantic conventions. It represents the number of workers
// on the CICD system by state.
type WorkerCount struct {
metric.Int64UpDownCounter
}
// NewWorkerCount returns a new WorkerCount instrument.
func NewWorkerCount(
m metric.Meter,
opt ...metric.Int64UpDownCounterOption,
) (WorkerCount, error) {
// Check if the meter is nil.
if m == nil {
return WorkerCount{noop.Int64UpDownCounter{}}, nil
}
i, err := m.Int64UpDownCounter(
"cicd.worker.count",
append([]metric.Int64UpDownCounterOption{
metric.WithDescription("The number of workers on the CICD system by state."),
metric.WithUnit("{count}"),
}, opt...)...,
)
if err != nil {
return WorkerCount{noop.Int64UpDownCounter{}}, err
}
return WorkerCount{i}, nil
}
// Inst returns the underlying metric instrument.
func (m WorkerCount) Inst() metric.Int64UpDownCounter {
return m.Int64UpDownCounter
}
// Name returns the semantic convention name of the instrument.
func (WorkerCount) Name() string {
return "cicd.worker.count"
}
// Unit returns the semantic convention unit of the instrument
func (WorkerCount) Unit() string {
return "{count}"
}
// Description returns the semantic convention description of the instrument
func (WorkerCount) Description() string {
return "The number of workers on the CICD system by state."
}
// Add adds incr to the existing count.
//
// The workerState is the the state of a CICD worker / agent.
func (m WorkerCount) Add(
ctx context.Context,
incr int64,
workerState WorkerStateAttr,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
append(
attrs,
attribute.String("cicd.worker.state", string(workerState)),
)...,
),
)
m.Int64UpDownCounter.Add(ctx, incr, *o...)
}

View File

@@ -0,0 +1,553 @@
// Code generated from semantic convention specification. DO NOT EDIT.
// Package httpconv provides types and functionality for OpenTelemetry semantic
// conventions in the "container" namespace.
package containerconv
import (
"context"
"sync"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/noop"
)
var (
addOptPool = &sync.Pool{New: func() any { return &[]metric.AddOption{} }}
recOptPool = &sync.Pool{New: func() any { return &[]metric.RecordOption{} }}
)
// CPUModeAttr is an attribute conforming to the cpu.mode semantic conventions.
// It represents the CPU mode for this data point. A container's CPU metric
// SHOULD be characterized *either* by data points with no `mode` labels,
// *or only* data points with `mode` labels.
type CPUModeAttr string
var (
// CPUModeUser is the none.
CPUModeUser CPUModeAttr = "user"
// CPUModeSystem is the none.
CPUModeSystem CPUModeAttr = "system"
// CPUModeNice is the none.
CPUModeNice CPUModeAttr = "nice"
// CPUModeIdle is the none.
CPUModeIdle CPUModeAttr = "idle"
// CPUModeIOWait is the none.
CPUModeIOWait CPUModeAttr = "iowait"
// CPUModeInterrupt is the none.
CPUModeInterrupt CPUModeAttr = "interrupt"
// CPUModeSteal is the none.
CPUModeSteal CPUModeAttr = "steal"
// CPUModeKernel is the none.
CPUModeKernel CPUModeAttr = "kernel"
)
// DiskIODirectionAttr is an attribute conforming to the disk.io.direction
// semantic conventions. It represents the disk IO operation direction.
type DiskIODirectionAttr string
var (
// DiskIODirectionRead is the none.
DiskIODirectionRead DiskIODirectionAttr = "read"
// DiskIODirectionWrite is the none.
DiskIODirectionWrite DiskIODirectionAttr = "write"
)
// NetworkIODirectionAttr is an attribute conforming to the network.io.direction
// semantic conventions. It represents the network IO operation direction.
type NetworkIODirectionAttr string
var (
// NetworkIODirectionTransmit is the none.
NetworkIODirectionTransmit NetworkIODirectionAttr = "transmit"
// NetworkIODirectionReceive is the none.
NetworkIODirectionReceive NetworkIODirectionAttr = "receive"
)
// CPUTime is an instrument used to record metric values conforming to the
// "container.cpu.time" semantic conventions. It represents the total CPU time
// consumed.
type CPUTime struct {
metric.Float64Counter
}
// NewCPUTime returns a new CPUTime instrument.
func NewCPUTime(
m metric.Meter,
opt ...metric.Float64CounterOption,
) (CPUTime, error) {
// Check if the meter is nil.
if m == nil {
return CPUTime{noop.Float64Counter{}}, nil
}
i, err := m.Float64Counter(
"container.cpu.time",
append([]metric.Float64CounterOption{
metric.WithDescription("Total CPU time consumed"),
metric.WithUnit("s"),
}, opt...)...,
)
if err != nil {
return CPUTime{noop.Float64Counter{}}, err
}
return CPUTime{i}, nil
}
// Inst returns the underlying metric instrument.
func (m CPUTime) Inst() metric.Float64Counter {
return m.Float64Counter
}
// Name returns the semantic convention name of the instrument.
func (CPUTime) Name() string {
return "container.cpu.time"
}
// Unit returns the semantic convention unit of the instrument
func (CPUTime) Unit() string {
return "s"
}
// Description returns the semantic convention description of the instrument
func (CPUTime) Description() string {
return "Total CPU time consumed"
}
// Add adds incr to the existing count.
//
// All additional attrs passed are included in the recorded value.
//
// Total CPU time consumed by the specific container on all available CPU cores
func (m CPUTime) Add(
ctx context.Context,
incr float64,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Float64Counter.Add(ctx, incr, *o...)
}
// AttrCPUMode returns an optional attribute for the "cpu.mode" semantic
// convention. It represents the CPU mode for this data point. A container's CPU
// metric SHOULD be characterized *either* by data points with no `mode` labels,
// *or only* data points with `mode` labels.
func (CPUTime) AttrCPUMode(val CPUModeAttr) attribute.KeyValue {
return attribute.String("cpu.mode", string(val))
}
// CPUUsage is an instrument used to record metric values conforming to the
// "container.cpu.usage" semantic conventions. It represents the container's CPU
// usage, measured in cpus. Range from 0 to the number of allocatable CPUs.
type CPUUsage struct {
metric.Int64Gauge
}
// NewCPUUsage returns a new CPUUsage instrument.
func NewCPUUsage(
m metric.Meter,
opt ...metric.Int64GaugeOption,
) (CPUUsage, error) {
// Check if the meter is nil.
if m == nil {
return CPUUsage{noop.Int64Gauge{}}, nil
}
i, err := m.Int64Gauge(
"container.cpu.usage",
append([]metric.Int64GaugeOption{
metric.WithDescription("Container's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs"),
metric.WithUnit("{cpu}"),
}, opt...)...,
)
if err != nil {
return CPUUsage{noop.Int64Gauge{}}, err
}
return CPUUsage{i}, nil
}
// Inst returns the underlying metric instrument.
func (m CPUUsage) Inst() metric.Int64Gauge {
return m.Int64Gauge
}
// Name returns the semantic convention name of the instrument.
func (CPUUsage) Name() string {
return "container.cpu.usage"
}
// Unit returns the semantic convention unit of the instrument
func (CPUUsage) Unit() string {
return "{cpu}"
}
// Description returns the semantic convention description of the instrument
func (CPUUsage) Description() string {
return "Container's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs"
}
// Record records val to the current distribution.
//
// All additional attrs passed are included in the recorded value.
//
// CPU usage of the specific container on all available CPU cores, averaged over
// the sample window
func (m CPUUsage) Record(
ctx context.Context,
val int64,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Int64Gauge.Record(ctx, val, *o...)
}
// AttrCPUMode returns an optional attribute for the "cpu.mode" semantic
// convention. It represents the CPU mode for this data point. A container's CPU
// metric SHOULD be characterized *either* by data points with no `mode` labels,
// *or only* data points with `mode` labels.
func (CPUUsage) AttrCPUMode(val CPUModeAttr) attribute.KeyValue {
return attribute.String("cpu.mode", string(val))
}
// DiskIO is an instrument used to record metric values conforming to the
// "container.disk.io" semantic conventions. It represents the disk bytes for the
// container.
type DiskIO struct {
metric.Int64Counter
}
// NewDiskIO returns a new DiskIO instrument.
func NewDiskIO(
m metric.Meter,
opt ...metric.Int64CounterOption,
) (DiskIO, error) {
// Check if the meter is nil.
if m == nil {
return DiskIO{noop.Int64Counter{}}, nil
}
i, err := m.Int64Counter(
"container.disk.io",
append([]metric.Int64CounterOption{
metric.WithDescription("Disk bytes for the container."),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return DiskIO{noop.Int64Counter{}}, err
}
return DiskIO{i}, nil
}
// Inst returns the underlying metric instrument.
func (m DiskIO) Inst() metric.Int64Counter {
return m.Int64Counter
}
// Name returns the semantic convention name of the instrument.
func (DiskIO) Name() string {
return "container.disk.io"
}
// Unit returns the semantic convention unit of the instrument
func (DiskIO) Unit() string {
return "By"
}
// Description returns the semantic convention description of the instrument
func (DiskIO) Description() string {
return "Disk bytes for the container."
}
// Add adds incr to the existing count.
//
// All additional attrs passed are included in the recorded value.
//
// The total number of bytes read/written successfully (aggregated from all
// disks).
func (m DiskIO) Add(
ctx context.Context,
incr int64,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Int64Counter.Add(ctx, incr, *o...)
}
// AttrDiskIODirection returns an optional attribute for the "disk.io.direction"
// semantic convention. It represents the disk IO operation direction.
func (DiskIO) AttrDiskIODirection(val DiskIODirectionAttr) attribute.KeyValue {
return attribute.String("disk.io.direction", string(val))
}
// AttrSystemDevice returns an optional attribute for the "system.device"
// semantic convention. It represents the device identifier.
func (DiskIO) AttrSystemDevice(val string) attribute.KeyValue {
return attribute.String("system.device", val)
}
// MemoryUsage is an instrument used to record metric values conforming to the
// "container.memory.usage" semantic conventions. It represents the memory usage
// of the container.
type MemoryUsage struct {
metric.Int64Counter
}
// NewMemoryUsage returns a new MemoryUsage instrument.
func NewMemoryUsage(
m metric.Meter,
opt ...metric.Int64CounterOption,
) (MemoryUsage, error) {
// Check if the meter is nil.
if m == nil {
return MemoryUsage{noop.Int64Counter{}}, nil
}
i, err := m.Int64Counter(
"container.memory.usage",
append([]metric.Int64CounterOption{
metric.WithDescription("Memory usage of the container."),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return MemoryUsage{noop.Int64Counter{}}, err
}
return MemoryUsage{i}, nil
}
// Inst returns the underlying metric instrument.
func (m MemoryUsage) Inst() metric.Int64Counter {
return m.Int64Counter
}
// Name returns the semantic convention name of the instrument.
func (MemoryUsage) Name() string {
return "container.memory.usage"
}
// Unit returns the semantic convention unit of the instrument
func (MemoryUsage) Unit() string {
return "By"
}
// Description returns the semantic convention description of the instrument
func (MemoryUsage) Description() string {
return "Memory usage of the container."
}
// Add adds incr to the existing count.
//
// Memory usage of the container.
func (m MemoryUsage) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Int64Counter.Add(ctx, incr)
return
}
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Int64Counter.Add(ctx, incr, *o...)
}
// NetworkIO is an instrument used to record metric values conforming to the
// "container.network.io" semantic conventions. It represents the network bytes
// for the container.
type NetworkIO struct {
metric.Int64Counter
}
// NewNetworkIO returns a new NetworkIO instrument.
func NewNetworkIO(
m metric.Meter,
opt ...metric.Int64CounterOption,
) (NetworkIO, error) {
// Check if the meter is nil.
if m == nil {
return NetworkIO{noop.Int64Counter{}}, nil
}
i, err := m.Int64Counter(
"container.network.io",
append([]metric.Int64CounterOption{
metric.WithDescription("Network bytes for the container."),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return NetworkIO{noop.Int64Counter{}}, err
}
return NetworkIO{i}, nil
}
// Inst returns the underlying metric instrument.
func (m NetworkIO) Inst() metric.Int64Counter {
return m.Int64Counter
}
// Name returns the semantic convention name of the instrument.
func (NetworkIO) Name() string {
return "container.network.io"
}
// Unit returns the semantic convention unit of the instrument
func (NetworkIO) Unit() string {
return "By"
}
// Description returns the semantic convention description of the instrument
func (NetworkIO) Description() string {
return "Network bytes for the container."
}
// Add adds incr to the existing count.
//
// All additional attrs passed are included in the recorded value.
//
// The number of bytes sent/received on all network interfaces by the container.
func (m NetworkIO) Add(
ctx context.Context,
incr int64,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Int64Counter.Add(ctx, incr, *o...)
}
// AttrNetworkInterfaceName returns an optional attribute for the
// "network.interface.name" semantic convention. It represents the network
// interface name.
func (NetworkIO) AttrNetworkInterfaceName(val string) attribute.KeyValue {
return attribute.String("network.interface.name", val)
}
// AttrNetworkIODirection returns an optional attribute for the
// "network.io.direction" semantic convention. It represents the network IO
// operation direction.
func (NetworkIO) AttrNetworkIODirection(val NetworkIODirectionAttr) attribute.KeyValue {
return attribute.String("network.io.direction", string(val))
}
// Uptime is an instrument used to record metric values conforming to the
// "container.uptime" semantic conventions. It represents the time the container
// has been running.
type Uptime struct {
metric.Float64Gauge
}
// NewUptime returns a new Uptime instrument.
func NewUptime(
m metric.Meter,
opt ...metric.Float64GaugeOption,
) (Uptime, error) {
// Check if the meter is nil.
if m == nil {
return Uptime{noop.Float64Gauge{}}, nil
}
i, err := m.Float64Gauge(
"container.uptime",
append([]metric.Float64GaugeOption{
metric.WithDescription("The time the container has been running"),
metric.WithUnit("s"),
}, opt...)...,
)
if err != nil {
return Uptime{noop.Float64Gauge{}}, err
}
return Uptime{i}, nil
}
// Inst returns the underlying metric instrument.
func (m Uptime) Inst() metric.Float64Gauge {
return m.Float64Gauge
}
// Name returns the semantic convention name of the instrument.
func (Uptime) Name() string {
return "container.uptime"
}
// Unit returns the semantic convention unit of the instrument
func (Uptime) Unit() string {
return "s"
}
// Description returns the semantic convention description of the instrument
func (Uptime) Description() string {
return "The time the container has been running"
}
// Record records val to the current distribution.
//
// Instrumentations SHOULD use a gauge with type `double` and measure uptime in
// seconds as a floating point number with the highest precision available.
// The actual accuracy would depend on the instrumentation and operating system.
func (m Uptime) Record(ctx context.Context, val float64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Float64Gauge.Record(ctx, val)
}
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Float64Gauge.Record(ctx, val, *o...)
}

View File

@@ -0,0 +1,271 @@
// Code generated from semantic convention specification. DO NOT EDIT.
// Package httpconv provides types and functionality for OpenTelemetry semantic
// conventions in the "cpu" namespace.
package cpuconv
import (
"context"
"sync"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/noop"
)
var (
addOptPool = &sync.Pool{New: func() any { return &[]metric.AddOption{} }}
recOptPool = &sync.Pool{New: func() any { return &[]metric.RecordOption{} }}
)
// ModeAttr is an attribute conforming to the cpu.mode semantic conventions. It
// represents the mode of the CPU.
type ModeAttr string
var (
// ModeUser is the none.
ModeUser ModeAttr = "user"
// ModeSystem is the none.
ModeSystem ModeAttr = "system"
// ModeNice is the none.
ModeNice ModeAttr = "nice"
// ModeIdle is the none.
ModeIdle ModeAttr = "idle"
// ModeIOWait is the none.
ModeIOWait ModeAttr = "iowait"
// ModeInterrupt is the none.
ModeInterrupt ModeAttr = "interrupt"
// ModeSteal is the none.
ModeSteal ModeAttr = "steal"
// ModeKernel is the none.
ModeKernel ModeAttr = "kernel"
)
// Frequency is an instrument used to record metric values conforming to the
// "cpu.frequency" semantic conventions. It represents the operating frequency of
// the logical CPU in Hertz.
type Frequency struct {
metric.Int64Gauge
}
// NewFrequency returns a new Frequency instrument.
func NewFrequency(
m metric.Meter,
opt ...metric.Int64GaugeOption,
) (Frequency, error) {
// Check if the meter is nil.
if m == nil {
return Frequency{noop.Int64Gauge{}}, nil
}
i, err := m.Int64Gauge(
"cpu.frequency",
append([]metric.Int64GaugeOption{
metric.WithDescription("Operating frequency of the logical CPU in Hertz."),
metric.WithUnit("Hz"),
}, opt...)...,
)
if err != nil {
return Frequency{noop.Int64Gauge{}}, err
}
return Frequency{i}, nil
}
// Inst returns the underlying metric instrument.
func (m Frequency) Inst() metric.Int64Gauge {
return m.Int64Gauge
}
// Name returns the semantic convention name of the instrument.
func (Frequency) Name() string {
return "cpu.frequency"
}
// Unit returns the semantic convention unit of the instrument
func (Frequency) Unit() string {
return "Hz"
}
// Description returns the semantic convention description of the instrument
func (Frequency) Description() string {
return "Operating frequency of the logical CPU in Hertz."
}
// Record records val to the current distribution.
//
// All additional attrs passed are included in the recorded value.
func (m Frequency) Record(
ctx context.Context,
val int64,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Int64Gauge.Record(ctx, val, *o...)
}
// AttrLogicalNumber returns an optional attribute for the "cpu.logical_number"
// semantic convention. It represents the logical CPU number [0..n-1].
func (Frequency) AttrLogicalNumber(val int) attribute.KeyValue {
return attribute.Int("cpu.logical_number", val)
}
// Time is an instrument used to record metric values conforming to the
// "cpu.time" semantic conventions. It represents the seconds each logical CPU
// spent on each mode.
type Time struct {
metric.Float64ObservableCounter
}
// NewTime returns a new Time instrument.
func NewTime(
m metric.Meter,
opt ...metric.Float64ObservableCounterOption,
) (Time, error) {
// Check if the meter is nil.
if m == nil {
return Time{noop.Float64ObservableCounter{}}, nil
}
i, err := m.Float64ObservableCounter(
"cpu.time",
append([]metric.Float64ObservableCounterOption{
metric.WithDescription("Seconds each logical CPU spent on each mode"),
metric.WithUnit("s"),
}, opt...)...,
)
if err != nil {
return Time{noop.Float64ObservableCounter{}}, err
}
return Time{i}, nil
}
// Inst returns the underlying metric instrument.
func (m Time) Inst() metric.Float64ObservableCounter {
return m.Float64ObservableCounter
}
// Name returns the semantic convention name of the instrument.
func (Time) Name() string {
return "cpu.time"
}
// Unit returns the semantic convention unit of the instrument
func (Time) Unit() string {
return "s"
}
// Description returns the semantic convention description of the instrument
func (Time) Description() string {
return "Seconds each logical CPU spent on each mode"
}
// AttrLogicalNumber returns an optional attribute for the "cpu.logical_number"
// semantic convention. It represents the logical CPU number [0..n-1].
func (Time) AttrLogicalNumber(val int) attribute.KeyValue {
return attribute.Int("cpu.logical_number", val)
}
// AttrMode returns an optional attribute for the "cpu.mode" semantic convention.
// It represents the mode of the CPU.
func (Time) AttrMode(val ModeAttr) attribute.KeyValue {
return attribute.String("cpu.mode", string(val))
}
// Utilization is an instrument used to record metric values conforming to the
// "cpu.utilization" semantic conventions. It represents the for each logical
// CPU, the utilization is calculated as the change in cumulative CPU time
// (cpu.time) over a measurement interval, divided by the elapsed time.
type Utilization struct {
metric.Int64Gauge
}
// NewUtilization returns a new Utilization instrument.
func NewUtilization(
m metric.Meter,
opt ...metric.Int64GaugeOption,
) (Utilization, error) {
// Check if the meter is nil.
if m == nil {
return Utilization{noop.Int64Gauge{}}, nil
}
i, err := m.Int64Gauge(
"cpu.utilization",
append([]metric.Int64GaugeOption{
metric.WithDescription("For each logical CPU, the utilization is calculated as the change in cumulative CPU time (cpu.time) over a measurement interval, divided by the elapsed time."),
metric.WithUnit("1"),
}, opt...)...,
)
if err != nil {
return Utilization{noop.Int64Gauge{}}, err
}
return Utilization{i}, nil
}
// Inst returns the underlying metric instrument.
func (m Utilization) Inst() metric.Int64Gauge {
return m.Int64Gauge
}
// Name returns the semantic convention name of the instrument.
func (Utilization) Name() string {
return "cpu.utilization"
}
// Unit returns the semantic convention unit of the instrument
func (Utilization) Unit() string {
return "1"
}
// Description returns the semantic convention description of the instrument
func (Utilization) Description() string {
return "For each logical CPU, the utilization is calculated as the change in cumulative CPU time (cpu.time) over a measurement interval, divided by the elapsed time."
}
// Record records val to the current distribution.
//
// All additional attrs passed are included in the recorded value.
func (m Utilization) Record(
ctx context.Context,
val int64,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Int64Gauge.Record(ctx, val, *o...)
}
// AttrLogicalNumber returns an optional attribute for the "cpu.logical_number"
// semantic convention. It represents the logical CPU number [0..n-1].
func (Utilization) AttrLogicalNumber(val int) attribute.KeyValue {
return attribute.Int("cpu.logical_number", val)
}
// AttrMode returns an optional attribute for the "cpu.mode" semantic convention.
// It represents the mode of the CPU.
func (Utilization) AttrMode(val ModeAttr) attribute.KeyValue {
return attribute.String("cpu.mode", string(val))
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,115 @@
// Code generated from semantic convention specification. DO NOT EDIT.
// Package httpconv provides types and functionality for OpenTelemetry semantic
// conventions in the "dns" namespace.
package dnsconv
import (
"context"
"sync"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/noop"
)
var (
addOptPool = &sync.Pool{New: func() any { return &[]metric.AddOption{} }}
recOptPool = &sync.Pool{New: func() any { return &[]metric.RecordOption{} }}
)
// ErrorTypeAttr is an attribute conforming to the error.type semantic
// conventions. It represents the describes the error the DNS lookup failed with.
type ErrorTypeAttr string
var (
// ErrorTypeOther is a fallback error value to be used when the instrumentation
// doesn't define a custom value.
ErrorTypeOther ErrorTypeAttr = "_OTHER"
)
// LookupDuration is an instrument used to record metric values conforming to the
// "dns.lookup.duration" semantic conventions. It represents the measures the
// time taken to perform a DNS lookup.
type LookupDuration struct {
metric.Float64Histogram
}
// NewLookupDuration returns a new LookupDuration instrument.
func NewLookupDuration(
m metric.Meter,
opt ...metric.Float64HistogramOption,
) (LookupDuration, error) {
// Check if the meter is nil.
if m == nil {
return LookupDuration{noop.Float64Histogram{}}, nil
}
i, err := m.Float64Histogram(
"dns.lookup.duration",
append([]metric.Float64HistogramOption{
metric.WithDescription("Measures the time taken to perform a DNS lookup."),
metric.WithUnit("s"),
}, opt...)...,
)
if err != nil {
return LookupDuration{noop.Float64Histogram{}}, err
}
return LookupDuration{i}, nil
}
// Inst returns the underlying metric instrument.
func (m LookupDuration) Inst() metric.Float64Histogram {
return m.Float64Histogram
}
// Name returns the semantic convention name of the instrument.
func (LookupDuration) Name() string {
return "dns.lookup.duration"
}
// Unit returns the semantic convention unit of the instrument
func (LookupDuration) Unit() string {
return "s"
}
// Description returns the semantic convention description of the instrument
func (LookupDuration) Description() string {
return "Measures the time taken to perform a DNS lookup."
}
// Record records val to the current distribution.
//
// The questionName is the the name being queried.
//
// All additional attrs passed are included in the recorded value.
func (m LookupDuration) Record(
ctx context.Context,
val float64,
questionName string,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
append(
attrs,
attribute.String("dns.question.name", questionName),
)...,
),
)
m.Float64Histogram.Record(ctx, val, *o...)
}
// AttrErrorType returns an optional attribute for the "error.type" semantic
// convention. It represents the describes the error the DNS lookup failed with.
func (LookupDuration) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
return attribute.String("error.type", string(val))
}

9
semconv/v1.32.0/doc.go Normal file
View 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.32.0
// version of the OpenTelemetry semantic conventions.
package semconv // import "go.opentelemetry.io/otel/semconv/v1.32.0"

View File

@@ -0,0 +1,9 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package semconv // import "go.opentelemetry.io/otel/semconv/v1.32.0"
const (
// ExceptionEventName is the name of the Span event representing an exception.
ExceptionEventName = "exception"
)

View File

@@ -0,0 +1,768 @@
// Code generated from semantic convention specification. DO NOT EDIT.
// Package httpconv provides types and functionality for OpenTelemetry semantic
// conventions in the "faas" namespace.
package faasconv
import (
"context"
"sync"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/noop"
)
var (
addOptPool = &sync.Pool{New: func() any { return &[]metric.AddOption{} }}
recOptPool = &sync.Pool{New: func() any { return &[]metric.RecordOption{} }}
)
// TriggerAttr is an attribute conforming to the faas.trigger semantic
// conventions. It represents the type of the trigger which caused this function
// invocation.
type TriggerAttr string
var (
// TriggerDatasource is a response to some data source operation such as a
// database or filesystem read/write.
TriggerDatasource TriggerAttr = "datasource"
// TriggerHTTP is the to provide an answer to an inbound HTTP request.
TriggerHTTP TriggerAttr = "http"
// TriggerPubSub is a function is set to be executed when messages are sent to a
// messaging system.
TriggerPubSub TriggerAttr = "pubsub"
// TriggerTimer is a function is scheduled to be executed regularly.
TriggerTimer TriggerAttr = "timer"
// TriggerOther is the if none of the others apply.
TriggerOther TriggerAttr = "other"
)
// Coldstarts is an instrument used to record metric values conforming to the
// "faas.coldstarts" semantic conventions. It represents the number of invocation
// cold starts.
type Coldstarts struct {
metric.Int64Counter
}
// NewColdstarts returns a new Coldstarts instrument.
func NewColdstarts(
m metric.Meter,
opt ...metric.Int64CounterOption,
) (Coldstarts, error) {
// Check if the meter is nil.
if m == nil {
return Coldstarts{noop.Int64Counter{}}, nil
}
i, err := m.Int64Counter(
"faas.coldstarts",
append([]metric.Int64CounterOption{
metric.WithDescription("Number of invocation cold starts"),
metric.WithUnit("{coldstart}"),
}, opt...)...,
)
if err != nil {
return Coldstarts{noop.Int64Counter{}}, err
}
return Coldstarts{i}, nil
}
// Inst returns the underlying metric instrument.
func (m Coldstarts) Inst() metric.Int64Counter {
return m.Int64Counter
}
// Name returns the semantic convention name of the instrument.
func (Coldstarts) Name() string {
return "faas.coldstarts"
}
// Unit returns the semantic convention unit of the instrument
func (Coldstarts) Unit() string {
return "{coldstart}"
}
// Description returns the semantic convention description of the instrument
func (Coldstarts) Description() string {
return "Number of invocation cold starts"
}
// Add adds incr to the existing count.
//
// All additional attrs passed are included in the recorded value.
func (m Coldstarts) Add(
ctx context.Context,
incr int64,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Int64Counter.Add(ctx, incr, *o...)
}
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
// convention. It represents the type of the trigger which caused this function
// invocation.
func (Coldstarts) AttrTrigger(val TriggerAttr) attribute.KeyValue {
return attribute.String("faas.trigger", string(val))
}
// CPUUsage is an instrument used to record metric values conforming to the
// "faas.cpu_usage" semantic conventions. It represents the distribution of CPU
// usage per invocation.
type CPUUsage struct {
metric.Float64Histogram
}
// NewCPUUsage returns a new CPUUsage instrument.
func NewCPUUsage(
m metric.Meter,
opt ...metric.Float64HistogramOption,
) (CPUUsage, error) {
// Check if the meter is nil.
if m == nil {
return CPUUsage{noop.Float64Histogram{}}, nil
}
i, err := m.Float64Histogram(
"faas.cpu_usage",
append([]metric.Float64HistogramOption{
metric.WithDescription("Distribution of CPU usage per invocation"),
metric.WithUnit("s"),
}, opt...)...,
)
if err != nil {
return CPUUsage{noop.Float64Histogram{}}, err
}
return CPUUsage{i}, nil
}
// Inst returns the underlying metric instrument.
func (m CPUUsage) Inst() metric.Float64Histogram {
return m.Float64Histogram
}
// Name returns the semantic convention name of the instrument.
func (CPUUsage) Name() string {
return "faas.cpu_usage"
}
// Unit returns the semantic convention unit of the instrument
func (CPUUsage) Unit() string {
return "s"
}
// Description returns the semantic convention description of the instrument
func (CPUUsage) Description() string {
return "Distribution of CPU usage per invocation"
}
// Record records val to the current distribution.
//
// All additional attrs passed are included in the recorded value.
func (m CPUUsage) Record(
ctx context.Context,
val float64,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Float64Histogram.Record(ctx, val, *o...)
}
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
// convention. It represents the type of the trigger which caused this function
// invocation.
func (CPUUsage) AttrTrigger(val TriggerAttr) attribute.KeyValue {
return attribute.String("faas.trigger", string(val))
}
// Errors is an instrument used to record metric values conforming to the
// "faas.errors" semantic conventions. It represents the number of invocation
// errors.
type Errors struct {
metric.Int64Counter
}
// NewErrors returns a new Errors instrument.
func NewErrors(
m metric.Meter,
opt ...metric.Int64CounterOption,
) (Errors, error) {
// Check if the meter is nil.
if m == nil {
return Errors{noop.Int64Counter{}}, nil
}
i, err := m.Int64Counter(
"faas.errors",
append([]metric.Int64CounterOption{
metric.WithDescription("Number of invocation errors"),
metric.WithUnit("{error}"),
}, opt...)...,
)
if err != nil {
return Errors{noop.Int64Counter{}}, err
}
return Errors{i}, nil
}
// Inst returns the underlying metric instrument.
func (m Errors) Inst() metric.Int64Counter {
return m.Int64Counter
}
// Name returns the semantic convention name of the instrument.
func (Errors) Name() string {
return "faas.errors"
}
// Unit returns the semantic convention unit of the instrument
func (Errors) Unit() string {
return "{error}"
}
// Description returns the semantic convention description of the instrument
func (Errors) Description() string {
return "Number of invocation errors"
}
// Add adds incr to the existing count.
//
// All additional attrs passed are included in the recorded value.
func (m Errors) Add(
ctx context.Context,
incr int64,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Int64Counter.Add(ctx, incr, *o...)
}
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
// convention. It represents the type of the trigger which caused this function
// invocation.
func (Errors) AttrTrigger(val TriggerAttr) attribute.KeyValue {
return attribute.String("faas.trigger", string(val))
}
// InitDuration is an instrument used to record metric values conforming to the
// "faas.init_duration" semantic conventions. It represents the measures the
// duration of the function's initialization, such as a cold start.
type InitDuration struct {
metric.Float64Histogram
}
// NewInitDuration returns a new InitDuration instrument.
func NewInitDuration(
m metric.Meter,
opt ...metric.Float64HistogramOption,
) (InitDuration, error) {
// Check if the meter is nil.
if m == nil {
return InitDuration{noop.Float64Histogram{}}, nil
}
i, err := m.Float64Histogram(
"faas.init_duration",
append([]metric.Float64HistogramOption{
metric.WithDescription("Measures the duration of the function's initialization, such as a cold start"),
metric.WithUnit("s"),
}, opt...)...,
)
if err != nil {
return InitDuration{noop.Float64Histogram{}}, err
}
return InitDuration{i}, nil
}
// Inst returns the underlying metric instrument.
func (m InitDuration) Inst() metric.Float64Histogram {
return m.Float64Histogram
}
// Name returns the semantic convention name of the instrument.
func (InitDuration) Name() string {
return "faas.init_duration"
}
// Unit returns the semantic convention unit of the instrument
func (InitDuration) Unit() string {
return "s"
}
// Description returns the semantic convention description of the instrument
func (InitDuration) Description() string {
return "Measures the duration of the function's initialization, such as a cold start"
}
// Record records val to the current distribution.
//
// All additional attrs passed are included in the recorded value.
func (m InitDuration) Record(
ctx context.Context,
val float64,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Float64Histogram.Record(ctx, val, *o...)
}
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
// convention. It represents the type of the trigger which caused this function
// invocation.
func (InitDuration) AttrTrigger(val TriggerAttr) attribute.KeyValue {
return attribute.String("faas.trigger", string(val))
}
// Invocations is an instrument used to record metric values conforming to the
// "faas.invocations" semantic conventions. It represents the number of
// successful invocations.
type Invocations struct {
metric.Int64Counter
}
// NewInvocations returns a new Invocations instrument.
func NewInvocations(
m metric.Meter,
opt ...metric.Int64CounterOption,
) (Invocations, error) {
// Check if the meter is nil.
if m == nil {
return Invocations{noop.Int64Counter{}}, nil
}
i, err := m.Int64Counter(
"faas.invocations",
append([]metric.Int64CounterOption{
metric.WithDescription("Number of successful invocations"),
metric.WithUnit("{invocation}"),
}, opt...)...,
)
if err != nil {
return Invocations{noop.Int64Counter{}}, err
}
return Invocations{i}, nil
}
// Inst returns the underlying metric instrument.
func (m Invocations) Inst() metric.Int64Counter {
return m.Int64Counter
}
// Name returns the semantic convention name of the instrument.
func (Invocations) Name() string {
return "faas.invocations"
}
// Unit returns the semantic convention unit of the instrument
func (Invocations) Unit() string {
return "{invocation}"
}
// Description returns the semantic convention description of the instrument
func (Invocations) Description() string {
return "Number of successful invocations"
}
// Add adds incr to the existing count.
//
// All additional attrs passed are included in the recorded value.
func (m Invocations) Add(
ctx context.Context,
incr int64,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Int64Counter.Add(ctx, incr, *o...)
}
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
// convention. It represents the type of the trigger which caused this function
// invocation.
func (Invocations) AttrTrigger(val TriggerAttr) attribute.KeyValue {
return attribute.String("faas.trigger", string(val))
}
// InvokeDuration is an instrument used to record metric values conforming to the
// "faas.invoke_duration" semantic conventions. It represents the measures the
// duration of the function's logic execution.
type InvokeDuration struct {
metric.Float64Histogram
}
// NewInvokeDuration returns a new InvokeDuration instrument.
func NewInvokeDuration(
m metric.Meter,
opt ...metric.Float64HistogramOption,
) (InvokeDuration, error) {
// Check if the meter is nil.
if m == nil {
return InvokeDuration{noop.Float64Histogram{}}, nil
}
i, err := m.Float64Histogram(
"faas.invoke_duration",
append([]metric.Float64HistogramOption{
metric.WithDescription("Measures the duration of the function's logic execution"),
metric.WithUnit("s"),
}, opt...)...,
)
if err != nil {
return InvokeDuration{noop.Float64Histogram{}}, err
}
return InvokeDuration{i}, nil
}
// Inst returns the underlying metric instrument.
func (m InvokeDuration) Inst() metric.Float64Histogram {
return m.Float64Histogram
}
// Name returns the semantic convention name of the instrument.
func (InvokeDuration) Name() string {
return "faas.invoke_duration"
}
// Unit returns the semantic convention unit of the instrument
func (InvokeDuration) Unit() string {
return "s"
}
// Description returns the semantic convention description of the instrument
func (InvokeDuration) Description() string {
return "Measures the duration of the function's logic execution"
}
// Record records val to the current distribution.
//
// All additional attrs passed are included in the recorded value.
func (m InvokeDuration) Record(
ctx context.Context,
val float64,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Float64Histogram.Record(ctx, val, *o...)
}
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
// convention. It represents the type of the trigger which caused this function
// invocation.
func (InvokeDuration) AttrTrigger(val TriggerAttr) attribute.KeyValue {
return attribute.String("faas.trigger", string(val))
}
// MemUsage is an instrument used to record metric values conforming to the
// "faas.mem_usage" semantic conventions. It represents the distribution of max
// memory usage per invocation.
type MemUsage struct {
metric.Int64Histogram
}
// NewMemUsage returns a new MemUsage instrument.
func NewMemUsage(
m metric.Meter,
opt ...metric.Int64HistogramOption,
) (MemUsage, error) {
// Check if the meter is nil.
if m == nil {
return MemUsage{noop.Int64Histogram{}}, nil
}
i, err := m.Int64Histogram(
"faas.mem_usage",
append([]metric.Int64HistogramOption{
metric.WithDescription("Distribution of max memory usage per invocation"),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return MemUsage{noop.Int64Histogram{}}, err
}
return MemUsage{i}, nil
}
// Inst returns the underlying metric instrument.
func (m MemUsage) Inst() metric.Int64Histogram {
return m.Int64Histogram
}
// Name returns the semantic convention name of the instrument.
func (MemUsage) Name() string {
return "faas.mem_usage"
}
// Unit returns the semantic convention unit of the instrument
func (MemUsage) Unit() string {
return "By"
}
// Description returns the semantic convention description of the instrument
func (MemUsage) Description() string {
return "Distribution of max memory usage per invocation"
}
// Record records val to the current distribution.
//
// All additional attrs passed are included in the recorded value.
func (m MemUsage) Record(
ctx context.Context,
val int64,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Int64Histogram.Record(ctx, val, *o...)
}
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
// convention. It represents the type of the trigger which caused this function
// invocation.
func (MemUsage) AttrTrigger(val TriggerAttr) attribute.KeyValue {
return attribute.String("faas.trigger", string(val))
}
// NetIO is an instrument used to record metric values conforming to the
// "faas.net_io" semantic conventions. It represents the distribution of net I/O
// usage per invocation.
type NetIO struct {
metric.Int64Histogram
}
// NewNetIO returns a new NetIO instrument.
func NewNetIO(
m metric.Meter,
opt ...metric.Int64HistogramOption,
) (NetIO, error) {
// Check if the meter is nil.
if m == nil {
return NetIO{noop.Int64Histogram{}}, nil
}
i, err := m.Int64Histogram(
"faas.net_io",
append([]metric.Int64HistogramOption{
metric.WithDescription("Distribution of net I/O usage per invocation"),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return NetIO{noop.Int64Histogram{}}, err
}
return NetIO{i}, nil
}
// Inst returns the underlying metric instrument.
func (m NetIO) Inst() metric.Int64Histogram {
return m.Int64Histogram
}
// Name returns the semantic convention name of the instrument.
func (NetIO) Name() string {
return "faas.net_io"
}
// Unit returns the semantic convention unit of the instrument
func (NetIO) Unit() string {
return "By"
}
// Description returns the semantic convention description of the instrument
func (NetIO) Description() string {
return "Distribution of net I/O usage per invocation"
}
// Record records val to the current distribution.
//
// All additional attrs passed are included in the recorded value.
func (m NetIO) Record(
ctx context.Context,
val int64,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Int64Histogram.Record(ctx, val, *o...)
}
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
// convention. It represents the type of the trigger which caused this function
// invocation.
func (NetIO) AttrTrigger(val TriggerAttr) attribute.KeyValue {
return attribute.String("faas.trigger", string(val))
}
// Timeouts is an instrument used to record metric values conforming to the
// "faas.timeouts" semantic conventions. It represents the number of invocation
// timeouts.
type Timeouts struct {
metric.Int64Counter
}
// NewTimeouts returns a new Timeouts instrument.
func NewTimeouts(
m metric.Meter,
opt ...metric.Int64CounterOption,
) (Timeouts, error) {
// Check if the meter is nil.
if m == nil {
return Timeouts{noop.Int64Counter{}}, nil
}
i, err := m.Int64Counter(
"faas.timeouts",
append([]metric.Int64CounterOption{
metric.WithDescription("Number of invocation timeouts"),
metric.WithUnit("{timeout}"),
}, opt...)...,
)
if err != nil {
return Timeouts{noop.Int64Counter{}}, err
}
return Timeouts{i}, nil
}
// Inst returns the underlying metric instrument.
func (m Timeouts) Inst() metric.Int64Counter {
return m.Int64Counter
}
// Name returns the semantic convention name of the instrument.
func (Timeouts) Name() string {
return "faas.timeouts"
}
// Unit returns the semantic convention unit of the instrument
func (Timeouts) Unit() string {
return "{timeout}"
}
// Description returns the semantic convention description of the instrument
func (Timeouts) Description() string {
return "Number of invocation timeouts"
}
// Add adds incr to the existing count.
//
// All additional attrs passed are included in the recorded value.
func (m Timeouts) Add(
ctx context.Context,
incr int64,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Int64Counter.Add(ctx, incr, *o...)
}
// AttrTrigger returns an optional attribute for the "faas.trigger" semantic
// convention. It represents the type of the trigger which caused this function
// invocation.
func (Timeouts) AttrTrigger(val TriggerAttr) attribute.KeyValue {
return attribute.String("faas.trigger", string(val))
}

View File

@@ -0,0 +1,678 @@
// Code generated from semantic convention specification. DO NOT EDIT.
// Package httpconv provides types and functionality for OpenTelemetry semantic
// conventions in the "gen_ai" namespace.
package genaiconv
import (
"context"
"sync"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/noop"
)
var (
addOptPool = &sync.Pool{New: func() any { return &[]metric.AddOption{} }}
recOptPool = &sync.Pool{New: func() any { return &[]metric.RecordOption{} }}
)
// ErrorTypeAttr is an attribute conforming to the error.type semantic
// conventions. It represents the describes a class of error the operation ended
// with.
type ErrorTypeAttr string
var (
// ErrorTypeOther is a fallback error value to be used when the instrumentation
// doesn't define a custom value.
ErrorTypeOther ErrorTypeAttr = "_OTHER"
)
// OperationNameAttr is an attribute conforming to the gen_ai.operation.name
// semantic conventions. It represents the name of the operation being performed.
type OperationNameAttr string
var (
// OperationNameChat is the chat completion operation such as [OpenAI Chat API]
// .
//
// [OpenAI Chat API]: https://platform.openai.com/docs/api-reference/chat
OperationNameChat OperationNameAttr = "chat"
// 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"
// OperationNameExecuteTool is the execute a tool.
OperationNameExecuteTool OperationNameAttr = "execute_tool"
)
// SystemAttr is an attribute conforming to the gen_ai.system semantic
// conventions. It represents the Generative AI product as identified by the
// client or server instrumentation.
type SystemAttr string
var (
// SystemOpenAI is the openAI.
SystemOpenAI SystemAttr = "openai"
// SystemVertexAI is the vertex AI.
SystemVertexAI SystemAttr = "vertex_ai"
// SystemGemini is the gemini.
SystemGemini SystemAttr = "gemini"
// SystemAnthropic is the anthropic.
SystemAnthropic SystemAttr = "anthropic"
// SystemCohere is the cohere.
SystemCohere SystemAttr = "cohere"
// SystemAzAIInference is the azure AI Inference.
SystemAzAIInference SystemAttr = "az.ai.inference"
// SystemAzAIOpenAI is the azure OpenAI.
SystemAzAIOpenAI SystemAttr = "az.ai.openai"
// SystemIBMWatsonxAI is the IBM Watsonx AI.
SystemIBMWatsonxAI SystemAttr = "ibm.watsonx.ai"
// SystemAWSBedrock is the AWS Bedrock.
SystemAWSBedrock SystemAttr = "aws.bedrock"
// SystemPerplexity is the perplexity.
SystemPerplexity SystemAttr = "perplexity"
// SystemXai is the xAI.
SystemXai SystemAttr = "xai"
// SystemDeepseek is the deepSeek.
SystemDeepseek SystemAttr = "deepseek"
// SystemGroq is the groq.
SystemGroq SystemAttr = "groq"
// SystemMistralAI is the mistral AI.
SystemMistralAI SystemAttr = "mistral_ai"
)
// TokenTypeAttr is an attribute conforming to the gen_ai.token.type semantic
// conventions. It represents the type of token being counted.
type TokenTypeAttr string
var (
// TokenTypeInput is the input tokens (prompt, input, etc.).
TokenTypeInput TokenTypeAttr = "input"
// TokenTypeOutput is the output tokens (completion, response, etc.).
TokenTypeOutput TokenTypeAttr = "output"
)
// ClientOperationDuration is an instrument used to record metric values
// conforming to the "gen_ai.client.operation.duration" semantic conventions. It
// represents the genAI operation duration.
type ClientOperationDuration struct {
metric.Float64Histogram
}
// NewClientOperationDuration returns a new ClientOperationDuration instrument.
func NewClientOperationDuration(
m metric.Meter,
opt ...metric.Float64HistogramOption,
) (ClientOperationDuration, error) {
// Check if the meter is nil.
if m == nil {
return ClientOperationDuration{noop.Float64Histogram{}}, nil
}
i, err := m.Float64Histogram(
"gen_ai.client.operation.duration",
append([]metric.Float64HistogramOption{
metric.WithDescription("GenAI operation duration"),
metric.WithUnit("s"),
}, opt...)...,
)
if err != nil {
return ClientOperationDuration{noop.Float64Histogram{}}, err
}
return ClientOperationDuration{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ClientOperationDuration) Inst() metric.Float64Histogram {
return m.Float64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ClientOperationDuration) Name() string {
return "gen_ai.client.operation.duration"
}
// Unit returns the semantic convention unit of the instrument
func (ClientOperationDuration) Unit() string {
return "s"
}
// Description returns the semantic convention description of the instrument
func (ClientOperationDuration) Description() string {
return "GenAI operation duration"
}
// Record records val to the current distribution.
//
// The operationName is the the name of the operation being performed.
//
// The system is the the Generative AI product as identified by the client or
// server instrumentation.
//
// All additional attrs passed are included in the recorded value.
func (m ClientOperationDuration) Record(
ctx context.Context,
val float64,
operationName OperationNameAttr,
system SystemAttr,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
append(
attrs,
attribute.String("gen_ai.operation.name", string(operationName)),
attribute.String("gen_ai.system", string(system)),
)...,
),
)
m.Float64Histogram.Record(ctx, val, *o...)
}
// AttrErrorType returns an optional attribute for the "error.type" semantic
// convention. It represents the describes a class of error the operation ended
// with.
func (ClientOperationDuration) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
return attribute.String("error.type", string(val))
}
// AttrRequestModel returns an optional attribute for the "gen_ai.request.model"
// semantic convention. It represents the name of the GenAI model a request is
// being made to.
func (ClientOperationDuration) AttrRequestModel(val string) attribute.KeyValue {
return attribute.String("gen_ai.request.model", val)
}
// AttrServerPort returns an optional attribute for the "server.port" semantic
// convention. It represents the genAI server port.
func (ClientOperationDuration) AttrServerPort(val int) attribute.KeyValue {
return attribute.Int("server.port", val)
}
// AttrResponseModel returns an optional attribute for the
// "gen_ai.response.model" semantic convention. It represents the name of the
// model that generated the response.
func (ClientOperationDuration) AttrResponseModel(val string) attribute.KeyValue {
return attribute.String("gen_ai.response.model", val)
}
// AttrServerAddress returns an optional attribute for the "server.address"
// semantic convention. It represents the genAI server address.
func (ClientOperationDuration) AttrServerAddress(val string) attribute.KeyValue {
return attribute.String("server.address", val)
}
// ClientTokenUsage is an instrument used to record metric values conforming to
// the "gen_ai.client.token.usage" semantic conventions. It represents the
// measures number of input and output tokens used.
type ClientTokenUsage struct {
metric.Int64Histogram
}
// NewClientTokenUsage returns a new ClientTokenUsage instrument.
func NewClientTokenUsage(
m metric.Meter,
opt ...metric.Int64HistogramOption,
) (ClientTokenUsage, error) {
// Check if the meter is nil.
if m == nil {
return ClientTokenUsage{noop.Int64Histogram{}}, nil
}
i, err := m.Int64Histogram(
"gen_ai.client.token.usage",
append([]metric.Int64HistogramOption{
metric.WithDescription("Measures number of input and output tokens used"),
metric.WithUnit("{token}"),
}, opt...)...,
)
if err != nil {
return ClientTokenUsage{noop.Int64Histogram{}}, err
}
return ClientTokenUsage{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ClientTokenUsage) Inst() metric.Int64Histogram {
return m.Int64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ClientTokenUsage) Name() string {
return "gen_ai.client.token.usage"
}
// Unit returns the semantic convention unit of the instrument
func (ClientTokenUsage) Unit() string {
return "{token}"
}
// Description returns the semantic convention description of the instrument
func (ClientTokenUsage) Description() string {
return "Measures number of input and output tokens used"
}
// Record records val to the current distribution.
//
// The operationName is the the name of the operation being performed.
//
// The system is the the Generative AI product as identified by the client or
// server instrumentation.
//
// The tokenType is the the type of token being counted.
//
// All additional attrs passed are included in the recorded value.
func (m ClientTokenUsage) Record(
ctx context.Context,
val int64,
operationName OperationNameAttr,
system SystemAttr,
tokenType TokenTypeAttr,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
append(
attrs,
attribute.String("gen_ai.operation.name", string(operationName)),
attribute.String("gen_ai.system", string(system)),
attribute.String("gen_ai.token.type", string(tokenType)),
)...,
),
)
m.Int64Histogram.Record(ctx, val, *o...)
}
// AttrRequestModel returns an optional attribute for the "gen_ai.request.model"
// semantic convention. It represents the name of the GenAI model a request is
// being made to.
func (ClientTokenUsage) AttrRequestModel(val string) attribute.KeyValue {
return attribute.String("gen_ai.request.model", val)
}
// AttrServerPort returns an optional attribute for the "server.port" semantic
// convention. It represents the genAI server port.
func (ClientTokenUsage) AttrServerPort(val int) attribute.KeyValue {
return attribute.Int("server.port", val)
}
// AttrResponseModel returns an optional attribute for the
// "gen_ai.response.model" semantic convention. It represents the name of the
// model that generated the response.
func (ClientTokenUsage) AttrResponseModel(val string) attribute.KeyValue {
return attribute.String("gen_ai.response.model", val)
}
// AttrServerAddress returns an optional attribute for the "server.address"
// semantic convention. It represents the genAI server address.
func (ClientTokenUsage) AttrServerAddress(val string) attribute.KeyValue {
return attribute.String("server.address", val)
}
// ServerRequestDuration is an instrument used to record metric values conforming
// to the "gen_ai.server.request.duration" semantic conventions. It represents
// the generative AI server request duration such as time-to-last byte or last
// output token.
type ServerRequestDuration struct {
metric.Float64Histogram
}
// NewServerRequestDuration returns a new ServerRequestDuration instrument.
func NewServerRequestDuration(
m metric.Meter,
opt ...metric.Float64HistogramOption,
) (ServerRequestDuration, error) {
// Check if the meter is nil.
if m == nil {
return ServerRequestDuration{noop.Float64Histogram{}}, nil
}
i, err := m.Float64Histogram(
"gen_ai.server.request.duration",
append([]metric.Float64HistogramOption{
metric.WithDescription("Generative AI server request duration such as time-to-last byte or last output token"),
metric.WithUnit("s"),
}, opt...)...,
)
if err != nil {
return ServerRequestDuration{noop.Float64Histogram{}}, err
}
return ServerRequestDuration{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ServerRequestDuration) Inst() metric.Float64Histogram {
return m.Float64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ServerRequestDuration) Name() string {
return "gen_ai.server.request.duration"
}
// Unit returns the semantic convention unit of the instrument
func (ServerRequestDuration) Unit() string {
return "s"
}
// Description returns the semantic convention description of the instrument
func (ServerRequestDuration) Description() string {
return "Generative AI server request duration such as time-to-last byte or last output token"
}
// Record records val to the current distribution.
//
// The operationName is the the name of the operation being performed.
//
// The system is the the Generative AI product as identified by the client or
// server instrumentation.
//
// All additional attrs passed are included in the recorded value.
func (m ServerRequestDuration) Record(
ctx context.Context,
val float64,
operationName OperationNameAttr,
system SystemAttr,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
append(
attrs,
attribute.String("gen_ai.operation.name", string(operationName)),
attribute.String("gen_ai.system", string(system)),
)...,
),
)
m.Float64Histogram.Record(ctx, val, *o...)
}
// AttrErrorType returns an optional attribute for the "error.type" semantic
// convention. It represents the describes a class of error the operation ended
// with.
func (ServerRequestDuration) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
return attribute.String("error.type", string(val))
}
// AttrRequestModel returns an optional attribute for the "gen_ai.request.model"
// semantic convention. It represents the name of the GenAI model a request is
// being made to.
func (ServerRequestDuration) AttrRequestModel(val string) attribute.KeyValue {
return attribute.String("gen_ai.request.model", val)
}
// AttrServerPort returns an optional attribute for the "server.port" semantic
// convention. It represents the genAI server port.
func (ServerRequestDuration) AttrServerPort(val int) attribute.KeyValue {
return attribute.Int("server.port", val)
}
// AttrResponseModel returns an optional attribute for the
// "gen_ai.response.model" semantic convention. It represents the name of the
// model that generated the response.
func (ServerRequestDuration) AttrResponseModel(val string) attribute.KeyValue {
return attribute.String("gen_ai.response.model", val)
}
// AttrServerAddress returns an optional attribute for the "server.address"
// semantic convention. It represents the genAI server address.
func (ServerRequestDuration) AttrServerAddress(val string) attribute.KeyValue {
return attribute.String("server.address", val)
}
// ServerTimePerOutputToken is an instrument used to record metric values
// conforming to the "gen_ai.server.time_per_output_token" semantic conventions.
// It represents the time per output token generated after the first token for
// successful responses.
type ServerTimePerOutputToken struct {
metric.Float64Histogram
}
// NewServerTimePerOutputToken returns a new ServerTimePerOutputToken instrument.
func NewServerTimePerOutputToken(
m metric.Meter,
opt ...metric.Float64HistogramOption,
) (ServerTimePerOutputToken, error) {
// Check if the meter is nil.
if m == nil {
return ServerTimePerOutputToken{noop.Float64Histogram{}}, nil
}
i, err := m.Float64Histogram(
"gen_ai.server.time_per_output_token",
append([]metric.Float64HistogramOption{
metric.WithDescription("Time per output token generated after the first token for successful responses"),
metric.WithUnit("s"),
}, opt...)...,
)
if err != nil {
return ServerTimePerOutputToken{noop.Float64Histogram{}}, err
}
return ServerTimePerOutputToken{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ServerTimePerOutputToken) Inst() metric.Float64Histogram {
return m.Float64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ServerTimePerOutputToken) Name() string {
return "gen_ai.server.time_per_output_token"
}
// Unit returns the semantic convention unit of the instrument
func (ServerTimePerOutputToken) Unit() string {
return "s"
}
// Description returns the semantic convention description of the instrument
func (ServerTimePerOutputToken) Description() string {
return "Time per output token generated after the first token for successful responses"
}
// Record records val to the current distribution.
//
// The operationName is the the name of the operation being performed.
//
// The system is the the Generative AI product as identified by the client or
// server instrumentation.
//
// All additional attrs passed are included in the recorded value.
func (m ServerTimePerOutputToken) Record(
ctx context.Context,
val float64,
operationName OperationNameAttr,
system SystemAttr,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
append(
attrs,
attribute.String("gen_ai.operation.name", string(operationName)),
attribute.String("gen_ai.system", string(system)),
)...,
),
)
m.Float64Histogram.Record(ctx, val, *o...)
}
// AttrRequestModel returns an optional attribute for the "gen_ai.request.model"
// semantic convention. It represents the name of the GenAI model a request is
// being made to.
func (ServerTimePerOutputToken) AttrRequestModel(val string) attribute.KeyValue {
return attribute.String("gen_ai.request.model", val)
}
// AttrServerPort returns an optional attribute for the "server.port" semantic
// convention. It represents the genAI server port.
func (ServerTimePerOutputToken) AttrServerPort(val int) attribute.KeyValue {
return attribute.Int("server.port", val)
}
// AttrResponseModel returns an optional attribute for the
// "gen_ai.response.model" semantic convention. It represents the name of the
// model that generated the response.
func (ServerTimePerOutputToken) AttrResponseModel(val string) attribute.KeyValue {
return attribute.String("gen_ai.response.model", val)
}
// AttrServerAddress returns an optional attribute for the "server.address"
// semantic convention. It represents the genAI server address.
func (ServerTimePerOutputToken) AttrServerAddress(val string) attribute.KeyValue {
return attribute.String("server.address", val)
}
// ServerTimeToFirstToken is an instrument used to record metric values
// conforming to the "gen_ai.server.time_to_first_token" semantic conventions. It
// represents the time to generate first token for successful responses.
type ServerTimeToFirstToken struct {
metric.Float64Histogram
}
// NewServerTimeToFirstToken returns a new ServerTimeToFirstToken instrument.
func NewServerTimeToFirstToken(
m metric.Meter,
opt ...metric.Float64HistogramOption,
) (ServerTimeToFirstToken, error) {
// Check if the meter is nil.
if m == nil {
return ServerTimeToFirstToken{noop.Float64Histogram{}}, nil
}
i, err := m.Float64Histogram(
"gen_ai.server.time_to_first_token",
append([]metric.Float64HistogramOption{
metric.WithDescription("Time to generate first token for successful responses"),
metric.WithUnit("s"),
}, opt...)...,
)
if err != nil {
return ServerTimeToFirstToken{noop.Float64Histogram{}}, err
}
return ServerTimeToFirstToken{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ServerTimeToFirstToken) Inst() metric.Float64Histogram {
return m.Float64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ServerTimeToFirstToken) Name() string {
return "gen_ai.server.time_to_first_token"
}
// Unit returns the semantic convention unit of the instrument
func (ServerTimeToFirstToken) Unit() string {
return "s"
}
// Description returns the semantic convention description of the instrument
func (ServerTimeToFirstToken) Description() string {
return "Time to generate first token for successful responses"
}
// Record records val to the current distribution.
//
// The operationName is the the name of the operation being performed.
//
// The system is the the Generative AI product as identified by the client or
// server instrumentation.
//
// All additional attrs passed are included in the recorded value.
func (m ServerTimeToFirstToken) Record(
ctx context.Context,
val float64,
operationName OperationNameAttr,
system SystemAttr,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
append(
attrs,
attribute.String("gen_ai.operation.name", string(operationName)),
attribute.String("gen_ai.system", string(system)),
)...,
),
)
m.Float64Histogram.Record(ctx, val, *o...)
}
// AttrRequestModel returns an optional attribute for the "gen_ai.request.model"
// semantic convention. It represents the name of the GenAI model a request is
// being made to.
func (ServerTimeToFirstToken) AttrRequestModel(val string) attribute.KeyValue {
return attribute.String("gen_ai.request.model", val)
}
// AttrServerPort returns an optional attribute for the "server.port" semantic
// convention. It represents the genAI server port.
func (ServerTimeToFirstToken) AttrServerPort(val int) attribute.KeyValue {
return attribute.Int("server.port", val)
}
// AttrResponseModel returns an optional attribute for the
// "gen_ai.response.model" semantic convention. It represents the name of the
// model that generated the response.
func (ServerTimeToFirstToken) AttrResponseModel(val string) attribute.KeyValue {
return attribute.String("gen_ai.response.model", val)
}
// AttrServerAddress returns an optional attribute for the "server.address"
// semantic convention. It represents the genAI server address.
func (ServerTimeToFirstToken) AttrServerAddress(val string) attribute.KeyValue {
return attribute.String("server.address", val)
}

View File

@@ -0,0 +1,508 @@
// Code generated from semantic convention specification. DO NOT EDIT.
// Package httpconv provides types and functionality for OpenTelemetry semantic
// conventions in the "go" namespace.
package goconv
import (
"context"
"sync"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/noop"
)
var (
addOptPool = &sync.Pool{New: func() any { return &[]metric.AddOption{} }}
recOptPool = &sync.Pool{New: func() any { return &[]metric.RecordOption{} }}
)
// MemoryTypeAttr is an attribute conforming to the go.memory.type semantic
// conventions. It represents the type of memory.
type MemoryTypeAttr string
var (
// MemoryTypeStack is the memory allocated from the heap that is reserved for
// stack space, whether or not it is currently in-use.
MemoryTypeStack MemoryTypeAttr = "stack"
// MemoryTypeOther is the memory used by the Go runtime, excluding other
// categories of memory usage described in this enumeration.
MemoryTypeOther MemoryTypeAttr = "other"
)
// ConfigGogc is an instrument used to record metric values conforming to the
// "go.config.gogc" semantic conventions. It represents the heap size target
// percentage configured by the user, otherwise 100.
type ConfigGogc struct {
metric.Int64ObservableUpDownCounter
}
// NewConfigGogc returns a new ConfigGogc instrument.
func NewConfigGogc(
m metric.Meter,
opt ...metric.Int64ObservableUpDownCounterOption,
) (ConfigGogc, error) {
// Check if the meter is nil.
if m == nil {
return ConfigGogc{noop.Int64ObservableUpDownCounter{}}, nil
}
i, err := m.Int64ObservableUpDownCounter(
"go.config.gogc",
append([]metric.Int64ObservableUpDownCounterOption{
metric.WithDescription("Heap size target percentage configured by the user, otherwise 100."),
metric.WithUnit("%"),
}, opt...)...,
)
if err != nil {
return ConfigGogc{noop.Int64ObservableUpDownCounter{}}, err
}
return ConfigGogc{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ConfigGogc) Inst() metric.Int64ObservableUpDownCounter {
return m.Int64ObservableUpDownCounter
}
// Name returns the semantic convention name of the instrument.
func (ConfigGogc) Name() string {
return "go.config.gogc"
}
// Unit returns the semantic convention unit of the instrument
func (ConfigGogc) Unit() string {
return "%"
}
// Description returns the semantic convention description of the instrument
func (ConfigGogc) Description() string {
return "Heap size target percentage configured by the user, otherwise 100."
}
// GoroutineCount is an instrument used to record metric values conforming to the
// "go.goroutine.count" semantic conventions. It represents the count of live
// goroutines.
type GoroutineCount struct {
metric.Int64ObservableUpDownCounter
}
// NewGoroutineCount returns a new GoroutineCount instrument.
func NewGoroutineCount(
m metric.Meter,
opt ...metric.Int64ObservableUpDownCounterOption,
) (GoroutineCount, error) {
// Check if the meter is nil.
if m == nil {
return GoroutineCount{noop.Int64ObservableUpDownCounter{}}, nil
}
i, err := m.Int64ObservableUpDownCounter(
"go.goroutine.count",
append([]metric.Int64ObservableUpDownCounterOption{
metric.WithDescription("Count of live goroutines."),
metric.WithUnit("{goroutine}"),
}, opt...)...,
)
if err != nil {
return GoroutineCount{noop.Int64ObservableUpDownCounter{}}, err
}
return GoroutineCount{i}, nil
}
// Inst returns the underlying metric instrument.
func (m GoroutineCount) Inst() metric.Int64ObservableUpDownCounter {
return m.Int64ObservableUpDownCounter
}
// Name returns the semantic convention name of the instrument.
func (GoroutineCount) Name() string {
return "go.goroutine.count"
}
// Unit returns the semantic convention unit of the instrument
func (GoroutineCount) Unit() string {
return "{goroutine}"
}
// Description returns the semantic convention description of the instrument
func (GoroutineCount) Description() string {
return "Count of live goroutines."
}
// MemoryAllocated is an instrument used to record metric values conforming to
// the "go.memory.allocated" semantic conventions. It represents the memory
// allocated to the heap by the application.
type MemoryAllocated struct {
metric.Int64ObservableCounter
}
// NewMemoryAllocated returns a new MemoryAllocated instrument.
func NewMemoryAllocated(
m metric.Meter,
opt ...metric.Int64ObservableCounterOption,
) (MemoryAllocated, error) {
// Check if the meter is nil.
if m == nil {
return MemoryAllocated{noop.Int64ObservableCounter{}}, nil
}
i, err := m.Int64ObservableCounter(
"go.memory.allocated",
append([]metric.Int64ObservableCounterOption{
metric.WithDescription("Memory allocated to the heap by the application."),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return MemoryAllocated{noop.Int64ObservableCounter{}}, err
}
return MemoryAllocated{i}, nil
}
// Inst returns the underlying metric instrument.
func (m MemoryAllocated) Inst() metric.Int64ObservableCounter {
return m.Int64ObservableCounter
}
// Name returns the semantic convention name of the instrument.
func (MemoryAllocated) Name() string {
return "go.memory.allocated"
}
// Unit returns the semantic convention unit of the instrument
func (MemoryAllocated) Unit() string {
return "By"
}
// Description returns the semantic convention description of the instrument
func (MemoryAllocated) Description() string {
return "Memory allocated to the heap by the application."
}
// MemoryAllocations is an instrument used to record metric values conforming to
// the "go.memory.allocations" semantic conventions. It represents the count of
// allocations to the heap by the application.
type MemoryAllocations struct {
metric.Int64ObservableCounter
}
// NewMemoryAllocations returns a new MemoryAllocations instrument.
func NewMemoryAllocations(
m metric.Meter,
opt ...metric.Int64ObservableCounterOption,
) (MemoryAllocations, error) {
// Check if the meter is nil.
if m == nil {
return MemoryAllocations{noop.Int64ObservableCounter{}}, nil
}
i, err := m.Int64ObservableCounter(
"go.memory.allocations",
append([]metric.Int64ObservableCounterOption{
metric.WithDescription("Count of allocations to the heap by the application."),
metric.WithUnit("{allocation}"),
}, opt...)...,
)
if err != nil {
return MemoryAllocations{noop.Int64ObservableCounter{}}, err
}
return MemoryAllocations{i}, nil
}
// Inst returns the underlying metric instrument.
func (m MemoryAllocations) Inst() metric.Int64ObservableCounter {
return m.Int64ObservableCounter
}
// Name returns the semantic convention name of the instrument.
func (MemoryAllocations) Name() string {
return "go.memory.allocations"
}
// Unit returns the semantic convention unit of the instrument
func (MemoryAllocations) Unit() string {
return "{allocation}"
}
// Description returns the semantic convention description of the instrument
func (MemoryAllocations) Description() string {
return "Count of allocations to the heap by the application."
}
// MemoryGCGoal is an instrument used to record metric values conforming to the
// "go.memory.gc.goal" semantic conventions. It represents the heap size target
// for the end of the GC cycle.
type MemoryGCGoal struct {
metric.Int64ObservableUpDownCounter
}
// NewMemoryGCGoal returns a new MemoryGCGoal instrument.
func NewMemoryGCGoal(
m metric.Meter,
opt ...metric.Int64ObservableUpDownCounterOption,
) (MemoryGCGoal, error) {
// Check if the meter is nil.
if m == nil {
return MemoryGCGoal{noop.Int64ObservableUpDownCounter{}}, nil
}
i, err := m.Int64ObservableUpDownCounter(
"go.memory.gc.goal",
append([]metric.Int64ObservableUpDownCounterOption{
metric.WithDescription("Heap size target for the end of the GC cycle."),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return MemoryGCGoal{noop.Int64ObservableUpDownCounter{}}, err
}
return MemoryGCGoal{i}, nil
}
// Inst returns the underlying metric instrument.
func (m MemoryGCGoal) Inst() metric.Int64ObservableUpDownCounter {
return m.Int64ObservableUpDownCounter
}
// Name returns the semantic convention name of the instrument.
func (MemoryGCGoal) Name() string {
return "go.memory.gc.goal"
}
// Unit returns the semantic convention unit of the instrument
func (MemoryGCGoal) Unit() string {
return "By"
}
// Description returns the semantic convention description of the instrument
func (MemoryGCGoal) Description() string {
return "Heap size target for the end of the GC cycle."
}
// MemoryLimit is an instrument used to record metric values conforming to the
// "go.memory.limit" semantic conventions. It represents the go runtime memory
// limit configured by the user, if a limit exists.
type MemoryLimit struct {
metric.Int64ObservableUpDownCounter
}
// NewMemoryLimit returns a new MemoryLimit instrument.
func NewMemoryLimit(
m metric.Meter,
opt ...metric.Int64ObservableUpDownCounterOption,
) (MemoryLimit, error) {
// Check if the meter is nil.
if m == nil {
return MemoryLimit{noop.Int64ObservableUpDownCounter{}}, nil
}
i, err := m.Int64ObservableUpDownCounter(
"go.memory.limit",
append([]metric.Int64ObservableUpDownCounterOption{
metric.WithDescription("Go runtime memory limit configured by the user, if a limit exists."),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return MemoryLimit{noop.Int64ObservableUpDownCounter{}}, err
}
return MemoryLimit{i}, nil
}
// Inst returns the underlying metric instrument.
func (m MemoryLimit) Inst() metric.Int64ObservableUpDownCounter {
return m.Int64ObservableUpDownCounter
}
// Name returns the semantic convention name of the instrument.
func (MemoryLimit) Name() string {
return "go.memory.limit"
}
// Unit returns the semantic convention unit of the instrument
func (MemoryLimit) Unit() string {
return "By"
}
// Description returns the semantic convention description of the instrument
func (MemoryLimit) Description() string {
return "Go runtime memory limit configured by the user, if a limit exists."
}
// MemoryUsed is an instrument used to record metric values conforming to the
// "go.memory.used" semantic conventions. It represents the memory used by the Go
// runtime.
type MemoryUsed struct {
metric.Int64ObservableCounter
}
// NewMemoryUsed returns a new MemoryUsed instrument.
func NewMemoryUsed(
m metric.Meter,
opt ...metric.Int64ObservableCounterOption,
) (MemoryUsed, error) {
// Check if the meter is nil.
if m == nil {
return MemoryUsed{noop.Int64ObservableCounter{}}, nil
}
i, err := m.Int64ObservableCounter(
"go.memory.used",
append([]metric.Int64ObservableCounterOption{
metric.WithDescription("Memory used by the Go runtime."),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return MemoryUsed{noop.Int64ObservableCounter{}}, err
}
return MemoryUsed{i}, nil
}
// Inst returns the underlying metric instrument.
func (m MemoryUsed) Inst() metric.Int64ObservableCounter {
return m.Int64ObservableCounter
}
// Name returns the semantic convention name of the instrument.
func (MemoryUsed) Name() string {
return "go.memory.used"
}
// Unit returns the semantic convention unit of the instrument
func (MemoryUsed) Unit() string {
return "By"
}
// Description returns the semantic convention description of the instrument
func (MemoryUsed) Description() string {
return "Memory used by the Go runtime."
}
// AttrMemoryType returns an optional attribute for the "go.memory.type" semantic
// convention. It represents the type of memory.
func (MemoryUsed) AttrMemoryType(val MemoryTypeAttr) attribute.KeyValue {
return attribute.String("go.memory.type", string(val))
}
// ProcessorLimit is an instrument used to record metric values conforming to the
// "go.processor.limit" semantic conventions. It represents the number of OS
// threads that can execute user-level Go code simultaneously.
type ProcessorLimit struct {
metric.Int64ObservableUpDownCounter
}
// NewProcessorLimit returns a new ProcessorLimit instrument.
func NewProcessorLimit(
m metric.Meter,
opt ...metric.Int64ObservableUpDownCounterOption,
) (ProcessorLimit, error) {
// Check if the meter is nil.
if m == nil {
return ProcessorLimit{noop.Int64ObservableUpDownCounter{}}, nil
}
i, err := m.Int64ObservableUpDownCounter(
"go.processor.limit",
append([]metric.Int64ObservableUpDownCounterOption{
metric.WithDescription("The number of OS threads that can execute user-level Go code simultaneously."),
metric.WithUnit("{thread}"),
}, opt...)...,
)
if err != nil {
return ProcessorLimit{noop.Int64ObservableUpDownCounter{}}, err
}
return ProcessorLimit{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ProcessorLimit) Inst() metric.Int64ObservableUpDownCounter {
return m.Int64ObservableUpDownCounter
}
// Name returns the semantic convention name of the instrument.
func (ProcessorLimit) Name() string {
return "go.processor.limit"
}
// Unit returns the semantic convention unit of the instrument
func (ProcessorLimit) Unit() string {
return "{thread}"
}
// Description returns the semantic convention description of the instrument
func (ProcessorLimit) Description() string {
return "The number of OS threads that can execute user-level Go code simultaneously."
}
// ScheduleDuration is an instrument used to record metric values conforming to
// the "go.schedule.duration" semantic conventions. It represents the time
// goroutines have spent in the scheduler in a runnable state before actually
// running.
type ScheduleDuration struct {
metric.Float64Histogram
}
// NewScheduleDuration returns a new ScheduleDuration instrument.
func NewScheduleDuration(
m metric.Meter,
opt ...metric.Float64HistogramOption,
) (ScheduleDuration, error) {
// Check if the meter is nil.
if m == nil {
return ScheduleDuration{noop.Float64Histogram{}}, nil
}
i, err := m.Float64Histogram(
"go.schedule.duration",
append([]metric.Float64HistogramOption{
metric.WithDescription("The time goroutines have spent in the scheduler in a runnable state before actually running."),
metric.WithUnit("s"),
}, opt...)...,
)
if err != nil {
return ScheduleDuration{noop.Float64Histogram{}}, err
}
return ScheduleDuration{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ScheduleDuration) Inst() metric.Float64Histogram {
return m.Float64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ScheduleDuration) Name() string {
return "go.schedule.duration"
}
// Unit returns the semantic convention unit of the instrument
func (ScheduleDuration) Unit() string {
return "s"
}
// Description returns the semantic convention description of the instrument
func (ScheduleDuration) Description() string {
return "The time goroutines have spent in the scheduler in a runnable state before actually running."
}
// Record records val to the current distribution.
//
// Computed from `/sched/latencies:seconds`. Bucket boundaries are provided by
// the runtime, and are subject to change.
func (m ScheduleDuration) Record(ctx context.Context, val float64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Float64Histogram.Record(ctx, val)
}
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Float64Histogram.Record(ctx, val, *o...)
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,876 @@
// Code generated from semantic convention specification. DO NOT EDIT.
// Package httpconv provides types and functionality for OpenTelemetry semantic
// conventions in the "hw" namespace.
package hwconv
import (
"context"
"sync"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/noop"
)
var (
addOptPool = &sync.Pool{New: func() any { return &[]metric.AddOption{} }}
recOptPool = &sync.Pool{New: func() any { return &[]metric.RecordOption{} }}
)
// ErrorTypeAttr is an attribute conforming to the error.type semantic
// conventions. It represents the type of error encountered by the component.
type ErrorTypeAttr string
var (
// ErrorTypeOther is a fallback error value to be used when the instrumentation
// doesn't define a custom value.
ErrorTypeOther ErrorTypeAttr = "_OTHER"
)
// StateAttr is an attribute conforming to the hw.state semantic conventions. It
// represents the current state of the component.
type StateAttr string
var (
// StateOk is the ok.
StateOk StateAttr = "ok"
// StateDegraded is the degraded.
StateDegraded StateAttr = "degraded"
// StateFailed is the failed.
StateFailed StateAttr = "failed"
)
// TypeAttr is an attribute conforming to the hw.type semantic conventions. It
// represents the type of the component.
type TypeAttr string
var (
// TypeBattery is the battery.
TypeBattery TypeAttr = "battery"
// TypeCPU is the CPU.
TypeCPU TypeAttr = "cpu"
// TypeDiskController is the disk controller.
TypeDiskController TypeAttr = "disk_controller"
// TypeEnclosure is the enclosure.
TypeEnclosure TypeAttr = "enclosure"
// TypeFan is the fan.
TypeFan TypeAttr = "fan"
// TypeGpu is the GPU.
TypeGpu TypeAttr = "gpu"
// TypeLogicalDisk is the logical disk.
TypeLogicalDisk TypeAttr = "logical_disk"
// TypeMemory is the memory.
TypeMemory TypeAttr = "memory"
// TypeNetwork is the network.
TypeNetwork TypeAttr = "network"
// TypePhysicalDisk is the physical disk.
TypePhysicalDisk TypeAttr = "physical_disk"
// TypePowerSupply is the power supply.
TypePowerSupply TypeAttr = "power_supply"
// TypeTapeDrive is the tape drive.
TypeTapeDrive TypeAttr = "tape_drive"
// TypeTemperature is the temperature.
TypeTemperature TypeAttr = "temperature"
// TypeVoltage is the voltage.
TypeVoltage TypeAttr = "voltage"
)
// Energy is an instrument used to record metric values conforming to the
// "hw.energy" semantic conventions. It represents the energy consumed by the
// component.
type Energy struct {
metric.Int64Counter
}
// NewEnergy returns a new Energy instrument.
func NewEnergy(
m metric.Meter,
opt ...metric.Int64CounterOption,
) (Energy, error) {
// Check if the meter is nil.
if m == nil {
return Energy{noop.Int64Counter{}}, nil
}
i, err := m.Int64Counter(
"hw.energy",
append([]metric.Int64CounterOption{
metric.WithDescription("Energy consumed by the component"),
metric.WithUnit("J"),
}, opt...)...,
)
if err != nil {
return Energy{noop.Int64Counter{}}, err
}
return Energy{i}, nil
}
// Inst returns the underlying metric instrument.
func (m Energy) Inst() metric.Int64Counter {
return m.Int64Counter
}
// Name returns the semantic convention name of the instrument.
func (Energy) Name() string {
return "hw.energy"
}
// Unit returns the semantic convention unit of the instrument
func (Energy) Unit() string {
return "J"
}
// Description returns the semantic convention description of the instrument
func (Energy) Description() string {
return "Energy consumed by the component"
}
// Add adds incr to the existing count.
//
// The id is the an identifier for the hardware component, unique within the
// monitored host
//
// The hwType is the type of the component
//
// All additional attrs passed are included in the recorded value.
func (m Energy) Add(
ctx context.Context,
incr int64,
id string,
hwType TypeAttr,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
append(
attrs,
attribute.String("hw.id", id),
attribute.String("hw.type", string(hwType)),
)...,
),
)
m.Int64Counter.Add(ctx, incr, *o...)
}
// AttrName returns an optional attribute for the "hw.name" semantic convention.
// It represents an easily-recognizable name for the hardware component.
func (Energy) AttrName(val string) attribute.KeyValue {
return attribute.String("hw.name", val)
}
// AttrParent returns an optional attribute for the "hw.parent" semantic
// convention. It represents the unique identifier of the parent component
// (typically the `hw.id` attribute of the enclosure, or disk controller).
func (Energy) AttrParent(val string) attribute.KeyValue {
return attribute.String("hw.parent", val)
}
// Errors is an instrument used to record metric values conforming to the
// "hw.errors" semantic conventions. It represents the number of errors
// encountered by the component.
type Errors struct {
metric.Int64Counter
}
// NewErrors returns a new Errors instrument.
func NewErrors(
m metric.Meter,
opt ...metric.Int64CounterOption,
) (Errors, error) {
// Check if the meter is nil.
if m == nil {
return Errors{noop.Int64Counter{}}, nil
}
i, err := m.Int64Counter(
"hw.errors",
append([]metric.Int64CounterOption{
metric.WithDescription("Number of errors encountered by the component"),
metric.WithUnit("{error}"),
}, opt...)...,
)
if err != nil {
return Errors{noop.Int64Counter{}}, err
}
return Errors{i}, nil
}
// Inst returns the underlying metric instrument.
func (m Errors) Inst() metric.Int64Counter {
return m.Int64Counter
}
// Name returns the semantic convention name of the instrument.
func (Errors) Name() string {
return "hw.errors"
}
// Unit returns the semantic convention unit of the instrument
func (Errors) Unit() string {
return "{error}"
}
// Description returns the semantic convention description of the instrument
func (Errors) Description() string {
return "Number of errors encountered by the component"
}
// Add adds incr to the existing count.
//
// The id is the an identifier for the hardware component, unique within the
// monitored host
//
// The hwType is the type of the component
//
// All additional attrs passed are included in the recorded value.
func (m Errors) Add(
ctx context.Context,
incr int64,
id string,
hwType TypeAttr,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
append(
attrs,
attribute.String("hw.id", id),
attribute.String("hw.type", string(hwType)),
)...,
),
)
m.Int64Counter.Add(ctx, incr, *o...)
}
// AttrErrorType returns an optional attribute for the "error.type" semantic
// convention. It represents the type of error encountered by the component.
func (Errors) AttrErrorType(val ErrorTypeAttr) attribute.KeyValue {
return attribute.String("error.type", string(val))
}
// AttrName returns an optional attribute for the "hw.name" semantic convention.
// It represents an easily-recognizable name for the hardware component.
func (Errors) AttrName(val string) attribute.KeyValue {
return attribute.String("hw.name", val)
}
// AttrParent returns an optional attribute for the "hw.parent" semantic
// convention. It represents the unique identifier of the parent component
// (typically the `hw.id` attribute of the enclosure, or disk controller).
func (Errors) AttrParent(val string) attribute.KeyValue {
return attribute.String("hw.parent", val)
}
// HostAmbientTemperature is an instrument used to record metric values
// conforming to the "hw.host.ambient_temperature" semantic conventions. It
// represents the ambient (external) temperature of the physical host.
type HostAmbientTemperature struct {
metric.Int64Gauge
}
// NewHostAmbientTemperature returns a new HostAmbientTemperature instrument.
func NewHostAmbientTemperature(
m metric.Meter,
opt ...metric.Int64GaugeOption,
) (HostAmbientTemperature, error) {
// Check if the meter is nil.
if m == nil {
return HostAmbientTemperature{noop.Int64Gauge{}}, nil
}
i, err := m.Int64Gauge(
"hw.host.ambient_temperature",
append([]metric.Int64GaugeOption{
metric.WithDescription("Ambient (external) temperature of the physical host"),
metric.WithUnit("Cel"),
}, opt...)...,
)
if err != nil {
return HostAmbientTemperature{noop.Int64Gauge{}}, err
}
return HostAmbientTemperature{i}, nil
}
// Inst returns the underlying metric instrument.
func (m HostAmbientTemperature) Inst() metric.Int64Gauge {
return m.Int64Gauge
}
// Name returns the semantic convention name of the instrument.
func (HostAmbientTemperature) Name() string {
return "hw.host.ambient_temperature"
}
// Unit returns the semantic convention unit of the instrument
func (HostAmbientTemperature) Unit() string {
return "Cel"
}
// Description returns the semantic convention description of the instrument
func (HostAmbientTemperature) Description() string {
return "Ambient (external) temperature of the physical host"
}
// Record records val to the current distribution.
//
// The id is the an identifier for the hardware component, unique within the
// monitored host
//
// All additional attrs passed are included in the recorded value.
func (m HostAmbientTemperature) Record(
ctx context.Context,
val int64,
id string,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
append(
attrs,
attribute.String("hw.id", id),
)...,
),
)
m.Int64Gauge.Record(ctx, val, *o...)
}
// AttrName returns an optional attribute for the "hw.name" semantic convention.
// It represents an easily-recognizable name for the hardware component.
func (HostAmbientTemperature) AttrName(val string) attribute.KeyValue {
return attribute.String("hw.name", val)
}
// AttrParent returns an optional attribute for the "hw.parent" semantic
// convention. It represents the unique identifier of the parent component
// (typically the `hw.id` attribute of the enclosure, or disk controller).
func (HostAmbientTemperature) AttrParent(val string) attribute.KeyValue {
return attribute.String("hw.parent", val)
}
// HostEnergy is an instrument used to record metric values conforming to the
// "hw.host.energy" semantic conventions. It represents the total energy consumed
// by the entire physical host, in joules.
type HostEnergy struct {
metric.Int64Counter
}
// NewHostEnergy returns a new HostEnergy instrument.
func NewHostEnergy(
m metric.Meter,
opt ...metric.Int64CounterOption,
) (HostEnergy, error) {
// Check if the meter is nil.
if m == nil {
return HostEnergy{noop.Int64Counter{}}, nil
}
i, err := m.Int64Counter(
"hw.host.energy",
append([]metric.Int64CounterOption{
metric.WithDescription("Total energy consumed by the entire physical host, in joules"),
metric.WithUnit("J"),
}, opt...)...,
)
if err != nil {
return HostEnergy{noop.Int64Counter{}}, err
}
return HostEnergy{i}, nil
}
// Inst returns the underlying metric instrument.
func (m HostEnergy) Inst() metric.Int64Counter {
return m.Int64Counter
}
// Name returns the semantic convention name of the instrument.
func (HostEnergy) Name() string {
return "hw.host.energy"
}
// Unit returns the semantic convention unit of the instrument
func (HostEnergy) Unit() string {
return "J"
}
// Description returns the semantic convention description of the instrument
func (HostEnergy) Description() string {
return "Total energy consumed by the entire physical host, in joules"
}
// Add adds incr to the existing count.
//
// The id is the an identifier for the hardware component, unique within the
// monitored host
//
// All additional attrs passed are included in the recorded value.
//
// The overall energy usage of a host MUST be reported using the specific
// `hw.host.energy` and `hw.host.power` metrics **only**, instead of the generic
// `hw.energy` and `hw.power` described in the previous section, to prevent
// summing up overlapping values.
func (m HostEnergy) Add(
ctx context.Context,
incr int64,
id string,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
append(
attrs,
attribute.String("hw.id", id),
)...,
),
)
m.Int64Counter.Add(ctx, incr, *o...)
}
// AttrName returns an optional attribute for the "hw.name" semantic convention.
// It represents an easily-recognizable name for the hardware component.
func (HostEnergy) AttrName(val string) attribute.KeyValue {
return attribute.String("hw.name", val)
}
// AttrParent returns an optional attribute for the "hw.parent" semantic
// convention. It represents the unique identifier of the parent component
// (typically the `hw.id` attribute of the enclosure, or disk controller).
func (HostEnergy) AttrParent(val string) attribute.KeyValue {
return attribute.String("hw.parent", val)
}
// HostHeatingMargin is an instrument used to record metric values conforming to
// the "hw.host.heating_margin" semantic conventions. It represents the by how
// many degrees Celsius the temperature of the physical host can be increased,
// before reaching a warning threshold on one of the internal sensors.
type HostHeatingMargin struct {
metric.Int64Gauge
}
// NewHostHeatingMargin returns a new HostHeatingMargin instrument.
func NewHostHeatingMargin(
m metric.Meter,
opt ...metric.Int64GaugeOption,
) (HostHeatingMargin, error) {
// Check if the meter is nil.
if m == nil {
return HostHeatingMargin{noop.Int64Gauge{}}, nil
}
i, err := m.Int64Gauge(
"hw.host.heating_margin",
append([]metric.Int64GaugeOption{
metric.WithDescription("By how many degrees Celsius the temperature of the physical host can be increased, before reaching a warning threshold on one of the internal sensors"),
metric.WithUnit("Cel"),
}, opt...)...,
)
if err != nil {
return HostHeatingMargin{noop.Int64Gauge{}}, err
}
return HostHeatingMargin{i}, nil
}
// Inst returns the underlying metric instrument.
func (m HostHeatingMargin) Inst() metric.Int64Gauge {
return m.Int64Gauge
}
// Name returns the semantic convention name of the instrument.
func (HostHeatingMargin) Name() string {
return "hw.host.heating_margin"
}
// Unit returns the semantic convention unit of the instrument
func (HostHeatingMargin) Unit() string {
return "Cel"
}
// Description returns the semantic convention description of the instrument
func (HostHeatingMargin) Description() string {
return "By how many degrees Celsius the temperature of the physical host can be increased, before reaching a warning threshold on one of the internal sensors"
}
// Record records val to the current distribution.
//
// The id is the an identifier for the hardware component, unique within the
// monitored host
//
// All additional attrs passed are included in the recorded value.
func (m HostHeatingMargin) Record(
ctx context.Context,
val int64,
id string,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
append(
attrs,
attribute.String("hw.id", id),
)...,
),
)
m.Int64Gauge.Record(ctx, val, *o...)
}
// AttrName returns an optional attribute for the "hw.name" semantic convention.
// It represents an easily-recognizable name for the hardware component.
func (HostHeatingMargin) AttrName(val string) attribute.KeyValue {
return attribute.String("hw.name", val)
}
// AttrParent returns an optional attribute for the "hw.parent" semantic
// convention. It represents the unique identifier of the parent component
// (typically the `hw.id` attribute of the enclosure, or disk controller).
func (HostHeatingMargin) AttrParent(val string) attribute.KeyValue {
return attribute.String("hw.parent", val)
}
// HostPower is an instrument used to record metric values conforming to the
// "hw.host.power" semantic conventions. It represents the instantaneous power
// consumed by the entire physical host in Watts (`hw.host.energy` is preferred).
type HostPower struct {
metric.Int64Gauge
}
// NewHostPower returns a new HostPower instrument.
func NewHostPower(
m metric.Meter,
opt ...metric.Int64GaugeOption,
) (HostPower, error) {
// Check if the meter is nil.
if m == nil {
return HostPower{noop.Int64Gauge{}}, nil
}
i, err := m.Int64Gauge(
"hw.host.power",
append([]metric.Int64GaugeOption{
metric.WithDescription("Instantaneous power consumed by the entire physical host in Watts (`hw.host.energy` is preferred)"),
metric.WithUnit("W"),
}, opt...)...,
)
if err != nil {
return HostPower{noop.Int64Gauge{}}, err
}
return HostPower{i}, nil
}
// Inst returns the underlying metric instrument.
func (m HostPower) Inst() metric.Int64Gauge {
return m.Int64Gauge
}
// Name returns the semantic convention name of the instrument.
func (HostPower) Name() string {
return "hw.host.power"
}
// Unit returns the semantic convention unit of the instrument
func (HostPower) Unit() string {
return "W"
}
// Description returns the semantic convention description of the instrument
func (HostPower) Description() string {
return "Instantaneous power consumed by the entire physical host in Watts (`hw.host.energy` is preferred)"
}
// Record records val to the current distribution.
//
// The id is the an identifier for the hardware component, unique within the
// monitored host
//
// All additional attrs passed are included in the recorded value.
//
// The overall energy usage of a host MUST be reported using the specific
// `hw.host.energy` and `hw.host.power` metrics **only**, instead of the generic
// `hw.energy` and `hw.power` described in the previous section, to prevent
// summing up overlapping values.
func (m HostPower) Record(
ctx context.Context,
val int64,
id string,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
append(
attrs,
attribute.String("hw.id", id),
)...,
),
)
m.Int64Gauge.Record(ctx, val, *o...)
}
// AttrName returns an optional attribute for the "hw.name" semantic convention.
// It represents an easily-recognizable name for the hardware component.
func (HostPower) AttrName(val string) attribute.KeyValue {
return attribute.String("hw.name", val)
}
// AttrParent returns an optional attribute for the "hw.parent" semantic
// convention. It represents the unique identifier of the parent component
// (typically the `hw.id` attribute of the enclosure, or disk controller).
func (HostPower) AttrParent(val string) attribute.KeyValue {
return attribute.String("hw.parent", val)
}
// Power is an instrument used to record metric values conforming to the
// "hw.power" semantic conventions. It represents the instantaneous power
// consumed by the component.
type Power struct {
metric.Int64Gauge
}
// NewPower returns a new Power instrument.
func NewPower(
m metric.Meter,
opt ...metric.Int64GaugeOption,
) (Power, error) {
// Check if the meter is nil.
if m == nil {
return Power{noop.Int64Gauge{}}, nil
}
i, err := m.Int64Gauge(
"hw.power",
append([]metric.Int64GaugeOption{
metric.WithDescription("Instantaneous power consumed by the component"),
metric.WithUnit("W"),
}, opt...)...,
)
if err != nil {
return Power{noop.Int64Gauge{}}, err
}
return Power{i}, nil
}
// Inst returns the underlying metric instrument.
func (m Power) Inst() metric.Int64Gauge {
return m.Int64Gauge
}
// Name returns the semantic convention name of the instrument.
func (Power) Name() string {
return "hw.power"
}
// Unit returns the semantic convention unit of the instrument
func (Power) Unit() string {
return "W"
}
// Description returns the semantic convention description of the instrument
func (Power) Description() string {
return "Instantaneous power consumed by the component"
}
// Record records val to the current distribution.
//
// The id is the an identifier for the hardware component, unique within the
// monitored host
//
// The hwType is the type of the component
//
// All additional attrs passed are included in the recorded value.
//
// It is recommended to report `hw.energy` instead of `hw.power` when possible.
func (m Power) Record(
ctx context.Context,
val int64,
id string,
hwType TypeAttr,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
append(
attrs,
attribute.String("hw.id", id),
attribute.String("hw.type", string(hwType)),
)...,
),
)
m.Int64Gauge.Record(ctx, val, *o...)
}
// AttrName returns an optional attribute for the "hw.name" semantic convention.
// It represents an easily-recognizable name for the hardware component.
func (Power) AttrName(val string) attribute.KeyValue {
return attribute.String("hw.name", val)
}
// AttrParent returns an optional attribute for the "hw.parent" semantic
// convention. It represents the unique identifier of the parent component
// (typically the `hw.id` attribute of the enclosure, or disk controller).
func (Power) AttrParent(val string) attribute.KeyValue {
return attribute.String("hw.parent", val)
}
// Status is an instrument used to record metric values conforming to the
// "hw.status" semantic conventions. It represents the operational status: `1`
// (true) or `0` (false) for each of the possible states.
type Status struct {
metric.Int64UpDownCounter
}
// NewStatus returns a new Status instrument.
func NewStatus(
m metric.Meter,
opt ...metric.Int64UpDownCounterOption,
) (Status, error) {
// Check if the meter is nil.
if m == nil {
return Status{noop.Int64UpDownCounter{}}, nil
}
i, err := m.Int64UpDownCounter(
"hw.status",
append([]metric.Int64UpDownCounterOption{
metric.WithDescription("Operational status: `1` (true) or `0` (false) for each of the possible states"),
metric.WithUnit("1"),
}, opt...)...,
)
if err != nil {
return Status{noop.Int64UpDownCounter{}}, err
}
return Status{i}, nil
}
// Inst returns the underlying metric instrument.
func (m Status) Inst() metric.Int64UpDownCounter {
return m.Int64UpDownCounter
}
// Name returns the semantic convention name of the instrument.
func (Status) Name() string {
return "hw.status"
}
// Unit returns the semantic convention unit of the instrument
func (Status) Unit() string {
return "1"
}
// Description returns the semantic convention description of the instrument
func (Status) Description() string {
return "Operational status: `1` (true) or `0` (false) for each of the possible states"
}
// Add adds incr to the existing count.
//
// The id is the an identifier for the hardware component, unique within the
// monitored host
//
// The state is the the current state of the component
//
// The hwType is the type of the component
//
// All additional attrs passed are included in the recorded value.
//
// `hw.status` is currently specified as an *UpDownCounter* but would ideally be
// represented using a [*StateSet* as defined in OpenMetrics]. This semantic
// convention will be updated once *StateSet* is specified in OpenTelemetry. This
// planned change is not expected to have any consequence on the way users query
// their timeseries backend to retrieve the values of `hw.status` over time.
//
// [ [*StateSet* as defined in OpenMetrics]: https://github.com/prometheus/OpenMetrics/blob/v1.0.0/specification/OpenMetrics.md#stateset
func (m Status) Add(
ctx context.Context,
incr int64,
id string,
state StateAttr,
hwType TypeAttr,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
append(
attrs,
attribute.String("hw.id", id),
attribute.String("hw.state", string(state)),
attribute.String("hw.type", string(hwType)),
)...,
),
)
m.Int64UpDownCounter.Add(ctx, incr, *o...)
}
// AttrName returns an optional attribute for the "hw.name" semantic convention.
// It represents an easily-recognizable name for the hardware component.
func (Status) AttrName(val string) attribute.KeyValue {
return attribute.String("hw.name", val)
}
// AttrParent returns an optional attribute for the "hw.parent" semantic
// convention. It represents the unique identifier of the parent component
// (typically the `hw.id` attribute of the enclosure, or disk controller).
func (Status) AttrParent(val string) attribute.KeyValue {
return attribute.String("hw.parent", val)
}

File diff suppressed because it is too large Load Diff

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,893 @@
// Code generated from semantic convention specification. DO NOT EDIT.
// Package httpconv provides types and functionality for OpenTelemetry semantic
// conventions in the "process" namespace.
package processconv
import (
"context"
"sync"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/noop"
)
var (
addOptPool = &sync.Pool{New: func() any { return &[]metric.AddOption{} }}
recOptPool = &sync.Pool{New: func() any { return &[]metric.RecordOption{} }}
)
// CPUModeAttr is an attribute conforming to the cpu.mode semantic conventions.
// It represents a process SHOULD be characterized *either* by data points with
// no `mode` labels, *or only* data points with `mode` labels.
type CPUModeAttr string
var (
// CPUModeUser is the none.
CPUModeUser CPUModeAttr = "user"
// CPUModeSystem is the none.
CPUModeSystem CPUModeAttr = "system"
// CPUModeNice is the none.
CPUModeNice CPUModeAttr = "nice"
// CPUModeIdle is the none.
CPUModeIdle CPUModeAttr = "idle"
// CPUModeIOWait is the none.
CPUModeIOWait CPUModeAttr = "iowait"
// CPUModeInterrupt is the none.
CPUModeInterrupt CPUModeAttr = "interrupt"
// CPUModeSteal is the none.
CPUModeSteal CPUModeAttr = "steal"
// CPUModeKernel is the none.
CPUModeKernel CPUModeAttr = "kernel"
)
// DiskIODirectionAttr is an attribute conforming to the disk.io.direction
// semantic conventions. It represents the disk IO operation direction.
type DiskIODirectionAttr string
var (
// DiskIODirectionRead is the none.
DiskIODirectionRead DiskIODirectionAttr = "read"
// DiskIODirectionWrite is the none.
DiskIODirectionWrite DiskIODirectionAttr = "write"
)
// NetworkIODirectionAttr is an attribute conforming to the network.io.direction
// semantic conventions. It represents the network IO operation direction.
type NetworkIODirectionAttr string
var (
// NetworkIODirectionTransmit is the none.
NetworkIODirectionTransmit NetworkIODirectionAttr = "transmit"
// NetworkIODirectionReceive is the none.
NetworkIODirectionReceive NetworkIODirectionAttr = "receive"
)
// ContextSwitchTypeAttr is an attribute conforming to the
// process.context_switch_type semantic conventions. It represents the specifies
// whether the context switches for this data point were voluntary or
// involuntary.
type ContextSwitchTypeAttr string
var (
// ContextSwitchTypeVoluntary is the none.
ContextSwitchTypeVoluntary ContextSwitchTypeAttr = "voluntary"
// ContextSwitchTypeInvoluntary is the none.
ContextSwitchTypeInvoluntary ContextSwitchTypeAttr = "involuntary"
)
// PagingFaultTypeAttr is an attribute conforming to the
// process.paging.fault_type semantic conventions. It represents the type of page
// fault for this data point. Type `major` is for major/hard page faults, and
// `minor` is for minor/soft page faults.
type PagingFaultTypeAttr string
var (
// PagingFaultTypeMajor is the none.
PagingFaultTypeMajor PagingFaultTypeAttr = "major"
// PagingFaultTypeMinor is the none.
PagingFaultTypeMinor PagingFaultTypeAttr = "minor"
)
// ContextSwitches is an instrument used to record metric values conforming to
// the "process.context_switches" semantic conventions. It represents the number
// of times the process has been context switched.
type ContextSwitches struct {
metric.Int64Counter
}
// NewContextSwitches returns a new ContextSwitches instrument.
func NewContextSwitches(
m metric.Meter,
opt ...metric.Int64CounterOption,
) (ContextSwitches, error) {
// Check if the meter is nil.
if m == nil {
return ContextSwitches{noop.Int64Counter{}}, nil
}
i, err := m.Int64Counter(
"process.context_switches",
append([]metric.Int64CounterOption{
metric.WithDescription("Number of times the process has been context switched."),
metric.WithUnit("{context_switch}"),
}, opt...)...,
)
if err != nil {
return ContextSwitches{noop.Int64Counter{}}, err
}
return ContextSwitches{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ContextSwitches) Inst() metric.Int64Counter {
return m.Int64Counter
}
// Name returns the semantic convention name of the instrument.
func (ContextSwitches) Name() string {
return "process.context_switches"
}
// Unit returns the semantic convention unit of the instrument
func (ContextSwitches) Unit() string {
return "{context_switch}"
}
// Description returns the semantic convention description of the instrument
func (ContextSwitches) Description() string {
return "Number of times the process has been context switched."
}
// Add adds incr to the existing count.
//
// All additional attrs passed are included in the recorded value.
func (m ContextSwitches) Add(
ctx context.Context,
incr int64,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Int64Counter.Add(ctx, incr, *o...)
}
// AttrContextSwitchType returns an optional attribute for the
// "process.context_switch_type" semantic convention. It represents the specifies
// whether the context switches for this data point were voluntary or
// involuntary.
func (ContextSwitches) AttrContextSwitchType(val ContextSwitchTypeAttr) attribute.KeyValue {
return attribute.String("process.context_switch_type", string(val))
}
// CPUTime is an instrument used to record metric values conforming to the
// "process.cpu.time" semantic conventions. It represents the total CPU seconds
// broken down by different states.
type CPUTime struct {
metric.Float64ObservableCounter
}
// NewCPUTime returns a new CPUTime instrument.
func NewCPUTime(
m metric.Meter,
opt ...metric.Float64ObservableCounterOption,
) (CPUTime, error) {
// Check if the meter is nil.
if m == nil {
return CPUTime{noop.Float64ObservableCounter{}}, nil
}
i, err := m.Float64ObservableCounter(
"process.cpu.time",
append([]metric.Float64ObservableCounterOption{
metric.WithDescription("Total CPU seconds broken down by different states."),
metric.WithUnit("s"),
}, opt...)...,
)
if err != nil {
return CPUTime{noop.Float64ObservableCounter{}}, err
}
return CPUTime{i}, nil
}
// Inst returns the underlying metric instrument.
func (m CPUTime) Inst() metric.Float64ObservableCounter {
return m.Float64ObservableCounter
}
// Name returns the semantic convention name of the instrument.
func (CPUTime) Name() string {
return "process.cpu.time"
}
// Unit returns the semantic convention unit of the instrument
func (CPUTime) Unit() string {
return "s"
}
// Description returns the semantic convention description of the instrument
func (CPUTime) Description() string {
return "Total CPU seconds broken down by different states."
}
// AttrCPUMode returns an optional attribute for the "cpu.mode" semantic
// convention. It represents a process SHOULD be characterized *either* by data
// points with no `mode` labels, *or only* data points with `mode` labels.
func (CPUTime) AttrCPUMode(val CPUModeAttr) attribute.KeyValue {
return attribute.String("cpu.mode", string(val))
}
// CPUUtilization is an instrument used to record metric values conforming to the
// "process.cpu.utilization" semantic conventions. It represents the difference
// in process.cpu.time since the last measurement, divided by the elapsed time
// and number of CPUs available to the process.
type CPUUtilization struct {
metric.Int64Gauge
}
// NewCPUUtilization returns a new CPUUtilization instrument.
func NewCPUUtilization(
m metric.Meter,
opt ...metric.Int64GaugeOption,
) (CPUUtilization, error) {
// Check if the meter is nil.
if m == nil {
return CPUUtilization{noop.Int64Gauge{}}, nil
}
i, err := m.Int64Gauge(
"process.cpu.utilization",
append([]metric.Int64GaugeOption{
metric.WithDescription("Difference in process.cpu.time since the last measurement, divided by the elapsed time and number of CPUs available to the process."),
metric.WithUnit("1"),
}, opt...)...,
)
if err != nil {
return CPUUtilization{noop.Int64Gauge{}}, err
}
return CPUUtilization{i}, nil
}
// Inst returns the underlying metric instrument.
func (m CPUUtilization) Inst() metric.Int64Gauge {
return m.Int64Gauge
}
// Name returns the semantic convention name of the instrument.
func (CPUUtilization) Name() string {
return "process.cpu.utilization"
}
// Unit returns the semantic convention unit of the instrument
func (CPUUtilization) Unit() string {
return "1"
}
// Description returns the semantic convention description of the instrument
func (CPUUtilization) Description() string {
return "Difference in process.cpu.time since the last measurement, divided by the elapsed time and number of CPUs available to the process."
}
// Record records val to the current distribution.
//
// All additional attrs passed are included in the recorded value.
func (m CPUUtilization) Record(
ctx context.Context,
val int64,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Int64Gauge.Record(ctx, val, *o...)
}
// AttrCPUMode returns an optional attribute for the "cpu.mode" semantic
// convention. It represents a process SHOULD be characterized *either* by data
// points with no `mode` labels, *or only* data points with `mode` labels.
func (CPUUtilization) AttrCPUMode(val CPUModeAttr) attribute.KeyValue {
return attribute.String("cpu.mode", string(val))
}
// DiskIO is an instrument used to record metric values conforming to the
// "process.disk.io" semantic conventions. It represents the disk bytes
// transferred.
type DiskIO struct {
metric.Int64Counter
}
// NewDiskIO returns a new DiskIO instrument.
func NewDiskIO(
m metric.Meter,
opt ...metric.Int64CounterOption,
) (DiskIO, error) {
// Check if the meter is nil.
if m == nil {
return DiskIO{noop.Int64Counter{}}, nil
}
i, err := m.Int64Counter(
"process.disk.io",
append([]metric.Int64CounterOption{
metric.WithDescription("Disk bytes transferred."),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return DiskIO{noop.Int64Counter{}}, err
}
return DiskIO{i}, nil
}
// Inst returns the underlying metric instrument.
func (m DiskIO) Inst() metric.Int64Counter {
return m.Int64Counter
}
// Name returns the semantic convention name of the instrument.
func (DiskIO) Name() string {
return "process.disk.io"
}
// Unit returns the semantic convention unit of the instrument
func (DiskIO) Unit() string {
return "By"
}
// Description returns the semantic convention description of the instrument
func (DiskIO) Description() string {
return "Disk bytes transferred."
}
// Add adds incr to the existing count.
//
// All additional attrs passed are included in the recorded value.
func (m DiskIO) Add(
ctx context.Context,
incr int64,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Int64Counter.Add(ctx, incr, *o...)
}
// AttrDiskIODirection returns an optional attribute for the "disk.io.direction"
// semantic convention. It represents the disk IO operation direction.
func (DiskIO) AttrDiskIODirection(val DiskIODirectionAttr) attribute.KeyValue {
return attribute.String("disk.io.direction", string(val))
}
// MemoryUsage is an instrument used to record metric values conforming to the
// "process.memory.usage" semantic conventions. It represents the amount of
// physical memory in use.
type MemoryUsage struct {
metric.Int64UpDownCounter
}
// NewMemoryUsage returns a new MemoryUsage instrument.
func NewMemoryUsage(
m metric.Meter,
opt ...metric.Int64UpDownCounterOption,
) (MemoryUsage, error) {
// Check if the meter is nil.
if m == nil {
return MemoryUsage{noop.Int64UpDownCounter{}}, nil
}
i, err := m.Int64UpDownCounter(
"process.memory.usage",
append([]metric.Int64UpDownCounterOption{
metric.WithDescription("The amount of physical memory in use."),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return MemoryUsage{noop.Int64UpDownCounter{}}, err
}
return MemoryUsage{i}, nil
}
// Inst returns the underlying metric instrument.
func (m MemoryUsage) Inst() metric.Int64UpDownCounter {
return m.Int64UpDownCounter
}
// Name returns the semantic convention name of the instrument.
func (MemoryUsage) Name() string {
return "process.memory.usage"
}
// Unit returns the semantic convention unit of the instrument
func (MemoryUsage) Unit() string {
return "By"
}
// Description returns the semantic convention description of the instrument
func (MemoryUsage) Description() string {
return "The amount of physical memory in use."
}
// Add adds incr to the existing count.
func (m MemoryUsage) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Int64UpDownCounter.Add(ctx, incr)
return
}
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Int64UpDownCounter.Add(ctx, incr, *o...)
}
// MemoryVirtual is an instrument used to record metric values conforming to the
// "process.memory.virtual" semantic conventions. It represents the amount of
// committed virtual memory.
type MemoryVirtual struct {
metric.Int64UpDownCounter
}
// NewMemoryVirtual returns a new MemoryVirtual instrument.
func NewMemoryVirtual(
m metric.Meter,
opt ...metric.Int64UpDownCounterOption,
) (MemoryVirtual, error) {
// Check if the meter is nil.
if m == nil {
return MemoryVirtual{noop.Int64UpDownCounter{}}, nil
}
i, err := m.Int64UpDownCounter(
"process.memory.virtual",
append([]metric.Int64UpDownCounterOption{
metric.WithDescription("The amount of committed virtual memory."),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return MemoryVirtual{noop.Int64UpDownCounter{}}, err
}
return MemoryVirtual{i}, nil
}
// Inst returns the underlying metric instrument.
func (m MemoryVirtual) Inst() metric.Int64UpDownCounter {
return m.Int64UpDownCounter
}
// Name returns the semantic convention name of the instrument.
func (MemoryVirtual) Name() string {
return "process.memory.virtual"
}
// Unit returns the semantic convention unit of the instrument
func (MemoryVirtual) Unit() string {
return "By"
}
// Description returns the semantic convention description of the instrument
func (MemoryVirtual) Description() string {
return "The amount of committed virtual memory."
}
// Add adds incr to the existing count.
func (m MemoryVirtual) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Int64UpDownCounter.Add(ctx, incr)
return
}
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Int64UpDownCounter.Add(ctx, incr, *o...)
}
// NetworkIO is an instrument used to record metric values conforming to the
// "process.network.io" semantic conventions. It represents the network bytes
// transferred.
type NetworkIO struct {
metric.Int64Counter
}
// NewNetworkIO returns a new NetworkIO instrument.
func NewNetworkIO(
m metric.Meter,
opt ...metric.Int64CounterOption,
) (NetworkIO, error) {
// Check if the meter is nil.
if m == nil {
return NetworkIO{noop.Int64Counter{}}, nil
}
i, err := m.Int64Counter(
"process.network.io",
append([]metric.Int64CounterOption{
metric.WithDescription("Network bytes transferred."),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return NetworkIO{noop.Int64Counter{}}, err
}
return NetworkIO{i}, nil
}
// Inst returns the underlying metric instrument.
func (m NetworkIO) Inst() metric.Int64Counter {
return m.Int64Counter
}
// Name returns the semantic convention name of the instrument.
func (NetworkIO) Name() string {
return "process.network.io"
}
// Unit returns the semantic convention unit of the instrument
func (NetworkIO) Unit() string {
return "By"
}
// Description returns the semantic convention description of the instrument
func (NetworkIO) Description() string {
return "Network bytes transferred."
}
// Add adds incr to the existing count.
//
// All additional attrs passed are included in the recorded value.
func (m NetworkIO) Add(
ctx context.Context,
incr int64,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Int64Counter.Add(ctx, incr, *o...)
}
// AttrNetworkIODirection returns an optional attribute for the
// "network.io.direction" semantic convention. It represents the network IO
// operation direction.
func (NetworkIO) AttrNetworkIODirection(val NetworkIODirectionAttr) attribute.KeyValue {
return attribute.String("network.io.direction", string(val))
}
// OpenFileDescriptorCount is an instrument used to record metric values
// conforming to the "process.open_file_descriptor.count" semantic conventions.
// It represents the number of file descriptors in use by the process.
type OpenFileDescriptorCount struct {
metric.Int64UpDownCounter
}
// NewOpenFileDescriptorCount returns a new OpenFileDescriptorCount instrument.
func NewOpenFileDescriptorCount(
m metric.Meter,
opt ...metric.Int64UpDownCounterOption,
) (OpenFileDescriptorCount, error) {
// Check if the meter is nil.
if m == nil {
return OpenFileDescriptorCount{noop.Int64UpDownCounter{}}, nil
}
i, err := m.Int64UpDownCounter(
"process.open_file_descriptor.count",
append([]metric.Int64UpDownCounterOption{
metric.WithDescription("Number of file descriptors in use by the process."),
metric.WithUnit("{file_descriptor}"),
}, opt...)...,
)
if err != nil {
return OpenFileDescriptorCount{noop.Int64UpDownCounter{}}, err
}
return OpenFileDescriptorCount{i}, nil
}
// Inst returns the underlying metric instrument.
func (m OpenFileDescriptorCount) Inst() metric.Int64UpDownCounter {
return m.Int64UpDownCounter
}
// Name returns the semantic convention name of the instrument.
func (OpenFileDescriptorCount) Name() string {
return "process.open_file_descriptor.count"
}
// Unit returns the semantic convention unit of the instrument
func (OpenFileDescriptorCount) Unit() string {
return "{file_descriptor}"
}
// Description returns the semantic convention description of the instrument
func (OpenFileDescriptorCount) Description() string {
return "Number of file descriptors in use by the process."
}
// Add adds incr to the existing count.
func (m OpenFileDescriptorCount) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Int64UpDownCounter.Add(ctx, incr)
return
}
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Int64UpDownCounter.Add(ctx, incr, *o...)
}
// PagingFaults is an instrument used to record metric values conforming to the
// "process.paging.faults" semantic conventions. It represents the number of page
// faults the process has made.
type PagingFaults struct {
metric.Int64Counter
}
// NewPagingFaults returns a new PagingFaults instrument.
func NewPagingFaults(
m metric.Meter,
opt ...metric.Int64CounterOption,
) (PagingFaults, error) {
// Check if the meter is nil.
if m == nil {
return PagingFaults{noop.Int64Counter{}}, nil
}
i, err := m.Int64Counter(
"process.paging.faults",
append([]metric.Int64CounterOption{
metric.WithDescription("Number of page faults the process has made."),
metric.WithUnit("{fault}"),
}, opt...)...,
)
if err != nil {
return PagingFaults{noop.Int64Counter{}}, err
}
return PagingFaults{i}, nil
}
// Inst returns the underlying metric instrument.
func (m PagingFaults) Inst() metric.Int64Counter {
return m.Int64Counter
}
// Name returns the semantic convention name of the instrument.
func (PagingFaults) Name() string {
return "process.paging.faults"
}
// Unit returns the semantic convention unit of the instrument
func (PagingFaults) Unit() string {
return "{fault}"
}
// Description returns the semantic convention description of the instrument
func (PagingFaults) Description() string {
return "Number of page faults the process has made."
}
// Add adds incr to the existing count.
//
// All additional attrs passed are included in the recorded value.
func (m PagingFaults) Add(
ctx context.Context,
incr int64,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Int64Counter.Add(ctx, incr, *o...)
}
// AttrPagingFaultType returns an optional attribute for the
// "process.paging.fault_type" semantic convention. It represents the type of
// page fault for this data point. Type `major` is for major/hard page faults,
// and `minor` is for minor/soft page faults.
func (PagingFaults) AttrPagingFaultType(val PagingFaultTypeAttr) attribute.KeyValue {
return attribute.String("process.paging.fault_type", string(val))
}
// ThreadCount is an instrument used to record metric values conforming to the
// "process.thread.count" semantic conventions. It represents the process threads
// count.
type ThreadCount struct {
metric.Int64UpDownCounter
}
// NewThreadCount returns a new ThreadCount instrument.
func NewThreadCount(
m metric.Meter,
opt ...metric.Int64UpDownCounterOption,
) (ThreadCount, error) {
// Check if the meter is nil.
if m == nil {
return ThreadCount{noop.Int64UpDownCounter{}}, nil
}
i, err := m.Int64UpDownCounter(
"process.thread.count",
append([]metric.Int64UpDownCounterOption{
metric.WithDescription("Process threads count."),
metric.WithUnit("{thread}"),
}, opt...)...,
)
if err != nil {
return ThreadCount{noop.Int64UpDownCounter{}}, err
}
return ThreadCount{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ThreadCount) Inst() metric.Int64UpDownCounter {
return m.Int64UpDownCounter
}
// Name returns the semantic convention name of the instrument.
func (ThreadCount) Name() string {
return "process.thread.count"
}
// Unit returns the semantic convention unit of the instrument
func (ThreadCount) Unit() string {
return "{thread}"
}
// Description returns the semantic convention description of the instrument
func (ThreadCount) Description() string {
return "Process threads count."
}
// Add adds incr to the existing count.
func (m ThreadCount) Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Int64UpDownCounter.Add(ctx, incr)
return
}
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Int64UpDownCounter.Add(ctx, incr, *o...)
}
// Uptime is an instrument used to record metric values conforming to the
// "process.uptime" semantic conventions. It represents the time the process has
// been running.
type Uptime struct {
metric.Float64Gauge
}
// NewUptime returns a new Uptime instrument.
func NewUptime(
m metric.Meter,
opt ...metric.Float64GaugeOption,
) (Uptime, error) {
// Check if the meter is nil.
if m == nil {
return Uptime{noop.Float64Gauge{}}, nil
}
i, err := m.Float64Gauge(
"process.uptime",
append([]metric.Float64GaugeOption{
metric.WithDescription("The time the process has been running."),
metric.WithUnit("s"),
}, opt...)...,
)
if err != nil {
return Uptime{noop.Float64Gauge{}}, err
}
return Uptime{i}, nil
}
// Inst returns the underlying metric instrument.
func (m Uptime) Inst() metric.Float64Gauge {
return m.Float64Gauge
}
// Name returns the semantic convention name of the instrument.
func (Uptime) Name() string {
return "process.uptime"
}
// Unit returns the semantic convention unit of the instrument
func (Uptime) Unit() string {
return "s"
}
// Description returns the semantic convention description of the instrument
func (Uptime) Description() string {
return "The time the process has been running."
}
// Record records val to the current distribution.
//
// Instrumentations SHOULD use a gauge with type `double` and measure uptime in
// seconds as a floating point number with the highest precision available.
// The actual accuracy would depend on the instrumentation and operating system.
func (m Uptime) Record(ctx context.Context, val float64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Float64Gauge.Record(ctx, val)
}
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Float64Gauge.Record(ctx, val, *o...)
}

View File

@@ -0,0 +1,713 @@
// Code generated from semantic convention specification. DO NOT EDIT.
// Package httpconv provides types and functionality for OpenTelemetry semantic
// conventions in the "rpc" namespace.
package rpcconv
import (
"context"
"sync"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/noop"
)
var (
addOptPool = &sync.Pool{New: func() any { return &[]metric.AddOption{} }}
recOptPool = &sync.Pool{New: func() any { return &[]metric.RecordOption{} }}
)
// ClientDuration is an instrument used to record metric values conforming to the
// "rpc.client.duration" semantic conventions. It represents the measures the
// duration of outbound RPC.
type ClientDuration struct {
metric.Float64Histogram
}
// NewClientDuration returns a new ClientDuration instrument.
func NewClientDuration(
m metric.Meter,
opt ...metric.Float64HistogramOption,
) (ClientDuration, error) {
// Check if the meter is nil.
if m == nil {
return ClientDuration{noop.Float64Histogram{}}, nil
}
i, err := m.Float64Histogram(
"rpc.client.duration",
append([]metric.Float64HistogramOption{
metric.WithDescription("Measures the duration of outbound RPC."),
metric.WithUnit("ms"),
}, opt...)...,
)
if err != nil {
return ClientDuration{noop.Float64Histogram{}}, err
}
return ClientDuration{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ClientDuration) Inst() metric.Float64Histogram {
return m.Float64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ClientDuration) Name() string {
return "rpc.client.duration"
}
// Unit returns the semantic convention unit of the instrument
func (ClientDuration) Unit() string {
return "ms"
}
// Description returns the semantic convention description of the instrument
func (ClientDuration) Description() string {
return "Measures the duration of outbound RPC."
}
// Record records val to the current distribution.
//
// While streaming RPCs may record this metric as start-of-batch
// to end-of-batch, it's hard to interpret in practice.
//
// **Streaming**: N/A.
func (m ClientDuration) Record(ctx context.Context, val float64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Float64Histogram.Record(ctx, val)
}
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Float64Histogram.Record(ctx, val, *o...)
}
// ClientRequestSize is an instrument used to record metric values conforming to
// the "rpc.client.request.size" semantic conventions. It represents the measures
// the size of RPC request messages (uncompressed).
type ClientRequestSize struct {
metric.Int64Histogram
}
// NewClientRequestSize returns a new ClientRequestSize instrument.
func NewClientRequestSize(
m metric.Meter,
opt ...metric.Int64HistogramOption,
) (ClientRequestSize, error) {
// Check if the meter is nil.
if m == nil {
return ClientRequestSize{noop.Int64Histogram{}}, nil
}
i, err := m.Int64Histogram(
"rpc.client.request.size",
append([]metric.Int64HistogramOption{
metric.WithDescription("Measures the size of RPC request messages (uncompressed)."),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return ClientRequestSize{noop.Int64Histogram{}}, err
}
return ClientRequestSize{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ClientRequestSize) Inst() metric.Int64Histogram {
return m.Int64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ClientRequestSize) Name() string {
return "rpc.client.request.size"
}
// Unit returns the semantic convention unit of the instrument
func (ClientRequestSize) Unit() string {
return "By"
}
// Description returns the semantic convention description of the instrument
func (ClientRequestSize) Description() string {
return "Measures the size of RPC request messages (uncompressed)."
}
// Record records val to the current distribution.
//
// **Streaming**: Recorded per message in a streaming batch
func (m ClientRequestSize) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Int64Histogram.Record(ctx, val)
}
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Int64Histogram.Record(ctx, val, *o...)
}
// ClientRequestsPerRPC is an instrument used to record metric values conforming
// to the "rpc.client.requests_per_rpc" semantic conventions. It represents the
// measures the number of messages received per RPC.
type ClientRequestsPerRPC struct {
metric.Int64Histogram
}
// NewClientRequestsPerRPC returns a new ClientRequestsPerRPC instrument.
func NewClientRequestsPerRPC(
m metric.Meter,
opt ...metric.Int64HistogramOption,
) (ClientRequestsPerRPC, error) {
// Check if the meter is nil.
if m == nil {
return ClientRequestsPerRPC{noop.Int64Histogram{}}, nil
}
i, err := m.Int64Histogram(
"rpc.client.requests_per_rpc",
append([]metric.Int64HistogramOption{
metric.WithDescription("Measures the number of messages received per RPC."),
metric.WithUnit("{count}"),
}, opt...)...,
)
if err != nil {
return ClientRequestsPerRPC{noop.Int64Histogram{}}, err
}
return ClientRequestsPerRPC{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ClientRequestsPerRPC) Inst() metric.Int64Histogram {
return m.Int64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ClientRequestsPerRPC) Name() string {
return "rpc.client.requests_per_rpc"
}
// Unit returns the semantic convention unit of the instrument
func (ClientRequestsPerRPC) Unit() string {
return "{count}"
}
// Description returns the semantic convention description of the instrument
func (ClientRequestsPerRPC) Description() string {
return "Measures the number of messages received per RPC."
}
// Record records val to the current distribution.
//
// Should be 1 for all non-streaming RPCs.
//
// **Streaming**: This metric is required for server and client streaming RPCs
func (m ClientRequestsPerRPC) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Int64Histogram.Record(ctx, val)
}
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Int64Histogram.Record(ctx, val, *o...)
}
// ClientResponseSize is an instrument used to record metric values conforming to
// the "rpc.client.response.size" semantic conventions. It represents the
// measures the size of RPC response messages (uncompressed).
type ClientResponseSize struct {
metric.Int64Histogram
}
// NewClientResponseSize returns a new ClientResponseSize instrument.
func NewClientResponseSize(
m metric.Meter,
opt ...metric.Int64HistogramOption,
) (ClientResponseSize, error) {
// Check if the meter is nil.
if m == nil {
return ClientResponseSize{noop.Int64Histogram{}}, nil
}
i, err := m.Int64Histogram(
"rpc.client.response.size",
append([]metric.Int64HistogramOption{
metric.WithDescription("Measures the size of RPC response messages (uncompressed)."),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return ClientResponseSize{noop.Int64Histogram{}}, err
}
return ClientResponseSize{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ClientResponseSize) Inst() metric.Int64Histogram {
return m.Int64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ClientResponseSize) Name() string {
return "rpc.client.response.size"
}
// Unit returns the semantic convention unit of the instrument
func (ClientResponseSize) Unit() string {
return "By"
}
// Description returns the semantic convention description of the instrument
func (ClientResponseSize) Description() string {
return "Measures the size of RPC response messages (uncompressed)."
}
// Record records val to the current distribution.
//
// **Streaming**: Recorded per response in a streaming batch
func (m ClientResponseSize) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Int64Histogram.Record(ctx, val)
}
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Int64Histogram.Record(ctx, val, *o...)
}
// ClientResponsesPerRPC is an instrument used to record metric values conforming
// to the "rpc.client.responses_per_rpc" semantic conventions. It represents the
// measures the number of messages sent per RPC.
type ClientResponsesPerRPC struct {
metric.Int64Histogram
}
// NewClientResponsesPerRPC returns a new ClientResponsesPerRPC instrument.
func NewClientResponsesPerRPC(
m metric.Meter,
opt ...metric.Int64HistogramOption,
) (ClientResponsesPerRPC, error) {
// Check if the meter is nil.
if m == nil {
return ClientResponsesPerRPC{noop.Int64Histogram{}}, nil
}
i, err := m.Int64Histogram(
"rpc.client.responses_per_rpc",
append([]metric.Int64HistogramOption{
metric.WithDescription("Measures the number of messages sent per RPC."),
metric.WithUnit("{count}"),
}, opt...)...,
)
if err != nil {
return ClientResponsesPerRPC{noop.Int64Histogram{}}, err
}
return ClientResponsesPerRPC{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ClientResponsesPerRPC) Inst() metric.Int64Histogram {
return m.Int64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ClientResponsesPerRPC) Name() string {
return "rpc.client.responses_per_rpc"
}
// Unit returns the semantic convention unit of the instrument
func (ClientResponsesPerRPC) Unit() string {
return "{count}"
}
// Description returns the semantic convention description of the instrument
func (ClientResponsesPerRPC) Description() string {
return "Measures the number of messages sent per RPC."
}
// Record records val to the current distribution.
//
// Should be 1 for all non-streaming RPCs.
//
// **Streaming**: This metric is required for server and client streaming RPCs
func (m ClientResponsesPerRPC) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Int64Histogram.Record(ctx, val)
}
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Int64Histogram.Record(ctx, val, *o...)
}
// ServerDuration is an instrument used to record metric values conforming to the
// "rpc.server.duration" semantic conventions. It represents the measures the
// duration of inbound RPC.
type ServerDuration struct {
metric.Float64Histogram
}
// NewServerDuration returns a new ServerDuration instrument.
func NewServerDuration(
m metric.Meter,
opt ...metric.Float64HistogramOption,
) (ServerDuration, error) {
// Check if the meter is nil.
if m == nil {
return ServerDuration{noop.Float64Histogram{}}, nil
}
i, err := m.Float64Histogram(
"rpc.server.duration",
append([]metric.Float64HistogramOption{
metric.WithDescription("Measures the duration of inbound RPC."),
metric.WithUnit("ms"),
}, opt...)...,
)
if err != nil {
return ServerDuration{noop.Float64Histogram{}}, err
}
return ServerDuration{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ServerDuration) Inst() metric.Float64Histogram {
return m.Float64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ServerDuration) Name() string {
return "rpc.server.duration"
}
// Unit returns the semantic convention unit of the instrument
func (ServerDuration) Unit() string {
return "ms"
}
// Description returns the semantic convention description of the instrument
func (ServerDuration) Description() string {
return "Measures the duration of inbound RPC."
}
// Record records val to the current distribution.
//
// While streaming RPCs may record this metric as start-of-batch
// to end-of-batch, it's hard to interpret in practice.
//
// **Streaming**: N/A.
func (m ServerDuration) Record(ctx context.Context, val float64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Float64Histogram.Record(ctx, val)
}
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Float64Histogram.Record(ctx, val, *o...)
}
// ServerRequestSize is an instrument used to record metric values conforming to
// the "rpc.server.request.size" semantic conventions. It represents the measures
// the size of RPC request messages (uncompressed).
type ServerRequestSize struct {
metric.Int64Histogram
}
// NewServerRequestSize returns a new ServerRequestSize instrument.
func NewServerRequestSize(
m metric.Meter,
opt ...metric.Int64HistogramOption,
) (ServerRequestSize, error) {
// Check if the meter is nil.
if m == nil {
return ServerRequestSize{noop.Int64Histogram{}}, nil
}
i, err := m.Int64Histogram(
"rpc.server.request.size",
append([]metric.Int64HistogramOption{
metric.WithDescription("Measures the size of RPC request messages (uncompressed)."),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return ServerRequestSize{noop.Int64Histogram{}}, err
}
return ServerRequestSize{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ServerRequestSize) Inst() metric.Int64Histogram {
return m.Int64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ServerRequestSize) Name() string {
return "rpc.server.request.size"
}
// Unit returns the semantic convention unit of the instrument
func (ServerRequestSize) Unit() string {
return "By"
}
// Description returns the semantic convention description of the instrument
func (ServerRequestSize) Description() string {
return "Measures the size of RPC request messages (uncompressed)."
}
// Record records val to the current distribution.
//
// **Streaming**: Recorded per message in a streaming batch
func (m ServerRequestSize) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Int64Histogram.Record(ctx, val)
}
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Int64Histogram.Record(ctx, val, *o...)
}
// ServerRequestsPerRPC is an instrument used to record metric values conforming
// to the "rpc.server.requests_per_rpc" semantic conventions. It represents the
// measures the number of messages received per RPC.
type ServerRequestsPerRPC struct {
metric.Int64Histogram
}
// NewServerRequestsPerRPC returns a new ServerRequestsPerRPC instrument.
func NewServerRequestsPerRPC(
m metric.Meter,
opt ...metric.Int64HistogramOption,
) (ServerRequestsPerRPC, error) {
// Check if the meter is nil.
if m == nil {
return ServerRequestsPerRPC{noop.Int64Histogram{}}, nil
}
i, err := m.Int64Histogram(
"rpc.server.requests_per_rpc",
append([]metric.Int64HistogramOption{
metric.WithDescription("Measures the number of messages received per RPC."),
metric.WithUnit("{count}"),
}, opt...)...,
)
if err != nil {
return ServerRequestsPerRPC{noop.Int64Histogram{}}, err
}
return ServerRequestsPerRPC{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ServerRequestsPerRPC) Inst() metric.Int64Histogram {
return m.Int64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ServerRequestsPerRPC) Name() string {
return "rpc.server.requests_per_rpc"
}
// Unit returns the semantic convention unit of the instrument
func (ServerRequestsPerRPC) Unit() string {
return "{count}"
}
// Description returns the semantic convention description of the instrument
func (ServerRequestsPerRPC) Description() string {
return "Measures the number of messages received per RPC."
}
// Record records val to the current distribution.
//
// Should be 1 for all non-streaming RPCs.
//
// **Streaming** : This metric is required for server and client streaming RPCs
func (m ServerRequestsPerRPC) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Int64Histogram.Record(ctx, val)
}
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Int64Histogram.Record(ctx, val, *o...)
}
// ServerResponseSize is an instrument used to record metric values conforming to
// the "rpc.server.response.size" semantic conventions. It represents the
// measures the size of RPC response messages (uncompressed).
type ServerResponseSize struct {
metric.Int64Histogram
}
// NewServerResponseSize returns a new ServerResponseSize instrument.
func NewServerResponseSize(
m metric.Meter,
opt ...metric.Int64HistogramOption,
) (ServerResponseSize, error) {
// Check if the meter is nil.
if m == nil {
return ServerResponseSize{noop.Int64Histogram{}}, nil
}
i, err := m.Int64Histogram(
"rpc.server.response.size",
append([]metric.Int64HistogramOption{
metric.WithDescription("Measures the size of RPC response messages (uncompressed)."),
metric.WithUnit("By"),
}, opt...)...,
)
if err != nil {
return ServerResponseSize{noop.Int64Histogram{}}, err
}
return ServerResponseSize{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ServerResponseSize) Inst() metric.Int64Histogram {
return m.Int64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ServerResponseSize) Name() string {
return "rpc.server.response.size"
}
// Unit returns the semantic convention unit of the instrument
func (ServerResponseSize) Unit() string {
return "By"
}
// Description returns the semantic convention description of the instrument
func (ServerResponseSize) Description() string {
return "Measures the size of RPC response messages (uncompressed)."
}
// Record records val to the current distribution.
//
// **Streaming**: Recorded per response in a streaming batch
func (m ServerResponseSize) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Int64Histogram.Record(ctx, val)
}
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Int64Histogram.Record(ctx, val, *o...)
}
// ServerResponsesPerRPC is an instrument used to record metric values conforming
// to the "rpc.server.responses_per_rpc" semantic conventions. It represents the
// measures the number of messages sent per RPC.
type ServerResponsesPerRPC struct {
metric.Int64Histogram
}
// NewServerResponsesPerRPC returns a new ServerResponsesPerRPC instrument.
func NewServerResponsesPerRPC(
m metric.Meter,
opt ...metric.Int64HistogramOption,
) (ServerResponsesPerRPC, error) {
// Check if the meter is nil.
if m == nil {
return ServerResponsesPerRPC{noop.Int64Histogram{}}, nil
}
i, err := m.Int64Histogram(
"rpc.server.responses_per_rpc",
append([]metric.Int64HistogramOption{
metric.WithDescription("Measures the number of messages sent per RPC."),
metric.WithUnit("{count}"),
}, opt...)...,
)
if err != nil {
return ServerResponsesPerRPC{noop.Int64Histogram{}}, err
}
return ServerResponsesPerRPC{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ServerResponsesPerRPC) Inst() metric.Int64Histogram {
return m.Int64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ServerResponsesPerRPC) Name() string {
return "rpc.server.responses_per_rpc"
}
// Unit returns the semantic convention unit of the instrument
func (ServerResponsesPerRPC) Unit() string {
return "{count}"
}
// Description returns the semantic convention description of the instrument
func (ServerResponsesPerRPC) Description() string {
return "Measures the number of messages sent per RPC."
}
// Record records val to the current distribution.
//
// Should be 1 for all non-streaming RPCs.
//
// **Streaming**: This metric is required for server and client streaming RPCs
func (m ServerResponsesPerRPC) Record(ctx context.Context, val int64, attrs ...attribute.KeyValue) {
if len(attrs) == 0 {
m.Int64Histogram.Record(ctx, val)
}
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(*o, metric.WithAttributes(attrs...))
m.Int64Histogram.Record(ctx, val, *o...)
}

View File

@@ -0,0 +1,9 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package semconv // import "go.opentelemetry.io/otel/semconv/v1.32.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.32.0"

View File

@@ -0,0 +1,233 @@
// Code generated from semantic convention specification. DO NOT EDIT.
// Package httpconv provides types and functionality for OpenTelemetry semantic
// conventions in the "signalr" namespace.
package signalrconv
import (
"context"
"sync"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/noop"
)
var (
addOptPool = &sync.Pool{New: func() any { return &[]metric.AddOption{} }}
recOptPool = &sync.Pool{New: func() any { return &[]metric.RecordOption{} }}
)
// ConnectionStatusAttr is an attribute conforming to the
// signalr.connection.status semantic conventions. It represents the signalR HTTP
// connection closure status.
type ConnectionStatusAttr string
var (
// ConnectionStatusNormalClosure is the connection was closed normally.
ConnectionStatusNormalClosure ConnectionStatusAttr = "normal_closure"
// ConnectionStatusTimeout is the connection was closed due to a timeout.
ConnectionStatusTimeout ConnectionStatusAttr = "timeout"
// ConnectionStatusAppShutdown is the connection was closed because the app is
// shutting down.
ConnectionStatusAppShutdown ConnectionStatusAttr = "app_shutdown"
)
// TransportAttr is an attribute conforming to the signalr.transport semantic
// conventions. It represents the [SignalR transport type].
//
// [SignalR transport type]: https://github.com/dotnet/aspnetcore/blob/main/src/SignalR/docs/specs/TransportProtocols.md
type TransportAttr string
var (
// TransportServerSentEvents is the serverSentEvents protocol.
TransportServerSentEvents TransportAttr = "server_sent_events"
// TransportLongPolling is the longPolling protocol.
TransportLongPolling TransportAttr = "long_polling"
// TransportWebSockets is the webSockets protocol.
TransportWebSockets TransportAttr = "web_sockets"
)
// ServerActiveConnections is an instrument used to record metric values
// conforming to the "signalr.server.active_connections" semantic conventions. It
// represents the number of connections that are currently active on the server.
type ServerActiveConnections struct {
metric.Int64UpDownCounter
}
// NewServerActiveConnections returns a new ServerActiveConnections instrument.
func NewServerActiveConnections(
m metric.Meter,
opt ...metric.Int64UpDownCounterOption,
) (ServerActiveConnections, error) {
// Check if the meter is nil.
if m == nil {
return ServerActiveConnections{noop.Int64UpDownCounter{}}, nil
}
i, err := m.Int64UpDownCounter(
"signalr.server.active_connections",
append([]metric.Int64UpDownCounterOption{
metric.WithDescription("Number of connections that are currently active on the server."),
metric.WithUnit("{connection}"),
}, opt...)...,
)
if err != nil {
return ServerActiveConnections{noop.Int64UpDownCounter{}}, err
}
return ServerActiveConnections{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ServerActiveConnections) Inst() metric.Int64UpDownCounter {
return m.Int64UpDownCounter
}
// Name returns the semantic convention name of the instrument.
func (ServerActiveConnections) Name() string {
return "signalr.server.active_connections"
}
// Unit returns the semantic convention unit of the instrument
func (ServerActiveConnections) Unit() string {
return "{connection}"
}
// Description returns the semantic convention description of the instrument
func (ServerActiveConnections) Description() string {
return "Number of connections that are currently active on the server."
}
// Add adds incr to the existing count.
//
// All additional attrs passed are included in the recorded value.
//
// Meter name: `Microsoft.AspNetCore.Http.Connections`; Added in: ASP.NET Core
// 8.0
func (m ServerActiveConnections) Add(
ctx context.Context,
incr int64,
attrs ...attribute.KeyValue,
) {
o := addOptPool.Get().(*[]metric.AddOption)
defer func() {
*o = (*o)[:0]
addOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Int64UpDownCounter.Add(ctx, incr, *o...)
}
// AttrConnectionStatus returns an optional attribute for the
// "signalr.connection.status" semantic convention. It represents the signalR
// HTTP connection closure status.
func (ServerActiveConnections) AttrConnectionStatus(val ConnectionStatusAttr) attribute.KeyValue {
return attribute.String("signalr.connection.status", string(val))
}
// AttrTransport returns an optional attribute for the "signalr.transport"
// semantic convention. It represents the [SignalR transport type].
//
// [SignalR transport type]: https://github.com/dotnet/aspnetcore/blob/main/src/SignalR/docs/specs/TransportProtocols.md
func (ServerActiveConnections) AttrTransport(val TransportAttr) attribute.KeyValue {
return attribute.String("signalr.transport", string(val))
}
// ServerConnectionDuration is an instrument used to record metric values
// conforming to the "signalr.server.connection.duration" semantic conventions.
// It represents the duration of connections on the server.
type ServerConnectionDuration struct {
metric.Float64Histogram
}
// NewServerConnectionDuration returns a new ServerConnectionDuration instrument.
func NewServerConnectionDuration(
m metric.Meter,
opt ...metric.Float64HistogramOption,
) (ServerConnectionDuration, error) {
// Check if the meter is nil.
if m == nil {
return ServerConnectionDuration{noop.Float64Histogram{}}, nil
}
i, err := m.Float64Histogram(
"signalr.server.connection.duration",
append([]metric.Float64HistogramOption{
metric.WithDescription("The duration of connections on the server."),
metric.WithUnit("s"),
}, opt...)...,
)
if err != nil {
return ServerConnectionDuration{noop.Float64Histogram{}}, err
}
return ServerConnectionDuration{i}, nil
}
// Inst returns the underlying metric instrument.
func (m ServerConnectionDuration) Inst() metric.Float64Histogram {
return m.Float64Histogram
}
// Name returns the semantic convention name of the instrument.
func (ServerConnectionDuration) Name() string {
return "signalr.server.connection.duration"
}
// Unit returns the semantic convention unit of the instrument
func (ServerConnectionDuration) Unit() string {
return "s"
}
// Description returns the semantic convention description of the instrument
func (ServerConnectionDuration) Description() string {
return "The duration of connections on the server."
}
// Record records val to the current distribution.
//
// All additional attrs passed are included in the recorded value.
//
// Meter name: `Microsoft.AspNetCore.Http.Connections`; Added in: ASP.NET Core
// 8.0
func (m ServerConnectionDuration) Record(
ctx context.Context,
val float64,
attrs ...attribute.KeyValue,
) {
o := recOptPool.Get().(*[]metric.RecordOption)
defer func() {
*o = (*o)[:0]
recOptPool.Put(o)
}()
*o = append(
*o,
metric.WithAttributes(
attrs...,
),
)
m.Float64Histogram.Record(ctx, val, *o...)
}
// AttrConnectionStatus returns an optional attribute for the
// "signalr.connection.status" semantic convention. It represents the signalR
// HTTP connection closure status.
func (ServerConnectionDuration) AttrConnectionStatus(val ConnectionStatusAttr) attribute.KeyValue {
return attribute.String("signalr.connection.status", string(val))
}
// AttrTransport returns an optional attribute for the "signalr.transport"
// semantic convention. It represents the [SignalR transport type].
//
// [SignalR transport type]: https://github.com/dotnet/aspnetcore/blob/main/src/SignalR/docs/specs/TransportProtocols.md
func (ServerConnectionDuration) AttrTransport(val TransportAttr) attribute.KeyValue {
return attribute.String("signalr.transport", string(val))
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,12 @@
params:
excluded_namespaces: ["aspnetcore", "dotnet", "jvm", "nodejs", "v8js"]
excluded_namespaces:
- "aspnetcore"
- "cpython"
- "dotnet"
- "jvm"
- "kestrel"
- "nodejs"
- "v8js"
excluded_attributes: ["messaging.client_id"]
templates:
- pattern: attribute_group.go.j2
@@ -16,12 +23,12 @@ templates:
file_name: attribute_group.go
- pattern: metric.go.j2
filter: >
semconv_metrics({
semconv_grouped_metrics({
"exclude_deprecated": true,
"exclude_root_namespace": $excluded_namespaces,
})
| sort_by(.metric_name)
application_mode: single
file_name: metric.go
application_mode: each
file_name: "{{ctx.root_namespace | camel_case | lower }}conv/metric.go"
comment_formats:
go:
format: markdown
@@ -59,6 +66,20 @@ text_maps:
double[]: "...float64"
boolean: bool
boolean[]: "...bool"
instrument:
cpu.time: Float64ObservableCounter
go.config.gogc: Int64ObservableUpDownCounter
go.goroutine.count: Int64ObservableUpDownCounter
go.memory.allocated: Int64ObservableCounter
go.memory.allocations: Int64ObservableCounter
go.memory.gc.goal: Int64ObservableUpDownCounter
go.memory.limit: Int64ObservableUpDownCounter
go.memory.used: Int64ObservableCounter
go.processor.limit: Int64ObservableUpDownCounter
process.cpu.time: Float64ObservableCounter
system.memory.usage: Int64ObservableGauge
system.memory.utilization: Float64ObservableGauge
system.network.io: Int64ObservableCounter
acronyms:
- ACL
- AI
@@ -73,14 +94,23 @@ acronyms:
- ASCII
- ASPNETCore
- AWS
- ActiveMQ
- AppHub
- CICD
- CPP
- CPU
- CSI
- CSS
- CVM
- ClickHouse
- CloudEvents
- CloudFoundry
- CockroachDB
- CosmosDB
- CouchDB
- CronJob
- DB
- DB2
- DC
- DNS
- DaemonSet
@@ -91,14 +121,23 @@ acronyms:
- EDB
- EKS
- EOF
- EventGrid
- EventHubs
- FC
- FaaS
- FirebirdSQL
- FirstSQL
- FreeBSD
- GC
- GCE
- GCP
- GNU
- GRPC
- GUID
- GraphQL
- HANA
- HBase
- HPA
- HPUX
- HSQLDB
- HTML
@@ -106,43 +145,71 @@ acronyms:
- HTTPS
- HanaDB
- IA64
- IBM
- ICC
- ID
- IO
- IOS
- IOWait
- IP
- IPv4
- IPv6
- ISO
- InProc
- InfluxDB
- InstantDB
- JDBC
- JMS
- JSON
- JSONRPC
- JVM
- K8S
- LHS
- MCC
- MNC
- MSSQL
- MariaDB
- MaxDB
- MongoDB
- MySQL
- NetBSD
- OCI
- OKE
- OS
- OTel
- OpenAI
- OpenBSD
- OpenSearch
- OpenShift
- OpenTracing
- PHP
- PID
- PPC32
- PPC64
- PostgreSQL
- PubSub
- QPS
- QUIC
- RAM
- RHS
- RPC
- RabbitMQ
- ReplicaSet
- ReplicationController
- ResourceQuota
- RocketMQ
- SAP
- SCF
- SDK
- SLA
- SMTP
- SPDY
- SQL
- SQLite
- SQS
- SSH
- ServiceBus
- SignalR
- StatefulSet
- TCP
- TLS
@@ -158,9 +225,9 @@ acronyms:
- VCS
- VM
- WebEngine
- WebJS
- XML
- XMPP
- XSRF
- XSS
- ZOS