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

fix(exporter-collector): default endpoint for node and browser #1197

Merged
merged 9 commits into from
Jun 17, 2020

Conversation

davidwitten
Copy link
Member

Which problem is this PR solving?

This PR addresses issue #1193

Essentially, the same endpoint doesn't work for both Node/browser. Browser requires the endpoint to end in /v1/trace and doesn't work when it's just localhost:55678. Node doesn't work if the endpoint ends in /v1/trace and only works if it's just localhost:55678.

Short description of the changes

Rather than having one endpoint in the base class (which only worked for browser). I added different default URLs in the node and browser CollectorExporter classes.

Testing

I tested this locally for both node and browser tracing. I also updated the common unit test.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jun 15, 2020

CLA Check
The committers are authorized under a signed CLA.

@codecov
Copy link

codecov bot commented Jun 15, 2020

Codecov Report

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

@@            Coverage Diff             @@
##           master    #1197      +/-   ##
==========================================
- Coverage   92.17%   92.16%   -0.01%     
==========================================
  Files         120      120              
  Lines        3410     3409       -1     
  Branches      697      696       -1     
==========================================
- Hits         3143     3142       -1     
  Misses        267      267              
Impacted Files Coverage Δ
...ry-exporter-collector/src/CollectorExporterBase.ts 89.74% <100.00%> (-0.26%) ⬇️

@@ -38,7 +38,7 @@ const { CollectorExporter } = require('@opentelemetry/exporter-collector');

const collectorOptions = {
serviceName: 'basic-service',
url: '<opentelemetry-collector-url>' // url is optional and can be omitted - default is http://localhost:55678/v1/trace
url: '<opentelemetry-collector-url>' // url is optional and can be omitted - default is http://localhost:55678
Copy link
Member

Choose a reason for hiding this comment

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

I would mention both (Node and Web) default URLs.

Copy link
Member Author

Choose a reason for hiding this comment

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

@mayurkale22 Should I also throw an error/alter the URL when someone enters an incorrect URL? (e.g. entering a URL that ends in /v1/trace for Node)

@@ -29,6 +29,8 @@ import { toCollectorExportTraceServiceRequest } from '../../transform';
import { GRPCQueueItem, TraceServiceClient } from './types';
import { removeProtocol } from './util';

const DEFAULT_COLLECTOR_URL = 'http://localhost:55678';
Copy link
Member

Choose a reason for hiding this comment

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

I think we should change this URL to localhost:55678 and remove removeProtocol logic from Node specific CollectorExporter module.

Copy link
Member

Choose a reason for hiding this comment

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

I would change the default url, but would live the removeProtocol to simply make it error proof for users

@@ -38,6 +40,10 @@ export class CollectorExporter extends CollectorExporterBase<
window.removeEventListener('unload', this.shutdown);
}

defaultURL(url: string | undefined) {
Copy link
Member

Choose a reason for hiding this comment

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

I would change the name to describe some action as defaultURL sounds like property and not a method. Maybe setDefaultUrl ?

Copy link
Member

Choose a reason for hiding this comment

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

For me, getDefaultUrl makes more sense than setDefaultUrl. We are not setting anything as a part of this method. WDYT @obecny @davidwitten ?

Copy link
Member

Choose a reason for hiding this comment

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

can be getDefaultUrl, chooseDefaultUrl etc. just something that sounds like action / method :)

Copy link
Member Author

Choose a reason for hiding this comment

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

@obecny @mayurkale22 Just fixed that, thanks!

Copy link
Member

@mayurkale22 mayurkale22 left a comment

Choose a reason for hiding this comment

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

LGTM. Congrats for your first contribution and welcome to OpenTelemetry Community!

Copy link
Member

@dyladan dyladan left a comment

Choose a reason for hiding this comment

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

This LGTM thanks!

@mayurkale22
Copy link
Member

@obecny would like to get your LGTM on this before merging.

@obecny
Copy link
Member

obecny commented Jun 16, 2020

@obecny would like to get your LGTM on this before merging.

There is just one tiny thing which I'm missing here, @davidwitten could you please add unit test for that ?

@davidwitten
Copy link
Member Author

@obecny Just added unit tests!

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.

lgtm, thx

@mayurkale22 mayurkale22 merged commit deb3570 into open-telemetry:master Jun 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Collector Exporter requires a different endpoint for Node vs. browser
6 participants