-
Notifications
You must be signed in to change notification settings - Fork 872
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add code attributes to spring-scheduling spans (#5306)
- Loading branch information
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
.../javaagent/instrumentation/spring/scheduling/SpringSchedulingCodeAttributesExtractor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.spring.scheduling; | ||
|
||
import io.opentelemetry.instrumentation.api.instrumenter.code.CodeAttributesExtractor; | ||
import javax.annotation.Nullable; | ||
import org.springframework.scheduling.support.ScheduledMethodRunnable; | ||
|
||
public class SpringSchedulingCodeAttributesExtractor | ||
extends CodeAttributesExtractor<Runnable, Void> { | ||
|
||
@Override | ||
protected Class<?> codeClass(Runnable runnable) { | ||
if (runnable instanceof ScheduledMethodRunnable) { | ||
ScheduledMethodRunnable scheduledMethodRunnable = (ScheduledMethodRunnable) runnable; | ||
return scheduledMethodRunnable.getTarget().getClass(); | ||
} else { | ||
return runnable.getClass(); | ||
} | ||
} | ||
|
||
@Override | ||
protected String methodName(Runnable runnable) { | ||
if (runnable instanceof ScheduledMethodRunnable) { | ||
ScheduledMethodRunnable scheduledMethodRunnable = (ScheduledMethodRunnable) runnable; | ||
return scheduledMethodRunnable.getMethod().getName(); | ||
} else { | ||
return "run"; | ||
} | ||
} | ||
|
||
@Override | ||
@Nullable | ||
protected String filePath(Runnable runnable) { | ||
return null; | ||
} | ||
|
||
@Override | ||
@Nullable | ||
protected Long lineNumber(Runnable runnable) { | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters