Search in sources :

Example 1 with TraceContext

use of co.elastic.apm.agent.impl.transaction.TraceContext in project apm-agent-java by elastic.

the class OTelBridgeStepsDefinitions method bridgedSpanHasLocalParent.

@Then("Elastic bridged span has local context as parent")
public void bridgedSpanHasLocalParent() {
    assertThat(localParentContext).isNotNull();
    SpanContext otelParentContext = io.opentelemetry.api.trace.Span.fromContext(localParentContext).getSpanContext();
    TraceContext bridgedSpanContext = getBridgedSpan().getTraceContext();
    assertThat(bridgedSpanContext.getTraceId().toString()).isEqualTo(otelParentContext.getTraceId());
    assertThat(bridgedSpanContext.getParentId().toString()).isEqualTo(otelParentContext.getSpanId());
}
Also used : SpanContext(io.opentelemetry.api.trace.SpanContext) TraceContext(co.elastic.apm.agent.impl.transaction.TraceContext) Then(io.cucumber.java.en.Then)

Example 2 with TraceContext

use of co.elastic.apm.agent.impl.transaction.TraceContext in project apm-agent-java by elastic.

the class ElasticApmApiInstrumentationTest method checkTransactionServiceInfo.

private void checkTransactionServiceInfo(ServiceInfo expected) {
    TraceContext traceContext = reporter.getFirstTransaction().getTraceContext();
    assertThat(traceContext.getServiceName()).isEqualTo(expected.getServiceName());
    assertThat(traceContext.getServiceVersion()).isEqualTo(expected.getServiceVersion());
}
Also used : TraceContext(co.elastic.apm.agent.impl.transaction.TraceContext)

Example 3 with TraceContext

use of co.elastic.apm.agent.impl.transaction.TraceContext in project apm-agent-java by elastic.

the class ElasticApmTracerTest method checkServiceInfo.

private static void checkServiceInfo(Transaction transaction, ServiceInfo expected) {
    TraceContext traceContext = transaction.getTraceContext();
    assertThat(traceContext.getServiceName()).isEqualTo(expected.getServiceName());
    assertThat(traceContext.getServiceVersion()).isEqualTo(expected.getServiceVersion());
}
Also used : TraceContext(co.elastic.apm.agent.impl.transaction.TraceContext)

Example 4 with TraceContext

use of co.elastic.apm.agent.impl.transaction.TraceContext in project apm-agent-java by elastic.

the class AbstractLambdaTest method testTraceContext.

@Test
public void testTraceContext() {
    ReqE input = createInput();
    if (!supportsContextPropagation()) {
        return;
    }
    getFunction().handleRequest(input, context);
    Transaction transaction = reporter.getFirstTransaction();
    TraceContext traceContext = transaction.getTraceContext();
    assertThat(traceContext.getTraceId().toString()).isEqualTo(TRACE_ID_EXAMPLE);
    assertThat(traceContext.getParentId().toString()).isEqualTo(PARENT_ID_EXAMPLE);
    assertThat(traceContext.getTraceState().getSampleRate()).isEqualTo(0.77d);
}
Also used : Transaction(co.elastic.apm.agent.impl.transaction.Transaction) TraceContext(co.elastic.apm.agent.impl.transaction.TraceContext) AbstractInstrumentationTest(co.elastic.apm.agent.AbstractInstrumentationTest) Test(org.junit.jupiter.api.Test)

Example 5 with TraceContext

use of co.elastic.apm.agent.impl.transaction.TraceContext in project apm-agent-java by elastic.

the class CallTreeTest method rootTraceContext.

public static TraceContext rootTraceContext(ElasticApmTracer tracer) {
    TraceContext traceContext = TraceContext.with64BitId(tracer);
    traceContext.asRootSpan(ConstantSampler.of(true));
    return traceContext;
}
Also used : TraceContext(co.elastic.apm.agent.impl.transaction.TraceContext)

Aggregations

TraceContext (co.elastic.apm.agent.impl.transaction.TraceContext)19 Test (org.junit.jupiter.api.Test)8 Transaction (co.elastic.apm.agent.impl.transaction.Transaction)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 AbstractInstrumentationTest (co.elastic.apm.agent.AbstractInstrumentationTest)3 Then (io.cucumber.java.en.Then)3 ElasticApmTracer (co.elastic.apm.agent.impl.ElasticApmTracer)2 Message (co.elastic.apm.agent.impl.context.Message)2 Request (co.elastic.apm.agent.impl.context.Request)2 TransactionContext (co.elastic.apm.agent.impl.context.TransactionContext)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 Headers (co.elastic.apm.agent.impl.context.Headers)1 ConstantSampler (co.elastic.apm.agent.impl.sampling.ConstantSampler)1 Sampler (co.elastic.apm.agent.impl.sampling.Sampler)1 AbstractSpan (co.elastic.apm.agent.impl.transaction.AbstractSpan)1 Id (co.elastic.apm.agent.impl.transaction.Id)1 Span (co.elastic.apm.agent.impl.transaction.Span)1 DisabledOnAppleSilicon (co.elastic.apm.agent.testutils.DisabledOnAppleSilicon)1 SpanContext (io.opentelemetry.api.trace.SpanContext)1 Scope (io.opentracing.Scope)1