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

chore: Update deprecations in instrumentation-express/examples #1842

Merged
merged 16 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
186 changes: 19 additions & 167 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ shows key aspects of tracing such as
## Installation

```sh
# from this directory
npm install
# from this directory, install all necessary dependencies from the workspace
npm run setup

# OR alternatively, install dependencies from npm as a standalone example app
npm install --workspaces=false
JamieDanielson marked this conversation as resolved.
Show resolved Hide resolved
```

Setup [Zipkin Tracing](https://zipkin.io/pages/quickstart.html)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
{
"name": "express-example",
"private": true,
"version": "0.28.0",
"version": "0.34.1",
"description": "Example of Express integration with OpenTelemetry",
"main": "index.js",
"scripts": {
"zipkin:server": "cross-env EXPORTER=zipkin ts-node src/server.ts",
"zipkin:client": "cross-env EXPORTER=zipkin ts-node src/client.ts",
"jaeger:server": "cross-env EXPORTER=jaeger ts-node src/server.ts",
"jaeger:client": "cross-env EXPORTER=jaeger ts-node src/client.ts",
"compile": "tsc -p ."
"compile": "tsc -p .",
"setup": "cd ../../../../ && npm ci && cd plugins/node/opentelemetry-instrumentation-express && npm run compile && cd examples && npm run compile"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/open-telemetry/opentelemetry-js.git"
"url": "git+ssh://git@github.com/open-telemetry/opentelemetry-js-contrib.git",
"directory": "plugins/node/opentelemetry-instrumentation-express"
},
"keywords": [
"opentelemetry",
Expand All @@ -26,24 +27,25 @@
"author": "OpenTelemetry Authors",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/open-telemetry/opentelemetry-js/issues"
"url": "https://github.com/open-telemetry/opentelemetry-js-contrib/issues"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-express/examples#readme",
"dependencies": {
"@opentelemetry/api": "^1.0.0",
"@opentelemetry/exporter-jaeger": "^1.0.0",
"@opentelemetry/exporter-zipkin": "^1.0.0",
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/exporter-jaeger": "^1.18.1",
"@opentelemetry/exporter-trace-otlp-proto": "^0.46.0",
"@opentelemetry/exporter-zipkin": "^1.18.1",
"@opentelemetry/instrumentation": "^0.46.0",
"@opentelemetry/instrumentation-express": "0.28.0",
"@opentelemetry/instrumentation-express": "^0.34.1",
"@opentelemetry/instrumentation-http": "^0.46.0",
"@opentelemetry/resources": "^1.0.0",
"@opentelemetry/sdk-trace-base": "^1.0.0",
"@opentelemetry/sdk-trace-node": "^1.0.0",
"@opentelemetry/semantic-conventions": "^1.0.0",
"@opentelemetry/resources": "^1.18.1",
"@opentelemetry/sdk-trace-base": "^1.18.1",
"@opentelemetry/sdk-trace-node": "^1.18.1",
"@opentelemetry/semantic-conventions": "^1.18.1",
trentm marked this conversation as resolved.
Show resolved Hide resolved
"axios": "^1.6.0",
"cross-env": "^7.0.3",
"express": "^4.17.1"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js#readme",
"devDependencies": {
"@types/express": "^4.17.13",
"ts-node": "^10.6.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
'use strict';

import { Sampler, SpanKind } from "@opentelemetry/api";
import { SpanKind, Attributes } from "@opentelemetry/api";

const opentelemetry = require('@opentelemetry/api');

// Not functionally required but gives some insight what happens behind the scenes
const { diag, DiagConsoleLogger, DiagLogLevel } = opentelemetry;
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO);

import { AlwaysOnSampler } from '@opentelemetry/core';
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';
import { JaegerExporter } from '@opentelemetry/exporter-jaeger';
import { Sampler, AlwaysOnSampler, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
import { ZipkinExporter } from '@opentelemetry/exporter-zipkin';
import { Resource } from '@opentelemetry/resources';
import { SemanticAttributes, SemanticResourceAttributes as ResourceAttributesSC } from '@opentelemetry/semantic-conventions';
import { SpanAttributes } from "@opentelemetry/api/build/src/trace/attributes";

const Exporter = (process.env.EXPORTER || '').toLowerCase().startsWith('z') ? ZipkinExporter : JaegerExporter;
const Exporter = (process.env.EXPORTER || '').toLowerCase().startsWith('z') ? ZipkinExporter : OTLPTraceExporter;
import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express';
const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http');

Expand Down Expand Up @@ -50,7 +48,7 @@ export const setupTracing = (serviceName: string) => {
return opentelemetry.trace.getTracer(serviceName);
};

type FilterFunction = (spanName: string, spanKind: SpanKind, attributes: SpanAttributes) => boolean;
type FilterFunction = (spanName: string, spanKind: SpanKind, attributes: Attributes) => boolean;

function filterSampler(filterFn: FilterFunction, parent: Sampler): Sampler {
return {
Expand All @@ -66,6 +64,6 @@ function filterSampler(filterFn: FilterFunction, parent: Sampler): Sampler {
}
}

function ignoreHealthCheck(spanName: string, spanKind: SpanKind, attributes: SpanAttributes) {
function ignoreHealthCheck(spanName: string, spanKind: SpanKind, attributes: Attributes) {
return spanKind !== opentelemetry.SpanKind.SERVER || attributes[SemanticAttributes.HTTP_ROUTE] !== "/health";
}
Loading