Skip to content

Commit b100c4e

Browse files
committed
Update to latest and generate enum for attributes with fixed values
1 parent 8e096a8 commit b100c4e

7 files changed

Lines changed: 30 additions & 6 deletions

File tree

android-agent/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ dependencies {
3131
implementation(project(":instrumentation:screen-orientation"))
3232

3333
testImplementation(libs.opentelemetry.semconv.kotlin)
34+
testImplementation(project(":semconv"))
3435
testImplementation(libs.robolectric)
3536
testImplementation(libs.okhttp.mockwebserver)
3637
testImplementation(libs.androidx.test.core)

android-agent/src/test/kotlin/io/opentelemetry/android/agent/EndUserClientSemConvTest.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55

66
package io.opentelemetry.android.agent
77

8-
import io.opentelemetry.kotlin.semconv.AppAttributes
9-
import io.opentelemetry.kotlin.semconv.IncubatingApi
8+
import io.opentelemetry.android.semconv.AppAttributes
109
import org.assertj.core.api.Assertions.assertThat
1110
import org.junit.Test
1211

13-
@OptIn(IncubatingApi::class)
1412
class EndUserClientSemConvTest {
1513
@Test
1614
fun `constants generated from the end-user-client registry are usable`() {

build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ allprojects {
2626
repositories {
2727
google()
2828
mavenCentral()
29-
mavenLocal()
3029
}
3130
}
3231

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
opentelemetry-instrumentation-alpha = "2.29.0-alpha"
33
#opentelemetry-instrumentation = "2.9.0" // alpha bom includes non-alpha bom
44
opentelemetry-contrib = "1.58.0-alpha"
5-
opentelemetry-semconv-kotlin = "0.6.0-SNAPSHOT"
5+
opentelemetry-semconv-kotlin = "0.5.0"
66
junit = "6.1.1"
77
byteBuddy = "1.18.11"
88
okhttp = "5.4.0"

semconv/model/android/registry.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# Imports the end-user-client registry's `app` attributes and events so Kotlin constants are
2+
# generated for them in this module (constants for imported attributes are only generated for
3+
# groups that are part of this registry). Attribute group entries match the public attribute
4+
# group ids the end-user-client registry declares; event entries match event names directly.
5+
imports:
6+
attribute_groups:
7+
- registry.end_user_client.app
8+
events:
9+
- app.nav_complete
110
groups:
211
- id: registry.android.semconv
312
type: attribute_group

semconv/model/manifest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ dependencies:
55
- name: otel
66
registry_path: https://github.com/open-telemetry/semantic-conventions@v1.43.0[model]
77
- name: end-user-client
8-
registry_path: https://github.com/bidetofevil/semantic-conventions-end-user-client@v0.2.0-dev[model]
8+
registry_path: https://github.com/bidetofevil/semantic-conventions-end-user-client@v0.3.0-dev[model]

semconv/templates/registry/kotlin/kotlin_semconv_template.kt.j2

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,21 @@ object {{ my_class_name }} {
2020
{%- endif %}
2121
const val {{ attribute.name | screaming_snake_case }}: String = "{{ attribute.name }}"
2222
{%- endfor %}
23+
{%- for attribute in ctx.attributes | rejectattr("name", "in", ctx.excluded_attributes) %}
24+
{%- if attribute is enum %}
25+
26+
{{ ("Values for " ~ (attribute.name | screaming_snake_case) ~ ".") | comment | trim | indent(4) -}}
27+
{%- if attribute is deprecated %}
28+
@Deprecated("{{ attribute.deprecated.note | replace('\n', ' ') | trim }}")
29+
{%- endif %}
30+
enum class {{ attribute.name | pascal_case }}Values(
31+
val value: {{ attribute.type | instantiated_type | map_text("kotlin_enum_type") }},
32+
) {
33+
{%- for member in attribute.type.members %}
34+
{{ "\n" if not loop.first }} {{ [member.brief or (member.id ~ '.')] | comment | trim | indent(8) }}
35+
{{ member.id | screaming_snake_case }}({{ member.value | print_member_value }}),
36+
{%- endfor %}
37+
}
38+
{%- endif %}
39+
{%- endfor %}
2340
}

0 commit comments

Comments
 (0)