This repository has been archived by the owner on Oct 3, 2023. It is now read-only.
TLS for all
Added a new option WithTLSCredentials
which allows ocagent to dial to servers using TLS Credentials.
This feature was requested in #44 and added with PR #45
This provides parity with ocagent's new TLS backed OpenCensus receiver with #45
Example
func Example_withTLS() {
// Please take at look at:
// https://godoc.org/google.golang.org/grpc/credentials#TransportCredentials
// for ways on how to initialize gRPC TransportCredentials.
creds, err := credentials.NewClientTLSFromFile("my-cert.pem", "")
if err != nil {
log.Fatalf("Failed to create gRPC client TLS credentials: %v", err)
}
exp, err := ocagent.NewExporter(ocagent.WithTLSCredentials(creds), ocagent.WithServiceName("engine"))
if err != nil {
log.Fatalf("Failed to create the agent exporter: %v", err)
}
defer exp.Stop()
// Now register it as a trace exporter.
trace.RegisterExporter(exp)
// Then use the OpenCensus tracing library, like we normally would.
ctx, span := trace.StartSpan(context.Background(), "Securely-Talking-To-Agent-Span")
defer span.End()
for i := 0; i < 10; i++ {
_, iSpan := trace.StartSpan(ctx, fmt.Sprintf("Sample-%d", i))
<-time.After(6 * time.Millisecond)
iSpan.End()
}
}