Skip to content

Commit 45f76f7

Browse files
committed
SF-5575 - adding in tracked function attributes to trace annotation
1 parent 19ac800 commit 45f76f7

File tree

3 files changed

+53
-13
lines changed

3 files changed

+53
-13
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
.project
33
.settings
44
target
5-
coverage.ec
5+
coverage.ec
6+
.idea
7+
*.iml

README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,17 @@ Add it as a maven dependency:
2626

2727
## Usage
2828

29-
Add custom instrumentation to classes using the @Trace annotation. The annotation needs to be added to the class and the method to be instrumented. This is an alternative to adding a custom configuration file (stackify-apm.json) to your application.
29+
Add custom instrumentation to classes using the @Trace annotation. The annotation needs to be added to
30+
the class and the method to be instrumented. This is an alternative to adding a custom configuration
31+
file (stackify-apm.json) to your application.
32+
33+
34+
#### Tracked Functions
35+
* **trackedFunction** marks a specific method as a tracked function.
36+
* **trackedFunctionName** gives control over how the tracked function will be identified in the dashboard. The function
37+
name can be a `String` and can also include the variables `{{ClassName}}`, `{{MethodName}}` and `{{MethodParameters[#]}}`
38+
(where `#` is an `int` referencing the parameter index on the annotated method, index starts at 0).
39+
3040

3141
```
3242
import com.stackify.apm.Trace;
@@ -45,7 +55,19 @@ public class ClassToBeInstrumented
4555
{
4656
...
4757
}
48-
58+
59+
@Trace(trackedFunction = true, trackedFunctionName = "Tracked Function Identifier")
60+
public void anotherMethodToBeInstrumentedAndMarkedAsTrackedFunction()
61+
{
62+
...
63+
}
64+
65+
@Trace(trackedFunction = true, trackedFunctionName = "Tracked Function {{ClassName}} - {{MethodParameters[0]}}")
66+
public void anotherMethodToBeInstrumentedAndMarkedAsTrackedFunctionVariable(String value)
67+
{
68+
...
69+
}
70+
4971
public void notInstrumented()
5072
{
5173
...

src/main/java/com/stackify/apm/Trace.java

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,43 +22,59 @@
2222

2323
/**
2424
* Trace Annotation for Stackify Java APM+
25-
*
2625
* <p>
27-
* Add custom instrumentation to classes using the @Trace annotation. The annotation
28-
* needs to be added to the class and the method to be instrumented. This is an
29-
* alternative to adding a custom configuration file (stackify-apm.json) to your
26+
* Add custom instrumentation to classes using the @Trace annotation. The annotation
27+
* needs to be added to the class and the method to be instrumented. This is an
28+
* alternative to adding a custom configuration file (stackify-apm.json) to your
3029
* application.
31-
*
30+
* <p>
3231
* <pre>
3332
* <code>
3433
* import com.stackify.apm.Trace;
35-
*
34+
*
3635
* {@literal @}Trace
37-
* public class ClassToBeInstrumented
36+
* public class ClassToBeInstrumented
3837
* {
3938
* {@literal @}Trace
4039
* public void methodToBeInstrumented()
4140
* {
4241
* ...
4342
* }
44-
*
43+
*
4544
* {@literal @}Trace
4645
* public void anotherMethodToBeInstrumented()
4746
* {
4847
* ...
4948
* }
50-
*
49+
*
50+
* {@literal @}Trace(trackedFunction = true, trackedFunctionName = "Function Identifier")
51+
* public void anotherMethodToBeInstrumentedAndMarkedAsTrackedFunction()
52+
* {
53+
* ...
54+
* }
55+
*
56+
* {@literal @}Trace(trackedFunction = true, trackedFunctionName = "Tracked Function {{ClassName}} - {{MethodParameters[0]}}")
57+
* public void anotherMethodToBeInstrumentedAndMarkedAsTrackedFunctionVariable(String value)
58+
* {
59+
* ...
60+
* }
61+
*
5162
* public void notInstrumented()
5263
* {
5364
* ...
5465
* }
5566
* }
56-
* </code>
67+
* </code>
5768
* </pre>
5869
*
5970
* @author Eric Martin
6071
*/
6172
@Retention(value = RetentionPolicy.RUNTIME)
6273
@Target(value = {ElementType.TYPE, ElementType.METHOD})
6374
public @interface Trace {
75+
76+
boolean trackedFunction() default false;
77+
78+
String trackedFunctionName() default "";
79+
6480
}

0 commit comments

Comments
 (0)