-
Notifications
You must be signed in to change notification settings - Fork 821
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: use a single eslintrc for all examples folders furthermore, override the strict rule that ships with airbnb * fix: turn off no-use-before-define * fix: install eslint in ci container Co-Authored-By: Daniel Dyla <[email protected]> * fix: ignore uninstalled packages lint errors We will not want to install all examples in CI Co-authored-by: Daniel Dyla <[email protected]> Co-authored-by: Mayur Kale <[email protected]>
- Loading branch information
1 parent
230842f
commit d7f4fe2
Showing
45 changed files
with
727 additions
and
715 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"env": { | ||
"node": true | ||
}, | ||
"extends": "airbnb-base", | ||
"parserOptions": { | ||
"sourceType": "script" | ||
}, | ||
"rules": { | ||
"strict": ["error", "global"], | ||
"no-use-before-define": ["error", "nofunc"], | ||
"no-console": "off", | ||
"import/no-unresolved": "off", | ||
"no-unused-vars": ["error", { "argsIgnorePattern": "^_" }] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,34 @@ | ||
'use strict'; | ||
|
||
const opentelemetry = require('@opentelemetry/core'); | ||
const config = require('./setup'); | ||
|
||
/** | ||
* The trace instance needs to be initialized first, if you want to enable | ||
* automatic tracing for built-in plugins (DNS in this case). | ||
*/ | ||
config.setupTracerAndExporters('dns-client-service'); | ||
|
||
const tracer = require('./tracer')('example-dns'); | ||
// eslint-disable-next-line import/order | ||
const dns = require('dns').promises; | ||
const tracer = opentelemetry.getTracer('example-dns'); | ||
|
||
/** A function which makes a dns lookup and handles response. */ | ||
function makeLookup() { | ||
// span corresponds to dns lookup. Here, we have manually created | ||
// the span, which is created to track work that happens outside of the | ||
// dns lookup query. | ||
const span = tracer.startSpan('dnsLookup'); | ||
tracer.withSpan(span, async () => { | ||
try { | ||
await dns.lookup('montreal.ca'); | ||
} catch (error) { | ||
span.setAttributes({ | ||
'error.name': error.name, | ||
'error.message': error.message | ||
}); | ||
}finally{ | ||
console.log(`traceid: ${span.context().traceId}`); | ||
span.end(); | ||
} | ||
}); | ||
// span corresponds to dns lookup. Here, we have manually created | ||
// the span, which is created to track work that happens outside of the | ||
// dns lookup query. | ||
const span = tracer.startSpan('dnsLookup'); | ||
tracer.withSpan(span, async () => { | ||
try { | ||
await dns.lookup('montreal.ca'); | ||
} catch (error) { | ||
span.setAttributes({ | ||
'error.name': error.name, | ||
'error.message': error.message, | ||
}); | ||
} finally { | ||
console.log(`traceid: ${span.context().traceId}`); | ||
span.end(); | ||
} | ||
}); | ||
|
||
// The process must live for at least the interval past any traces that | ||
// must be exported, or some risk being lost if they are recorded after the | ||
// last export. | ||
console.log('Sleeping 5 seconds before shutdown to ensure all records are flushed.') | ||
setTimeout(() => { console.log('Completed.'); }, 5000); | ||
// The process must live for at least the interval past any traces that | ||
// must be exported, or some risk being lost if they are recorded after the | ||
// last export. | ||
console.log('Sleeping 5 seconds before shutdown to ensure all records are flushed.'); | ||
setTimeout(() => { console.log('Completed.'); }, 5000); | ||
} | ||
|
||
makeLookup(); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict'; | ||
|
||
const opentelemetry = require('@opentelemetry/core'); | ||
const { NodeTracerRegistry } = require('@opentelemetry/node'); | ||
const { SimpleSpanProcessor } = require('@opentelemetry/tracing'); | ||
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger'); | ||
const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin'); | ||
|
||
const EXPORTER = process.env.EXPORTER || ''; | ||
|
||
module.exports = (serviceName) => { | ||
const registry = new NodeTracerRegistry({ | ||
plugins: { | ||
dns: { | ||
enabled: true, | ||
path: '@opentelemetry/plugin-dns', | ||
// Avoid dns lookup loop with http zipkin calls | ||
ignoreHostnames: ['localhost'], | ||
}, | ||
}, | ||
}); | ||
|
||
let exporter; | ||
if (EXPORTER.toLowerCase().startsWith('z')) { | ||
exporter = new ZipkinExporter({ | ||
serviceName, | ||
}); | ||
} else { | ||
exporter = new JaegerExporter({ | ||
serviceName, | ||
}); | ||
} | ||
|
||
registry.addSpanProcessor(new SimpleSpanProcessor(exporter)); | ||
|
||
// Initialize the OpenTelemetry APIs to use the BasicTracerRegistry bindings | ||
opentelemetry.initGlobalTracerRegistry(registry); | ||
|
||
return opentelemetry.getTracer(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.