Skip to content

Support enum and array based attributes in codegen#1898

Open
bidetofevil wants to merge 3 commits into
open-telemetry:mainfrom
bidetofevil:hho/enum-attribute-values
Open

Support enum and array based attributes in codegen#1898
bidetofevil wants to merge 3 commits into
open-telemetry:mainfrom
bidetofevil:hho/enum-attribute-values

Conversation

@bidetofevil

Copy link
Copy Markdown
Contributor

Fixed attribute templates to work with enum and array-based attribute values. Add in some codegen to create enums and then changed a few internal semconv to use them.

Copilot AI review requested due to automatic review settings July 15, 2026 06:02
@bidetofevil bidetofevil requested a review from a team as a code owner July 15, 2026 06:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Kotlin semantic-convention codegen templates to support enum-typed attributes (and prepares support for array-typed attributes), then switches a few Android internal semantic conventions and instrumentations to use the generated enums instead of hard-coded strings.

Changes:

  • Update Kotlin weaver/codegen templates to (a) skip any-typed event attributes, (b) generate AttributeKey constants for array types, and (c) generate enum “Values” types for enum attributes.
  • Update the Android semconv registry to express screen.orientation, start.type, and websocket.message.type as enums.
  • Update instrumentation code to use the generated enum values (e.g., StartTypeValues.COLD.value) instead of string literals.

PR Merge Tier: Tier 3 (build/codegen changes + cross-module behavior wiring)

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
semconv/templates/registry/kotlin/weaver.yaml Adds type mappings for array AttributeKey generation and filters out any-typed event attributes.
semconv/templates/registry/kotlin/kotlin_semconv_template.kt.j2 Generates AttributeKey fields for array types and emits enum value classes for enum attributes.
semconv/templates/registry/kotlin/kotlin_event_template.kt.j2 Adds array-attribute handling via AttributeKey.*ArrayKey(...) when emitting event attributes.
semconv/model/android/registry.yaml Converts several attributes from string to enum definitions with members.
instrumentation/screen-orientation/.../ScreenOrientationDetector.kt Uses generated ScreenOrientationValues instead of hard-coded orientation strings.
instrumentation/okhttp3-websocket/.../WebsocketListenerWrapper.kt Uses generated WebsocketMessageTypeValues instead of hard-coded message type strings.
instrumentation/activity/.../AppStartupTimer.kt Uses generated StartTypeValues.COLD.value instead of "cold".
instrumentation/activity/.../ActivityTracer.kt Uses generated StartTypeValues.{WARM,HOT}.value instead of "warm"/"hot".

Comment on lines 7 to 11
package io.opentelemetry.android.semconv.events

import io.opentelemetry.api.common.AttributeKey
import io.opentelemetry.api.common.Attributes
import io.opentelemetry.api.logs.Logger

@LikeTheSalad LikeTheSalad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I think it's worth checking the comment from Copilot, but overall LGTM.

@fractalwrench fractalwrench left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants