Skip to content

Commit 7bbffa8

Browse files
committed
updates to span attributes
1 parent 2adaf60 commit 7bbffa8

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

Kotlin-Coroutines_1.4/src/main/java/kotlinx/coroutines/BuildersKt.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,10 @@ public static final kotlinx.coroutines.Job launch(CoroutineScope scope, Coroutin
111111
}
112112
if (name != null) {
113113
NewRelic.getAgent().getTracedMethod().setMetricName("Custom", "Builders", "launch", name);
114+
NewRelic.getAgent().getTracedMethod().addCustomAttribute("CoroutineName", name);
114115
} else {
115116
NewRelic.getAgent().getTracedMethod().setMetricName("Custom", "Builders", "launch");
117+
NewRelic.getAgent().getTracedMethod().addCustomAttribute("CoroutineName", "Could not determine");
116118
}
117119
NewRelic.getAgent().getTracedMethod().addCustomAttribute("Block", block.toString());
118120
Token token = Utils.getToken(context);

Kotlin-Coroutines_1.5/src/main/java/kotlinx/coroutines/BuildersKt.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ public static final <T> T runBlocking(CoroutineContext context, Function2<? supe
3434
String name = Utils.getCoroutineName(context);
3535
if(name != null) {
3636
NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Builders","runBlocking",name);
37+
NewRelic.getAgent().getTracedMethod().addCustomAttribute("CoroutineName", name);
3738
} else {
3839
NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Builders","runBlocking");
40+
NewRelic.getAgent().getTracedMethod().addCustomAttribute("CoroutineName", "Could not determine");
3941
}
4042
NewRelic.getAgent().getTracedMethod().addCustomAttribute("Block", block.toString());
4143

@@ -50,14 +52,18 @@ public static final <T> T runBlocking(CoroutineContext context, Function2<? supe
5052
@Trace(dispatcher = true)
5153
public static final <T> Deferred<T> async(CoroutineScope scope, CoroutineContext context, CoroutineStart cStart, Function2<? super CoroutineScope, ? super Continuation<? super T>, ? extends Object> block) {
5254
if (!Utils.ignoreScope(scope)) {
55+
NewRelic.getAgent().getTracedMethod().addCustomAttribute("CoroutineStart", cStart.name());
56+
NewRelic.getAgent().getTracedMethod().addCustomAttribute("CoroutineScope-Class", scope.getClass().getName());
5357
String name = Utils.getCoroutineName(context);
5458
if(name == null) {
5559
name = Utils.getCoroutineName(scope.getCoroutineContext());
5660
}
5761
if(name != null) {
5862
NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Builders","async",name);
63+
NewRelic.getAgent().getTracedMethod().addCustomAttribute("CoroutineName", name);
5964
} else {
6065
NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Builders","async");
66+
NewRelic.getAgent().getTracedMethod().addCustomAttribute("CoroutineName", "Could not determine");
6167
}
6268

6369
Token token = Utils.getToken(context);
@@ -111,8 +117,10 @@ public static final kotlinx.coroutines.Job launch(CoroutineScope scope, Coroutin
111117
}
112118
if (name != null) {
113119
NewRelic.getAgent().getTracedMethod().setMetricName("Custom", "Builders", "launch", name);
120+
NewRelic.getAgent().getTracedMethod().addCustomAttribute("CoroutineName", name);
114121
} else {
115122
NewRelic.getAgent().getTracedMethod().setMetricName("Custom", "Builders", "launch");
123+
NewRelic.getAgent().getTracedMethod().addCustomAttribute("CoroutineName", "Could not determine");
116124
}
117125
NewRelic.getAgent().getTracedMethod().addCustomAttribute("Block", block.toString());
118126
Token token = Utils.getToken(context);

Kotlin-Coroutines_1.7/src/main/java/kotlinx/coroutines/BuildersKt.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,18 @@ public static final <T> T runBlocking(CoroutineContext context, Function2<? supe
5050
@Trace(dispatcher = true)
5151
public static final <T> Deferred<T> async(CoroutineScope scope, CoroutineContext context, CoroutineStart cStart, Function2<? super CoroutineScope, ? super Continuation<? super T>, ? extends Object> block) {
5252
if (!Utils.ignoreScope(scope)) {
53+
NewRelic.getAgent().getTracedMethod().addCustomAttribute("CoroutineStart", cStart.name());
54+
NewRelic.getAgent().getTracedMethod().addCustomAttribute("CoroutineScope-Class", scope.getClass().getName());
5355
String name = Utils.getCoroutineName(context);
5456
if(name == null) {
5557
name = Utils.getCoroutineName(scope.getCoroutineContext());
5658
}
5759
if(name != null) {
5860
NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Builders","async",name);
61+
NewRelic.getAgent().getTracedMethod().addCustomAttribute("CoroutineName", name);
5962
} else {
6063
NewRelic.getAgent().getTracedMethod().setMetricName("Custom","Builders","async");
64+
NewRelic.getAgent().getTracedMethod().addCustomAttribute("CoroutineName", "Could not determine");
6165
}
6266

6367
Token token = Utils.getToken(context);
@@ -111,8 +115,10 @@ public static final kotlinx.coroutines.Job launch(CoroutineScope scope, Coroutin
111115
}
112116
if (name != null) {
113117
NewRelic.getAgent().getTracedMethod().setMetricName("Custom", "Builders", "launch", name);
118+
NewRelic.getAgent().getTracedMethod().addCustomAttribute("CoroutineName", name);
114119
} else {
115120
NewRelic.getAgent().getTracedMethod().setMetricName("Custom", "Builders", "launch");
121+
NewRelic.getAgent().getTracedMethod().addCustomAttribute("CoroutineName", "Could not determine");
116122
}
117123
NewRelic.getAgent().getTracedMethod().addCustomAttribute("Block", block.toString());
118124
Token token = Utils.getToken(context);

0 commit comments

Comments
 (0)