opentelemetry-collector icon indicating copy to clipboard operation
opentelemetry-collector copied to clipboard

feat(processor): preserve auth in batch processor

Open therealpandey opened this issue 1 year ago • 7 comments

Description

This PR preserves the authData in the client context after the batch processor. The idea is that the auth data can be used after the batch processor in subsequent processors and exporters.

Testing

  • Current unit tests modified to include the context
  • Need help with adding unit tests which choose auth is preserved.

therealpandey avatar Apr 19 '24 12:04 therealpandey

@grandwizard28 Thanks for the PR! Are there any related issues to this?

mx-psi avatar Apr 19 '24 14:04 mx-psi

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 91.78%. Comparing base (4a58092) to head (45f83ea). Report is 118 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10002   +/-   ##
=======================================
  Coverage   91.77%   91.78%           
=======================================
  Files         360      360           
  Lines       16641    16643    +2     
=======================================
+ Hits        15273    15275    +2     
  Misses       1041     1041           
  Partials      327      327           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Apr 19 '24 14:04 codecov[bot]

Hey @mx-psi, There are no current issues related to this. The background is while using any auth extension, we generally want to propagate some data (for example user_id) across processors and exporters but the batch processor is dropping the clientInfo.Auth struct.

I thought this would make a nice edition to the core since the batch processor is widely used.

Do let me know your thoughts on the above hypothesis :)

therealpandey avatar Apr 19 '24 14:04 therealpandey

Hey @jpkrohling @mx-psi, Any thoughts here?

therealpandey avatar Apr 23 '24 10:04 therealpandey

If you look at the exportCtx @jpkrohling, it looks like the following:

exportCtx := client.NewContext(context.Background(), client.Info{
		Metadata: client.NewMetadata(md),
	})

There is no AuthData preservation happening here at all. We are creating a new context altogether.

Do you want me to still create an issue?

therealpandey avatar May 06 '24 12:05 therealpandey

No, the code you are looking for is here:

https://github.com/open-telemetry/opentelemetry-collector/blob/7855bf2ababecdddfea82e4b1a15fd81be2d2d66/processor/batchprocessor/batch_processor.go#L326

This will create a new shard based on the context for that is available in the consume function, which does have client metadata.

jpkrohling avatar May 07 '24 09:05 jpkrohling

Hey @jpkrohling, Created an issue for this: https://github.com/open-telemetry/opentelemetry-collector/issues/10093

therealpandey avatar May 09 '24 14:05 therealpandey

This PR was marked stale due to lack of activity. It will be closed in 14 days.

github-actions[bot] avatar May 24 '24 03:05 github-actions[bot]

Closed as inactive. Feel free to reopen if this PR is still being worked on.

github-actions[bot] avatar Jun 07 '24 03:06 github-actions[bot]