Skip to content

Commit

Permalink
docs: use ATTR_SERVICE_NAME instead of deprecated SemanticResourceAtt…
Browse files Browse the repository at this point in the history
…ributes.SERVICE_NAME and remove SemanticResourceAttributes.SERVICE_VERSION from Angular examples
  • Loading branch information
GauthierPLM committed Nov 6, 2024
1 parent c9fee27 commit a2d5d36
Show file tree
Hide file tree
Showing 82 changed files with 223 additions and 236 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { Resource } from '@opentelemetry/resources';
import { B3Propagator } from '@opentelemetry/propagator-b3';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";

const resource = Resource.default().merge(
new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '{{MYAPP}}',
[SemanticResourceAttributes.SERVICE_VERSION]: '0.1.0',
[ATTR_SERVICE_NAME]: '{{MYAPP}}',
})
);

Expand Down Expand Up @@ -89,4 +88,4 @@ Update your Dockerfile as:
# Run the app with the required OpenTelemetry configuration. app.js is your application main file.
CMD ["ng", "serve"]
...
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { Resource } from '@opentelemetry/resources';
import { B3Propagator } from '@opentelemetry/propagator-b3';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";

const resource = Resource.default().merge(
new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '{{MYAPP}}',
[SemanticResourceAttributes.SERVICE_VERSION]: '0.1.0',
[ATTR_SERVICE_NAME]: '{{MYAPP}}',
})
);

Expand Down Expand Up @@ -90,4 +89,4 @@ Update your Dockerfile as:
# Run the app with the required OpenTelemetry configuration. app.js is your application main file.
CMD ["ng", "serve"]
...
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { Resource } from '@opentelemetry/resources';
import { B3Propagator } from '@opentelemetry/propagator-b3';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";

const resource = Resource.default().merge(
new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '{{MYAPP}}',
[SemanticResourceAttributes.SERVICE_VERSION]: '0.1.0',
[ATTR_SERVICE_NAME]: '{{MYAPP}}',
})
);

Expand Down Expand Up @@ -80,4 +79,4 @@ registerInstrumentations({

```ts
import './app/instrument';
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { Resource } from '@opentelemetry/resources';
import { B3Propagator } from '@opentelemetry/propagator-b3';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";

const resource = Resource.default().merge(
new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '{{MYAPP}}',
[SemanticResourceAttributes.SERVICE_VERSION]: '0.1.0',
[ATTR_SERVICE_NAME]: '{{MYAPP}}',
})
);

Expand Down Expand Up @@ -77,4 +76,4 @@ registerInstrumentations({

```ts
import './app/instrument';
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { Resource } from '@opentelemetry/resources';
import { B3Propagator } from '@opentelemetry/propagator-b3';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";

const resource = Resource.default().merge(
new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '{MYAPP}',
[SemanticResourceAttributes.SERVICE_VERSION]: '0.1.0',
[ATTR_SERVICE_NAME]: '{MYAPP}',
})
);

Expand Down Expand Up @@ -76,4 +75,4 @@ registerInstrumentations({

```ts
import './app/instrument';
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { Resource } from '@opentelemetry/resources';
import { B3Propagator } from '@opentelemetry/propagator-b3';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";

const resource = Resource.default().merge(
new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '{{MYAPP}}',
[SemanticResourceAttributes.SERVICE_VERSION]: '0.1.0',
[ATTR_SERVICE_NAME]: '{{MYAPP}}',
})
);

Expand Down Expand Up @@ -77,4 +76,4 @@ registerInstrumentations({

```ts
import './app/instrument';
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { Resource } from '@opentelemetry/resources';
import { B3Propagator } from '@opentelemetry/propagator-b3';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";

const resource = Resource.default().merge(
new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '{MYAPP}',
[SemanticResourceAttributes.SERVICE_VERSION]: '0.1.0',
[ATTR_SERVICE_NAME]: '{MYAPP}',
})
);

Expand Down Expand Up @@ -76,4 +75,4 @@ registerInstrumentations({

```ts
import './app/instrument';
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { Resource } from '@opentelemetry/resources';
import { B3Propagator } from '@opentelemetry/propagator-b3';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";

const resource = Resource.default().merge(
new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '{{MYAPP}}',
[SemanticResourceAttributes.SERVICE_VERSION]: '0.1.0',
[ATTR_SERVICE_NAME]: '{{MYAPP}}',
})
);

Expand Down Expand Up @@ -77,4 +76,4 @@ registerInstrumentations({

```ts
import './app/instrument';
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { Resource } from '@opentelemetry/resources';
import { B3Propagator } from '@opentelemetry/propagator-b3';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";

const resource = Resource.default().merge(
new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '{MYAPP}',
[SemanticResourceAttributes.SERVICE_VERSION]: '0.1.0',
[ATTR_SERVICE_NAME]: '{MYAPP}',
})
);

Expand Down Expand Up @@ -76,4 +75,4 @@ registerInstrumentations({

```ts
import './app/instrument';
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { Resource } from '@opentelemetry/resources';
import { B3Propagator } from '@opentelemetry/propagator-b3';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";

const resource = Resource.default().merge(
new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '{{MYAPP}}',
[SemanticResourceAttributes.SERVICE_VERSION]: '0.1.0',
[ATTR_SERVICE_NAME]: '{{MYAPP}}',
})
);

Expand Down Expand Up @@ -77,4 +76,4 @@ registerInstrumentations({

```ts
import './app/instrument';
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { Resource } from '@opentelemetry/resources';
import { B3Propagator } from '@opentelemetry/propagator-b3';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";

const resource = Resource.default().merge(
new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '{MYAPP}',
[SemanticResourceAttributes.SERVICE_VERSION]: '0.1.0',
[ATTR_SERVICE_NAME]: '{MYAPP}',
})
);

Expand Down Expand Up @@ -76,4 +75,4 @@ registerInstrumentations({

```ts
import './app/instrument';
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { Resource } from '@opentelemetry/resources';
import { B3Propagator } from '@opentelemetry/propagator-b3';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";

const resource = Resource.default().merge(
new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '{{MYAPP}}',
[SemanticResourceAttributes.SERVICE_VERSION]: '0.1.0',
[ATTR_SERVICE_NAME]: '{{MYAPP}}',
})
);

Expand Down Expand Up @@ -83,4 +82,4 @@ OpenTelemetry Node SDK currently does not detect the headers from `.env` files a
```bash
import './app/instrument';
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { Resource } from '@opentelemetry/resources';
import { B3Propagator } from '@opentelemetry/propagator-b3';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";

const resource = Resource.default().merge(
new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '<service_name>',
[SemanticResourceAttributes.SERVICE_VERSION]: '0.1.0',
[ATTR_SERVICE_NAME]: '<service_name>',
})
);

Expand Down Expand Up @@ -79,4 +78,4 @@ registerInstrumentations({
```bash
import './app/instrument';
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const opentelemetry = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http');
const { Resource } = require('@opentelemetry/resources');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { ATTR_SERVICE_NAME } = require('@opentelemetry/semantic-conventions');

// do not set headers in exporterOptions, the OTel spec recommends setting headers through ENV variables
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#specifying-headers-via-environment-variables
Expand All @@ -37,7 +37,7 @@ const sdk = new opentelemetry.NodeSDK({
traceExporter,
instrumentations: [getNodeAutoInstrumentations()],
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '{{MYAPP}}'
[ATTR_SERVICE_NAME]: '{{MYAPP}}'
})
});

Expand Down Expand Up @@ -68,4 +68,4 @@ ENV OTEL_EXPORTER_OTLP_HEADERS="signoz-access-token={{SIGNOZ_INGESTION_KEY}}"
# Run the app with the required OpenTelemetry configuration. app.js is your application main file.
CMD ["node", "-r", "./tracing.js", "app.js"]
...
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const opentelemetry = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http');
const { Resource } = require('@opentelemetry/resources');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { ATTR_SERVICE_NAME } = require('@opentelemetry/semantic-conventions');

const exporterOptions = {
url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4318/v1/traces',
Expand All @@ -35,7 +35,7 @@ const sdk = new opentelemetry.NodeSDK({
traceExporter,
instrumentations: [getNodeAutoInstrumentations()],
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '{{MYAPP}}'
[ATTR_SERVICE_NAME]: '{{MYAPP}}'
})
});

Expand Down Expand Up @@ -63,4 +63,4 @@ Set the SigNoz ingestion key Environment variable and update your run command to
# Run the app with the required OpenTelemetry configuration. app.js is your application main file.
CMD ["node", "-r", "./tracing.js", "app.js"]
...
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const opentelemetry = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http');
const { Resource } = require('@opentelemetry/resources');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { ATTR_SERVICE_NAME } = require('@opentelemetry/semantic-conventions');

const exporterOptions = {
url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4318/v1/traces',
Expand All @@ -38,7 +38,7 @@ const sdk = new opentelemetry.NodeSDK({
traceExporter,
instrumentations: [getNodeAutoInstrumentations()],
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '{{MYAPP}}'
[ATTR_SERVICE_NAME]: '{{MYAPP}}'
})
});

Expand All @@ -53,4 +53,4 @@ process.on('SIGTERM', () => {
.catch((error) => console.log('Error terminating tracing', error))
.finally(() => process.exit(0));
});
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const opentelemetry = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http');
const { Resource } = require('@opentelemetry/resources');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { ATTR_SERVICE_NAME } = require('@opentelemetry/semantic-conventions');

// do not set headers in exporterOptions, the OTel spec recommends setting headers through ENV variables
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#specifying-headers-via-environment-variables
Expand All @@ -37,7 +37,7 @@ const sdk = new opentelemetry.NodeSDK({
traceExporter,
instrumentations: [getNodeAutoInstrumentations()],
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: '{{MYAPP}}'
[ATTR_SERVICE_NAME]: '{{MYAPP}}'
})
});

Expand All @@ -52,4 +52,4 @@ process.on('SIGTERM', () => {
.catch((error) => console.log('Error terminating tracing', error))
.finally(() => process.exit(0));
});
```
```
Loading

0 comments on commit a2d5d36

Please sign in to comment.