### Question:
TraceProtoUtils { public static TraceConfig traceConfigFromProto( io.opentelemetry.proto.trace.v1.TraceConfig traceConfigProto) { return TraceConfig.getDefault() .toBuilder() .setSampler(fromProtoSampler(traceConfigProto)) .setMaxNumberOfAttributes((int) traceConfigProto.getMaxNumberOfAttributes()) .setMaxNumberOfEvents((int) traceConfigProto.getMaxNumberOfTimedEvents()) .setMaxNumberOfLinks((int) traceConfigProto.getMaxNumberOfLinks()) .setMaxNumberOfAttributesPerEvent( (int) traceConfigProto.getMaxNumberOfAttributesPerTimedEvent()) .setMaxNumberOfAttributesPerLink((int) traceConfigProto.getMaxNumberOfAttributesPerLink()) .build(); } private  TraceProtoUtils(); static ByteString toProtoSpanId(String spanId); static ByteString toProtoTraceId(String traceId); static TraceConfig traceConfigFromProto(
      io.opentelemetry.proto.trace.v1.TraceConfig traceConfigProto);  }### Answer:
@Test void traceConfigFromProto() { TraceConfig traceConfig = TraceProtoUtils.traceConfigFromProto(TRACE_CONFIG_PROTO); assertThat(traceConfig.getSampler()).isEqualTo(Samplers.alwaysOn()); assertThat(traceConfig.getMaxNumberOfAttributes()).isEqualTo(10); assertThat(traceConfig.getMaxNumberOfEvents()).isEqualTo(9); assertThat(traceConfig.getMaxNumberOfLinks()).isEqualTo(8); assertThat(traceConfig.getMaxNumberOfAttributesPerEvent()).isEqualTo(2); assertThat(traceConfig.getMaxNumberOfAttributesPerLink()).isEqualTo(1); }
@Test void traceConfigFromProto_AlwaysOffSampler() { TraceConfig traceConfig = TraceProtoUtils.traceConfigFromProto( io.opentelemetry.proto.trace.v1.TraceConfig.newBuilder() .setConstantSampler( ConstantSampler.newBuilder().setDecision(ConstantDecision.ALWAYS_OFF).build()) .setMaxNumberOfAttributes(10) .setMaxNumberOfTimedEvents(9) .setMaxNumberOfLinks(8) .setMaxNumberOfAttributesPerTimedEvent(2) .setMaxNumberOfAttributesPerLink(1) .build()); assertThat(traceConfig.getSampler()).isEqualTo(Samplers.alwaysOff()); }
@Test void traceConfigFromProto_ProbabilitySampler() { TraceConfig traceConfig = TraceProtoUtils.traceConfigFromProto( io.opentelemetry.proto.trace.v1.TraceConfig.newBuilder() .setTraceIdRatioBased(TraceIdRatioBased.newBuilder().setSamplingRatio(0.1).build()) .setMaxNumberOfAttributes(10) .setMaxNumberOfTimedEvents(9) .setMaxNumberOfLinks(8) .setMaxNumberOfAttributesPerTimedEvent(2) .setMaxNumberOfAttributesPerLink(1) .build()); assertThat(traceConfig.getSampler()).isEqualTo(Samplers.traceIdRatioBased(0.1)); }