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: add redis plugin example #534

Merged

Conversation

markwolff
Copy link
Member

Which problem is this PR solving?

Short description of the changes

  • Adds example showing redis plugin being used in an express app

@codecov-io
Copy link

codecov-io commented Nov 14, 2019

Codecov Report

Merging #534 into master will decrease coverage by 3.49%.
The diff coverage is n/a.

@@            Coverage Diff            @@
##           master     #534     +/-   ##
=========================================
- Coverage   90.38%   86.88%   -3.5%     
=========================================
  Files         150      143      -7     
  Lines        7590     7123    -467     
  Branches      666      645     -21     
=========================================
- Hits         6860     6189    -671     
- Misses        730      934    +204
Impacted Files Coverage Δ
...try-core/test/trace/fixtures/test-package/index.js 0% <0%> (-100%) ⬇️
...st/trace/fixtures/test-package/foo/bar/internal.js 0% <0%> (-100%) ⬇️
...pentelemetry-core/src/platform/node/performance.ts 0% <0%> (-100%) ⬇️
...ckages/opentelemetry-core/test/platform/id.test.ts 0% <0%> (-77.78%) ⬇️
...entelemetry-core/test/common/ConsoleLogger.test.ts 0% <0%> (-77.02%) ⬇️
...ntelemetry-core/test/trace/NoRecordingSpan.test.ts 0% <0%> (-71.43%) ⬇️
...ackages/opentelemetry-core/src/platform/node/id.ts 0% <0%> (-71.43%) ⬇️
...s/opentelemetry-core/test/trace/tracestate.test.ts 0% <0%> (-65.07%) ⬇️
...ges/opentelemetry-core/test/trace/NoopSpan.test.ts 0% <0%> (-63.64%) ⬇️
...s/opentelemetry-core/test/context/B3Format.test.ts 0% <0%> (-63.4%) ⬇️
... and 26 more

- SpanContext Propagation (from Client to Server)
- Span Events
- Span Attributes

Copy link
Member

Choose a reason for hiding this comment

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

Could you please explain a little more on actual example: what operations are we executing and what are the components involved?

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.

Overall LGTM, added few comments

function setupTracerAndExporters(service) {
const tracer = new NodeTracer({
plugins: {
http: {
Copy link
Member

Choose a reason for hiding this comment

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

By default, http plugins is enabled with correct path, do you still want to add here? Once #503 merged, will add that into default supported plugins list.

Copy link
Member Author

@markwolff markwolff Nov 14, 2019

Choose a reason for hiding this comment

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

If I specify redis plugin here, will that "overwrite" the default list and only load the redis plugin and not any other default plugins? Ultimately this is all moot once redis becomes a default plugin, so I'm fine with blocking this until it becomes default (and making this just a default new NodeTracer())

Copy link
Member

Choose a reason for hiding this comment

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

Yes the plugins object overwrites the default, it does not merge with it. In any case, the redis plugin is now in the default list anyways so this doesn't matter.


```sh
# from this directory
npm run docker:start
Copy link
Member

Choose a reason for hiding this comment

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

Quiestion: if I want to start zipkin and jaeger at the same time, should I run this command twice or can be already omitted. Maybe just add some additional information here ?


tracer.withSpan(span, async () => {
try {
const res = await axios.get('http://localhost:8080/run_test');
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 replace axios with standard http to avoid 3rd parties ?

Copy link
Member Author

@markwolff markwolff Nov 20, 2019

Choose a reason for hiding this comment

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

I am currently using axios since it removes a lot of the unimportant "noise code" in the sample. Currently nothing interesting happens in client.js other than kicking off the trace, so I would prefer to keep axios here so that the sample highlights the redis usage. WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

My thought was just to have consistency within all the examples and codebase. So far we don't use axios, but rather just standard libraries as then the user can choose what he wants. If that's the way to go then fine I just think we should have consistency :).

Copy link
Member

Choose a reason for hiding this comment

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

I actually don't mind the use of axios here. In fact, it shows that third party libraries can be used. These are meant to be examples of real world use and almost nobody uses the http library directly. These aren't shipped to customers in the bundle so additional dependencies don't have as big a burden as they do in the packages


// Require in rest of modules
const express = require('express');
const axios = require('axios').default;
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 replace axios with standard http to avoid 3rd parties ?

@OlivierAlbertini OlivierAlbertini added the document Documentation-related label Nov 18, 2019
@mayurkale22
Copy link
Member

@open-telemetry/javascript-approvers Please review when you get a chance.

Copy link
Member

@OlivierAlbertini OlivierAlbertini left a comment

Choose a reason for hiding this comment

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

LGTM

"devDependencies": {
"cross-env": "^6.0.0"
}
}
Copy link
Member

Choose a reason for hiding this comment

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

missing new line

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in 67b46cc

},
"keywords": [
"opentelemetry",
"http",
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
"http",
"redis",

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in 67b46cc

@mayurkale22 mayurkale22 merged commit 39c6a19 into open-telemetry:master Nov 27, 2019
@markwolff markwolff deleted the markwolff/add-redis-example branch November 27, 2019 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
document Documentation-related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Examples][Plugin]: Add redis plugin example
8 participants