Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lwc-events: support enums as tag values #1652

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ trait LwcEvent {
*/
def tagValue(key: String): String = {
extractValue(key) match {
case v: String => v
case _ => null
case v: String => v
case e: Enum[_] => e.name()
case _ => null
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package com.netflix.atlas.lwc.events
import com.netflix.atlas.core.util.SortedTagMap
import munit.FunSuite

import java.lang.System.Logger

class LwcEventSuite extends FunSuite {

import LwcEventSuite.*
Expand All @@ -33,6 +35,10 @@ class LwcEventSuite extends FunSuite {
assertEquals(sampleLwcEvent.tagValue("node"), "i-123")
}

test("tagValue: enum") {
assertEquals(sampleLwcEvent.tagValue("level"), "TRACE")
}

test("tagValue: missing") {
assertEquals(sampleLwcEvent.tagValue("foo"), null)
}
Expand Down Expand Up @@ -80,6 +86,7 @@ object LwcEventSuite {
key match {
case "tags" => span.tags
case "duration" => span.duration
case "level" => Logger.Level.TRACE
case k => span.tags.getOrElse(k, null)
}
}
Expand Down
Loading