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

refactor(attributes): move enums to @opentelemetry/semantic-conventions #1160

Merged
merged 9 commits into from
Jun 15, 2020
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*!
* Copyright 2020, OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -14,32 +14,62 @@
* limitations under the License.
*/

/**
* Attributes Names according to [OpenTelemetry attributes specs](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-http.md#common-attributes)
*/
/**
* Common attribute names defined by the Opetelemetry Semantic Conventions specification
* https://github.com/open-telemetry/opentelemetry-specification/tree/master/specification/trace/semantic_conventions
*/
export enum AttributeNames {
HTTP_HOST = 'http.host',
COMPONENT = 'component',

// grpc
GRPC_KIND = 'grpc.kind', // SERVER or CLIENT
GRPC_METHOD = 'grpc.method',
GRPC_STATUS_CODE = 'grpc.status_code',
GRPC_ERROR_NAME = 'grpc.error_name',
GRPC_ERROR_MESSAGE = 'grpc.error_message',

// http
HTTP_HOST = 'http.host',
HTTP_METHOD = 'http.method',
HTTP_TARGET = 'http.target',
HTTP_ROUTE = 'http.route',
HTTP_URL = 'http.url',
HTTP_STATUS_CODE = 'http.status_code',
HTTP_STATUS_TEXT = 'http.status_text',
HTTP_FLAVOR = 'http.flavor',
HTTP_SERVER_NAME = 'http.server_name',
HTTP_CLIENT_IP = 'http.client_ip',
HTTP_SCHEME = 'http.scheme',

// http (NOT ON OFFICIAL SPEC)
HTTP_ERROR_NAME = 'http.error_name',
HTTP_ERROR_MESSAGE = 'http.error_message',
HTTP_USER_AGENT = 'http.user_agent',

// General network connection attributes
NET_PEER_IP = 'net.peer.ip',
NET_PEER_PORT = 'net.peer.port',
NET_PEER_NAME = 'net.peer.name',
NET_PEER_IPV4 = 'net.peer.ipv4',
NET_PEER_IPV6 = 'net.peer.ipv6',
NET_PEER_SERVICE = 'net.peer.service',
NET_HOST_IP = 'net.host.ip',
NET_HOST_PORT = 'net.host.port',
NET_HOST_NAME = 'net.host.name',
NET_TRANSPORT = 'net.transport',

// IP
IP_TCP = 'IP.TCP',
IP_UDP = 'IP.UDP',
HTTP_SERVER_NAME = 'http.server_name',
HTTP_CLIENT_IP = 'http.client_ip',
// NOT ON OFFICIAL SPEC
HTTP_ERROR_NAME = 'http.error_name',
HTTP_ERROR_MESSAGE = 'http.error_message',
HTTP_USER_AGENT = 'http.user_agent',

// db
// required: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/database.md
DB_TYPE = 'db.type',
DB_INSTANCE = 'db.instance',
DB_STATEMENT = 'db.statement',
PEER_ADDRESS = 'net.peer.address',
PEER_HOSTNAME = 'net.peer.host',

// db (optional)
DB_USER = 'db.user',
}
1 change: 1 addition & 0 deletions packages/opentelemetry-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export * from './common/ConsoleLogger';
export * from './common/NoopLogger';
export * from './common/time';
export * from './common/types';
export * from './common/attributes';
export * from './ExportResult';
export * from './version';
export * from './context/context';
Expand Down
24 changes: 0 additions & 24 deletions packages/opentelemetry-plugin-grpc/src/enums/AttributeNames.ts

This file was deleted.

3 changes: 1 addition & 2 deletions packages/opentelemetry-plugin-grpc/src/grpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ import {
SpanOptions,
Status,
} from '@opentelemetry/api';
import { BasePlugin } from '@opentelemetry/core';
import { BasePlugin, AttributeNames } from '@opentelemetry/core';
import * as events from 'events';
import * as grpcTypes from 'grpc';
import * as path from 'path';
import * as shimmer from 'shimmer';
import { AttributeNames } from './enums/AttributeNames';
import {
grpc,
GrpcClientFunc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

import { SpanKind } from '@opentelemetry/api';
import * as assert from 'assert';
import { AttributeNames } from '../../src/enums/AttributeNames';
import { GrpcPlugin } from '../../src/grpc';
import * as grpc from 'grpc';
import { ReadableSpan } from '@opentelemetry/tracing';
import {
AttributeNames,
hrTimeToMilliseconds,
hrTimeToMicroseconds,
} from '@opentelemetry/core';
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-plugin-http/src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
TraceFlags,
} from '@opentelemetry/api';
import {
AttributeNames,
BasePlugin,
NoRecordingSpan,
getExtractedSpanContext,
Expand All @@ -40,7 +41,6 @@ import { Socket } from 'net';
import * as semver from 'semver';
import * as shimmer from 'shimmer';
import * as url from 'url';
import { AttributeNames } from './enums/AttributeNames';
import {
Err,
Func,
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion packages/opentelemetry-plugin-xml-http-request/src/xhr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import * as api from '@opentelemetry/api';
import {
AttributeNames,
BasePlugin,
hrTime,
isUrlIgnored,
Expand All @@ -30,7 +31,6 @@ import {
PerformanceTimingNames as PTN,
} from '@opentelemetry/web';
import * as shimmer from 'shimmer';
import { AttributeNames } from './enums/AttributeNames';
import { EventNames } from './enums/EventNames';
import {
OpenFunction,
Expand Down