Thanks for reply the welcome
The span is of type co.elastic.apm.opentracing.ApmSpan
, so not a noop.
To narrow this down, I created a test span, started, logged an error, then finished it.
io.opentracing.Span span = this.elasticApmTracer
.buildSpan("Test-Error-Span")
.start();
span.log(
ImmutableMap.of(
"event", "BOOM-Exception",
"error.object", new Exception("BOOM")
)
);
span.finish();
I bumped the log level as you suggested (nice tip). I didn't notice any smoking guns. There were a few flush calls which contained the test trace:
DEBUG co.elastic.apm.agent.report.IntakeV2ReportingEventHandler - Receiving FLUSH event (sequence 53)
TRACE co.elastic.apm.agent.report.serialize.DslJsonSerializer ...
The json that got flushed had the trace, but no error details:
{
"transaction": {
"timestamp": 1592390077519004,
"name": "Test-Error-Span",
"id": "a1de5eeb641f807f",
"trace_id": "4d9ac1981d005b6cf2a80d1724145c6c",
"type": "unknown",
"duration": 4.298,
"context": {
"tags": {}
},
"span_count": {
"dropped": 0,
"started": 0
},
"sampled": true
}
}
... in a later flush
{
"metricset": {
"timestamp": 1592390103155000,
"transaction": {
"name": "Test-Error-Span",
"type": "unknown"
},
"span": {
"type": "app",
"subtype": null
},
"tags": {},
"samples": {
"span.self_time.count": {
"value": 1
},
"span.self_time.sum.us": {
"value": 4298
}
}
}
}
"metricset": {
"timestamp": 1592390103155000,
"transaction": {
"name": "Test-Error-Span",
"type": "unknown"
},
"tags": {},
"samples": {
"transaction.duration.count": {
"value": 1
},
"transaction.duration.sum.us": {
"value": 4298
},
"transaction.breakdown.count": {
"value": 1
}
}
}
}
I didn't see any text that was logged against the span (i.e. 'BOOM-Exception', or just 'BOOM');
The underlying co.elastic.apm.opentracing.ApmSpan
seems to just have a noop for all logging calls:
public ApmSpan log(String event) {
this.log(Collections.singletonMap("event", event));
return this;
}
public ApmSpan log(Map<String, ?> fields) {
return this.log(-1L, fields);
}
public ApmSpan log(long timestampMicroseconds, String event) {
this.log(timestampMicroseconds, Collections.singletonMap("event", event));
return this;
}
public ApmSpan log(long timestampMicroseconds, Map<String, ?> fields) {
return this;
}
Not sure how that'd log anything unless there is some runtime weaving going on by the agent.
(Edit: looks like the source does elude to some injection going on: https://github.com/elastic/apm-agent-java/blob/master/apm-opentracing/src/main/java/co/elastic/apm/opentracing/ApmSpan.java)
Not sure what I'm doing wrong here?
Thanks for any help