Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TLS for SAPM and SignalFx receiver #215

Merged
merged 4 commits into from
May 29, 2020

Conversation

ccaraman
Copy link
Contributor

@ccaraman ccaraman commented May 7, 2020

Description: Adds TLS for both SAPM and SignalFx Receiver.

Testing: Added tests to create a TLS connection to the receiver and manually tested using Otel Collector and Smart Agent.

Documentation: Expanded readme's to add information about TLS.

@ccaraman ccaraman requested a review from a team as a code owner May 7, 2020 22:45
@ccaraman
Copy link
Contributor Author

ccaraman commented May 7, 2020

cc @brianashby-sfx for doc changes.

@bogdandrutu
Copy link
Member

@ccaraman I think we should share the config from core, see:
open-telemetry/opentelemetry-collector#927

Do you think that is possible?

@jrcamp
Copy link
Contributor

jrcamp commented May 8, 2020

We were also trying to do this in #198

@ccaraman
Copy link
Contributor Author

ccaraman commented May 8, 2020

@bogdandrutu

@ccaraman I think we should share the config from core, see:
open-telemetry/opentelemetry-collector#927

Do you think that is possible?

Yes, that is totally possible. I didn't see that PR so I didn't know that was coming in the pipeline. I'll take a look

@jrcamp - should we then wait on #198 and get the first mentioned pr to work for HTTP as well?

@jrcamp
Copy link
Contributor

jrcamp commented May 8, 2020

I think the upstream issue linked above will supersede most of #198. (Though we're doing some other common config structs for HTTP that will be built on top of TLSConfig but shouldn't block your work here.)

@ccaraman
Copy link
Contributor Author

@bogdandrutu and @jrcamp - since this is using the common receiver settings (for http server) - i don't think this blocks this pr getting reviewed. There is testing logic around https connection so that can be reviewed before the refactor of the tls configuration.

@codecov
Copy link

codecov bot commented May 26, 2020

Codecov Report

Merging #215 into master will increase coverage by 0.03%.
The diff coverage is 90.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #215      +/-   ##
==========================================
+ Coverage   78.51%   78.54%   +0.03%     
==========================================
  Files         153      153              
  Lines        7567     7578      +11     
==========================================
+ Hits         5941     5952      +11     
  Misses       1295     1295              
  Partials      331      331              
Impacted Files Coverage Δ
receiver/signalfxreceiver/receiver.go 88.33% <80.00%> (+0.61%) ⬆️
receiver/sapmreceiver/factory.go 79.41% <100.00%> (ø)
receiver/sapmreceiver/trace_receiver.go 74.07% <100.00%> (+1.70%) ⬆️
receiver/signalfxreceiver/factory.go 86.66% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 82b1adf...5cba3f8. Read the comment docs.

Copy link
Contributor

@jrcamp jrcamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm just a couple suggestions

resp, err = sendSapm(tt.args.config.Endpoint, tt.args.sapm, tt.args.zipped)
assert.NoError(t, err, fmt.Sprintf("should not have failed when sending sapm %v", resp))
resp, err = sendSapm(tt.args.config.Endpoint, tt.args.sapm, tt.args.zipped, tt.args.useTLS)
require.NoError(t, err, fmt.Sprintf("should not have failed when sending sapm %v", err))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
require.NoError(t, err, fmt.Sprintf("should not have failed when sending sapm %v", err))
require.NoErrorf(t, err, "should not have failed when sending sapm %v", err)

}

resp, err := client.Do(req)
require.NoError(t, err, fmt.Sprintf("should not have failed when sending to signalFx receiver %v", err))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
require.NoError(t, err, fmt.Sprintf("should not have failed when sending to signalFx receiver %v", err))
require.NoErrorf(t, err, "should not have failed when sending to signalFx receiver %v", err)

url := fmt.Sprintf("https://%s/v2/datapoint", addr)

req, err := http.NewRequest("POST", url, bytes.NewReader(body))
require.NoError(t, err, fmt.Sprintf("should have no errors with new request: %v", err))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
require.NoError(t, err, fmt.Sprintf("should have no errors with new request: %v", err))
require.NoErrorf(t, err, "should have no errors with new request: %v", err)

req.Header.Set("Content-Type", "application/x-protobuf")

caCert, err := ioutil.ReadFile("./testdata/testcert.crt")
require.NoError(t, err, fmt.Sprintf("failed to load certificate: %v", err))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
require.NoError(t, err, fmt.Sprintf("failed to load certificate: %v", err))
require.NoErrorf(t, err, "failed to load certificate: %v", err)

@jrcamp jrcamp removed their assignment May 29, 2020
@tigrannajaryan tigrannajaryan self-assigned this May 29, 2020
Collector automation moved this from In progress to Reviewer approved May 29, 2020
@tigrannajaryan tigrannajaryan merged commit 5f04eb4 into open-telemetry:master May 29, 2020
Collector automation moved this from Reviewer approved to Done May 29, 2020
wyTrivail referenced this pull request in mxiamxia/opentelemetry-collector-contrib Jul 13, 2020
Adds TLS for both SAPM and SignalFx Receiver.

Testing: Added tests to create a TLS connection to the receiver and manually tested using Otel Collector and Smart Agent.

Documentation: Expanded readme's to add information about TLS.
ljmsc referenced this pull request in ljmsc/opentelemetry-collector-contrib Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Collector
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants