Skip to content

Commit 33715fd

Browse files
authored
adding metrics semconv (#1633)
1 parent 768c387 commit 33715fd

File tree

4 files changed

+419
-0
lines changed

4 files changed

+419
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
// DO NOT EDIT, this is an Auto-generated file from script/semantic-conventions
4+
5+
declare(strict_types=1);
6+
7+
namespace OpenTelemetry\SemConv\Metrics;
8+
9+
interface {{ ctx.root_namespace | pascal_case }}Metrics
10+
{
11+
{# blank line #}
12+
{%- for metric in ctx.metrics %}
13+
{% set const_name = metric.metric_name | screaming_snake_case %}
14+
{%- if metric is deprecated %}
15+
{%- set deprecated_phpdoc = "@deprecated" -%}
16+
{% else %}
17+
{% set deprecated_phpdoc = "" %}
18+
{%- endif -%}
19+
{%- if metric is stable -%}
20+
{%- set stability_phpdoc = "@stable" -%}
21+
{%- else -%}
22+
{%- set stability_phpdoc = "@experimental" -%}
23+
{%- endif -%}
24+
{%- set instrument_phpdoc = "Instrument: " ~ metric.instrument -%}
25+
{%- set unit_phpdoc = "Unit: " ~ metric.unit -%}
26+
{{ [metric.brief, concat_if(metric.note), instrument_phpdoc, unit_phpdoc, deprecated_phpdoc, stability_phpdoc] | comment(indent=4) | replace(' \n', '\n') }}
27+
public const {{ const_name }} = '{{ metric.metric_name }}';
28+
29+
{% endfor %}
30+
}
31+
{# blank line #}

script/semantic-conventions/templates/registry/php/weaver.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ params:
33
# this behavior is fully controlled by jinja templates
44
# TODO exclude more namespaces, eg: ios, aspnetcore, signalr, android, dotnet, jvm, kestrel, browser, device, ...
55
excluded_namespaces: [cloudfoundry, dotnet, hw, nodejs, profile]
6+
excluded_metrics_namespaces: [aspnetcore, azure, cicd, container, cpu, cpython, db, dns, dotnet, faas, gen_ai, go, hw, jvm, k8s, kestrel, messaging, nodejs, process, rpc, signalr, system, v8js, vcs]
67

78
# excluded attributes will be commented out in the generated code
89
# this behavior is fully controlled by jinja templates
@@ -55,6 +56,17 @@ templates:
5556
| map(.[-1])
5657
application_mode: single
5758
file_name: "ResourceAttributeValues.php"
59+
- template: Metrics.php.j2
60+
filter: >
61+
semconv_grouped_metrics({
62+
"exclude_root_namespace": $excluded_metrics_namespaces,
63+
"exclude_stability": [],
64+
}) | map({
65+
root_namespace: .root_namespace,
66+
metrics: .metrics,
67+
})
68+
application_mode: each
69+
file_name: "Metrics/{{ctx.root_namespace | pascal_case}}Metrics.php"
5870
whitespace_control:
5971
trim_blocks: true
6072
lstrip_blocks: true

src/SemConv/Metrics/HttpMetrics.php

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<?php
2+
3+
// DO NOT EDIT, this is an Auto-generated file from script/semantic-conventions
4+
5+
declare(strict_types=1);
6+
7+
namespace OpenTelemetry\SemConv\Metrics;
8+
9+
interface HttpMetrics
10+
{
11+
/**
12+
* Number of active HTTP requests.
13+
*
14+
* Instrument: updowncounter
15+
* Unit: {request}
16+
*
17+
* @experimental
18+
*/
19+
public const HTTP_CLIENT_ACTIVE_REQUESTS = 'http.client.active_requests';
20+
21+
/**
22+
* The duration of the successfully established outbound HTTP connections.
23+
*
24+
* Instrument: histogram
25+
* Unit: s
26+
*
27+
* @experimental
28+
*/
29+
public const HTTP_CLIENT_CONNECTION_DURATION = 'http.client.connection.duration';
30+
31+
/**
32+
* Number of outbound HTTP connections that are currently active or idle on the client.
33+
*
34+
* Instrument: updowncounter
35+
* Unit: {connection}
36+
*
37+
* @experimental
38+
*/
39+
public const HTTP_CLIENT_OPEN_CONNECTIONS = 'http.client.open_connections';
40+
41+
/**
42+
* Size of HTTP client request bodies.
43+
* The size of the request payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) header. For requests using transport encoding, this should be the compressed size.
44+
*
45+
* Instrument: histogram
46+
* Unit: By
47+
*
48+
* @experimental
49+
*/
50+
public const HTTP_CLIENT_REQUEST_BODY_SIZE = 'http.client.request.body.size';
51+
52+
/**
53+
* Duration of HTTP client requests.
54+
*
55+
* Instrument: histogram
56+
* Unit: s
57+
*
58+
* @stable
59+
*/
60+
public const HTTP_CLIENT_REQUEST_DURATION = 'http.client.request.duration';
61+
62+
/**
63+
* Size of HTTP client response bodies.
64+
* The size of the response payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) header. For requests using transport encoding, this should be the compressed size.
65+
*
66+
* Instrument: histogram
67+
* Unit: By
68+
*
69+
* @experimental
70+
*/
71+
public const HTTP_CLIENT_RESPONSE_BODY_SIZE = 'http.client.response.body.size';
72+
73+
/**
74+
* Number of active HTTP server requests.
75+
*
76+
* Instrument: updowncounter
77+
* Unit: {request}
78+
*
79+
* @experimental
80+
*/
81+
public const HTTP_SERVER_ACTIVE_REQUESTS = 'http.server.active_requests';
82+
83+
/**
84+
* Size of HTTP server request bodies.
85+
* The size of the request payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) header. For requests using transport encoding, this should be the compressed size.
86+
*
87+
* Instrument: histogram
88+
* Unit: By
89+
*
90+
* @experimental
91+
*/
92+
public const HTTP_SERVER_REQUEST_BODY_SIZE = 'http.server.request.body.size';
93+
94+
/**
95+
* Duration of HTTP server requests.
96+
*
97+
* Instrument: histogram
98+
* Unit: s
99+
*
100+
* @stable
101+
*/
102+
public const HTTP_SERVER_REQUEST_DURATION = 'http.server.request.duration';
103+
104+
/**
105+
* Size of HTTP server response bodies.
106+
* The size of the response payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) header. For requests using transport encoding, this should be the compressed size.
107+
*
108+
* Instrument: histogram
109+
* Unit: By
110+
*
111+
* @experimental
112+
*/
113+
public const HTTP_SERVER_RESPONSE_BODY_SIZE = 'http.server.response.body.size';
114+
115+
}

0 commit comments

Comments
 (0)