Skip to content

Commit

Permalink
Expose setTrustedCertificates in JaegerGrpcSpanExporterBuilder for mT…
Browse files Browse the repository at this point in the history
…LS Support (#4061)

* adding setTrustedCertificates to JaegerGrpcSpanExporterBuilder for mTLS support

* fixing formatting error

* added setTrustedCertificates to JaegerGrpcSpanExporterBuilder

* added validConfig test for setTrustedCertificates mTLS support

* removing unnecessary comments
  • Loading branch information
kyle-lt committed Jan 7, 2022
1 parent c28797a commit edbe46a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
Comparing source compatibility of against
No changes.
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporterBuilder (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporterBuilder setTrustedCertificates(byte[])
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ public JaegerGrpcSpanExporterBuilder setTimeout(Duration timeout) {
return this;
}

/**
* Sets the certificate chain to use for verifying servers when TLS is enabled. The {@code byte[]}
* should contain an X.509 certificate collection in PEM format. If not set, TLS connections will
* use the system default trusted certificates.
*/
public JaegerGrpcSpanExporterBuilder setTrustedCertificates(byte[] trustedCertificatesPem) {
delegate.setTrustedCertificates(trustedCertificatesPem);
return this;
}

/**
* Constructs a new instance of the exporter based on the builder's values.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package io.opentelemetry.exporter.jaeger;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.fail;

Expand Down Expand Up @@ -33,6 +34,7 @@
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
import java.net.InetAddress;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -286,6 +288,16 @@ private static Optional<Model.KeyValue> getTagValue(List<Model.KeyValue> tags, S
return tags.stream().filter(kv -> kv.getKey().equals(tagKey)).findFirst();
}

@Test
@SuppressWarnings("PreferJavaTimeOverload")
void validConfig() {
assertThatCode(
() ->
JaegerGrpcSpanExporter.builder()
.setTrustedCertificates("foobar".getBytes(StandardCharsets.UTF_8)))
.doesNotThrowAnyException();
}

@Test
@SuppressWarnings("PreferJavaTimeOverload")
void invalidConfig() {
Expand Down

0 comments on commit edbe46a

Please sign in to comment.