Skip to content

Commit

Permalink
remove default endpoint, stub initTracer()
Browse files Browse the repository at this point in the history
Having a default means each invocation of otel-cli might timeout on
trying to connect over OTLP.

With this change, in the absence of --endpoint or OTEL_EXPORTER_OTLP_ENDPOINT
otel-cli will now not configure opentelemetry-go at all, but the rest of
otel-cli will work as usual, just no spans are sent out.

Signed-off-by: Amy Tobey <atobey@equinix.com>
  • Loading branch information
Amy Tobey committed Aug 26, 2021
1 parent 980a370 commit a9dbdea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions cmd/plumbing.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ import (
func initTracer() (context.Context, func()) {
ctx := context.Background()

// when no endpoint is set, do not set up plumbing. everything will still
// run but in non-recording mode, and otel-cli is effectively disabled
// and will not time out trying to connect out
if otlpEndpoint == "" {
return ctx, func() {}
}

grpcOpts := []otlpgrpc.Option{otlpgrpc.WithEndpoint(otlpEndpoint)}

// gRPC does the right thing and forces us to say WithInsecure to disable encryption,
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func addCommonParams(cmd *cobra.Command) {
// --config / -c a viper configuration file
cmd.Flags().StringVarP(&cfgFile, "config", "c", "", "config file (default is $HOME/.otel-cli.yaml)")

cmd.Flags().StringVar(&otlpEndpoint, "endpoint", "localhost:4317", "dial address for the desired OTLP/gRPC endpoint")
cmd.Flags().StringVar(&otlpEndpoint, "endpoint", "", "dial address for the desired OTLP/gRPC endpoint")
viper.BindPFlag("endpoint", rootCmd.Flags().Lookup("endpoint"))
viper.BindEnv("OTEL_EXPORTER_OTLP_ENDPOINT", "endpoint")
}
Expand Down

0 comments on commit a9dbdea

Please sign in to comment.