chore: update http example (#3651)
* update versions in http example * use newer active span methods for http example * fix(changelog): add changelog entry * Add http example to lerna --------- Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>
This commit is contained in:
parent
494efffcf4
commit
4a4484a910
|
@ -27,6 +27,8 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/
|
||||||
|
|
||||||
### :books: (Refine Doc)
|
### :books: (Refine Doc)
|
||||||
|
|
||||||
|
* chore: update http example [#3651](https://github.com/open-telemetry/opentelemetry-js/pull/3651) @JamieDanielson
|
||||||
|
|
||||||
### :house: (Internal)
|
### :house: (Internal)
|
||||||
|
|
||||||
* fix(sdk-metrics): fix flaky LastValueAggregator test by using fake timer [#3587](https://github.com/open-telemetry/opentelemetry-js/pull/3587) @pichlermarc
|
* fix(sdk-metrics): fix flaky LastValueAggregator test by using fake timer [#3587](https://github.com/open-telemetry/opentelemetry-js/pull/3587) @pichlermarc
|
||||||
|
|
|
@ -9,8 +9,7 @@ function makeRequest() {
|
||||||
// span corresponds to outgoing requests. Here, we have manually created
|
// span corresponds to outgoing requests. Here, we have manually created
|
||||||
// the span, which is created to track work that happens outside of the
|
// the span, which is created to track work that happens outside of the
|
||||||
// request lifecycle entirely.
|
// request lifecycle entirely.
|
||||||
const span = tracer.startSpan('makeRequest');
|
tracer.startActiveSpan('makeRequest', (span) => {
|
||||||
api.context.with(api.trace.setSpan(api.context.active(), span), () => {
|
|
||||||
http.get({
|
http.get({
|
||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
port: 8080,
|
port: 8080,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "http-example",
|
"name": "http-example",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.25.0",
|
"version": "0.35.1",
|
||||||
"description": "Example of HTTP integration with OpenTelemetry",
|
"description": "Example of HTTP integration with OpenTelemetry",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -28,15 +28,15 @@
|
||||||
"url": "https://github.com/open-telemetry/opentelemetry-js/issues"
|
"url": "https://github.com/open-telemetry/opentelemetry-js/issues"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@opentelemetry/api": "^1.0.2",
|
"@opentelemetry/api": "^1.3.0",
|
||||||
"@opentelemetry/exporter-jaeger": "0.25.0",
|
"@opentelemetry/exporter-jaeger": "1.9.1",
|
||||||
"@opentelemetry/exporter-zipkin": "0.25.0",
|
"@opentelemetry/exporter-zipkin": "1.9.1",
|
||||||
"@opentelemetry/instrumentation": "0.25.0",
|
"@opentelemetry/instrumentation": "0.35.1",
|
||||||
"@opentelemetry/instrumentation-http": "0.25.0",
|
"@opentelemetry/instrumentation-http": "0.35.1",
|
||||||
"@opentelemetry/resources": "0.25.0",
|
"@opentelemetry/resources": "1.9.1",
|
||||||
"@opentelemetry/semantic-conventions": "0.25.0",
|
"@opentelemetry/semantic-conventions": "1.9.1",
|
||||||
"@opentelemetry/sdk-trace-node": "0.25.0",
|
"@opentelemetry/sdk-trace-node": "1.9.1",
|
||||||
"@opentelemetry/sdk-trace-base": "0.25.0"
|
"@opentelemetry/sdk-trace-base": "1.9.1"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/examples/http",
|
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/examples/http",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -19,9 +19,10 @@ function startServer(port) {
|
||||||
|
|
||||||
/** A function which handles requests and send response. */
|
/** A function which handles requests and send response. */
|
||||||
function handleRequest(request, response) {
|
function handleRequest(request, response) {
|
||||||
const currentSpan = api.trace.getSpan(api.context.active());
|
const currentSpan = api.trace.getActiveSpan();
|
||||||
// display traceid in the terminal
|
// display traceid in the terminal
|
||||||
console.log(`traceid: ${currentSpan.spanContext().traceId}`);
|
const traceId = currentSpan.spanContext().traceId;
|
||||||
|
console.log(`traceId: ${traceId}`);
|
||||||
const span = tracer.startSpan('handleRequest', {
|
const span = tracer.startSpan('handleRequest', {
|
||||||
kind: 1, // server
|
kind: 1, // server
|
||||||
attributes: { key: 'value' },
|
attributes: { key: 'value' },
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"selenium-tests",
|
"selenium-tests",
|
||||||
"examples/otlp-exporter-node",
|
"examples/otlp-exporter-node",
|
||||||
"examples/opentelemetry-web",
|
"examples/opentelemetry-web",
|
||||||
|
"examples/http",
|
||||||
"examples/https"
|
"examples/https"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue