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

feat: exporter collector TLS option #1063

Merged
merged 22 commits into from
May 19, 2020
Merged

feat: exporter collector TLS option #1063

merged 22 commits into from
May 19, 2020

Conversation

mzahor
Copy link
Contributor

@mzahor mzahor commented May 15, 2020

Resolves this: #1062

@codecov-io
Copy link

codecov-io commented May 15, 2020

Codecov Report

Merging #1063 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #1063   +/-   ##
=======================================
  Coverage   95.12%   95.12%           
=======================================
  Files         213      213           
  Lines        8950     8951    +1     
  Branches      806      806           
=======================================
+ Hits         8514     8515    +1     
  Misses        436      436           
Impacted Files Coverage Δ
...emetry-exporter-collector/src/CollectorExporter.ts 90.47% <100.00%> (+0.23%) ⬆️

@dyladan dyladan linked an issue May 15, 2020 that may be closed by this pull request
@dyladan
Copy link
Member

dyladan commented May 15, 2020

Certs exist only for testing purposes yes? If so they should be in the test directory.

@mzahor
Copy link
Contributor Author

mzahor commented May 18, 2020

Certs exist only for testing purposes yes? If so they should be in the test directory.

Good point, fixed. Let me know if you have any other comments.

Copy link
Member

@vmarchaud vmarchaud left a comment

Choose a reason for hiding this comment

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

lgtm

@@ -0,0 +1,11 @@
rm ca.crt ca.key client.crt client.csr client.key server.crt server.csr server.key
Copy link
Member

Choose a reason for hiding this comment

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

Can you please add some comments or documentation on what this file does, when it should be run, why it is here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, would this document be a good place for it?

Copy link
Member

Choose a reason for hiding this comment

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

Don't think so. That file is for general contribution guidelines and things that apply to the whole repository, not a specific package. I would just add it as comments to the top of this file, and/or add a note in the collector exporter readme.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, thanks.

@@ -49,6 +49,32 @@ provider.register();

```

By default, plaintext connection is used. In order to use TLS, provide `credentials` option like so:
Copy link
Member

Choose a reason for hiding this comment

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

Please add a note similar to "to see how to generate credentials, you can refer to the script used to generate certificates for tests [here](link to certs sh)."

@mayurkale22 mayurkale22 added the enhancement New feature or request label May 18, 2020
@mayurkale22
Copy link
Member

@obecny would like to get your eyes on this.

Copy link
Member

@obecny obecny left a comment

Choose a reason for hiding this comment

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

I think this needs to be refactored into specific platforms

import { ExportResult, NoopLogger } from '@opentelemetry/core';
import { ReadableSpan, SpanExporter } from '@opentelemetry/tracing';
import { Attributes, Logger } from '@opentelemetry/api';
import * as grpc from 'grpc';
Copy link
Member

@obecny obecny May 18, 2020

Choose a reason for hiding this comment

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

CollectorExporter is used by web and node. grpc is not part of web so this won't be working fine and also credentials are not needed in web so far.
I think ExporterCollector should be treated as base class and not be exported (outside - only internally). Then inside folder platform inside node and browser you should create a new files ExporterCollector. The web can simply return the "base" ExporterCollector but the node you can then simply extend the base with all needed functionality that you added here. Then export the extended class correctly

Copy link
Member

Choose a reason for hiding this comment

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

I understand the credentials will only work in node, but it won't break web right?

Copy link
Member

Choose a reason for hiding this comment

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

it will break as grpc is a node package, cannot be included into web

Copy link
Member

Choose a reason for hiding this comment

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

unless we just let credentials to exists in both, but then explain that you should not use it which might be misleading why. By splitting this it will be easier to add stuff I think

Copy link
Member

Choose a reason for hiding this comment

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

It is type only and is compiled away. In recent versions of ts there is even a way to enforce this by doing import type { ChannelCredentials } from 'grpc';

Copy link
Member

Choose a reason for hiding this comment

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

I'm affraid that once we allow having anything from grpc here it is like asking for more trouble in future - who will remember then that we should not do that. Splitting this now will save us troubles later and it will be easier to maintain it too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@obecny I've refactored it as you suggested. Please check if web/node exports are done correctly, I'm not sure I understand the initial idea with separate exports for each env. Let me know if you have any other comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also if you wanna do any changes yourself - feel free to push.

@@ -49,6 +49,34 @@ provider.register();

```

By default, plaintext connection is used. In order to use TLS, provide `credentials` option like so:
```js
Copy link
Member

Choose a reason for hiding this comment

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

please mark this is for node only, not browser

@codecov-commenter
Copy link

codecov-commenter commented May 19, 2020

Codecov Report

Merging #1063 into master will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1063      +/-   ##
==========================================
- Coverage   95.17%   95.17%   -0.01%     
==========================================
  Files         216      216              
  Lines        9063     9062       -1     
  Branches      819      819              
==========================================
- Hits         8626     8625       -1     
  Misses        437      437              
Impacted Files Coverage Δ
...ry-exporter-collector/src/CollectorExporterBase.ts 90.00% <100.00%> (ø)
.../opentelemetry-exporter-collector/src/transform.ts 95.71% <100.00%> (ø)

Copy link
Member

@obecny obecny left a comment

Choose a reason for hiding this comment

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

the changes lgtm, I checked if it works fine and there was just one bug with web version - added comment.

There is one thing which can be now changed / refactored. This is with regards to platform/node/CollectorExporter.ts line 32
traceServiceClients = ... it was needed before to have reference to Collector, now you could simply use this as you have a Collector instance in place.

FYI if you want to test collector in web

  1. update lerna.json and add
    "examples/collector-exporter-node",
    "examples/tracer-web",

into packages section - this is just temporary to be able to bootstrap and debug examples (don't commit this)
2. npm i from root folder
3. npm run watch from packages/opentelemetry-exporter-collector
4. npm run start from examples/tracer-web
5. npm run docker:start from examples/collector-exporter-node
6. Open page at http://localhost:8090/user-interaction/ and click some button to generate traces
7. Open page at http://localhost:9411/zipkin/ to check traces

@mzahor
Copy link
Contributor Author

mzahor commented May 19, 2020

@obecny Thanks a lot for the detailed feedback! Fixed all the comments and checked as you suggested with web example - seems to work fine. Let me know if you have any other comments.

Copy link
Member

@obecny obecny left a comment

Choose a reason for hiding this comment

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

thx for all your work, looks gr8 :)

@dyladan dyladan added the Merge:LGTM This PR is ready to be merged by a Maintainer (has enough valid approvals, successful build, etc.) label May 19, 2020
@mayurkale22 mayurkale22 merged commit e912842 into open-telemetry:master May 19, 2020
@mzahor mzahor deleted the feat/otlp-tls branch May 20, 2020 07:22
pichlermarc pushed a commit to dynatrace-oss-contrib/opentelemetry-js that referenced this pull request Dec 15, 2023
* fix(sendMessageBatch): add sqs test

* fix(sendMessageBatch): remove unused parameter

* fix(fix comment): fix comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Merge:LGTM This PR is ready to be merged by a Maintainer (has enough valid approvals, successful build, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: TLS support for collector exporter
7 participants