ThundraTracer
, which is retrieved from io.thundra.agent.trace.TraceSupport
, you can create your own custom spans. In the following example, we show how to create a custom span to instrument user operation.@Traceable
annotation – they must be marked with this annotation. The class level @Traceable
annotation is mandatory; if not marked with the annotation, classes won’t be checked or traced. Additionally, methods can be marked with this annotation as well.get
method is traced automatically.getFromCache
and getFromRepository
methods are traced in addition to the get
method.justMarker
property and annotate the desired method with the method level @Traceable
annotation.get
method is traced because the class level @Traceable annotation is marked and only the get
method is annotated.thundra_agent_trace_instrument_traceableConfig*
format, meaning a name must start with the thundra_agent_trace_instrument_traceableConfig
. For example, thundra_agent_trace_instrument_traceableConfig
, thundra_agent_trace_instrument_traceableConfig1
, thundra_audit_auditableDefx
, etc.<class-def>.<method-def>[propName1=propValue1,propName2=propValue2,...]
format, where property definitions are optional. The asterisk character (*) in the <class-def>
and <method-def>
is supported. For example:get
method in the com.mycompany.UserService
class: com.mycompany.UserService.get
validate
in the class com.mycompany.UserService
: com.mycompany.UserService.validate*
com.mycompany.UserService
class: com.mycompany.UserService.*
com.mycompany
package: com.mycompany.*.*
thundra_agent_trace_instrument_traceableConfig
environment variables can be ordered. If a definition’s order is lower than others, it is checked before those with a higher order. So a thundra_agent_trace_instrument_traceableConfig
definition can override another definition that has a higher order. Default order is 0
. There are two ways to configure order of an thundra_agent_trace_instrument_traceableConfig
environment variable:com.mycompany.UserService.*[...,...,order=1]
means that the order of the definition is 1
.thundra_agent_trace_instrument_traceableConfig
environment variable name. For example, thundra_agent_trace_instrument_traceableConfig1
means that the order of the definition is 1
.thundra_agent_trace_instrument_traceablePrefixes
environment variable, you can narrow down the scope of classes to be checked in order to reduce instrumentation overhead (and reduce cold-start overhead as well). Multiple prefixes can be specified by splitting them with a comma (,
).thundra_agent_trace_instrument_traceablePrefixes
environment variable to io.thundra.lambda.demo
and thus only check classes from the io.thundra.lambda.demo
package.methodModifiers
attribute of the @Traceable
annotation can be configured to specify modifiers of methods to be traced. In this instance, modifiers are the flags defined in the java.lang.reflect.Modifier
class. The ANY_METHOD_MODIFIER
constant in the io.thundra.agent.trace.instrument.config.TraceableConfig
can be used to trace any defined method in a class.UserService
class:methodModifiers
property of the thundra_agent_trace_instrument_traceableConfig
environment variable can be configured as a hexadecimal format definition of modifiers from the java.lang.reflect.Modifier
class, as shown below:0x00000001
means public methods.0x00000002
means private methods.0x00000004
means protected methods.0x00000008
means static methods.0x00000001 | 0x00000002
means private or public methods. As shown here, multiple modifiers can be combined with the | character.0x70000000
means any method.|
character and this means logical OR
.UserService
class over environment variables, the thundra_agent_trace_instrument_traceableConfig
environment variable can be specified as io.thundra.lambda.demo.service.UserService.*[...,...,methodModifiers=0x00000001|0x00000002]
traceArguments
attribute of the @Traceable
annotation can be set to true
for tracing method arguments. Additionally, the following properties can be configured for more detailed argument tracing:arg-0
, arg-1
, etc. The traceArgumentNames
attribute can be set to true, which will extract argument names if a local variable table of the associated method is available in the owner class’s bytecode.toString
method of the argument instance. If you want to serialize the argument value in a structured format, such as JSON, you can set the serializeArgumentsAsJson
attribute to true
.traceArguments
property of the thundra_agent_trace_instrument_traceableConfig
environment variable can be set to true
.traceArgumentNames
property of the thundra_agent_trace_instrument_traceableConfig
environment variable to true
.serializeArgumentsAsJson
to true
.UserService
class over environment variables, the thundra_agent_trace_instrument_traceableConfig
environment variable can be specified as io.thundra.lambda.demo.service.UserService.*[...,...,traceArguments=true,traceArgumentNames=true,serializeArgumentsAsJson=true].
traceReturnValue
attribute of the @Traceable
annotation can be set to true
in order to trace return values. By default, the return value is generated from the toString
method of the return value instance. If you want to serialize the return value in a structured format, such as JSON, you can set the serializeReturnValueAsJson
attribute to true
.traceReturnValue
property of the thundra_agent_trace_instrument_traceableConfig
environment variable can be set to true
. In a similar way, serializing return values as JSON can be configured by setting serializeReturnValueAsJson
to true
.UserService
class over environment variables, the thundra_agent_trace_instrument_traceableConfig
environment variable can be specified as io.thundra.lambda.demo.service.UserService.*[...,...,traceReturnValue=true,serializeReturnValueAsJson=true].
traceError
attribute of the @Traceable
annotation can be set to true
.traceError
property of the thundra_agent_trace_instrument_traceableConfig
environment variable can be set to true
.UserService
class over environment variables, the thundra_agent_trace_instrument_traceableConfig
environment variable can be specified as io.thundra.lambda.demo.service.UserService.*[...,...,traceError=true].
thundra-agent-trace-instrument-metadatagen
module needs to be in the dependencies/classpath during compilation. It includes the Java Annotation processor and generates metadata about classes to be used for tracing at runtime, like offline debugging.provided
scope for Maven).traceLineByLine
attribute of the @Traceable
annotation can be set to true
for debugging methods offline.TOKEN
Authorizerio.thundra.agent.lambda.core.auth.TokenAuthorizerContext
class as the input type for your custom authorizer. It provides all the required properties, such as authorizationToken
and methodArn
. To see your custom authorizer in a distributed trace map, you need to use this TokenAuthorizerContext
class as the input type for your custom authorizer handler.REQUEST
Authorizerio.thundra.agent.lambda.core.auth.RequestAuthorizerContext
class as the input type for your custom authorizer. It provides all the required properties, such as methodArn
, resource
, path
, httpMethod
, header
, queryStringParameters
, pathParameters
, stageVariables
, requestContext
, etc.. To see your custom authorizer in a distributed trace map, you need to use this RequestAuthorizerContext
class as the input type for your custom authorizer handler.