Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

semconv: Add metric generation #4880

Merged
merged 27 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fb8d9f2
Adds some basic constants for metrics utilizing a new jinja template
carrbs Feb 2, 2024
67eff23
Merge branch 'main' into 4528-semconv-add-metrics
carrbs Feb 6, 2024
bd60b70
Updates generated comments with more explicit nomenclature; Adds Unit…
carrbs Feb 6, 2024
d778687
Update CHANGELOG
carrbs Feb 7, 2024
3701d37
fix merge conflicts from upstream
carrbs Feb 20, 2024
58ff3f0
fix overlooked merge conflict
carrbs Feb 20, 2024
35d6077
change the types of generated consts to string; format generation to …
carrbs Feb 22, 2024
a2943d4
Merge branch 'main' into 4528-semconv-add-metrics
carrbs Feb 22, 2024
e396ef9
trim trailing (repeated) periods in the description
carrbs Feb 22, 2024
c54516b
Merge branch 'main' into 4528-semconv-add-metrics
carrbs Feb 22, 2024
b6a005f
Merge branch 'main' into 4528-semconv-add-metrics
carrbs Feb 22, 2024
4c12cc5
Merge branch '4528-semconv-add-metrics' of github.com:carrbs/opentele…
carrbs Feb 22, 2024
f702f77
fix merge conflicts in CHANGELOG
carrbs Mar 13, 2024
14b878e
manual formatting of some proper nouns; simplify the license header
carrbs Mar 13, 2024
dccb44d
update metrics file with concise generated license header
carrbs Mar 14, 2024
2177316
revert special formatting logic for JVM and ASPNETCore
carrbs Mar 15, 2024
83f8bc4
fix merge conflicts in CHANGELOG
carrbs Mar 15, 2024
2a5c712
Update CHANGELOG.md
pellared Mar 15, 2024
e4b3c7a
Merge branch 'main' into 4528-semconv-add-metrics
XSAM Mar 18, 2024
070dbfc
Merge branch 'main' into 4528-semconv-add-metrics
pellared Mar 27, 2024
1545359
Merge branch 'main' into 4528-semconv-add-metrics
pellared Mar 28, 2024
3d492f6
Fixes a bad CHANGELOG merge conflict on a previous commit
carrbs Apr 3, 2024
296624e
Update CHANGELOG.md
pellared Apr 4, 2024
a6b7315
Merge branch 'main' into 4528-semconv-add-metrics
pellared Apr 4, 2024
fc08d9c
Merge branch 'main' into 4528-semconv-add-metrics
pellared Apr 4, 2024
bb71975
Merge branch 'main' into 4528-semconv-add-metrics
pellared Apr 4, 2024
04f11d0
Merge branch 'main' into 4528-semconv-add-metrics
MrAlias Apr 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased]

### Added

- Adds a new template to generate metric semantic conventions, as well as adding it to the Makefile `semconv-generate` script to add the metric.go file to the v1.24.0 directory. (#4528)
pellared marked this conversation as resolved.
Show resolved Hide resolved

## [1.23.0] 2024-02-06

This release contains the first stable, `v1`, release of the following modules:
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ semconv-generate: | $(SEMCONVGEN) $(SEMCONVKIT)
$(SEMCONVGEN) -i "$(OTEL_SEMCONV_REPO)/model/." --only=attribute_group -p conventionType=trace -f attribute_group.go -t "$(SEMCONVPKG)/template.j2" -s "$(TAG)"
$(SEMCONVGEN) -i "$(OTEL_SEMCONV_REPO)/model/." --only=event -p conventionType=event -f event.go -t "$(SEMCONVPKG)/template.j2" -s "$(TAG)"
$(SEMCONVGEN) -i "$(OTEL_SEMCONV_REPO)/model/." --only=resource -p conventionType=resource -f resource.go -t "$(SEMCONVPKG)/template.j2" -s "$(TAG)"
$(SEMCONVGEN) -i "$(OTEL_SEMCONV_REPO)/model/." --only=metric -f metric.go -t "$(SEMCONVPKG)/metric_template.j2" -s "$(TAG)"
$(SEMCONVKIT) -output "$(SEMCONVPKG)/$(TAG)" -tag "$(TAG)"

.PHONY: gorelease
Expand All @@ -314,5 +315,5 @@ add-tags: | $(MULTIMOD)
$(MULTIMOD) verify && $(MULTIMOD) tag -m ${MODSET} -c ${COMMIT}

.PHONY: lint-markdown
lint-markdown:
lint-markdown:
docker run -v "$(CURDIR):$(WORKDIR)" docker://avtodev/markdown-lint:v1 -c $(WORKDIR)/.markdownlint.yaml $(WORKDIR)/**/*.md
50 changes: 50 additions & 0 deletions semconv/metric_template.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{%- macro to_go_name(fqn) -%}
{{fqn | replace(".", " ") | replace("_", " ") | title | replace(" ", "")}}
{%- endmacro -%}
{%- macro it_reps(brief) -%}
It represents {% if brief[:2] == "A " or brief[:3] == "An " or brief[:4] == "The " -%}
{{ brief[0]|lower }}{{ brief[1:] }}
{%- else -%}
the {{ brief[0]|lower }}{{ brief[1:] }}
{%- endif -%}
{%- endmacro -%}
{%- macro keydoc(metric) -%}
{%- if metric.stability|string() == "StabilityLevel.DEPRECATED" -%}
{{ to_go_name(metric.metric_name) }} 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) }}
{%- endif %}
{%- endmacro -%}
// 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.

// Code generated from semantic convention specification. DO NOT EDIT.

package semconv // import [[IMPORTPATH]]

import "go.opentelemetry.io/otel/attribute"

const (
{% for id in semconvs %}
{%- if semconvs[id].GROUP_TYPE_NAME == 'metric' %}{% set metric = semconvs[id] %}
// {{ keydoc(metric) | wordwrap(76, break_long_words=false, break_on_hyphens=false, wrapstring="\n// ") }}
// Instrument: {{ metric.instrument }}
// Unit: {{ metric.unit }}
// Stability: {{ metric.stability }}
{{to_go_name(metric.metric_name)}}Name = attribute.Key("{{metric.metric_name}}")
{{to_go_name(metric.metric_name)}}Unit = attribute.Key("{{metric.unit}}")
{{to_go_name(metric.metric_name)}}Description = attribute.Key("{{metric.brief}}")
{%- endif %}
{% endfor %}
)
Loading