Skip to content

Conversation

@xue20xi
Copy link

@xue20xi xue20xi commented Jul 25, 2025

Fix #6661

@codecov
Copy link

codecov bot commented Jul 25, 2025

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.9%. Comparing base (70e2375) to head (6c579af).
⚠️ Report is 305 commits behind head on main.

Files with missing lines Patch % Lines
exporters/otlp/otlplog/otlploggrpc/client.go 0.0% 2 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #7087   +/-   ##
=====================================
  Coverage   82.9%   82.9%           
=====================================
  Files        262     262           
  Lines      24460   24463    +3     
=====================================
+ Hits       20281   20287    +6     
+ Misses      3801    3799    -2     
+ Partials     378     377    -1     
Files with missing lines Coverage Δ
exporters/otlp/otlplog/otlploggrpc/client.go 89.9% <0.0%> (-2.0%) ⬇️

... and 23 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xue20xi
Copy link
Author

xue20xi commented Jul 27, 2025

Hi Team,
Is there any suggestions about how to pass below check?
https://github.com/open-telemetry/opentelemetry-go/pull/7087/checks?check_run_id=46766265777

It seems it's not possible to test the grpc dial options from below link.

// It is not possible to compare grpc dial options directly, so we just check that the client is created

@dmathieu
Copy link
Member

The codecov check is not a blocker.
However, it would be nice to have a test case testing your condition and ensuring the grpc credentials value is indeed set.

@MrAlias MrAlias changed the title Fix 6661, set config.gRPCCredentials.Value properly when using TLS/mTLS certificates Set config.gRPCCredentials.Value properly when using TLS/mTLS certificates Jul 28, 2025
@MrAlias MrAlias added the pkg:exporter:otlp Related to the OTLP exporter package label Jul 28, 2025
@pellared pellared changed the title Set config.gRPCCredentials.Value properly when using TLS/mTLS certificates otlploggrpc: set config.gRPCCredentials.Value properly when using TLS/mTLS certificates Jul 30, 2025
@pellared
Copy link
Member

pellared commented Aug 4, 2025

@xue20xi, are you able to address the follow comment (from #7087 (comment)):

it would be nice to have a test case testing your condition and ensuring the grpc credentials value is indeed set

?

@xue20xi
Copy link
Author

xue20xi commented Aug 4, 2025

The codecov check is not a blocker. However, it would be nice to have a test case testing your condition and ensuring the grpc credentials value is indeed set.

Hi @pellared , I have not find a way to do the test, it seems the result returned by newGRPCDialOptions() can not be invoked, the method apply() is private.

type DialOption interface {
	apply(*dialOptions)
}

I have tried to write something like below, but the opt.apply() method is private method, can not be invoked.

func TestNewGRPCDialOptions(t *testing.T) {
	t.Run("WithTLS", func(t *testing.T) {
		var c config
		var rootCAs *x509.CertPool
		var certs []tls.Certificate
		c.tlsCfg = newSetting(&tls.Config{RootCAs: rootCAs, Certificates: certs})
		var dialOptions []grpc.DialOption
		dialOptions = newGRPCDialOptions(c)
		for _, opt := range dialOptions {
			opt.apply()
		}
	})
}

@pellared
Copy link
Member

pellared commented Aug 4, 2025

How about creating unit tests for newGRPCDialOptions where cfg config is set up using newConfig so that user-facing options and env vars are parsed the same way as in production code ?

@XSAM, any other proposal?

@XSAM
Copy link
Member

XSAM commented Aug 19, 2025

How about creating unit tests for newGRPCDialOptions where cfg config is set up using newConfig so that user-facing options and env vars are parsed the same way as in production code ?

@XSAM, any other proposal?

Another approach could be using an End-to-End test to actually test against a TLS gRPC server.

The test pseudo code could be something like this

  func TestClientWithTLSCertificate(t *testing.T) {
      // Create a test TLS server
      cert, key := generateTestCertificate()
      tlsConfig := &tls.Config{Certificates: []tls.Certificate{cert}}

      // Start gRPC server with TLS
      creds := credentials.NewTLS(tlsConfig)
      srv := grpc.NewServer(grpc.Creds(creds))

      // Set environment variable
      t.Setenv("OTEL_EXPORTER_OTLP_LOGS_CERTIFICATE", certPEM)

      // Create client and verify it can connect
      client, err := New(context.Background())
      require.NoError(t, err)

      // Export logs and verify success
      err = client.Export(context.Background(), testLogs)
      assert.NoError(t, err)
  }

@pellared
Copy link
Member

@xue20xi, bump 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg:exporter:otlp Related to the OTLP exporter package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

otlploggrpc does not work with self-signed certificates

5 participants