diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/go_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/go_attributes.py deleted file mode 100644 index f13ba2f0496..00000000000 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/go_attributes.py +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright The OpenTelemetry Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from enum import Enum -from typing import Final - -GO_MEMORY_TYPE: Final = "go.memory.type" -""" -The type of memory. -""" - - -class GoMemoryTypeValues(Enum): - STACK = "stack" - """Memory allocated from the heap that is reserved for stack space, whether or not it is currently in-use.""" - OTHER = "other" - """Memory used by the Go runtime, excluding other categories of memory usage described in this enumeration.""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/v8js_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/v8js_attributes.py deleted file mode 100644 index 15817f1571f..00000000000 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/v8js_attributes.py +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright The OpenTelemetry Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from enum import Enum -from typing import Final - -V8JS_GC_TYPE: Final = "v8js.gc.type" -""" -The type of garbage collection. -""" - -V8JS_HEAP_SPACE_NAME: Final = "v8js.heap.space.name" -""" -The name of the space type of heap memory. -Note: Value can be retrieved from value `space_name` of [`v8.getHeapSpaceStatistics()`](https://nodejs.org/api/v8.html#v8getheapspacestatistics). -""" - - -class V8jsGcTypeValues(Enum): - MAJOR = "major" - """Major (Mark Sweep Compact).""" - MINOR = "minor" - """Minor (Scavenge).""" - INCREMENTAL = "incremental" - """Incremental (Incremental Marking).""" - WEAKCB = "weakcb" - """Weak Callbacks (Process Weak Callbacks).""" - - -class V8jsHeapSpaceNameValues(Enum): - NEW_SPACE = "new_space" - """New memory space.""" - OLD_SPACE = "old_space" - """Old memory space.""" - CODE_SPACE = "code_space" - """Code memory space.""" - MAP_SPACE = "map_space" - """Map memory space.""" - LARGE_OBJECT_SPACE = "large_object_space" - """Large object memory space.""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/go_metrics.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/go_metrics.py deleted file mode 100644 index 11dc352fa78..00000000000 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/go_metrics.py +++ /dev/null @@ -1,179 +0,0 @@ -# Copyright The OpenTelemetry Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -from typing import Final - -from opentelemetry.metrics import Counter, Histogram, Meter, UpDownCounter - -GO_CONFIG_GOGC: Final = "go.config.gogc" -""" -Heap size target percentage configured by the user, otherwise 100 -Instrument: updowncounter -Unit: % -Note: The value range is [0.0,100.0]. Computed from `/gc/gogc:percent`. -""" - - -def create_go_config_gogc(meter: Meter) -> UpDownCounter: - """Heap size target percentage configured by the user, otherwise 100""" - return meter.create_up_down_counter( - name=GO_CONFIG_GOGC, - description="Heap size target percentage configured by the user, otherwise 100.", - unit="%", - ) - - -GO_GOROUTINE_COUNT: Final = "go.goroutine.count" -""" -Count of live goroutines -Instrument: updowncounter -Unit: {goroutine} -Note: Computed from `/sched/goroutines:goroutines`. -""" - - -def create_go_goroutine_count(meter: Meter) -> UpDownCounter: - """Count of live goroutines""" - return meter.create_up_down_counter( - name=GO_GOROUTINE_COUNT, - description="Count of live goroutines.", - unit="{goroutine}", - ) - - -GO_MEMORY_ALLOCATED: Final = "go.memory.allocated" -""" -Memory allocated to the heap by the application -Instrument: counter -Unit: By -Note: Computed from `/gc/heap/allocs:bytes`. -""" - - -def create_go_memory_allocated(meter: Meter) -> Counter: - """Memory allocated to the heap by the application""" - return meter.create_counter( - name=GO_MEMORY_ALLOCATED, - description="Memory allocated to the heap by the application.", - unit="By", - ) - - -GO_MEMORY_ALLOCATIONS: Final = "go.memory.allocations" -""" -Count of allocations to the heap by the application -Instrument: counter -Unit: {allocation} -Note: Computed from `/gc/heap/allocs:objects`. -""" - - -def create_go_memory_allocations(meter: Meter) -> Counter: - """Count of allocations to the heap by the application""" - return meter.create_counter( - name=GO_MEMORY_ALLOCATIONS, - description="Count of allocations to the heap by the application.", - unit="{allocation}", - ) - - -GO_MEMORY_GC_GOAL: Final = "go.memory.gc.goal" -""" -Heap size target for the end of the GC cycle -Instrument: updowncounter -Unit: By -Note: Computed from `/gc/heap/goal:bytes`. -""" - - -def create_go_memory_gc_goal(meter: Meter) -> UpDownCounter: - """Heap size target for the end of the GC cycle""" - return meter.create_up_down_counter( - name=GO_MEMORY_GC_GOAL, - description="Heap size target for the end of the GC cycle.", - unit="By", - ) - - -GO_MEMORY_LIMIT: Final = "go.memory.limit" -""" -Go runtime memory limit configured by the user, if a limit exists -Instrument: updowncounter -Unit: By -Note: Computed from `/gc/gomemlimit:bytes`. This metric is excluded if the limit obtained from the Go runtime is math.MaxInt64. -""" - - -def create_go_memory_limit(meter: Meter) -> UpDownCounter: - """Go runtime memory limit configured by the user, if a limit exists""" - return meter.create_up_down_counter( - name=GO_MEMORY_LIMIT, - description="Go runtime memory limit configured by the user, if a limit exists.", - unit="By", - ) - - -GO_MEMORY_USED: Final = "go.memory.used" -""" -Memory used by the Go runtime -Instrument: updowncounter -Unit: By -Note: Computed from `(/memory/classes/total:bytes - /memory/classes/heap/released:bytes)`. -""" - - -def create_go_memory_used(meter: Meter) -> UpDownCounter: - """Memory used by the Go runtime""" - return meter.create_up_down_counter( - name=GO_MEMORY_USED, - description="Memory used by the Go runtime.", - unit="By", - ) - - -GO_PROCESSOR_LIMIT: Final = "go.processor.limit" -""" -The number of OS threads that can execute user-level Go code simultaneously -Instrument: updowncounter -Unit: {thread} -Note: Computed from `/sched/gomaxprocs:threads`. -""" - - -def create_go_processor_limit(meter: Meter) -> UpDownCounter: - """The number of OS threads that can execute user-level Go code simultaneously""" - return meter.create_up_down_counter( - name=GO_PROCESSOR_LIMIT, - description="The number of OS threads that can execute user-level Go code simultaneously.", - unit="{thread}", - ) - - -GO_SCHEDULE_DURATION: Final = "go.schedule.duration" -""" -The time goroutines have spent in the scheduler in a runnable state before actually running -Instrument: histogram -Unit: s -Note: Computed from `/sched/latencies:seconds`. Bucket boundaries are provided by the runtime, and are subject to change. -""" - - -def create_go_schedule_duration(meter: Meter) -> Histogram: - """The time goroutines have spent in the scheduler in a runnable state before actually running""" - return meter.create_histogram( - name=GO_SCHEDULE_DURATION, - description="The time goroutines have spent in the scheduler in a runnable state before actually running.", - unit="s", - ) diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/veightjs_metrics.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/veightjs_metrics.py deleted file mode 100644 index e06da57df49..00000000000 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/veightjs_metrics.py +++ /dev/null @@ -1,107 +0,0 @@ -# Copyright The OpenTelemetry Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -from typing import Final - -from opentelemetry.metrics import Histogram, Meter, UpDownCounter - -V8JS_GC_DURATION: Final = "v8js.gc.duration" -""" -Garbage collection duration -Instrument: histogram -Unit: s -Note: The values can be retrieve from [`perf_hooks.PerformanceObserver(...).observe({ entryTypes: ['gc'] })`](https://nodejs.org/api/perf_hooks.html#performanceobserverobserveoptions). -""" - - -def create_v8js_gc_duration(meter: Meter) -> Histogram: - """Garbage collection duration""" - return meter.create_histogram( - name=V8JS_GC_DURATION, - description="Garbage collection duration.", - unit="s", - ) - - -V8JS_HEAP_SPACE_AVAILABLE_SIZE: Final = "v8js.heap.space.available_size" -""" -Heap space available size -Instrument: updowncounter -Unit: By -Note: Value can be retrieved from value `space_available_size` of [`v8.getHeapSpaceStatistics()`](https://nodejs.org/api/v8.html#v8getheapspacestatistics). -""" - - -def create_v8js_heap_space_available_size(meter: Meter) -> UpDownCounter: - """Heap space available size""" - return meter.create_up_down_counter( - name=V8JS_HEAP_SPACE_AVAILABLE_SIZE, - description="Heap space available size.", - unit="By", - ) - - -V8JS_HEAP_SPACE_PHYSICAL_SIZE: Final = "v8js.heap.space.physical_size" -""" -Committed size of a heap space -Instrument: updowncounter -Unit: By -Note: Value can be retrieved from value `physical_space_size` of [`v8.getHeapSpaceStatistics()`](https://nodejs.org/api/v8.html#v8getheapspacestatistics). -""" - - -def create_v8js_heap_space_physical_size(meter: Meter) -> UpDownCounter: - """Committed size of a heap space""" - return meter.create_up_down_counter( - name=V8JS_HEAP_SPACE_PHYSICAL_SIZE, - description="Committed size of a heap space.", - unit="By", - ) - - -V8JS_MEMORY_HEAP_LIMIT: Final = "v8js.memory.heap.limit" -""" -Total heap memory size pre-allocated -Instrument: updowncounter -Unit: By -Note: The value can be retrieved from value `space_size` of [`v8.getHeapSpaceStatistics()`](https://nodejs.org/api/v8.html#v8getheapspacestatistics). -""" - - -def create_v8js_memory_heap_limit(meter: Meter) -> UpDownCounter: - """Total heap memory size pre-allocated""" - return meter.create_up_down_counter( - name=V8JS_MEMORY_HEAP_LIMIT, - description="Total heap memory size pre-allocated.", - unit="By", - ) - - -V8JS_MEMORY_HEAP_USED: Final = "v8js.memory.heap.used" -""" -Heap Memory size allocated -Instrument: updowncounter -Unit: By -Note: The value can be retrieved from value `space_used_size` of [`v8.getHeapSpaceStatistics()`](https://nodejs.org/api/v8.html#v8getheapspacestatistics). -""" - - -def create_v8js_memory_heap_used(meter: Meter) -> UpDownCounter: - """Heap Memory size allocated""" - return meter.create_up_down_counter( - name=V8JS_MEMORY_HEAP_USED, - description="Heap Memory size allocated.", - unit="By", - ) diff --git a/scripts/semconv/generate.sh b/scripts/semconv/generate.sh index 26a582ac09e..a04cc105aee 100755 --- a/scripts/semconv/generate.sh +++ b/scripts/semconv/generate.sh @@ -5,9 +5,9 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" ROOT_DIR="${SCRIPT_DIR}/../.." # freeze the spec version to make SemanticAttributes generation reproducible -SEMCONV_VERSION=1.26.0 +SEMCONV_VERSION=1.27.0 SEMCONV_VERSION_TAG=v$SEMCONV_VERSION -OTEL_WEAVER_IMG_VERSION=0.7.0 +OTEL_WEAVER_IMG_VERSION=0.8.0 INCUBATING_DIR=_incubating cd ${SCRIPT_DIR} diff --git a/scripts/semconv/templates/registry/common.j2 b/scripts/semconv/templates/registry/common.j2 index 323e2bcdfa7..99dcf1495da 100644 --- a/scripts/semconv/templates/registry/common.j2 +++ b/scripts/semconv/templates/registry/common.j2 @@ -15,10 +15,6 @@ {% endmacro -%} -{%- macro to_const_name(attr_name) -%} -{{attr_name | upper | replace('.', '_')}} -{%- endmacro %} - {%- macro str_or_empty(str) -%} {% if str is none %}{{""}}{% else %}{{str}}{% endif %} {%- endmacro %} @@ -36,7 +32,3 @@ from deprecated import deprecated {%- endif -%} {%- endmacro-%} - -{%- macro print_value(type, value) -%} -{%- if type == "string" -%}"{{value}}"{%-else-%}{{value}}{%-endif-%} -{%- endmacro -%} diff --git a/scripts/semconv/templates/registry/semantic_attributes.j2 b/scripts/semconv/templates/registry/semantic_attributes.j2 index fa7f80ca478..1cc155712bd 100644 --- a/scripts/semconv/templates/registry/semantic_attributes.j2 +++ b/scripts/semconv/templates/registry/semantic_attributes.j2 @@ -14,7 +14,7 @@ from typing import Final -{% set file_name = ctx.output + (ctx.root_namespace | kebab_case | replace('-', '_')) ~ "_attributes.py" -%} +{% set file_name = ctx.output + (ctx.root_namespace | snake_case) ~ "_attributes.py" -%} {{- template.set_file_name(file_name) -}} {%- import 'common.j2' as c %} @@ -24,7 +24,7 @@ from typing import Final {{c.import_deprecated(enum_attributes)}} {%- macro attribute_name(attribute) -%} -{{c.to_const_name(attribute.name)}}{%- if attribute.type is template_type -%}_TEMPLATE{%- endif -%} +{{ attribute.name | screaming_snake_case }}{%- if attribute.type is template_type -%}_TEMPLATE{%- endif -%} {%- endmacro -%} {%- macro stable_class_ref(const_name, separator) -%} @@ -65,9 +65,9 @@ from typing import Final {%- endif %} class {{class_name}}(Enum): {%- for member in attribute.type.members %} - {% set member_name = c.to_const_name(member.id) -%} + {% set member_name = member.id | screaming_snake_case -%} {%- set doc_string=write_docstring(class_name + '.' + member_name, member.brief or member.id, "", member.deprecated, member.stability, false)-%} - {{member_name}} = {{c.print_value(attribute.type | instantiated_type, member.value) }} + {{member_name}} = {{ member.value | print_member_value }} {% if doc_string %}"""{{doc_string}}"""{% endif %} {%- endfor %} {% endfor %} \ No newline at end of file diff --git a/scripts/semconv/templates/registry/semantic_metrics.j2 b/scripts/semconv/templates/registry/semantic_metrics.j2 index 0fe6a61eb89..49550cf538e 100644 --- a/scripts/semconv/templates/registry/semantic_metrics.j2 +++ b/scripts/semconv/templates/registry/semantic_metrics.j2 @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -{% set file_name = ctx.output + ctx.root_namespace | kebab_case | replace('-', '_') ~ "_metrics.py" -%} +{% set file_name = ctx.output + ctx.root_namespace | snake_case ~ "_metrics.py" -%} {{- template.set_file_name(file_name) -}} {% import 'common.j2' as c -%} @@ -66,8 +66,8 @@ CallbackT = Union[ from typing import Final {{ import_instrument_classes(filtered_metrics) }} -{%- for metric in ctx.metrics | sort(attribute="metric_name") %} -{% set const_name = c.to_const_name(metric.metric_name) %} +{%- for metric in ctx.metrics %} +{% set const_name = metric.metric_name | screaming_snake_case %} {{const_name}}: Final = "{{metric.metric_name}}" {%- set doc_string=write_docstring(metric, const_name, "")-%}{%- if doc_string %} """{{doc_string}} diff --git a/scripts/semconv/templates/registry/weaver.yaml b/scripts/semconv/templates/registry/weaver.yaml index dd7f708beb2..42018173d82 100644 --- a/scripts/semconv/templates/registry/weaver.yaml +++ b/scripts/semconv/templates/registry/weaver.yaml @@ -1,7 +1,6 @@ params: # excluded namespaces will not be generated - # this behavior is fully controlled by jinja templates - excluded_namespaces: [ios, aspnetcore, signalr, android, dotnet, jvm, kestrel] + excluded_namespaces: [ios, aspnetcore, signalr, android, dotnet, jvm, kestrel, v8js, veightjs, go, node.js] # excluded attributes will be commented out in the generated code # this behavior is fully controlled by jinja templates