Skip to content
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
1 change: 0 additions & 1 deletion elasticapm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
)
from elasticapm.utils.disttracing import trace_parent_from_headers, trace_parent_from_string # noqa: F401


_activation_method = None

try:
Expand Down
8 changes: 5 additions & 3 deletions elasticapm/contrib/serverless/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,11 @@ def send_partial_transaction(self) -> None:
data = transport._json_serializer({"metadata": self.client.build_metadata()}) + "\n"
data += transport._json_serializer({"transaction": transaction.to_dict()})
partial_transaction_url = urllib.parse.urljoin(
self.client.config.server_url
if self.client.config.server_url.endswith("/")
else self.client.config.server_url + "/",
(
self.client.config.server_url
if self.client.config.server_url.endswith("/")
else self.client.config.server_url + "/"
),
"register/transaction",
)
try:
Expand Down
1 change: 1 addition & 0 deletions elasticapm/contrib/tornado/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
instrumentation. This module only creates the client for later use by the
that instrumentation, and triggers the global instrumentation itself.
"""

import tornado

import elasticapm
Expand Down
1 change: 1 addition & 0 deletions elasticapm/instrumentation/packages/tornado.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"""
Instrumentation for Tornado
"""

import elasticapm
from elasticapm.conf import constants
from elasticapm.instrumentation.packages.asyncio.base import AbstractInstrumentedModule, AsyncAbstractInstrumentedModule
Expand Down
12 changes: 6 additions & 6 deletions elasticapm/metrics/sets/prometheus.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ def _prom_counter_handler(self, name, samples, unit) -> None:
# given name. The pair consists of the value, and a "created" timestamp.
# We only use the former.
for total_sample, _ in grouper(samples, 2):
self.counter(
self._registry.client.config.prometheus_metrics_prefix + name, **total_sample.labels
).val = total_sample.value
self.counter(self._registry.client.config.prometheus_metrics_prefix + name, **total_sample.labels).val = (
total_sample.value
)

def _prom_gauge_handler(self, name, samples, unit) -> None:
# Counters can be converted 1:1 from Prometheus to our
# format. Each sample represents a distinct labelset for a
# given name
for sample in samples:
self.gauge(
self._registry.client.config.prometheus_metrics_prefix + name, **sample.labels
).val = sample.value
self.gauge(self._registry.client.config.prometheus_metrics_prefix + name, **sample.labels).val = (
sample.value
)

def _prom_summary_handler(self, name, samples, unit) -> None:
# Prometheus Summaries are analogous to our Timers, having
Expand Down
1 change: 0 additions & 1 deletion tests/contrib/asyncio/starlette_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

import pytest # isort:skip


starlette = pytest.importorskip("starlette") # isort:skip

import os
Expand Down
6 changes: 2 additions & 4 deletions tests/instrumentation/asyncio_tests/aiopg_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,14 @@ async def test_composable_queries(instrument, cursor, elasticapm_client):


async def test_callproc(instrument, cursor, elasticapm_client):
await cursor.execute(
"""
await cursor.execute("""
CREATE OR REPLACE FUNCTION squareme(me INT)
RETURNS INTEGER
LANGUAGE SQL
AS $$
SELECT me*me;
$$;
"""
)
""")
elasticapm_client.begin_transaction("test")
await cursor.callproc("squareme", [2])
result = await cursor.fetchall()
Expand Down
21 changes: 6 additions & 15 deletions tests/instrumentation/cassandra_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,10 @@ def cassandra_session(cassandra_cluster):
session.execute("DROP KEYSPACE testkeyspace;")
except ConfigurationException:
pass
session.execute(
"""
session.execute("""
CREATE KEYSPACE testkeyspace
WITH REPLICATION = { 'class' : 'SimpleStrategy' ,'replication_factor' : 1 }
"""
)
""")
session.execute("USE testkeyspace;")
session.execute("CREATE TABLE testkeyspace.users ( id UUID PRIMARY KEY, name text);")
yield session
Expand Down Expand Up @@ -98,12 +96,10 @@ def test_cassandra_connect(instrument, elasticapm_client, cassandra_cluster):
def test_cassandra_connect_keyspace(instrument, elasticapm_client, cassandra_cluster):
session = cassandra_cluster.connect()
try:
session.execute(
"""
session.execute("""
CREATE KEYSPACE testkeyspace
WITH REPLICATION = { 'class' : 'SimpleStrategy' ,'replication_factor' : 1 }
"""
)
""")
elasticapm_client.begin_transaction("transaction.test")
sess = cassandra_cluster.connect("testkeyspace")
elasticapm_client.end_transaction("test")
Expand Down Expand Up @@ -185,19 +181,14 @@ def test_signature_create_keyspace():


def test_signature_create_columnfamily():
assert (
extract_signature(
"""CREATE COLUMNFAMILY users (
assert extract_signature("""CREATE COLUMNFAMILY users (
userid text PRIMARY KEY,
first_name text,
last_name text,
emails set<text>,
top_scores list<int>,
todo map<timestamp, text>
);"""
)
== "CREATE COLUMNFAMILY"
)
);""") == "CREATE COLUMNFAMILY"


def test_select_from_collection():
Expand Down
6 changes: 2 additions & 4 deletions tests/instrumentation/psycopg2_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,16 +447,14 @@ def test_psycopg2_composable_query_works(instrument, postgres_connection, elasti
@pytest.mark.skipif(not has_postgres_configured, reason="PostgresSQL not configured")
def test_psycopg2_call_stored_procedure(instrument, postgres_connection, elasticapm_client):
cursor = postgres_connection.cursor()
cursor.execute(
"""
cursor.execute("""
CREATE OR REPLACE FUNCTION squareme(me INT)
RETURNS INTEGER
LANGUAGE SQL
AS $$
SELECT me*me;
$$;
"""
)
""")
elasticapm_client.begin_transaction("test")
cursor.callproc("squareme", [2])
result = cursor.fetchall()
Expand Down
Loading