-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit 30f0bf5 Author: Hannah Stepanek <[email protected]> Date: Fri Jun 9 16:12:09 2023 -0700 Add OTLP protocol class & protos (#821) * Add protos under packages for otlp * Add common otlp proto payload methods * Add new oltp protocol class * Remove ML event from log message * Remove params, add api-key header & expose path The params are not relevant to OTLP so remove these. The api-key header is how we provide the license key to OTLP so add this. The path to upload dimensional metrics and events are different in OTLP so expose the path so it can be overriden inside the coresponding data_collector methods. * Add otlp_port and otlp_host settings * Default to JSON if protobuf not available & warn * Move otlp_utils to core * Call encode in protocol class * Patch issues with data collector * Move resource to utils & add log proto imports --------- Co-authored-by: Tim Pansino <[email protected]> commit e970884 Author: Timothy Pansino <[email protected]> Date: Thu Jun 8 13:17:28 2023 -0700 Dimensional Metrics (#815) * Wiring dimensional metrics * Squashed commit of the following: commit c2d4629 Author: Timothy Pansino <[email protected]> Date: Wed May 10 15:59:13 2023 -0700 Add required option for tox v4 (#795) * Add required option for tox v4 * Update tox in GHA * Remove py27 no-cache-dir commit a963649 Author: Hannah Stepanek <[email protected]> Date: Tue May 9 10:46:39 2023 -0700 Run coverage around pytest (#813) * Run coverage around pytest * Trigger tests * Fixup * Add redis client_no_touch to ignore list * Temporarily remove kafka from coverage * Remove coverage for old libs commit 3d82845 Author: Lalleh Rafeei <[email protected]> Date: Wed May 3 14:50:30 2023 -0700 Omit some frameworks from coverage analysis (#810) * Omit some frameworks from coverage analysis * Remove commas * Change format of omit * Add relative_files option to coverage * Add absolute directory * Add envsitepackagedir * Add coveragerc file * Add codecov.yml * [Mega-Linter] Apply linters fixes * Revert coveragerc file settings * Add files in packages and more frameworks * Remove commented line --------- Co-authored-by: lrafeei <[email protected]> Co-authored-by: Hannah Stepanek <[email protected]> commit fd0fa35 Author: Uma Annamalai <[email protected]> Date: Tue May 2 10:55:36 2023 -0700 Add testing for genshi and mako. (#799) * Add testing for genshi and mako. * [Mega-Linter] Apply linters fixes --------- Co-authored-by: umaannamalai <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> commit be4fb3d Author: Lalleh Rafeei <[email protected]> Date: Mon May 1 16:01:09 2023 -0700 Add tests for Waitress (#797) * Change import format * Initial commit * Add more tests to adapter_waitress * Remove commented out code * [Mega-Linter] Apply linters fixes * Add assertions to all tests * Add more NR testing to waitress --------- Co-authored-by: lrafeei <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> commit 7103506 Author: Hannah Stepanek <[email protected]> Date: Mon May 1 14:12:31 2023 -0700 Add tests for pyodbc (#796) * Add tests for pyodbc * Move imports into tests to get import coverage * Fixup: remove time import * Trigger tests --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> commit 363122a Author: Hannah Stepanek <[email protected]> Date: Mon May 1 13:34:35 2023 -0700 Pin virtualenv, fix pip arg deprecation & disable kafka tests (#803) * Pin virtualenv * Fixup: use 20.21.1 instead * Replace install-options with config-settings See pypa/pip#11358. * Temporarily disable kafka tests * Add dimensional stats table to stats engine * Add attribute processing to metric identity * Add testing for dimensional metrics * Cover tags as list not dict * Commit suggestions from code review
- Loading branch information
1 parent
14e5a45
commit 3199cc8
Showing
7 changed files
with
167 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# Copyright 2010 New Relic, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""This module provides common utilities for interacting with OTLP protocol buffers.""" | ||
|
||
import logging | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
try: | ||
from newrelic.packages.opentelemetry_proto.common_pb2 import AnyValue, KeyValue | ||
from newrelic.packages.opentelemetry_proto.logs_pb2 import ( | ||
LogRecord, | ||
ResourceLogs, | ||
ScopeLogs, | ||
) | ||
from newrelic.packages.opentelemetry_proto.metrics_pb2 import ( | ||
AggregationTemporality, | ||
Metric, | ||
MetricsData, | ||
NumberDataPoint, | ||
ResourceMetrics, | ||
ScopeMetrics, | ||
Sum, | ||
Summary, | ||
SummaryDataPoint, | ||
) | ||
from newrelic.packages.opentelemetry_proto.resource_pb2 import Resource | ||
|
||
AGGREGATION_TEMPORALITY_DELTA = AggregationTemporality.AGGREGATION_TEMPORALITY_DELTA | ||
ValueAtQuantile = SummaryDataPoint.ValueAtQuantile | ||
|
||
otlp_encode = lambda payload: payload.SerializeToString() | ||
OTLP_CONTENT_TYPE = "application/x-protobuf" | ||
|
||
except ImportError: | ||
from newrelic.common.encoding_utils import json_encode | ||
|
||
def otlp_encode(*args, **kwargs): | ||
_logger.warn( | ||
"Using OTLP integration while protobuf is not installed. This may result in larger payload sizes and data loss." | ||
) | ||
return json_encode(*args, **kwargs) | ||
|
||
Resource = dict | ||
ValueAtQuantile = dict | ||
AnyValue = dict | ||
KeyValue = dict | ||
NumberDataPoint = dict | ||
SummaryDataPoint = dict | ||
Sum = dict | ||
Summary = dict | ||
Metric = dict | ||
MetricsData = dict | ||
ScopeMetrics = dict | ||
ResourceMetrics = dict | ||
AGGREGATION_TEMPORALITY_DELTA = 1 | ||
ResourceLogs = dict | ||
ScopeLogs = dict | ||
LogRecord = dict | ||
OTLP_CONTENT_TYPE = "application/json" | ||
|
||
|
||
def create_key_value(key, value): | ||
if isinstance(value, bool): | ||
return KeyValue(key=key, value=AnyValue(bool_value=value)) | ||
elif isinstance(value, int): | ||
return KeyValue(key=key, value=AnyValue(int_value=value)) | ||
elif isinstance(value, float): | ||
return KeyValue(key=key, value=AnyValue(double_value=value)) | ||
elif isinstance(value, str): | ||
return KeyValue(key=key, value=AnyValue(string_value=value)) | ||
# Technically AnyValue accepts array, kvlist, and bytes however, since | ||
# those are not valid custom attribute types according to our api spec, | ||
# we will not bother to support them here either. | ||
else: | ||
_logger.warn("Unsupported attribute value type %s: %s." % (key, value)) | ||
|
||
|
||
def create_key_values_from_iterable(iterable): | ||
if isinstance(iterable, dict): | ||
iterable = iterable.items() | ||
|
||
# The create_key_value list may return None if the value is an unsupported type | ||
# so filter None values out before returning. | ||
return list( | ||
filter( | ||
lambda i: i is not None, | ||
(create_key_value(key, value) for key, value in iterable), | ||
) | ||
) | ||
|
||
|
||
def create_resource(attributes=None): | ||
attributes = attributes or {"instrumentation.provider": "nr_performance_monitoring"} | ||
return Resource(attributes=create_key_values_from_iterable(attributes)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters