Last active
April 22, 2021 15:34
-
-
Save svrnm/2a1f856e485bd056796be9a44d4fe77f to your computer and use it in GitHub Desktop.
otel-dns-net-http-combined
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
'use strict'; | |
const { diag, DiagConsoleLogger, DiagLogLevel } = require('@opentelemetry/api'); | |
const { NodeTracerProvider } = require('@opentelemetry/node'); | |
const { NetInstrumentation } = require('@opentelemetry/instrumentation-net'); | |
const { DnsInstrumentation } = require('@opentelemetry/instrumentation-dns'); | |
const { registerInstrumentations } = require('@opentelemetry/instrumentation'); | |
const { SimpleSpanProcessor, ConsoleSpanExporter } = require('@opentelemetry/tracing'); | |
const provider = new NodeTracerProvider(); | |
provider.register(); | |
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.ALL); | |
provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter())); | |
registerInstrumentations({ | |
instrumentations: [ | |
new NetInstrumentation(), | |
new DnsInstrumentation({ | |
// Avoid dns lookup loop with http zipkin calls | |
ignoreHostnames: ['localhost'], | |
}), | |
// new TLSInstrumentation(), | |
], | |
tracerProvider: provider, | |
}); | |
const net = require('net'); | |
const dns = require('dns'); | |
const https = require('https'); | |
https.get('https://opentelemetry.io/', (res) => { | |
console.log('statusCode:', res.statusCode); | |
console.log('headers:', res.headers); | |
res.on('data', () => { | |
process.stdout.write('.'); | |
}); | |
}).on('error', (e) => { | |
console.error(e); | |
}); |
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
Applying patch for net module | |
Applying patch for dns | |
patch lookup function | |
patch lookup function | |
PluginLoader#load: trying to load [email protected] | |
PluginLoader#load: applying patch to [email protected] using @opentelemetry/plugin-dns module | |
PluginLoader#load: could not load plugin @opentelemetry/plugin-dns of module dns. Error: Cannot find module '@opentelemetry/plugin-dns' | |
Require stack: | |
- ... | |
PluginLoader#load: trying to load [email protected] | |
PluginLoader#load: applying patch to [email protected] using @opentelemetry/plugin-https module | |
applying patch to [email protected] | |
wrap lookup callback function and starts span | |
https plugin outgoingRequest | |
_traceClientRequest return request | |
executing wrapped lookup callback function | |
{ | |
traceId: '326b540c3e6025f04cac2081322a0281', | |
parentId: undefined, | |
name: 'dns.lookup', | |
id: 'c0497285f44dfe3c', | |
kind: 2, | |
timestamp: 1619105598818466, | |
duration: 36903, | |
attributes: { | |
'net.peer.host': 'opentelemetry.io', | |
'peer.ipv4': '18.198.108.208' | |
}, | |
status: { code: 0 }, | |
events: [] | |
} | |
executing original lookup callback function | |
{ | |
traceId: '3c4b5fbedb67e28da8f5569f2a0b36b3', | |
parentId: undefined, | |
name: 'tcp.connect', | |
id: '42879d4ea1fe0620', | |
kind: 0, | |
timestamp: 1619105598816848, | |
duration: 63850, | |
attributes: { | |
'net.transport': 'IP.TCP', | |
'net.peer.name': 'opentelemetry.io', | |
'net.peer.port': 443, | |
'net.peer.ip': '18.198.108.208', | |
'net.host.ip': '192.168.229.67', | |
'net.host.port': 51491 | |
}, | |
status: { code: 0 }, | |
events: [] | |
} | |
statusCode: 200 | |
headers: { | |
'cache-control': 'public, max-age=0, must-revalidate', | |
'content-type': 'text/html; charset=UTF-8', | |
date: 'Thu, 22 Apr 2021 14:56:35 GMT', | |
etag: '"4d00acf1293d23a88db4dfbbd4ff03fb-ssl"', | |
'strict-transport-security': 'max-age=31536000', | |
age: '2203', | |
'content-length': '13663', | |
connection: 'close', | |
server: 'Netlify', | |
'x-nf-request-id': 'cba28332-51b0-449d-a8f0-5c968dc5ca1f-12590647' | |
} | |
outgoingRequest on response() | |
.outgoingRequest on end() | |
{ | |
traceId: '7fc66ee5e079f25416ef6712f3497a0b', | |
parentId: undefined, | |
name: 'HTTP GET', | |
id: 'b89e0e4ab581372c', | |
kind: 2, | |
timestamp: 1619105598802973, | |
duration: 157881, | |
attributes: { | |
'http.url': 'https://opentelemetry.io/', | |
'http.method': 'GET', | |
'http.target': '/', | |
'net.peer.name': 'opentelemetry.io', | |
'net.peer.ip': '18.198.108.208', | |
'net.peer.port': 443, | |
'http.host': 'opentelemetry.io:443', | |
'http.response_content_length_uncompressed': 13663, | |
'http.status_code': 200, | |
'http.status_text': 'OK', | |
'http.flavor': '1.1', | |
'net.transport': 'IP.TCP' | |
}, | |
status: { code: 1 }, | |
even |
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
{ | |
"dependencies": { | |
"@opentelemetry/api": "^0.18.1", | |
"@opentelemetry/exporter-jaeger": "^0.18.2", | |
"@opentelemetry/exporter-zipkin": "^0.18.2", | |
"@opentelemetry/instrumentation": "^0.18.2", | |
"@opentelemetry/instrumentation-net": "^0.15.0", | |
"@opentelemetry/instrumentation-dns": "^0.15.0", | |
"@opentelemetry/node": "^0.18.2", | |
"@opentelemetry/plugin-https": "^0.18.2", | |
"@opentelemetry/tracing": "^0.18.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment