Skip to content

Commit

Permalink
Implemented span compression algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
beniwohli committed Sep 9, 2021
1 parent 6739158 commit aad1525
Show file tree
Hide file tree
Showing 10 changed files with 383 additions and 67 deletions.
12 changes: 12 additions & 0 deletions elasticapm/conf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,18 @@ class Config(_ConfigBase):
],
type=int,
)
span_compression_exact_match_max_duration = _ConfigValue(
"span_compression_exact_match_max_duration",
default=5,
validators=[duration_validator],
type=int,
)
span_compression_same_kind_max_duration = _ConfigValue(
"span_compression_exact_match_max_duration",
default=5,
validators=[duration_validator],
type=int,
)
collect_local_variables = _ConfigValue("COLLECT_LOCAL_VARIABLES", default="errors")
source_lines_error_app_frames = _ConfigValue("SOURCE_LINES_ERROR_APP_FRAMES", type=int, default=5)
source_lines_error_library_frames = _ConfigValue("SOURCE_LINES_ERROR_LIBRARY_FRAMES", type=int, default=5)
Expand Down
1 change: 1 addition & 0 deletions elasticapm/instrumentation/packages/dbapi2.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ def _trace_sql(self, method, sql, params, action=QUERY_ACTION):
span_action=action,
extra={"db": {"type": "sql", "statement": sql_string}, "destination": self._self_destination_info},
skip_frames=1,
leaf=True,
) as span:
if params is None:
result = method(sql)
Expand Down
2 changes: 2 additions & 0 deletions elasticapm/instrumentation/packages/httpcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ def call(self, module, method, wrapped, instance, args, kwargs):
span_id=parent_id, trace_options=TracingOptions(recorded=True)
)
self._set_disttracing_headers(headers, trace_parent, transaction)
if leaf_span:
leaf_span.dist_tracing_propagated = True
response = wrapped(*args, **kwargs)
if len(response) > 4:
# httpcore < 0.11.0
Expand Down
2 changes: 2 additions & 0 deletions elasticapm/instrumentation/packages/httplib2.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ def call(self, module, method, wrapped, instance, args, kwargs):
span_id=parent_id, trace_options=TracingOptions(recorded=True)
)
self._set_disttracing_headers(params["headers"], trace_parent, transaction)
if leaf_span:
leaf_span.dist_tracing_propagated = True

response, content = wrapped(*args, **kwargs)
if span.context:
Expand Down
2 changes: 2 additions & 0 deletions elasticapm/instrumentation/packages/urllib.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ def call(self, module, method, wrapped, instance, args, kwargs):
span_id=parent_id, trace_options=TracingOptions(recorded=True)
)
self._set_disttracing_headers(request_object, trace_parent, transaction)
if leaf_span:
leaf_span.dist_tracing_propagated = True
response = wrapped(*args, **kwargs)
if response:
status = getattr(response, "status", None) or response.getcode() # Python 2 compat
Expand Down
2 changes: 2 additions & 0 deletions elasticapm/instrumentation/packages/urllib3.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ def call(self, module, method, wrapped, instance, args, kwargs):
span_id=parent_id, trace_options=TracingOptions(recorded=True)
)
args, kwargs = update_headers(args, kwargs, instance, transaction, trace_parent)
if leaf_span:
leaf_span.dist_tracing_propagated = True
response = wrapped(*args, **kwargs)
if response:
if span.context:
Expand Down
Loading

0 comments on commit aad1525

Please sign in to comment.