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

feat: updated spec to v1.5.0 and renamed resource class #2345

Merged
merged 15 commits into from
Jul 25, 2021
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ To request automatic tracing support for a module not on this list, please [file

## Upgrade guidelines

### 0.23.x to x

- `ResourceAttributes` renamed to `SemanticResourceAttributes` in the `@opentelemetry/semantic-conventions` package

### 0.20.x to x

### 0.19.x to 0.20.0
Expand Down
4 changes: 2 additions & 2 deletions examples/basic-tracer-node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

const opentelemetry = require('@opentelemetry/api');
const { Resource } = require('@opentelemetry/resources');
const { ResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { BasicTracerProvider, ConsoleSpanExporter, SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger');

const provider = new BasicTracerProvider({
resource: new Resource({
[ResourceAttributes.SERVICE_NAME]: 'basic-service',
[SemanticResourceAttributes.SERVICE_NAME]: 'basic-service',
}),
});

Expand Down
4 changes: 2 additions & 2 deletions examples/collector-exporter-node/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { CollectorMetricExporter } = require('@opentelemetry/exporter-collector')
// const { CollectorMetricExporter } = require('@opentelemetry/exporter-collector-proto');
const { MeterProvider } = require('@opentelemetry/metrics');
const { Resource } = require('@opentelemetry/resources');
const { ResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');

// Optional and only needed to see the internal diagnostic logging (during development)
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);
Expand All @@ -19,7 +19,7 @@ const meter = new MeterProvider({
exporter: metricExporter,
interval: 1000,
resource: new Resource({
[ResourceAttributes.SERVICE_NAME]: 'basic-metric-service',
[SemanticResourceAttributes.SERVICE_NAME]: 'basic-metric-service',
}),
}).getMeter('example-exporter-collector');

Expand Down
4 changes: 2 additions & 2 deletions examples/collector-exporter-node/tracing.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const opentelemetry = require('@opentelemetry/api');
const { BasicTracerProvider, ConsoleSpanExporter, SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector');
const { Resource } = require('@opentelemetry/resources');
const { ResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
// const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector-grpc');
// const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector-proto');

Expand All @@ -21,7 +21,7 @@ const exporter = new CollectorTraceExporter({

const provider = new BasicTracerProvider({
resource: new Resource({
[ResourceAttributes.SERVICE_NAME]: 'basic-service',
[SemanticResourceAttributes.SERVICE_NAME]: 'basic-service',
}),
});
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
Expand Down
4 changes: 2 additions & 2 deletions examples/grpc-js/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const opentelemetry = require('@opentelemetry/api');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { NodeTracerProvider } = require('@opentelemetry/node');
const { Resource } = require('@opentelemetry/resources');
const { ResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger');
const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin');
Expand All @@ -15,7 +15,7 @@ const EXPORTER = process.env.EXPORTER || '';
module.exports = (serviceName) => {
const provider = new NodeTracerProvider({
resource: new Resource({
[ResourceAttributes.SERVICE_NAME]: serviceName,
[SemanticResourceAttributes.SERVICE_NAME]: serviceName,
}),
});

Expand Down
4 changes: 2 additions & 2 deletions examples/grpc/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const opentelemetry = require('@opentelemetry/api');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { NodeTracerProvider } = require('@opentelemetry/node');
const { Resource } = require('@opentelemetry/resources');
const { ResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger');
const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin');
Expand All @@ -15,7 +15,7 @@ const EXPORTER = process.env.EXPORTER || '';
module.exports = (serviceName) => {
const provider = new NodeTracerProvider({
resource: new Resource({
[ResourceAttributes.SERVICE_NAME]: serviceName,
[SemanticResourceAttributes.SERVICE_NAME]: serviceName,
}),
});

Expand Down
4 changes: 2 additions & 2 deletions examples/http/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const opentelemetry = require('@opentelemetry/api');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { NodeTracerProvider } = require('@opentelemetry/node');
const { Resource } = require('@opentelemetry/resources');
const { ResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger');
const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin');
Expand All @@ -15,7 +15,7 @@ const EXPORTER = process.env.EXPORTER || '';
module.exports = (serviceName) => {
const provider = new NodeTracerProvider({
resource: new Resource({
[ResourceAttributes.SERVICE_NAME]: serviceName,
[SemanticResourceAttributes.SERVICE_NAME]: serviceName,
}),
});

Expand Down
4 changes: 2 additions & 2 deletions examples/https/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const opentelemetry = require('@opentelemetry/api');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { NodeTracerProvider } = require('@opentelemetry/node');
const { Resource } = require('@opentelemetry/resources');
const { ResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger');
const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin');
Expand All @@ -17,7 +17,7 @@ module.exports = (serviceName) => {
let exporter;
const provider = new NodeTracerProvider({
resource: new Resource({
[ResourceAttributes.SERVICE_NAME]: serviceName,
[SemanticResourceAttributes.SERVICE_NAME]: serviceName,
}),
});

Expand Down
4 changes: 2 additions & 2 deletions examples/opentracing-shim/shim.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const { ResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { Resource } = require('@opentelemetry/resources');
const { NodeTracerProvider } = require('@opentelemetry/node');
const { SimpleSpanProcessor } = require('@opentelemetry/tracing');
Expand All @@ -10,7 +10,7 @@ const { TracerShim } = require('@opentelemetry/shim-opentracing');

function shim(serviceName) {
const provider = new NodeTracerProvider({
resource: new Resource({ [ResourceAttributes.SERVICE_NAME]: serviceName }),
resource: new Resource({ [SemanticResourceAttributes.SERVICE_NAME]: serviceName }),
});

provider.addSpanProcessor(new SimpleSpanProcessor(getExporter(serviceName)));
Expand Down
4 changes: 2 additions & 2 deletions examples/tracer-web/examples/metrics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { DiagConsoleLogger, DiagLogLevel, diag } = require('@opentelemetry/api');
const { CollectorMetricExporter } = require('@opentelemetry/exporter-collector');
const { MeterProvider } = require('@opentelemetry/metrics');
const { Resource } = require('@opentelemetry/resources');
const { ResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');

// Optional and only needed to see the internal diagnostic logging (during development)
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);
Expand All @@ -26,7 +26,7 @@ function startMetrics() {
exporter: metricExporter,
interval: 1000,
resource: new Resource({
[ResourceAttributes.SERVICE_NAME]: 'basic-metric-service',
[SemanticResourceAttributes.SERVICE_NAME]: 'basic-metric-service',
}),
}).getMeter('example-exporter-collector');

Expand Down
4 changes: 2 additions & 2 deletions getting-started/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ After you install these dependencies, initialize and register them. Modify `trac
const { diag, DiagConsoleLogger, DiagLogLevel } = require("@opentelemetry/api");
const { NodeTracerProvider } = require("@opentelemetry/node");
const { Resource } = require('@opentelemetry/resources');
const { ResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { SimpleSpanProcessor } = require("@opentelemetry/tracing");
const { ZipkinExporter } = require("@opentelemetry/exporter-zipkin");
const { registerInstrumentations } = require("@opentelemetry/instrumentation");
Expand All @@ -135,7 +135,7 @@ const { GrpcInstrumentation } = require("@opentelemetry/instrumentation-grpc");

const provider = new NodeTracerProvider({
resource: new Resource({
[ResourceAttributes.SERVICE_NAME]: "getting-started",
[SemanticResourceAttributes.SERVICE_NAME]: "getting-started",
})
});

Expand Down
4 changes: 2 additions & 2 deletions getting-started/traced-example/tracing.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
const { NodeTracerProvider } = require("@opentelemetry/node");
const { SimpleSpanProcessor } = require("@opentelemetry/tracing");
const { Resource } = require('@opentelemetry/resources');
const { ResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { ZipkinExporter } = require("@opentelemetry/exporter-zipkin");
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { ExpressInstrumentation } = require('@opentelemetry/instrumentation-express');
const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http');

const provider = new NodeTracerProvider({
resource: new Resource({
[ResourceAttributes.SERVICE_NAME]: "getting-started",
[SemanticResourceAttributes.SERVICE_NAME]: "getting-started",
})
});

Expand Down
3 changes: 2 additions & 1 deletion getting-started/ts-example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,12 @@ import { ZipkinExporter } from '@opentelemetry/exporter-zipkin';
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express';
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';

const provider: NodeTracerProvider = new NodeTracerProvider({
logLevel: LogLevel.ERROR,
resource: new Resource({
[ResourceAttributes.SERVICE_NAME]: 'getting-started',
[SemanticResourceAttributes.SERVICE_NAME]: 'getting-started',
}),
});

Expand Down
4 changes: 2 additions & 2 deletions getting-started/ts-example/traced-example/tracing.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NodeTracerProvider } from '@opentelemetry/node';
const { Resource } = require('@opentelemetry/resources');
const { ResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');

import { SimpleSpanProcessor } from '@opentelemetry/tracing';
import { ZipkinExporter } from '@opentelemetry/exporter-zipkin';
Expand All @@ -13,7 +13,7 @@ const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http');

const provider: NodeTracerProvider = new NodeTracerProvider({
resource: new Resource({
[ResourceAttributes.SERVICE_NAME]: 'getting-started',
[SemanticResourceAttributes.SERVICE_NAME]: 'getting-started',
}),
});
provider.addSpanProcessor(
Expand Down
10 changes: 5 additions & 5 deletions packages/opentelemetry-core/src/platform/browser/sdk-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
import { VERSION } from '../../version';
import {
TelemetrySdkLanguageValues,
ResourceAttributes,
SemanticResourceAttributes,
} from '@opentelemetry/semantic-conventions';

/** Constants describing the SDK in use */
export const SDK_INFO = {
[ResourceAttributes.TELEMETRY_SDK_NAME]: 'opentelemetry',
[ResourceAttributes.PROCESS_RUNTIME_NAME]: 'browser',
[ResourceAttributes.TELEMETRY_SDK_LANGUAGE]: TelemetrySdkLanguageValues.WEBJS,
[ResourceAttributes.TELEMETRY_SDK_VERSION]: VERSION,
[SemanticResourceAttributes.TELEMETRY_SDK_NAME]: 'opentelemetry',
[SemanticResourceAttributes.PROCESS_RUNTIME_NAME]: 'browser',
[SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE]: TelemetrySdkLanguageValues.WEBJS,
[SemanticResourceAttributes.TELEMETRY_SDK_VERSION]: VERSION,
};
10 changes: 5 additions & 5 deletions packages/opentelemetry-core/src/platform/node/sdk-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
import { VERSION } from '../../version';
import {
TelemetrySdkLanguageValues,
ResourceAttributes,
SemanticResourceAttributes,
} from '@opentelemetry/semantic-conventions';

/** Constants describing the SDK in use */
export const SDK_INFO = {
[ResourceAttributes.TELEMETRY_SDK_NAME]: 'opentelemetry',
[ResourceAttributes.PROCESS_RUNTIME_NAME]: 'node',
[ResourceAttributes.TELEMETRY_SDK_LANGUAGE]:
[SemanticResourceAttributes.TELEMETRY_SDK_NAME]: 'opentelemetry',
[SemanticResourceAttributes.PROCESS_RUNTIME_NAME]: 'node',
[SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE]:
TelemetrySdkLanguageValues.NODEJS,
[ResourceAttributes.TELEMETRY_SDK_VERSION]: VERSION,
[SemanticResourceAttributes.TELEMETRY_SDK_VERSION]: VERSION,
};
4 changes: 2 additions & 2 deletions packages/opentelemetry-exporter-jaeger/src/jaeger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { diag } from '@opentelemetry/api';
import { ExportResult, ExportResultCode, getEnv } from '@opentelemetry/core';
import { ReadableSpan, SpanExporter } from '@opentelemetry/tracing';
import { Socket } from 'dgram';
import { ResourceAttributes } from '@opentelemetry/semantic-conventions';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { spanToThrift } from './transform';
import * as jaegerTypes from './types';

Expand Down Expand Up @@ -155,7 +155,7 @@ export class JaegerExporter implements SpanExporter {
sender._client.unref();
}

const serviceNameTag = span.tags.find(t => t.key === ResourceAttributes.SERVICE_NAME)
const serviceNameTag = span.tags.find(t => t.key === SemanticResourceAttributes.SERVICE_NAME)
const serviceName = serviceNameTag?.vStr || 'unknown_service';

sender.setProcess({
Expand Down
6 changes: 3 additions & 3 deletions packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { ReadableSpan } from '@opentelemetry/tracing';
import { TraceFlags } from '@opentelemetry/api';
import { Resource } from '@opentelemetry/resources';
import * as nock from 'nock';
import { ResourceAttributes } from '@opentelemetry/semantic-conventions';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';

describe('JaegerExporter', () => {
const readableSpan: ReadableSpan = {
Expand All @@ -47,7 +47,7 @@ describe('JaegerExporter', () => {
events: [],
duration: [32, 800000000],
resource: new Resource({
[ResourceAttributes.SERVICE_NAME]: 'opentelemetry'
[SemanticResourceAttributes.SERVICE_NAME]: 'opentelemetry'
}),
instrumentationLibrary: {
name: 'default',
Expand All @@ -70,7 +70,7 @@ describe('JaegerExporter', () => {
const scope =nock(mockedEndpoint)
.post('/')
.reply(202)

const exporter = new JaegerExporter({
endpoint: mockedEndpoint,
});
Expand Down
8 changes: 4 additions & 4 deletions packages/opentelemetry-exporter-zipkin/src/zipkin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
statusCodeTagName,
statusDescriptionTagName,
} from './transform';
import { ResourceAttributes } from '@opentelemetry/semantic-conventions';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { prepareGetHeaders } from './utils';

/**
Expand Down Expand Up @@ -66,7 +66,7 @@ export class ZipkinExporter implements SpanExporter {
) {
const serviceName = String(
this._serviceName ||
spans[0].resource.attributes[ResourceAttributes.SERVICE_NAME] ||
spans[0].resource.attributes[SemanticResourceAttributes.SERVICE_NAME] ||
this.DEFAULT_SERVICE_NAME
);

Expand Down Expand Up @@ -128,8 +128,8 @@ export class ZipkinExporter implements SpanExporter {
toZipkinSpan(
span,
String(
span.attributes[ResourceAttributes.SERVICE_NAME] ||
span.resource.attributes[ResourceAttributes.SERVICE_NAME] ||
span.attributes[SemanticResourceAttributes.SERVICE_NAME] ||
span.resource.attributes[SemanticResourceAttributes.SERVICE_NAME] ||
serviceName
),
this._statusCodeTagName,
Expand Down
Loading