Skip to content

Commit

Permalink
Merge pull request #869 from typelevel/update/opentelemetry-semconv-1…
Browse files Browse the repository at this point in the history
….29.0-alpha

Update opentelemetry-semconv to 1.29.0-alpha
  • Loading branch information
iRevive authored Dec 19, 2024
2 parents b71f939 + 76464b7 commit bed8e48
Show file tree
Hide file tree
Showing 42 changed files with 2,136 additions and 544 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ val MUnitScalaCheckEffectVersion = "2.0.0-M2"
val OpenTelemetryVersion = "1.45.0"
val OpenTelemetryInstrumentationVersion = "2.10.0"
val OpenTelemetryInstrumentationAlphaVersion = "2.10.0-alpha"
val OpenTelemetrySemConvVersion = "1.28.0-alpha"
val OpenTelemetrySemConvVersion = "1.29.0-alpha"
val OpenTelemetryProtoVersion = "1.4.0-alpha"
val PekkoStreamVersion = "1.1.2"
val PekkoHttpVersion = "1.1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
{%- endmacro -%}

{%- macro stability(type) -%}
{%- if type == "experimental" -%} Stability.experimental
{%- if type == "development" -%} Stability.development
{%- elif not type -%} Stability.development
{%- elif type == "stable" -%} Stability.stable
{%- else -%} _unknown_stability_type_{{ type }}
{%- endif -%}
Expand All @@ -68,7 +69,11 @@
{%- elif type == "double" -%} {{ input }}
{%- elif type == "boolean" -%} {{ input }}
{%- elif type == "string" -%} "{{ input }}"
{%- else -%} _unknown type_{{ input }}
{%- elif type == "int[]" -%} Seq({{ input | join(', ') }})
{%- elif type == "double[]" -%} Seq({{ input | join(', ') }})
{%- elif type == "boolean[]" -%} Seq({{ input | join(', ') }})
{%- elif type == "string[]" -%} Seq({{ input | map('tojson') | join(', ') }})
{%- else -%} _unknown type_{{ type }}_{{ input }}
{%- endif -%}
{% endmacro %}

Expand Down Expand Up @@ -132,7 +137,7 @@ import org.typelevel.otel4s.metrics._
{%- if required_imports.stable == true %}
import org.typelevel.otel4s.semconv.attributes._
{%- endif %}
{%- if required_imports.experimental == true %}
{%- if required_imports.experimental == true and params.experimental == true %}
import org.typelevel.otel4s.semconv.experimental.attributes._
{%- endif %}

Expand Down Expand Up @@ -161,16 +166,20 @@ object {{ object_name }} {
@deprecated("Use stable `{{ stableRef(metric) }}` instead.", "")
{%- endif %}
object {{ objectName(metric) }} extends MetricSpec {

{%- if params.experimental == true -%}
{%- set metric_attributes = metric.attributes %}
{% else %}
{%- set metric_attributes = metric.attributes | selectattr("stability", "equalto", "stable") | list %}
{% endif %}
val name: String = "{{ metric.metric_name }}"
val description: String = "{{ metric.brief }}"
val unit: String = "{{ metric.unit }}"
val stability: Stability = {{ stability(metric.stability) }}
val attributeSpecs: List[AttributeSpec[_]] = {% if metric.attributes | length > 0 %}AttributeSpecs.specs{% else %}Nil{% endif %}
val attributeSpecs: List[AttributeSpec[_]] = {% if metric_attributes | length > 0 %}AttributeSpecs.specs{% else %}Nil{% endif %}

{% if metric.attributes | length > 0 %}
{% if metric_attributes | length > 0 %}
object AttributeSpecs {
{% for attribute in metric.attributes | sort(attribute='name') %}
{% for attribute in metric_attributes | sort(attribute='name') %}
{{ [attribute.brief, concat_if("\n\n@note\n\n", attribute.note)] | comment(indent=6) | replace('$', "$$")}}
{%- if attribute is deprecated %}
@deprecated("{{ attribute.deprecated }}", "")
Expand All @@ -186,7 +195,7 @@ object {{ object_name }} {
)
{% endfor %}
val specs: List[AttributeSpec[_]] =
List({%- for attribute in metric.attributes | sort(attribute='name') %}
List({%- for attribute in metric_attributes | sort(attribute='name') %}
{{ attribute.name | camel_case }},{% endfor %}
)
}
Expand Down
2 changes: 1 addition & 1 deletion project/SemanticConventionsGenerator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import scala.sys.process._

object SemanticConventionsGenerator {

private val generatorVersion = "v0.9.1"
private val generatorVersion = "v0.12.0"

// generates semantic conventions by using `otel/weaver` in docker
def generate(version: String, rootDir: File): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ object AwsExperimentalAttributes {
* @note
* <p> The `copy_source` attribute applies to S3 copy operations and corresponds to the `--copy-source` parameter
* of the <a href="https://docs.aws.amazon.com/cli/latest/reference/s3api/copy-object.html">copy-object operation
* within the S3 API</a>. This applies in particular to the following operations: <p> <ul> <li><a
* within the S3 API</a>. This applies in particular to the following operations: <ul> <li><a
* href="https://docs.aws.amazon.com/cli/latest/reference/s3api/copy-object.html">copy-object</a> <li><a
* href="https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part-copy.html">upload-part-copy</a> </ul>
*/
Expand All @@ -257,7 +257,7 @@ object AwsExperimentalAttributes {
* href="https://docs.aws.amazon.com/cli/latest/reference/s3api/index.html">S3 API</a> operations. <p>
* @note
* <p> The `key` attribute is applicable to all object-related S3 operations, i.e. that require the object key as a
* mandatory parameter. This applies in particular to the following operations: <p> <ul> <li><a
* mandatory parameter. This applies in particular to the following operations: <ul> <li><a
* href="https://docs.aws.amazon.com/cli/latest/reference/s3api/copy-object.html">copy-object</a> <li><a
* href="https://docs.aws.amazon.com/cli/latest/reference/s3api/delete-object.html">delete-object</a> <li><a
* href="https://docs.aws.amazon.com/cli/latest/reference/s3api/get-object.html">get-object</a> <li><a
Expand Down Expand Up @@ -295,7 +295,7 @@ object AwsExperimentalAttributes {
* @note
* <p> The `upload_id` attribute applies to S3 multipart-upload operations and corresponds to the `--upload-id`
* parameter of the <a href="https://docs.aws.amazon.com/cli/latest/reference/s3api/index.html">S3 API</a>
* multipart operations. This applies in particular to the following operations: <p> <ul> <li><a
* multipart operations. This applies in particular to the following operations: <ul> <li><a
* href="https://docs.aws.amazon.com/cli/latest/reference/s3api/abort-multipart-upload.html">abort-multipart-upload</a>
* <li><a
* href="https://docs.aws.amazon.com/cli/latest/reference/s3api/complete-multipart-upload.html">complete-multipart-upload</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ object CicdExperimentalAttributes {
AttributeKey("cicd.pipeline.run.id")

/** The human readable name of a task within a pipeline. Task here most closely aligns with a <a
* href="https://en.wikipedia.org/wiki/Pipeline_(computing)">computing process</a> in a pipeline. Other terms for
* tasks include commands, steps, and procedures.
* href="https://wikipedia.org/wiki/Pipeline_(computing)">computing process</a> in a pipeline. Other terms for tasks
* include commands, steps, and procedures.
*/
val CicdPipelineTaskName: AttributeKey[String] =
AttributeKey("cicd.pipeline.task.name")
Expand All @@ -43,8 +43,8 @@ object CicdExperimentalAttributes {
val CicdPipelineTaskRunId: AttributeKey[String] =
AttributeKey("cicd.pipeline.task.run.id")

/** The <a href="https://en.wikipedia.org/wiki/URL">URL</a> of the pipeline run providing the complete address in
* order to locate and identify the pipeline run.
/** The <a href="https://wikipedia.org/wiki/URL">URL</a> of the pipeline run providing the complete address in order
* to locate and identify the pipeline run.
*/
val CicdPipelineTaskRunUrlFull: AttributeKey[String] =
AttributeKey("cicd.pipeline.task.run.url.full")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ object CloudExperimentalAttributes {
* <p> On some cloud providers, it may not be possible to determine the full ID at startup, so it may be necessary
* to set `cloud.resource_id` as a span attribute instead. <p> The exact value to use for `cloud.resource_id`
* depends on the cloud provider. The following well-known definitions MUST be used if you set this attribute and
* they apply: <p> <ul> <li><strong>AWS Lambda:</strong> The function <a
* they apply: <ul> <li><strong>AWS Lambda:</strong> The function <a
* href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">ARN</a>. Take care not to use
* the "invoked ARN" directly but replace any <a
* href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html">alias suffix</a> with the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ object CloudfoundryExperimentalAttributes {
/** The index of the application instance. 0 when just one instance is active. <p>
* @note
* <p> CloudFoundry defines the `instance_id` in the <a
* href="https://github.com/cloudfoundry/loggregator-api#v2-envelope">Loggegator v2 envelope</a>. It is used for
* href="https://github.com/cloudfoundry/loggregator-api#v2-envelope">Loggregator v2 envelope</a>. It is used for
* logs and metrics emitted by CloudFoundry. It is supposed to contain the application instance index for
* applications deployed on the runtime. <p> Application instrumentation should use the value from environment
* variable `CF_INSTANCE_INDEX`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,9 @@ object DbExperimentalAttributes {
/** The name of a collection (table, container) within the database. <p>
* @note
* <p> It is RECOMMENDED to capture the value as provided by the application without attempting to do any case
* normalization. If the collection name is parsed from the query text, it SHOULD be the first collection name
* found in the query and it SHOULD match the value provided in the query text including any schema and database
* name prefix. For batch operations, if the individual operations are known to have the same collection name then
* that collection name SHOULD be used, otherwise `db.collection.name` SHOULD NOT be captured. This attribute has
* normalization. <p> The collection name SHOULD NOT be extracted from `db.query.text`, unless the query format is
* known to only ever have a single collection name present. <p> For batch operations, if the individual operations
* are known to have the same collection name then that collection name SHOULD be used. <p> This attribute has
* stability level RELEASE CANDIDATE.
*/
val DbCollectionName: AttributeKey[String] =
Expand All @@ -113,23 +112,39 @@ object DbExperimentalAttributes {
val DbCosmosdbConnectionMode: AttributeKey[String] =
AttributeKey("db.cosmosdb.connection_mode")

/** Account or request <a href="https://learn.microsoft.com/azure/cosmos-db/consistency-levels">consistency level</a>.
*/
val DbCosmosdbConsistencyLevel: AttributeKey[String] =
AttributeKey("db.cosmosdb.consistency_level")

/** Deprecated, use `db.collection.name` instead.
*/
@deprecated("Replaced by `db.collection.name`.", "")
val DbCosmosdbContainer: AttributeKey[String] =
AttributeKey("db.cosmosdb.container")

/** Cosmos DB Operation Type.
/** Deprecated, no replacement at this time.
*/
@deprecated("No replacement at this time.", "")
val DbCosmosdbOperationType: AttributeKey[String] =
AttributeKey("db.cosmosdb.operation_type")

/** RU consumed for that operation
/** List of regions contacted during operation in the order that they were contacted. If there is more than one region
* listed, it indicates that the operation was performed on multiple regions i.e. cross-regional call. <p>
* @note
* <p> Region name matches the format of `displayName` in <a
* href="https://learn.microsoft.com/rest/api/subscription/subscriptions/list-locations?view=rest-subscription-2021-10-01&tabs=HTTP#location">Azure
* Location API</a>
*/
val DbCosmosdbRegionsContacted: AttributeKey[Seq[String]] =
AttributeKey("db.cosmosdb.regions_contacted")

/** Request units consumed for the operation.
*/
val DbCosmosdbRequestCharge: AttributeKey[Double] =
AttributeKey("db.cosmosdb.request_charge")

/** Request payload size in bytes
/** Request payload size in bytes.
*/
val DbCosmosdbRequestContentLength: AttributeKey[Long] =
AttributeKey("db.cosmosdb.request_content_length")
Expand Down Expand Up @@ -230,25 +245,44 @@ object DbExperimentalAttributes {
/** The name of the operation or command being executed. <p>
* @note
* <p> It is RECOMMENDED to capture the value as provided by the application without attempting to do any case
* normalization. If the operation name is parsed from the query text, it SHOULD be the first operation name found
* in the query. For batch operations, if the individual operations are known to have the same operation name then
* that operation name SHOULD be used prepended by `BATCH `, otherwise `db.operation.name` SHOULD be `BATCH` or
* some other database system specific term if more applicable. This attribute has stability level RELEASE
* CANDIDATE.
* normalization. <p> The operation name SHOULD NOT be extracted from `db.query.text`, unless the query format is
* known to only ever have a single operation name present. <p> For batch operations, if the individual operations
* are known to have the same operation name then that operation name SHOULD be used prepended by `BATCH `,
* otherwise `db.operation.name` SHOULD be `BATCH` or some other database system specific term if more applicable.
* <p> This attribute has stability level RELEASE CANDIDATE.
*/
val DbOperationName: AttributeKey[String] =
AttributeKey("db.operation.name")

/** A query parameter used in `db.query.text`, with `<key>` being the parameter name, and the attribute value being a
* string representation of the parameter value. <p>
/** A database operation parameter, with `<key>` being the parameter name, and the attribute value being a string
* representation of the parameter value. <p>
* @note
* <p> Query parameters should only be captured when `db.query.text` is parameterized with placeholders. If a
* parameter has no name and instead is referenced only by index, then `<key>` SHOULD be the 0-based index. This
* attribute has stability level RELEASE CANDIDATE.
* <p> If a parameter has no name and instead is referenced only by index, then `<key>` SHOULD be the 0-based
* index. If `db.query.text` is also captured, then `db.operation.parameter.<key>` SHOULD match up with the
* parameterized placeholders present in `db.query.text`. This attribute has stability level RELEASE CANDIDATE.
*/
val DbOperationParameter: AttributeKey[String] =
AttributeKey("db.operation.parameter")

/** A query parameter used in `db.query.text`, with `<key>` being the parameter name, and the attribute value being a
* string representation of the parameter value.
*/
@deprecated("Replaced by `db.operation.parameter`.", "")
val DbQueryParameter: AttributeKey[String] =
AttributeKey("db.query.parameter")

/** Low cardinality representation of a database query text. <p>
* @note
* <p> `db.query.summary` provides static summary of the query text. It describes a class of database queries and
* is useful as a grouping key, especially when analyzing telemetry for database calls involving complex queries.
* Summary may be available to the instrumentation through instrumentation hooks or other means. If it is not
* available, instrumentations that support query parsing SHOULD generate a summary following <a
* href="../../docs/database/database-spans.md#generating-a-summary-of-the-query-text">Generating query summary</a>
* section. This attribute has stability level RELEASE CANDIDATE.
*/
val DbQuerySummary: AttributeKey[String] =
AttributeKey("db.query.summary")

/** The database query being executed. <p>
* @note
* <p> For sanitization see <a
Expand All @@ -269,6 +303,11 @@ object DbExperimentalAttributes {
val DbRedisDatabaseIndex: AttributeKey[Long] =
AttributeKey("db.redis.database_index")

/** Number of rows returned by the operation.
*/
val DbResponseReturnedRows: AttributeKey[Long] =
AttributeKey("db.response.returned_rows")

/** Database response status code. <p>
* @note
* <p> The status code returned by the database. Usually it represents an error code, but may also represent
Expand Down Expand Up @@ -391,7 +430,7 @@ object DbExperimentalAttributes {
abstract class DbCosmosdbConnectionModeValue(val value: String)
object DbCosmosdbConnectionModeValue {

/** Gateway (HTTP) connections mode
/** Gateway (HTTP) connection.
*/
case object Gateway extends DbCosmosdbConnectionModeValue("gateway")

Expand All @@ -400,9 +439,37 @@ object DbExperimentalAttributes {
case object Direct extends DbCosmosdbConnectionModeValue("direct")
}

/** Values for [[DbCosmosdbConsistencyLevel]].
*/
abstract class DbCosmosdbConsistencyLevelValue(val value: String)
object DbCosmosdbConsistencyLevelValue {

/** strong.
*/
case object Strong extends DbCosmosdbConsistencyLevelValue("Strong")

/** bounded_staleness.
*/
case object BoundedStaleness extends DbCosmosdbConsistencyLevelValue("BoundedStaleness")

/** session.
*/
case object Session extends DbCosmosdbConsistencyLevelValue("Session")

/** eventual.
*/
case object Eventual extends DbCosmosdbConsistencyLevelValue("Eventual")

/** consistent_prefix.
*/
case object ConsistentPrefix extends DbCosmosdbConsistencyLevelValue("ConsistentPrefix")
}

/** Values for [[DbCosmosdbOperationType]].
*/
@deprecated("No replacement at this time.", "")
abstract class DbCosmosdbOperationTypeValue(val value: String)
@annotation.nowarn("cat=deprecation")
object DbCosmosdbOperationTypeValue {

/** batch.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ object DeploymentExperimentalAttributes {
* @note
* <p> `deployment.environment.name` does not affect the uniqueness constraints defined through the
* `service.namespace`, `service.name` and `service.instance.id` resource attributes. This implies that resources
* carrying the following attribute combinations MUST be considered to be identifying the same service: <p> <ul>
* carrying the following attribute combinations MUST be considered to be identifying the same service: <ul>
* <li>`service.name=frontend`, `deployment.environment.name=production` <li>`service.name=frontend`,
* `deployment.environment.name=staging`. </ul>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ object ErrorExperimentalAttributes {
* instrumentation libraries and applications should be prepared for `error.type` to have high cardinality at query
* time when no additional filters are applied. <p> If the operation has completed successfully, instrumentations
* SHOULD NOT set `error.type`. <p> If a specific domain defines its own set of error identifiers (such as HTTP or
* gRPC status codes), it's RECOMMENDED to: <p> <ul> <li>Use a domain-specific attribute <li>Set `error.type` to
* gRPC status codes), it's RECOMMENDED to: <ul> <li>Use a domain-specific attribute <li>Set `error.type` to
* capture all errors, regardless of whether they are defined within the domain-specific set or not. </ul>
*/
@deprecated(
Expand Down
Loading

0 comments on commit bed8e48

Please sign in to comment.