Skip to content

Commit ff5529a

Browse files
authored
Signed-off-by: Bogdan Drutu <[email protected]>
1 parent d34b66b commit ff5529a

File tree

3 files changed

+6
-56
lines changed

3 files changed

+6
-56
lines changed

exporters/otlp/trace/src/jmh/java/io/opentelemetry/exporter/otlp/trace/RequestMarshalState.java

+2-8
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
import io.opentelemetry.api.common.AttributeKey;
99
import io.opentelemetry.api.common.Attributes;
1010
import io.opentelemetry.api.trace.SpanContext;
11-
import io.opentelemetry.api.trace.SpanId;
1211
import io.opentelemetry.api.trace.SpanKind;
1312
import io.opentelemetry.api.trace.TraceFlags;
14-
import io.opentelemetry.api.trace.TraceId;
1513
import io.opentelemetry.api.trace.TraceState;
1614
import io.opentelemetry.sdk.common.InstrumentationLibraryInfo;
1715
import io.opentelemetry.sdk.resources.Resource;
@@ -47,12 +45,8 @@ public class RequestMarshalState {
4745

4846
private static final InstrumentationLibraryInfo INSTRUMENTATION_LIBRARY_INFO =
4947
InstrumentationLibraryInfo.create("name", null);
50-
private static final byte[] TRACE_ID_BYTES =
51-
new byte[] {123, 46, 23, 78, 12, 5, (byte) 180, (byte) 223, 45, 89, 71, 61, 62, 29, 34, 54};
52-
private static final String TRACE_ID = TraceId.fromBytes(TRACE_ID_BYTES);
53-
private static final byte[] SPAN_ID_BYTES =
54-
new byte[] {(byte) 198, (byte) 245, (byte) 213, (byte) 156, 46, 31, 29, 101};
55-
private static final String SPAN_ID = SpanId.fromBytes(SPAN_ID_BYTES);
48+
private static final String TRACE_ID = "7b2e170db4df2d593ddb4ddf2ddf2d59";
49+
private static final String SPAN_ID = "170d3ddb4d23e81f";
5650
private static final SpanContext SPAN_CONTEXT =
5751
SpanContext.create(TRACE_ID, SPAN_ID, TraceFlags.getSampled(), TraceState.getDefault());
5852

exporters/otlp/trace/src/test/java/io/opentelemetry/exporter/otlp/trace/TraceMarshalerTest.java

+2-7
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111
import io.opentelemetry.api.common.AttributeKey;
1212
import io.opentelemetry.api.common.Attributes;
1313
import io.opentelemetry.api.trace.SpanContext;
14-
import io.opentelemetry.api.trace.SpanId;
1514
import io.opentelemetry.api.trace.SpanKind;
1615
import io.opentelemetry.api.trace.TraceFlags;
17-
import io.opentelemetry.api.trace.TraceId;
1816
import io.opentelemetry.api.trace.TraceState;
1917
import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest;
2018
import io.opentelemetry.sdk.common.InstrumentationLibraryInfo;
@@ -52,11 +50,8 @@ class TraceMarshalerTest {
5250

5351
private static final InstrumentationLibraryInfo INSTRUMENTATION_LIBRARY_INFO =
5452
InstrumentationLibraryInfo.create("name", null);
55-
private static final byte[] TRACE_ID_BYTES =
56-
new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4};
57-
private static final String TRACE_ID = TraceId.fromBytes(TRACE_ID_BYTES);
58-
private static final byte[] SPAN_ID_BYTES = new byte[] {0, 0, 0, 0, 4, 3, 2, 1};
59-
private static final String SPAN_ID = SpanId.fromBytes(SPAN_ID_BYTES);
53+
private static final String TRACE_ID = "00000000000000000000000001020304";
54+
private static final String SPAN_ID = "0000000004030201";
6055

6156
private static final SpanContext SPAN_CONTEXT =
6257
SpanContext.create(

sdk/trace/src/test/java/io/opentelemetry/sdk/trace/samplers/TraceIdRatioBasedSamplerTest.java

+2-41
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import io.opentelemetry.api.trace.SpanContext;
1414
import io.opentelemetry.api.trace.SpanKind;
1515
import io.opentelemetry.api.trace.TraceFlags;
16-
import io.opentelemetry.api.trace.TraceId;
1716
import io.opentelemetry.api.trace.TraceState;
1817
import io.opentelemetry.context.Context;
1918
import io.opentelemetry.sdk.trace.IdGenerator;
@@ -148,26 +147,7 @@ void sampleBasedOnTraceId() {
148147
final Sampler defaultProbability = Sampler.traceIdRatioBased(0.0001);
149148
// This traceId will not be sampled by the Probability Sampler because the last 8 bytes as long
150149
// is not less than probability * Long.MAX_VALUE;
151-
String notSampledTraceId =
152-
TraceId.fromBytes(
153-
new byte[] {
154-
0,
155-
0,
156-
0,
157-
0,
158-
0,
159-
0,
160-
0,
161-
0,
162-
(byte) 0x8F,
163-
(byte) 0xFF,
164-
(byte) 0xFF,
165-
(byte) 0xFF,
166-
(byte) 0xFF,
167-
(byte) 0xFF,
168-
(byte) 0xFF,
169-
(byte) 0xFF
170-
});
150+
String notSampledTraceId = "00000000000000008fffffffffffffff";
171151
SamplingResult samplingResult1 =
172152
defaultProbability.shouldSample(
173153
invalidParentContext,
@@ -179,26 +159,7 @@ void sampleBasedOnTraceId() {
179159
assertThat(samplingResult1.getDecision()).isEqualTo(SamplingDecision.DROP);
180160
// This traceId will be sampled by the Probability Sampler because the last 8 bytes as long
181161
// is less than probability * Long.MAX_VALUE;
182-
String sampledTraceId =
183-
TraceId.fromBytes(
184-
new byte[] {
185-
(byte) 0x00,
186-
(byte) 0x00,
187-
(byte) 0xFF,
188-
(byte) 0xFF,
189-
(byte) 0xFF,
190-
(byte) 0xFF,
191-
(byte) 0xFF,
192-
(byte) 0xFF,
193-
0,
194-
0,
195-
0,
196-
0,
197-
0,
198-
0,
199-
0,
200-
0
201-
});
162+
String sampledTraceId = "0000ffffffffffff0000000000000000";
202163
SamplingResult samplingResult2 =
203164
defaultProbability.shouldSample(
204165
invalidParentContext,

0 commit comments

Comments
 (0)