File: semantic_attributes-h.j2

package info (click to toggle)
opentelemetry-cpp 1.23.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,368 kB
  • sloc: cpp: 96,239; sh: 1,766; makefile: 38; python: 31
file content (132 lines) | stat: -rw-r--r-- 3,609 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
{#
  Copyright The OpenTelemetry Authors
  SPDX-License-Identifier: Apache-2.0

  This file is:
  - a Jinja template,
  - used to generate semantic conventions,
  - using weaver.

  For doc on the template syntax:
  https://jinja.palletsprojects.com/en/3.0.x/

  For doc on the semantic conventions:
  https://github.com/open-telemetry/semantic-conventions

  For doc on weaver:
  https://github.com/open-telemetry/weaver
#}
/*
 * Copyright The OpenTelemetry Authors
 * SPDX-License-Identifier: Apache-2.0
 */

/*
 * DO NOT EDIT, this is an Auto-generated file from:
 * buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2
 */
{# ========================================================================== #}
{#
    DESIGN NOTES:
    - Use the debug flag to dump the semantic convention data
      in the generated output, to inspect it.
#}
{# ========================================================================== #}

{% set debug = false %}

{% set file_name = ctx.output + (ctx.root_namespace | snake_case) ~ "_attributes.h" %}
{{ template.set_file_name(file_name) }}

{% set attributes = ctx.attributes | list %}
{% set enum_attributes = attributes | select("enum") | rejectattr("name", "in", ctx.excluded_attributes) | list %}

{% macro attribute_namespace(ctx) %}
{{ ctx.root_namespace | snake_case }}
{% endmacro %}

{% macro attribute_name(attribute) %}
k{{ attribute.name | pascal_case }}
{% endmacro %}

{% macro attribute_type(attribute) %}
{{ attribute.type | enum_type | map_text("cpp_types") }}
{% endmacro %}

{% macro enum_namespace_name(attribute) %}
{{ attribute.name | pascal_case ~ "Values"}}
{% endmacro %}

{% macro enum_name(member) %}
k{{ member.id | pascal_case }}
{% endmacro %}

{% set cpp_attribute_namespace = attribute_namespace(ctx) %}

{# ========================================================================== #}

#pragma once

#include "opentelemetry/common/macros.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace semconv
{
namespace {{ cpp_attribute_namespace -}}
{

{% for attribute in attributes %}
    {% if debug %}
// DEBUG: {{ attribute }}
    {% endif %}
    {% set cpp_attr_name = attribute_name(attribute) %}
    {% set excluded = attribute.name in ctx.excluded_attributes %}
    {% if excluded %}
#if 0
// Excluded attribute:
    {% endif %}
    {% if attribute is deprecated %}
{{ [attribute.brief, "\n", "@deprecated", attribute.deprecated, "\n", attribute.note] | comment(ident=2) }}
OPENTELEMETRY_DEPRECATED
    {% else %}
{{ [attribute.brief, "\n", attribute.note] | comment(ident=2) }}
    {% endif %}
static constexpr const char *{{cpp_attr_name}} = "{{attribute.name}}";
    {% if excluded %}
#endif
    {% endif %}

{% endfor %}

{% for attribute in enum_attributes %}
    {% set class_name = attribute.name | pascal_case ~ "Values" %}
    {% set cpp_enum_name = enum_namespace_name(attribute) %}
    {% set cpp_enum_type = attribute_type(attribute) %}
    {% if debug %}
// DEBUG: {{ attribute }}
    {% endif %}
namespace {{cpp_enum_name -}}
{
    {% for member in attribute.type.members %}
        {% set member_name = enum_name(member) %}
        {% if debug %}
// DEBUG: {{ member }}
        {% endif %}
        {% if member is deprecated %}
{{ [member.brief, "\n", "@deprecated", member.deprecated] | comment(ident=2) }}
OPENTELEMETRY_DEPRECATED
        {% else %}
{{ member.brief | comment(ident=2) }}
        {% endif %}
static constexpr {{ cpp_enum_type }} {{ member_name }} = {{ member.value | print_member_value }};

    {% endfor %}
}

{% endfor %}

}
}
OPENTELEMETRY_END_NAMESPACE