Skip to content

Commit

Permalink
Merge 79db51e into 494efff
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieDanielson authored Mar 2, 2023
2 parents 494efff + 79db51e commit d950b6e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/

### :books: (Refine Doc)

* chore: update http example [#3651](https://github.com/open-telemetry/opentelemetry-js/pull/3651) @JamieDanielson

### :house: (Internal)

* fix(sdk-metrics): fix flaky LastValueAggregator test by using fake timer [#3587](https://github.com/open-telemetry/opentelemetry-js/pull/3587) @pichlermarc
Expand Down
3 changes: 1 addition & 2 deletions examples/http/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ function makeRequest() {
// span corresponds to outgoing requests. Here, we have manually created
// the span, which is created to track work that happens outside of the
// request lifecycle entirely.
const span = tracer.startSpan('makeRequest');
api.context.with(api.trace.setSpan(api.context.active(), span), () => {
tracer.startActiveSpan('makeRequest', (span) => {
http.get({
host: 'localhost',
port: 8080,
Expand Down
20 changes: 10 additions & 10 deletions examples/http/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "http-example",
"private": true,
"version": "0.25.0",
"version": "0.35.1",
"description": "Example of HTTP integration with OpenTelemetry",
"main": "index.js",
"scripts": {
Expand All @@ -28,15 +28,15 @@
"url": "https://github.com/open-telemetry/opentelemetry-js/issues"
},
"dependencies": {
"@opentelemetry/api": "^1.0.2",
"@opentelemetry/exporter-jaeger": "0.25.0",
"@opentelemetry/exporter-zipkin": "0.25.0",
"@opentelemetry/instrumentation": "0.25.0",
"@opentelemetry/instrumentation-http": "0.25.0",
"@opentelemetry/resources": "0.25.0",
"@opentelemetry/semantic-conventions": "0.25.0",
"@opentelemetry/sdk-trace-node": "0.25.0",
"@opentelemetry/sdk-trace-base": "0.25.0"
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/exporter-jaeger": "1.9.1",
"@opentelemetry/exporter-zipkin": "1.9.1",
"@opentelemetry/instrumentation": "0.35.1",
"@opentelemetry/instrumentation-http": "0.35.1",
"@opentelemetry/resources": "1.9.1",
"@opentelemetry/semantic-conventions": "1.9.1",
"@opentelemetry/sdk-trace-node": "1.9.1",
"@opentelemetry/sdk-trace-base": "1.9.1"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/examples/http",
"devDependencies": {
Expand Down
5 changes: 3 additions & 2 deletions examples/http/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ function startServer(port) {

/** A function which handles requests and send response. */
function handleRequest(request, response) {
const currentSpan = api.trace.getSpan(api.context.active());
const currentSpan = api.trace.getActiveSpan();
// 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', {
kind: 1, // server
attributes: { key: 'value' },
Expand Down

0 comments on commit d950b6e

Please sign in to comment.