File: semantic_metrics-h.j2

package info (click to toggle)
opentelemetry-cpp 1.23.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,372 kB
  • sloc: cpp: 96,239; sh: 1,766; makefile: 36; python: 31
file content (228 lines) | stat: -rw-r--r-- 6,882 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
{#
  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_metrics-h.j2
 */
{# ========================================================================== #}
{#
    DESIGN NOTES:
    - Use the debug flag to dump the semantic convention data
      in the generated output, to inspect it.
    - Some instruments are not supported in the SDK.
      For these, we do not generate the code.
#}
{# ========================================================================== #}

{% set debug = false %}

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

{% set metrics = ctx.metrics | list %}

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

{% macro func_metric_name(metric) %}
{{ metric.id | pascal_case }}
{% endmacro %}

{% macro var_metric_name(metric) %}
k{{ metric.id | pascal_case }}
{% endmacro %}

{% macro descr_metric_name(metric) %}
descr{{ metric.id | pascal_case }}
{% endmacro %}

{% macro unit_metric_name(metric) %}
unit{{ metric.id | pascal_case }}
{% endmacro %}

{% macro sync_instrument_min_abi_version(metric) %}
{{ metric.instrument | map_text("cpp_sync_min_abi_version") | trim }}
{% endmacro %}

{% macro sync_instrument_int64_type(metric) %}
{{ metric.instrument | map_text("cpp_sync_instrument_to_int64_type") | trim }}
{% endmacro %}

{% macro sync_instrument_double_type(metric) %}
{{ metric.instrument | map_text("cpp_sync_instrument_to_double_type") | trim }}
{% endmacro %}

{% macro sync_instrument_int64_factory(metric) %}
{{ metric.instrument | map_text("cpp_sync_instrument_to_int64_factory") }}
{% endmacro %}

{% macro sync_instrument_double_factory(metric) %}
{{ metric.instrument | map_text("cpp_sync_instrument_to_double_factory") }}
{% endmacro %}

{% macro async_instrument_min_abi_version(metric) %}
{{ metric.instrument | map_text("cpp_async_min_abi_version") | trim }}
{% endmacro %}

{% macro async_instrument_type(metric) %}
{{ metric.instrument | map_text("cpp_async_instrument_to_type") }}
{% endmacro %}

{% macro async_instrument_int64_factory(metric) %}
{{ metric.instrument | map_text("cpp_async_instrument_to_int64_factory") }}
{% endmacro %}

{% macro async_instrument_double_factory(metric) %}
{{ metric.instrument | map_text("cpp_async_instrument_to_double_factory") }}
{% endmacro %}

{% set cpp_metric_namespace = metric_namespace(ctx) %}

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

#pragma once

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

OPENTELEMETRY_BEGIN_NAMESPACE
namespace semconv
{
namespace {{ cpp_metric_namespace -}}
{

{% for metric in ctx.metrics %}
    {% if debug %}
// DEBUG: {{ metric }}
    {% endif %}
    {% set f_metric_name = func_metric_name(metric) %}
    {% set v_metric_name = var_metric_name(metric) %}
    {% set descr = descr_metric_name(metric) %}
    {% set unit = unit_metric_name(metric) %}
    {% set sync_min_abi_version = (sync_instrument_min_abi_version(metric)) %}
    {% set async_min_abi_version = (async_instrument_min_abi_version(metric)) %}
    {% set sync_int64_type = sync_instrument_int64_type(metric) %}
    {% set sync_double_type = sync_instrument_double_type(metric) %}
    {% set async_type = async_instrument_type(metric) %}
    {% set sync_int64_factory = sync_instrument_int64_factory(metric) %}
    {% set sync_double_factory = sync_instrument_double_factory(metric) %}
    {% set async_int64_factory = async_instrument_int64_factory(metric) %}
    {% set async_double_factory = async_instrument_double_factory(metric) %}
    {% set excluded = metric.id in ctx.excluded_attributes %}
    {% if excluded %}
#if 0
// Excluded metric:
    {% endif %}
    {% if metric is deprecated %}
{{ [metric.brief, "\n", "@deprecated", metric.deprecated, "\n", metric.note, "\n", metric.instrument] | comment(ident=2) }}
OPENTELEMETRY_DEPRECATED
    {% else %}
{{ [metric.brief, "\n", metric.note, "\n", metric.instrument] | comment(ident=2) }}
    {% endif %}
static constexpr const char *{{v_metric_name}} = "{{metric.metric_name}}";
    {% if metric is deprecated %}
OPENTELEMETRY_DEPRECATED
    {% endif %}
static constexpr const char *{{descr}} = "{{metric.brief}}";
    {% if metric is deprecated %}
OPENTELEMETRY_DEPRECATED
    {% endif %}
static constexpr const char *{{unit}} = "{{metric.unit}}";

    {% if sync_min_abi_version|trim != "0" %}
        {% if sync_min_abi_version|trim != "1" %}
#if OPENTELEMETRY_ABI_VERSION_NO >= {{sync_min_abi_version}}
        {% endif %}
        {% if metric is deprecated %}
OPENTELEMETRY_DEPRECATED
        {% endif %}
static inline nostd::unique_ptr<{{sync_int64_type-}}>
CreateSyncInt64{{f_metric_name-}}(metrics::Meter *meter)
{
  return meter->{{sync_int64_factory}}(
    {{v_metric_name}},
    {{descr}},
    {{unit}});
}

        {% if metric is deprecated %}
OPENTELEMETRY_DEPRECATED
        {% endif %}
static inline nostd::unique_ptr<{{sync_double_type-}}>
CreateSyncDouble{{f_metric_name-}}(metrics::Meter *meter)
{
  return meter->{{sync_double_factory}}(
    {{v_metric_name}},
    {{descr}},
    {{unit}});
}
        {% if sync_min_abi_version|trim != "1" %}
#endif /* OPENTELEMETRY_ABI_VERSION_NO */
        {% endif %}
    {% endif %}

    {% if async_min_abi_version|trim != "0" %}
        {% if async_min_abi_version|trim != "1" %}
#if OPENTELEMETRY_ABI_VERSION_NO >= {{async_min_abi_version}}
        {% endif %}
        {% if metric is deprecated %}
OPENTELEMETRY_DEPRECATED
        {% endif %}
static inline nostd::shared_ptr<{{async_type-}}>
CreateAsyncInt64{{f_metric_name-}}(metrics::Meter *meter)
{
  return meter->{{async_int64_factory}}(
    {{v_metric_name}},
    {{descr}},
    {{unit}});
}

        {% if metric is deprecated %}
OPENTELEMETRY_DEPRECATED
        {% endif %}
static inline nostd::shared_ptr<{{async_type-}}>
CreateAsyncDouble{{f_metric_name-}}(metrics::Meter *meter)
{
  return meter->{{async_double_factory}}(
    {{v_metric_name}},
    {{descr}},
    {{unit}});
}
        {% if async_min_abi_version|trim != "1" %}
#endif /* OPENTELEMETRY_ABI_VERSION_NO */
        {% endif %}
    {% endif %}

    {% if excluded %}
#endif /* 0 */
    {% endif %}

{% endfor %}

}
}
OPENTELEMETRY_END_NAMESPACE