-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
808 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{%- macro to_java_instrument_builder_factory(instrument) -%} | ||
{%- if instrument == "counter" -%} | ||
counterBuilder | ||
{%- elif instrument == "histogram" -%} | ||
histogramBuilder | ||
{%- elif instrument == "updowncounter" -%} | ||
upDownCounterBuilder | ||
{%- elif instrument == "gauge" -%} | ||
gaugeBuilder | ||
{%- endif -%} | ||
{%- endmacro %} | ||
{%- macro to_java_instrument_builder_type(instrument) -%} | ||
{%- if instrument == "counter" -%} | ||
LongCounterBuilder | ||
{%- elif instrument == "histogram" -%} | ||
DoubleHistogramBuilder | ||
{%- elif instrument == "updowncounter" -%} | ||
LongUpDownCounterBuilder | ||
{%- elif instrument == "gauge" -%} | ||
DoubleGaugeBuilder | ||
{%- endif -%} | ||
{%- endmacro %} | ||
{%- set filtered_metrics = metrics | select(filter) | list %} | ||
{%- if filtered_metrics | count > 0 %} | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.api.semconv; | ||
|
||
import io.opentelemetry.api.metrics.DoubleGaugeBuilder; | ||
import io.opentelemetry.api.metrics.DoubleHistogramBuilder; | ||
import io.opentelemetry.api.metrics.LongCounterBuilder; | ||
import io.opentelemetry.api.metrics.LongUpDownCounterBuilder; | ||
import io.opentelemetry.api.metrics.Meter; | ||
|
||
class {{ root_namespace | to_camelcase(True) }}Metrics { | ||
{%- for metric in filtered_metrics %} | ||
/** | ||
* {{metric.brief | to_doc_brief}} | ||
*/ | ||
public static final {{ to_java_instrument_builder_type(metric.instrument) }} create{{metric.metric_name | to_camelcase(True)}}(Meter meter) { | ||
return meter.{{to_java_instrument_builder_factory(metric.instrument)}}("{{ metric.metric_name }}") | ||
.setDescription("{{ metric.brief }}") | ||
.setUnit("{{ metric.unit }}"); | ||
} | ||
{% endfor %} | ||
} | ||
{%endif%} |
92 changes: 92 additions & 0 deletions
92
src/main/java/io/opentelemetry/semconv/v1_23_1/DbMetrics.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.api.semconv; | ||
|
||
import io.opentelemetry.api.metrics.DoubleHistogramBuilder; | ||
import io.opentelemetry.api.metrics.LongCounterBuilder; | ||
import io.opentelemetry.api.metrics.LongUpDownCounterBuilder; | ||
import io.opentelemetry.api.metrics.Meter; | ||
|
||
class DbMetrics { | ||
/** The time it took to create a new connection */ | ||
public static final DoubleHistogramBuilder createDbClientConnectionsCreateTime(Meter meter) { | ||
return meter | ||
.histogramBuilder("db.client.connections.create_time") | ||
.setDescription("The time it took to create a new connection") | ||
.setUnit("ms"); | ||
} | ||
|
||
/** The maximum number of idle open connections allowed */ | ||
public static final LongUpDownCounterBuilder createDbClientConnectionsIdleMax(Meter meter) { | ||
return meter | ||
.upDownCounterBuilder("db.client.connections.idle.max") | ||
.setDescription("The maximum number of idle open connections allowed") | ||
.setUnit("{connection}"); | ||
} | ||
|
||
/** The minimum number of idle open connections allowed */ | ||
public static final LongUpDownCounterBuilder createDbClientConnectionsIdleMin(Meter meter) { | ||
return meter | ||
.upDownCounterBuilder("db.client.connections.idle.min") | ||
.setDescription("The minimum number of idle open connections allowed") | ||
.setUnit("{connection}"); | ||
} | ||
|
||
/** The maximum number of open connections allowed */ | ||
public static final LongUpDownCounterBuilder createDbClientConnectionsMax(Meter meter) { | ||
return meter | ||
.upDownCounterBuilder("db.client.connections.max") | ||
.setDescription("The maximum number of open connections allowed") | ||
.setUnit("{connection}"); | ||
} | ||
|
||
/** The number of pending requests for an open connection, cumulative for the entire pool */ | ||
public static final LongUpDownCounterBuilder createDbClientConnectionsPendingRequests( | ||
Meter meter) { | ||
return meter | ||
.upDownCounterBuilder("db.client.connections.pending_requests") | ||
.setDescription( | ||
"The number of pending requests for an open connection, cumulative for the entire pool") | ||
.setUnit("{request}"); | ||
} | ||
|
||
/** | ||
* The number of connection timeouts that have occurred trying to obtain a connection from the | ||
* pool | ||
*/ | ||
public static final LongCounterBuilder createDbClientConnectionsTimeouts(Meter meter) { | ||
return meter | ||
.counterBuilder("db.client.connections.timeouts") | ||
.setDescription( | ||
"The number of connection timeouts that have occurred trying to obtain a connection from the pool") | ||
.setUnit("{timeout}"); | ||
} | ||
|
||
/** The number of connections that are currently in state described by the `state` attribute */ | ||
public static final LongUpDownCounterBuilder createDbClientConnectionsUsage(Meter meter) { | ||
return meter | ||
.upDownCounterBuilder("db.client.connections.usage") | ||
.setDescription( | ||
"The number of connections that are currently in state described by the `state` attribute") | ||
.setUnit("{connection}"); | ||
} | ||
|
||
/** The time between borrowing a connection and returning it to the pool */ | ||
public static final DoubleHistogramBuilder createDbClientConnectionsUseTime(Meter meter) { | ||
return meter | ||
.histogramBuilder("db.client.connections.use_time") | ||
.setDescription("The time between borrowing a connection and returning it to the pool") | ||
.setUnit("ms"); | ||
} | ||
|
||
/** The time it took to obtain an open connection from the pool */ | ||
public static final DoubleHistogramBuilder createDbClientConnectionsWaitTime(Meter meter) { | ||
return meter | ||
.histogramBuilder("db.client.connections.wait_time") | ||
.setDescription("The time it took to obtain an open connection from the pool") | ||
.setUnit("ms"); | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
src/main/java/io/opentelemetry/semconv/v1_23_1/FaasMetrics.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.api.semconv; | ||
|
||
import io.opentelemetry.api.metrics.DoubleHistogramBuilder; | ||
import io.opentelemetry.api.metrics.LongCounterBuilder; | ||
import io.opentelemetry.api.metrics.Meter; | ||
|
||
class FaasMetrics { | ||
/** Number of invocation cold starts */ | ||
public static final LongCounterBuilder createFaasColdstarts(Meter meter) { | ||
return meter | ||
.counterBuilder("faas.coldstarts") | ||
.setDescription("Number of invocation cold starts") | ||
.setUnit("{coldstart}"); | ||
} | ||
|
||
/** Distribution of CPU usage per invocation */ | ||
public static final DoubleHistogramBuilder createFaasCpuUsage(Meter meter) { | ||
return meter | ||
.histogramBuilder("faas.cpu_usage") | ||
.setDescription("Distribution of CPU usage per invocation") | ||
.setUnit("s"); | ||
} | ||
|
||
/** Number of invocation errors */ | ||
public static final LongCounterBuilder createFaasErrors(Meter meter) { | ||
return meter | ||
.counterBuilder("faas.errors") | ||
.setDescription("Number of invocation errors") | ||
.setUnit("{error}"); | ||
} | ||
|
||
/** Measures the duration of the function's initialization, such as a cold start */ | ||
public static final DoubleHistogramBuilder createFaasInitDuration(Meter meter) { | ||
return meter | ||
.histogramBuilder("faas.init_duration") | ||
.setDescription( | ||
"Measures the duration of the function's initialization, such as a cold start") | ||
.setUnit("s"); | ||
} | ||
|
||
/** Number of successful invocations */ | ||
public static final LongCounterBuilder createFaasInvocations(Meter meter) { | ||
return meter | ||
.counterBuilder("faas.invocations") | ||
.setDescription("Number of successful invocations") | ||
.setUnit("{invocation}"); | ||
} | ||
|
||
/** Measures the duration of the function's logic execution */ | ||
public static final DoubleHistogramBuilder createFaasInvokeDuration(Meter meter) { | ||
return meter | ||
.histogramBuilder("faas.invoke_duration") | ||
.setDescription("Measures the duration of the function's logic execution") | ||
.setUnit("s"); | ||
} | ||
|
||
/** Distribution of max memory usage per invocation */ | ||
public static final DoubleHistogramBuilder createFaasMemUsage(Meter meter) { | ||
return meter | ||
.histogramBuilder("faas.mem_usage") | ||
.setDescription("Distribution of max memory usage per invocation") | ||
.setUnit("By"); | ||
} | ||
|
||
/** Distribution of net I/O usage per invocation */ | ||
public static final DoubleHistogramBuilder createFaasNetIo(Meter meter) { | ||
return meter | ||
.histogramBuilder("faas.net_io") | ||
.setDescription("Distribution of net I/O usage per invocation") | ||
.setUnit("By"); | ||
} | ||
|
||
/** Number of invocation timeouts */ | ||
public static final LongCounterBuilder createFaasTimeouts(Meter meter) { | ||
return meter | ||
.counterBuilder("faas.timeouts") | ||
.setDescription("Number of invocation timeouts") | ||
.setUnit("{timeout}"); | ||
} | ||
} |
Oops, something went wrong.