From f0adb23143e56dffc3face697b17349dd3281f56 Mon Sep 17 00:00:00 2001 From: Mario Jonke Date: Fri, 29 Jan 2021 22:15:26 +0100 Subject: [PATCH] Remove 'component' span attribute in instrumentations (#301) --- CHANGELOG.md | 5 ++ .../aiohttp_client/__init__.py | 1 - .../tests/test_aiohttp_client_integration.py | 12 +--- .../instrumentation/aiopg/__init__.py | 12 ++-- .../instrumentation/aiopg/wrappers.py | 46 ++++++--------- .../tests/test_aiopg_integration.py | 4 +- .../instrumentation/asgi/__init__.py | 1 - .../tests/test_asgi_middleware.py | 2 - .../instrumentation/dbapi/__init__.py | 58 ++++++++----------- .../tests/test_dbapi_integration.py | 9 +-- .../instrumentation/elasticsearch/__init__.py | 3 +- .../tests/test_elasticsearch.py | 12 ++-- .../tests/test_falcon.py | 3 - .../tests/test_programmatic.py | 1 - .../instrumentation/mysql/__init__.py | 9 +-- .../instrumentation/psycopg2/__init__.py | 9 +-- .../instrumentation/pymongo/__init__.py | 4 +- .../instrumentation/pymysql/__init__.py | 9 +-- .../tests/test_programmatic.py | 1 - .../instrumentation/requests/__init__.py | 1 - .../tests/test_requests_integration.py | 12 +--- .../instrumentation/sqlite3/__init__.py | 9 +-- .../instrumentation/tornado/__init__.py | 1 - .../instrumentation/tornado/client.py | 1 - .../tests/test_instrumentation.py | 11 ---- .../instrumentation/urllib/__init__.py | 1 - .../tests/test_urllib_integration.py | 3 - .../instrumentation/wsgi/__init__.py | 1 - .../tests/test_wsgi_middleware.py | 2 - 29 files changed, 77 insertions(+), 166 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd722622a2..adfaace015 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://github.com/open-telemetry/opentelemetry-python-contrib/compare/v0.17b0...HEAD) +### Changed +- Remove `component` span attribute in instrumentations. + `opentelemetry-instrumentation-aiopg`, `opentelemetry-instrumentation-dbapi` Remove unused `database_type` parameter from `trace_integration` function. + ([#301](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/301)) + ## [0.17b0](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.17b0) - 2021-01-20 ### Added diff --git a/instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/__init__.py b/instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/__init__.py index c708802a92..1ff76e96da 100644 --- a/instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/__init__.py @@ -169,7 +169,6 @@ async def on_request_start( if trace_config_ctx.span.is_recording(): attributes = { - "component": "http", "http.method": http_method, "http.url": trace_config_ctx.url_filter(params.url) if callable(trace_config_ctx.url_filter) diff --git a/instrumentation/opentelemetry-instrumentation-aiohttp-client/tests/test_aiohttp_client_integration.py b/instrumentation/opentelemetry-instrumentation-aiohttp-client/tests/test_aiohttp_client_integration.py index f073465348..363b0356d4 100644 --- a/instrumentation/opentelemetry-instrumentation-aiohttp-client/tests/test_aiohttp_client_integration.py +++ b/instrumentation/opentelemetry-instrumentation-aiohttp-client/tests/test_aiohttp_client_integration.py @@ -129,7 +129,6 @@ def test_status_codes(self): "HTTP GET", (span_status, None), { - "component": "http", "http.method": "GET", "http.url": "http://{}:{}/test-path?query=param#foobar".format( host, port @@ -187,7 +186,6 @@ def test_span_name_option(self): expected, (StatusCode.UNSET, None), { - "component": "http", "http.method": method, "http.url": "http://{}:{}{}".format( host, port, path @@ -219,7 +217,6 @@ def strip_query_params(url: yarl.URL) -> str: "HTTP GET", (StatusCode.UNSET, None), { - "component": "http", "http.method": "GET", "http.url": "http://{}:{}/some/path".format( host, port @@ -256,11 +253,7 @@ async def do_request(url): ( "HTTP GET", (expected_status, None), - { - "component": "http", - "http.method": "GET", - "http.url": url, - }, + {"http.method": "GET", "http.url": url}, ) ] ) @@ -285,7 +278,6 @@ async def request_handler(request): "HTTP GET", (StatusCode.ERROR, None), { - "component": "http", "http.method": "GET", "http.url": "http://{}:{}/test_timeout".format( host, port @@ -315,7 +307,6 @@ async def request_handler(request): "HTTP GET", (StatusCode.ERROR, None), { - "component": "http", "http.method": "GET", "http.url": "http://{}:{}/test_too_many_redirects".format( host, port @@ -364,7 +355,6 @@ def test_instrument(self): self.get_default_request(), self.URL, self.default_handler ) span = self.assert_spans(1) - self.assertEqual("http", span.attributes["component"]) self.assertEqual("GET", span.attributes["http.method"]) self.assertEqual( "http://{}:{}/test-path".format(host, port), diff --git a/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/__init__.py b/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/__init__.py index 176fc82b40..ffae8df5cc 100644 --- a/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/__init__.py @@ -58,8 +58,7 @@ class AiopgInstrumentor(BaseInstrumentor): "user": "info.user", } - _DATABASE_COMPONENT = "postgresql" - _DATABASE_TYPE = "sql" + _DATABASE_SYSTEM = "postgresql" def _instrument(self, **kwargs): """Integrate with PostgreSQL aiopg library. @@ -70,8 +69,7 @@ def _instrument(self, **kwargs): wrappers.wrap_connect( __name__, - self._DATABASE_COMPONENT, - self._DATABASE_TYPE, + self._DATABASE_SYSTEM, self._CONNECTION_ATTRIBUTES, version=__version__, tracer_provider=tracer_provider, @@ -79,8 +77,7 @@ def _instrument(self, **kwargs): wrappers.wrap_create_pool( __name__, - self._DATABASE_COMPONENT, - self._DATABASE_TYPE, + self._DATABASE_SYSTEM, self._CONNECTION_ATTRIBUTES, version=__version__, tracer_provider=tracer_provider, @@ -104,8 +101,7 @@ def instrument_connection(self, connection): return wrappers.instrument_connection( __name__, connection, - self._DATABASE_COMPONENT, - self._DATABASE_TYPE, + self._DATABASE_SYSTEM, self._CONNECTION_ATTRIBUTES, ) diff --git a/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/wrappers.py b/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/wrappers.py index 63a5d17514..706648d643 100644 --- a/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/wrappers.py +++ b/instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/wrappers.py @@ -24,7 +24,7 @@ from opentelemetry import trace from opentelemetry.instrumentation.aiopg import trace_integration - trace_integration(aiopg.connection, "_connect", "postgresql", "sql") + trace_integration(aiopg.connection, "_connect", "postgresql") API --- @@ -48,8 +48,7 @@ def trace_integration( - database_component: str, - database_type: str = "", + database_system: str, connection_attributes: typing.Dict = None, tracer_provider: typing.Optional[TracerProvider] = None, ): @@ -57,19 +56,17 @@ def trace_integration( based on dbapi integration, where replaced sync wrap methods to async Args: - database_component: Database driver name or - database name "postgreSQL". - database_type: The Database type. For any SQL database, "sql". + database_system: An identifier for the database management system (DBMS) + product being used. connection_attributes: Attribute names for database, port, host and user in Connection object. tracer_provider: The :class:`opentelemetry.trace.TracerProvider` to - use. If ommited the current configured one is used. + use. If omitted the current configured one is used. """ wrap_connect( __name__, - database_component, - database_type, + database_system, connection_attributes, __version__, tracer_provider, @@ -78,8 +75,7 @@ def trace_integration( def wrap_connect( name: str, - database_component: str, - database_type: str = "", + database_system: str, connection_attributes: typing.Dict = None, version: str = "", tracer_provider: typing.Optional[TracerProvider] = None, @@ -89,14 +85,13 @@ def wrap_connect( Args: name: Name of opentelemetry extension for aiopg. - database_component: Database driver name - or database name "postgreSQL". - database_type: The Database type. For any SQL database, "sql". + database_system: An identifier for the database management system (DBMS) + product being used. connection_attributes: Attribute names for database, port, host and user in Connection object. version: Version of opentelemetry extension for aiopg. tracer_provider: The :class:`opentelemetry.trace.TracerProvider` to - use. If ommited the current configured one is used. + use. If omitted the current configured one is used. """ # pylint: disable=unused-argument @@ -108,8 +103,7 @@ def wrap_connect_( ): db_integration = AiopgIntegration( name, - database_component, - database_type=database_type, + database_system, connection_attributes=connection_attributes, version=version, tracer_provider=tracer_provider, @@ -135,8 +129,7 @@ def unwrap_connect(): def instrument_connection( name: str, connection, - database_component: str, - database_type: str = "", + database_system: str, connection_attributes: typing.Dict = None, version: str = "", tracer_provider: typing.Optional[TracerProvider] = None, @@ -146,21 +139,20 @@ def instrument_connection( Args: name: Name of opentelemetry extension for aiopg. connection: The connection to instrument. - database_component: Database driver name or database name "postgreSQL". - database_type: The Database type. For any SQL database, "sql". + database_system: An identifier for the database management system (DBMS) + product being used. connection_attributes: Attribute names for database, port, host and user in a connection object. version: Version of opentelemetry extension for aiopg. tracer_provider: The :class:`opentelemetry.trace.TracerProvider` to - use. If ommited the current configured one is used. + use. If omitted the current configured one is used. Returns: An instrumented connection. """ db_integration = AiopgIntegration( name, - database_component, - database_type, + database_system, connection_attributes=connection_attributes, version=version, tracer_provider=tracer_provider, @@ -187,8 +179,7 @@ def uninstrument_connection(connection): def wrap_create_pool( name: str, - database_component: str, - database_type: str = "", + database_system: str, connection_attributes: typing.Dict = None, version: str = "", tracer_provider: typing.Optional[TracerProvider] = None, @@ -202,8 +193,7 @@ def wrap_create_pool_( ): db_integration = AiopgIntegration( name, - database_component, - database_type, + database_system, connection_attributes=connection_attributes, version=version, tracer_provider=tracer_provider, diff --git a/instrumentation/opentelemetry-instrumentation-aiopg/tests/test_aiopg_integration.py b/instrumentation/opentelemetry-instrumentation-aiopg/tests/test_aiopg_integration.py index 78c342df9b..27d47ca415 100644 --- a/instrumentation/opentelemetry-instrumentation-aiopg/tests/test_aiopg_integration.py +++ b/instrumentation/opentelemetry-instrumentation-aiopg/tests/test_aiopg_integration.py @@ -242,7 +242,6 @@ def test_span_succeeded(self): db_integration = AiopgIntegration( self.tracer, "testcomponent", - "testtype", connection_attributes, capture_parameters=True, ) @@ -259,7 +258,6 @@ def test_span_succeeded(self): self.assertEqual(span.name, "Test") self.assertIs(span.kind, trace_api.SpanKind.CLIENT) - self.assertEqual(span.attributes["component"], "testcomponent") self.assertEqual(span.attributes["db.system"], "testcomponent") self.assertEqual(span.attributes["db.name"], "testdatabase") self.assertEqual(span.attributes["db.statement"], "Test query") @@ -294,7 +292,7 @@ def test_span_not_recording(self): mock_tracer.use_span.return_value.__enter__ = mock_span mock_tracer.use_span.return_value.__exit__ = True db_integration = AiopgIntegration( - mock_tracer, "testcomponent", "testtype", connection_attributes + mock_tracer, "testcomponent", connection_attributes ) mock_connection = async_call( db_integration.wrapped_connection( diff --git a/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py b/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py index 0947eadf08..b81b8b77f7 100644 --- a/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py @@ -72,7 +72,6 @@ def collect_request_attributes(scope): http_url = http_url + ("?" + urllib.parse.unquote(query_string)) result = { - "component": scope["type"], "http.scheme": scope.get("scheme"), "http.host": server_host, "net.host.port": port, diff --git a/instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_middleware.py b/instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_middleware.py index aecc06b082..7c4ae20a77 100644 --- a/instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_middleware.py +++ b/instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_middleware.py @@ -134,7 +134,6 @@ def validate_outputs(self, outputs, error=None, modifiers=None): "name": "GET asgi", "kind": trace_api.SpanKind.SERVER, "attributes": { - "component": "http", "http.method": "GET", "http.scheme": "http", "net.host.port": 80, @@ -321,7 +320,6 @@ def test_request_attributes(self): self.assertDictEqual( attrs, { - "component": "http", "http.method": "GET", "http.host": "127.0.0.1", "http.target": "/", diff --git a/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py b/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py index 67c25f9881..6a20e3dbfc 100644 --- a/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py @@ -29,9 +29,9 @@ # Ex: mysql.connector - trace_integration(mysql.connector, "connect", "mysql", "sql") + trace_integration(mysql.connector, "connect", "mysql") # Ex: pyodbc - trace_integration(pyodbc, "Connection", "odbc", "sql") + trace_integration(pyodbc, "Connection", "odbc") API --- @@ -55,8 +55,7 @@ def trace_integration( connect_module: typing.Callable[..., typing.Any], connect_method_name: str, - database_component: str, - database_type: str = "", + database_system: str, connection_attributes: typing.Dict = None, tracer_provider: typing.Optional[TracerProvider] = None, capture_parameters: bool = False, @@ -68,21 +67,19 @@ def trace_integration( Args: connect_module: Module name where connect method is available. connect_method_name: The connect method name. - database_component: Database driver name or database name "JDBI", - "jdbc", "odbc", "postgreSQL". - database_type: The Database type. For any SQL database, "sql". + database_system: An identifier for the database management system (DBMS) + product being used. connection_attributes: Attribute names for database, port, host and user in Connection object. tracer_provider: The :class:`opentelemetry.trace.TracerProvider` to - use. If ommited the current configured one is used. + use. If omitted the current configured one is used. capture_parameters: Configure if db.statement.parameters should be captured. """ wrap_connect( __name__, connect_module, connect_method_name, - database_component, - database_type, + database_system, connection_attributes, version=__version__, tracer_provider=tracer_provider, @@ -95,8 +92,7 @@ def wrap_connect( name: str, connect_module: typing.Callable[..., typing.Any], connect_method_name: str, - database_component: str, - database_type: str = "", + database_system: str, connection_attributes: typing.Dict = None, version: str = "", tracer_provider: typing.Optional[TracerProvider] = None, @@ -107,14 +103,14 @@ def wrap_connect( https://www.python.org/dev/peps/pep-0249/ Args: - tracer: The :class:`opentelemetry.trace.Tracer` to use. connect_module: Module name where connect method is available. connect_method_name: The connect method name. - database_component: Database driver name or database name "JDBI", - "jdbc", "odbc", "postgreSQL". - database_type: The Database type. For any SQL database, "sql". + database_system: An identifier for the database management system (DBMS) + product being used. connection_attributes: Attribute names for database, port, host and user in Connection object. + tracer_provider: The :class:`opentelemetry.trace.TracerProvider` to + use. If omitted the current configured one is used. capture_parameters: Configure if db.statement.parameters should be captured. """ @@ -131,8 +127,7 @@ def wrap_connect_( ): db_integration = db_api_integration_factory( name, - database_component, - database_type=database_type, + database_system, connection_attributes=connection_attributes, version=version, tracer_provider=tracer_provider, @@ -164,8 +159,7 @@ def unwrap_connect( def instrument_connection( name: str, connection, - database_component: str, - database_type: str = "", + database_system: str, connection_attributes: typing.Dict = None, version: str = "", tracer_provider: typing.Optional[TracerProvider] = None, @@ -174,21 +168,20 @@ def instrument_connection( """Enable instrumentation in a database connection. Args: - tracer: The :class:`opentelemetry.trace.Tracer` to use. connection: The connection to instrument. - database_component: Database driver name or database name "JDBI", - "jdbc", "odbc", "postgreSQL". - database_type: The Database type. For any SQL database, "sql". + database_system: An identifier for the database management system (DBMS) + product being used. connection_attributes: Attribute names for database, port, host and user in a connection object. + tracer_provider: The :class:`opentelemetry.trace.TracerProvider` to + use. If omitted the current configured one is used. capture_parameters: Configure if db.statement.parameters should be captured. Returns: An instrumented connection. """ db_integration = DatabaseApiIntegration( name, - database_component, - database_type, + database_system, connection_attributes=connection_attributes, version=version, tracer_provider=tracer_provider, @@ -218,8 +211,7 @@ class DatabaseApiIntegration: def __init__( self, name: str, - database_component: str, - database_type: str = "sql", + database_system: str, connection_attributes=None, version: str = "", tracer_provider: typing.Optional[TracerProvider] = None, @@ -237,8 +229,7 @@ def __init__( self._version = version self._tracer_provider = tracer_provider self.capture_parameters = capture_parameters - self.database_component = database_component - self.database_type = database_type + self.database_system = database_system self.connection_props = {} self.span_attributes = {} self.name = "" @@ -275,7 +266,7 @@ def get_connection_attributes(self, connection): ) if attribute: self.connection_props[key] = attribute - self.name = self.database_component + self.name = self.database_system self.database = self.connection_props.get("database", "") if self.database: # PyMySQL encodes names with utf-8 @@ -334,10 +325,7 @@ def _populate_span( return statement = self.get_statement(cursor, args) span.set_attribute( - "component", self._db_api_integration.database_component - ) - span.set_attribute( - "db.system", self._db_api_integration.database_component + "db.system", self._db_api_integration.database_system ) span.set_attribute("db.name", self._db_api_integration.database) span.set_attribute("db.statement", statement) diff --git a/instrumentation/opentelemetry-instrumentation-dbapi/tests/test_dbapi_integration.py b/instrumentation/opentelemetry-instrumentation-dbapi/tests/test_dbapi_integration.py index c07f44c2b4..5a8b34530e 100644 --- a/instrumentation/opentelemetry-instrumentation-dbapi/tests/test_dbapi_integration.py +++ b/instrumentation/opentelemetry-instrumentation-dbapi/tests/test_dbapi_integration.py @@ -40,7 +40,7 @@ def test_span_succeeded(self): "user": "user", } db_integration = dbapi.DatabaseApiIntegration( - self.tracer, "testcomponent", "testtype", connection_attributes + self.tracer, "testcomponent", connection_attributes ) mock_connection = db_integration.wrapped_connection( mock_connect, {}, connection_props @@ -53,7 +53,6 @@ def test_span_succeeded(self): self.assertEqual(span.name, "Test") self.assertIs(span.kind, trace_api.SpanKind.CLIENT) - self.assertEqual(span.attributes["component"], "testcomponent") self.assertEqual(span.attributes["db.system"], "testcomponent") self.assertEqual(span.attributes["db.name"], "testdatabase") self.assertEqual(span.attributes["db.statement"], "Test query") @@ -67,7 +66,7 @@ def test_span_succeeded(self): def test_span_name(self): db_integration = dbapi.DatabaseApiIntegration( - self.tracer, "testcomponent", "testtype", {} + self.tracer, "testcomponent", {} ) mock_connection = db_integration.wrapped_connection( mock_connect, {}, {} @@ -102,7 +101,6 @@ def test_span_succeeded_with_capture_of_statement_parameters(self): db_integration = dbapi.DatabaseApiIntegration( self.tracer, "testcomponent", - "testtype", connection_attributes, capture_parameters=True, ) @@ -117,7 +115,6 @@ def test_span_succeeded_with_capture_of_statement_parameters(self): self.assertEqual(span.name, "Test") self.assertIs(span.kind, trace_api.SpanKind.CLIENT) - self.assertEqual(span.attributes["component"], "testcomponent") self.assertEqual(span.attributes["db.system"], "testcomponent") self.assertEqual(span.attributes["db.name"], "testdatabase") self.assertEqual(span.attributes["db.statement"], "Test query") @@ -152,7 +149,7 @@ def test_span_not_recording(self): mock_tracer.use_span.return_value.__enter__ = mock_span mock_tracer.use_span.return_value.__exit__ = True db_integration = dbapi.DatabaseApiIntegration( - mock_tracer, "testcomponent", "testtype", connection_attributes + mock_tracer, "testcomponent", connection_attributes ) mock_connection = db_integration.wrapped_connection( mock_connect, {}, connection_props diff --git a/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/__init__.py b/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/__init__.py index 5df7f6a807..848ec135a8 100644 --- a/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/__init__.py @@ -128,8 +128,7 @@ def wrapper(wrapped, _, args, kwargs): ) as span: if span.is_recording(): attributes = { - "component": "elasticsearch-py", - "db.type": "elasticsearch", + "db.system": "elasticsearch", } if url: attributes["elasticsearch.url"] = url diff --git a/instrumentation/opentelemetry-instrumentation-elasticsearch/tests/test_elasticsearch.py b/instrumentation/opentelemetry-instrumentation-elasticsearch/tests/test_elasticsearch.py index ea0e6ce2fb..fbdf5f3952 100644 --- a/instrumentation/opentelemetry-instrumentation-elasticsearch/tests/test_elasticsearch.py +++ b/instrumentation/opentelemetry-instrumentation-elasticsearch/tests/test_elasticsearch.py @@ -248,8 +248,7 @@ def test_dsl_search(self, request_mock): self.assertEqual( span.attributes, { - "component": "elasticsearch-py", - "db.type": "elasticsearch", + "db.system": "elasticsearch", "elasticsearch.url": "/test-index/_search", "elasticsearch.method": helpers.dsl_search_method, "db.statement": str( @@ -276,8 +275,7 @@ def test_dsl_create(self, request_mock): self.assertEqual( span1.attributes, { - "component": "elasticsearch-py", - "db.type": "elasticsearch", + "db.system": "elasticsearch", "elasticsearch.url": "/test-index", "elasticsearch.method": "HEAD", }, @@ -285,8 +283,7 @@ def test_dsl_create(self, request_mock): self.assertEqual(span2.name, "Elasticsearch/test-index") attributes = { - "component": "elasticsearch-py", - "db.type": "elasticsearch", + "db.system": "elasticsearch", "elasticsearch.url": "/test-index", "elasticsearch.method": "PUT", } @@ -312,8 +309,7 @@ def test_dsl_index(self, request_mock): span = spans[0] self.assertEqual(span.name, helpers.dsl_index_span_name) attributes = { - "component": "elasticsearch-py", - "db.type": "elasticsearch", + "db.system": "elasticsearch", "elasticsearch.url": helpers.dsl_index_url, "elasticsearch.method": "PUT", } diff --git a/instrumentation/opentelemetry-instrumentation-falcon/tests/test_falcon.py b/instrumentation/opentelemetry-instrumentation-falcon/tests/test_falcon.py index 616db2837f..73088d7611 100644 --- a/instrumentation/opentelemetry-instrumentation-falcon/tests/test_falcon.py +++ b/instrumentation/opentelemetry-instrumentation-falcon/tests/test_falcon.py @@ -95,7 +95,6 @@ def _test_method(self, method): self.assert_span_has_attributes( span, { - "component": "http", "http.method": method, "http.server_name": "falconframework.org", "http.scheme": "http", @@ -122,7 +121,6 @@ def test_404(self): self.assert_span_has_attributes( span, { - "component": "http", "http.method": "GET", "http.server_name": "falconframework.org", "http.scheme": "http", @@ -155,7 +153,6 @@ def test_500(self): self.assert_span_has_attributes( span, { - "component": "http", "http.method": "GET", "http.server_name": "falconframework.org", "http.scheme": "http", diff --git a/instrumentation/opentelemetry-instrumentation-flask/tests/test_programmatic.py b/instrumentation/opentelemetry-instrumentation-flask/tests/test_programmatic.py index 495b4a739a..377ce88842 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/tests/test_programmatic.py +++ b/instrumentation/opentelemetry-instrumentation-flask/tests/test_programmatic.py @@ -28,7 +28,6 @@ def expected_attributes(override_attributes): default_attributes = { - "component": "http", "http.method": "GET", "http.server_name": "localhost", "http.scheme": "http", diff --git a/instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/__init__.py b/instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/__init__.py index 7440ee8bc2..9fdf594c56 100644 --- a/instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql/__init__.py @@ -54,8 +54,7 @@ class MySQLInstrumentor(BaseInstrumentor): "user": "user", } - _DATABASE_COMPONENT = "mysql" - _DATABASE_TYPE = "sql" + _DATABASE_SYSTEM = "mysql" def _instrument(self, **kwargs): """Integrate with MySQL Connector/Python library. @@ -67,8 +66,7 @@ def _instrument(self, **kwargs): __name__, mysql.connector, "connect", - self._DATABASE_COMPONENT, - self._DATABASE_TYPE, + self._DATABASE_SYSTEM, self._CONNECTION_ATTRIBUTES, version=__version__, tracer_provider=tracer_provider, @@ -93,8 +91,7 @@ def instrument_connection(self, connection): return dbapi.instrument_connection( tracer, connection, - self._DATABASE_COMPONENT, - self._DATABASE_TYPE, + self._DATABASE_SYSTEM, self._CONNECTION_ATTRIBUTES, ) diff --git a/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/__init__.py b/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/__init__.py index ef807963aa..1190d1c083 100644 --- a/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/__init__.py @@ -62,8 +62,7 @@ class Psycopg2Instrumentor(BaseInstrumentor): "user": "info.user", } - _DATABASE_COMPONENT = "postgresql" - _DATABASE_TYPE = "sql" + _DATABASE_SYSTEM = "postgresql" def _instrument(self, **kwargs): """Integrate with PostgreSQL Psycopg library. @@ -75,8 +74,7 @@ def _instrument(self, **kwargs): __name__, psycopg2, "connect", - self._DATABASE_COMPONENT, - self._DATABASE_TYPE, + self._DATABASE_SYSTEM, self._CONNECTION_ATTRIBUTES, version=__version__, tracer_provider=tracer_provider, @@ -152,8 +150,7 @@ def _new_cursor_factory(db_api=None, base_factory=None): if not db_api: db_api = DatabaseApiIntegration( __name__, - Psycopg2Instrumentor._DATABASE_COMPONENT, - database_type=Psycopg2Instrumentor._DATABASE_TYPE, + Psycopg2Instrumentor._DATABASE_SYSTEM, connection_attributes=Psycopg2Instrumentor._CONNECTION_ATTRIBUTES, version=__version__, ) diff --git a/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py b/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py index abcbe0d633..39de8e32c5 100644 --- a/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-pymongo/src/opentelemetry/instrumentation/pymongo/__init__.py @@ -45,7 +45,7 @@ from opentelemetry.trace import SpanKind, get_tracer from opentelemetry.trace.status import Status, StatusCode -DATABASE_TYPE = "mongodb" +DATABASE_SYSTEM = "mongodb" class CommandTracer(monitoring.CommandListener): @@ -68,7 +68,7 @@ def started(self, event: monitoring.CommandStartedEvent): try: span = self._tracer.start_span(name, kind=SpanKind.CLIENT) if span.is_recording(): - span.set_attribute("db.system", DATABASE_TYPE) + span.set_attribute("db.system", DATABASE_SYSTEM) span.set_attribute("db.name", event.database_name) span.set_attribute("db.statement", statement) if event.connection_id is not None: diff --git a/instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql/__init__.py b/instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql/__init__.py index afceefafed..5e9952bc47 100644 --- a/instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql/__init__.py @@ -55,8 +55,7 @@ class PyMySQLInstrumentor(BaseInstrumentor): "user": "user", } - _DATABASE_COMPONENT = "mysql" - _DATABASE_TYPE = "sql" + _DATABASE_SYSTEM = "mysql" def _instrument(self, **kwargs): """Integrate with the PyMySQL library. @@ -68,8 +67,7 @@ def _instrument(self, **kwargs): __name__, pymysql, "connect", - self._DATABASE_COMPONENT, - self._DATABASE_TYPE, + self._DATABASE_SYSTEM, self._CONNECTION_ATTRIBUTES, version=__version__, tracer_provider=tracer_provider, @@ -93,8 +91,7 @@ def instrument_connection(self, connection): return dbapi.instrument_connection( __name__, connection, - self._DATABASE_COMPONENT, - self._DATABASE_TYPE, + self._DATABASE_SYSTEM, self._CONNECTION_ATTRIBUTES, version=__version__, ) diff --git a/instrumentation/opentelemetry-instrumentation-pyramid/tests/test_programmatic.py b/instrumentation/opentelemetry-instrumentation-pyramid/tests/test_programmatic.py index e5bbcb056b..2affc3f5d3 100644 --- a/instrumentation/opentelemetry-instrumentation-pyramid/tests/test_programmatic.py +++ b/instrumentation/opentelemetry-instrumentation-pyramid/tests/test_programmatic.py @@ -28,7 +28,6 @@ def expected_attributes(override_attributes): default_attributes = { - "component": "http", "http.method": "GET", "http.server_name": "localhost", "http.scheme": "http", diff --git a/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py b/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py index bb6b0577ce..3781545e8b 100644 --- a/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py @@ -139,7 +139,6 @@ def _instrumented_requests_call( exception = None with recorder.record_client_duration(labels): if span.is_recording(): - span.set_attribute("component", "http") span.set_attribute("http.method", method) span.set_attribute("http.url", url) diff --git a/instrumentation/opentelemetry-instrumentation-requests/tests/test_requests_integration.py b/instrumentation/opentelemetry-instrumentation-requests/tests/test_requests_integration.py index 7749c1f8ab..b981655db0 100644 --- a/instrumentation/opentelemetry-instrumentation-requests/tests/test_requests_integration.py +++ b/instrumentation/opentelemetry-instrumentation-requests/tests/test_requests_integration.py @@ -79,7 +79,6 @@ def test_basic(self): self.assertEqual( span.attributes, { - "component": "http", "http.method": "GET", "http.url": self.URL, "http.status_code": 200, @@ -255,7 +254,6 @@ def span_callback(span, result: requests.Response): self.assertEqual( span.attributes, { - "component": "http", "http.method": "GET", "http.url": self.URL, "http.status_code": 200, @@ -287,8 +285,7 @@ def test_requests_exception_without_response(self, *_, **__): span = self.assert_span() self.assertEqual( - span.attributes, - {"component": "http", "http.method": "GET", "http.url": self.URL}, + span.attributes, {"http.method": "GET", "http.url": self.URL} ) self.assertEqual(span.status.status_code, StatusCode.ERROR) @@ -323,8 +320,7 @@ def test_requests_exception_without_proper_response_type(self, *_, **__): span = self.assert_span() self.assertEqual( - span.attributes, - {"component": "http", "http.method": "GET", "http.url": self.URL}, + span.attributes, {"http.method": "GET", "http.url": self.URL} ) self.assertEqual(span.status.status_code, StatusCode.ERROR) @@ -361,7 +357,6 @@ def test_requests_exception_with_response(self, *_, **__): self.assertEqual( span.attributes, { - "component": "http", "http.method": "GET", "http.url": self.URL, "http.status_code": 500, @@ -423,8 +418,7 @@ def test_invalid_url(self): self.assertEqual(span.name, "HTTP POST") self.assertEqual( - span.attributes, - {"component": "http", "http.method": "POST", "http.url": url}, + span.attributes, {"http.method": "POST", "http.url": url} ) self.assertEqual(span.status.status_code, StatusCode.ERROR) diff --git a/instrumentation/opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3/__init__.py b/instrumentation/opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3/__init__.py index bad033b292..7ba76968af 100644 --- a/instrumentation/opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-sqlite3/src/opentelemetry/instrumentation/sqlite3/__init__.py @@ -51,8 +51,7 @@ class SQLite3Instrumentor(BaseInstrumentor): # No useful attributes of sqlite3 connection object _CONNECTION_ATTRIBUTES = {} - _DATABASE_COMPONENT = "sqlite" - _DATABASE_TYPE = "sql" + _DATABASE_SYSTEM = "sqlite" def _instrument(self, **kwargs): """Integrate with SQLite3 Python library. @@ -64,8 +63,7 @@ def _instrument(self, **kwargs): __name__, sqlite3, "connect", - self._DATABASE_COMPONENT, - self._DATABASE_TYPE, + self._DATABASE_SYSTEM, self._CONNECTION_ATTRIBUTES, version=__version__, tracer_provider=tracer_provider, @@ -90,8 +88,7 @@ def instrument_connection(self, connection): return dbapi.instrument_connection( tracer, connection, - self._DATABASE_COMPONENT, - self._DATABASE_TYPE, + self._DATABASE_SYSTEM, self._CONNECTION_ATTRIBUTES, ) diff --git a/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py b/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py index d825fbb71b..5806b3664c 100644 --- a/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/__init__.py @@ -174,7 +174,6 @@ def _log_exception(tracer, func, handler, args, kwargs): def _get_attributes_from_request(request): attrs = { - "component": "tornado", "http.method": request.method, "http.scheme": request.protocol, "http.host": request.host, diff --git a/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/client.py b/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/client.py index 5ec001bdab..810c6458e1 100644 --- a/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/client.py +++ b/instrumentation/opentelemetry-instrumentation-tornado/src/opentelemetry/instrumentation/tornado/client.py @@ -43,7 +43,6 @@ def fetch_async(tracer, func, _, args, kwargs): if span.is_recording(): attributes = { - "component": "tornado", "http.url": request.url, "http.method": request.method, } diff --git a/instrumentation/opentelemetry-instrumentation-tornado/tests/test_instrumentation.py b/instrumentation/opentelemetry-instrumentation-tornado/tests/test_instrumentation.py index 21002c83cd..3bdf007717 100644 --- a/instrumentation/opentelemetry-instrumentation-tornado/tests/test_instrumentation.py +++ b/instrumentation/opentelemetry-instrumentation-tornado/tests/test_instrumentation.py @@ -128,7 +128,6 @@ def _test_http_method_call(self, method): self.assert_span_has_attributes( server, { - "component": "tornado", "http.method": method, "http.scheme": "http", "http.host": "127.0.0.1:" + str(self.get_http_port()), @@ -146,7 +145,6 @@ def _test_http_method_call(self, method): self.assert_span_has_attributes( client, { - "component": "tornado", "http.url": self.get_url("/"), "http.method": method, "http.status_code": 201, @@ -205,7 +203,6 @@ def _test_async_handler(self, url, handler_name): self.assert_span_has_attributes( server, { - "component": "tornado", "http.method": "GET", "http.scheme": "http", "http.host": "127.0.0.1:" + str(self.get_http_port()), @@ -223,7 +220,6 @@ def _test_async_handler(self, url, handler_name): self.assert_span_has_attributes( client, { - "component": "tornado", "http.url": self.get_url(url), "http.method": "GET", "http.status_code": 201, @@ -243,7 +239,6 @@ def test_500(self): self.assert_span_has_attributes( server, { - "component": "tornado", "http.method": "GET", "http.scheme": "http", "http.host": "127.0.0.1:" + str(self.get_http_port()), @@ -258,7 +253,6 @@ def test_500(self): self.assert_span_has_attributes( client, { - "component": "tornado", "http.url": self.get_url("/error"), "http.method": "GET", "http.status_code": 500, @@ -278,7 +272,6 @@ def test_404(self): self.assert_span_has_attributes( server, { - "component": "tornado", "http.method": "GET", "http.scheme": "http", "http.host": "127.0.0.1:" + str(self.get_http_port()), @@ -294,7 +287,6 @@ def test_404(self): self.assert_span_has_attributes( client, { - "component": "tornado", "http.url": self.get_url("/missing-url"), "http.method": "GET", "http.status_code": 404, @@ -324,7 +316,6 @@ def test_dynamic_handler(self): self.assert_span_has_attributes( server, { - "component": "tornado", "http.method": "GET", "http.scheme": "http", "http.host": "127.0.0.1:" + str(self.get_http_port()), @@ -342,7 +333,6 @@ def test_dynamic_handler(self): self.assert_span_has_attributes( client, { - "component": "tornado", "http.url": self.get_url("/dyna"), "http.method": "GET", "http.status_code": 202, @@ -362,7 +352,6 @@ def test_excluded(path): self.assert_span_has_attributes( client, { - "component": "tornado", "http.url": self.get_url(path), "http.method": "GET", "http.status_code": 200, diff --git a/instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/__init__.py b/instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/__init__.py index 3958a666ba..dddf2a00a0 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-urllib/src/opentelemetry/instrumentation/urllib/__init__.py @@ -163,7 +163,6 @@ def _instrumented_open_call( exception = None with recorder.record_client_duration(labels): if span.is_recording(): - span.set_attribute("component", "http") span.set_attribute("http.method", method) span.set_attribute("http.url", url) diff --git a/instrumentation/opentelemetry-instrumentation-urllib/tests/test_urllib_integration.py b/instrumentation/opentelemetry-instrumentation-urllib/tests/test_urllib_integration.py index 28f84a62e1..d6af3acee8 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib/tests/test_urllib_integration.py +++ b/instrumentation/opentelemetry-instrumentation-urllib/tests/test_urllib_integration.py @@ -104,7 +104,6 @@ def test_basic(self): self.assertEqual( span.attributes, { - "component": "http", "http.method": "GET", "http.url": self.URL, "http.status_code": 200, @@ -289,7 +288,6 @@ def span_callback(span, result: HTTPResponse): self.assertEqual( span.attributes, { - "component": "http", "http.method": "GET", "http.url": self.URL, "http.status_code": 200, @@ -320,7 +318,6 @@ def test_requests_exception_with_response(self, *_, **__): self.assertEqual( dict(span.attributes), { - "component": "http", "http.method": "GET", "http.url": "http://httpbin.org/status/500", "http.status_code": 500, diff --git a/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py b/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py index dd83203fe1..c336a1320b 100644 --- a/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py @@ -104,7 +104,6 @@ def collect_request_attributes(environ): WSGI environ and returns a dictionary to be used as span creation attributes.""" result = { - "component": "http", "http.method": environ.get("REQUEST_METHOD"), "http.server_name": environ.get("SERVER_NAME"), "http.scheme": environ.get("wsgi.url_scheme"), diff --git a/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py b/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py index d563ee673d..d5168e3280 100644 --- a/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py +++ b/instrumentation/opentelemetry-instrumentation-wsgi/tests/test_wsgi_middleware.py @@ -106,7 +106,6 @@ def validate_response( self.assertEqual(span_list[0].name, span_name) self.assertEqual(span_list[0].kind, trace_api.SpanKind.SERVER) expected_attributes = { - "component": "http", "http.server_name": "127.0.0.1", "http.scheme": "http", "net.host.port": 80, @@ -215,7 +214,6 @@ def test_request_attributes(self): self.assertDictEqual( attrs, { - "component": "http", "http.method": "GET", "http.host": "127.0.0.1", "http.url": "http://127.0.0.1/?foo=bar",