Skip to content
This repository was archived by the owner on May 11, 2026. It is now read-only.
Open
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 @@ -120,6 +120,10 @@ public void startSpanWithParent(SpanBuilder spanBuilder, Span parent) {
* @param id The optional id to associate with the span
*/
public void startSpanWithParent(SpanBuilder spanBuilder, Span parent, String id) {
if (log.isLoggable(Level.FINEST)) {
log.finest("Start span as child of span = " + parent);
}

if (parent != null) {
spanBuilder.asChildOf(parent.context());
}
Expand Down Expand Up @@ -151,6 +155,10 @@ public void startSpanWithContext(SpanBuilder spanBuilder, SpanContext context) {
* @param id The optional id to associate with the span
*/
public void startSpanWithContext(SpanBuilder spanBuilder, SpanContext context, String id) {
if (log.isLoggable(Level.FINEST)) {
log.finest("Start span as child of context = " + context);
}

if (context != null) {
spanBuilder.asChildOf(context);
}
Expand Down Expand Up @@ -188,6 +196,10 @@ public void startSpan(SpanBuilder spanBuilder, String id) {
protected void doStartSpanWithParent(SpanBuilder spanBuilder, String id) {
Span parentSpan = getSpan();

if (log.isLoggable(Level.FINEST)) {
log.finest("Start span as child of = " + parentSpan);
}

if (parentSpan != null) {
spanBuilder.asChildOf(parentSpan);
}
Expand All @@ -203,14 +215,14 @@ protected void doStartSpan(SpanBuilder spanBuilder, String id) {
traceState.set(ts);

if (log.isLoggable(Level.FINEST)) {
log.finest("Create trace state = " + ts);
log.finest("Created trace state = " + ts);
}
}

Span span = spanBuilder.start();

if (log.isLoggable(Level.FINEST)) {
log.finest("Start span = " + span + " id = " + id + " trace state = " + ts);
log.finest("Started span = " + span + " id = " + id + " trace state = " + ts);
}

ts.pushSpan(span, id);
Expand Down Expand Up @@ -286,9 +298,6 @@ public Span getSpan() {
return span;
}

if (log.isLoggable(Level.FINEST)) {
log.finest("Get span requested, but no trace state");
}
return null;
}

Expand Down Expand Up @@ -459,6 +468,33 @@ public void setVariable(String name, Object value) {
}
}

/**
* This method removes the end part of a string beginning
* at a specified delimiter.
*
* @param original The original string
* @param delim The delimiter identifying the point to truncate
* @return The modified string
*/
public String truncateAtDelimiter(String original, String delim) {
int index = original.indexOf(delim);
if (index != -1) {
return original.substring(0, index);
}
return original;
}

/**
* This method returns the simple class name of the supplied
* object.
*
* @param obj The object
* @return The simple class name
*/
public String simpleClassName(Object obj) {
return obj.getClass().getSimpleName();
}

/**
* This class represents the state information being accumulated for a
* trace instance.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Exclude 'onMessage' method as will conflict with instrumentation of JMS/MDB

RULE org.jboss.ee(1) EE Component Start
CLASS org.jboss.as.ee.component.ProxyInvocationHandler
METHOD invoke(Object,Method,Object[])
HELPER org.hawkular.apm.agent.opentracing.OpenTracingManager
AT ENTRY
IF !$2.getName().equals("onMessage")
DO
startSpanWithParent(getTracer().buildSpan($2.getName())
.withTag("EJB.uri", truncateAtDelimiter(simpleClassName($1),"$$$")),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a more reliable way to get the proxied bean name? Also, is this the bean name (interface), or the implementing class name? Would it be interesting to store also the kind of bean being invoked (Home, Local Home, Remote)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its the implementing class name. I'll investigate, I originally copied some byteman rules someone else had created for tracking EJB usage.

getSpan());
ENDRULE

RULE org.jboss.ee(1) EE Component Finish
CLASS org.jboss.as.ee.component.ProxyInvocationHandler
METHOD invoke(Object,Method,Object[])
HELPER org.hawkular.apm.agent.opentracing.OpenTracingManager
AT EXIT
IF !$2.getName().equals("onMessage") && hasSpan()
DO
finishSpan();
ENDRULE
Original file line number Diff line number Diff line change
Expand Up @@ -435,4 +435,8 @@ public Map<String, Object> state() {
}
return state;
}

public String toString() {
return super.toString() + "[operationName=" + getOperationName() + " state=" + state() + "]";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super does not define toString() if it's added we end up with two operation names.

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.UUID;

import org.hawkular.apm.api.logging.Logger;
import org.hawkular.apm.api.logging.Logger.Level;
import org.hawkular.apm.api.model.Constants;
import org.hawkular.apm.api.model.trace.NodeType;
import org.hawkular.apm.client.api.recorder.BatchTraceRecorder;
Expand Down Expand Up @@ -85,6 +86,10 @@ Map<String, Object> getTraceState(SpanContext spanContext) {
ret.putAll(span.state());
}

if (log.isLoggable(Level.FINEST)) {
log.finest("Trace state = " + ret);
}

return ret;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.concurrent.atomic.AtomicInteger;

import org.hawkular.apm.api.logging.Logger;
import org.hawkular.apm.api.logging.Logger.Level;
import org.hawkular.apm.api.model.Constants;
import org.hawkular.apm.api.model.Property;
import org.hawkular.apm.api.model.config.ReportingLevel;
Expand Down Expand Up @@ -123,6 +124,9 @@ public void endProcessingNode() {
}

if (sampled) {
if (log.isLoggable(Level.FINEST)) {
log.finest("Record trace: " + trace);
}
recorder.record(trace);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public int getInitialRetryCount() {
@Override
public void publish(String tenantId, List<Trace> traces) throws Exception {
long startTime = clock.millis();
if (log.isLoggable(Level.FINEST)) {
log.finest("Publish traces: " + traces);
}
int statusCode = postAsJsonTo(tenantId, "traces/fragments", traces);
if (log.isLoggable(Level.FINEST)) {
log.finest("Status code is: " + statusCode);
Expand Down