Skip to content

Commit

Permalink
Merge branch 'open-telemetry:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
tonycody authored Jul 19, 2022
2 parents ae43bfb + f14d936 commit ba3477b
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:
# Otherwise, set variable to the commit of your branch on
# opentelemetry-python-contrib which is compatible with these Core repo
# changes.
CONTRIB_REPO_SHA: 42ff80bef8a03ff214a54323a2631da06e6dc5e4
CONTRIB_REPO_SHA: c37a77e2efa9b67d4b017a3aa6d5e5f0bc5433c9
# This is needed because we do not clone the core repo in contrib builds anymore.
# When running contrib builds as part of core builds, we use actions/checkout@v2 which
# does not set an environment variable (simply just runs tox), which is different when
Expand Down
38 changes: 21 additions & 17 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/open-telemetry/opentelemetry-python/compare/v1.12.0rc2-0.32b0...HEAD)
## [Unreleased]

- Change tracing to use `Resource.to_json()`
([#2784](https://github.com/open-telemetry/opentelemetry-python/pull/2784))
- Fix get_log_emitter instrumenting_module_version args typo
([#2830](https://github.com/open-telemetry/opentelemetry-python/pull/2830))
- Fix OTLP gRPC exporter warning message
([#2781](https://github.com/open-telemetry/opentelemetry-python/pull/2781))
- Fix tracing decorator with late configuration
([#2754](https://github.com/open-telemetry/opentelemetry-python/pull/2754))
- Fix --insecure of CLI argument
([#2696](https://github.com/open-telemetry/opentelemetry-python/pull/2696))

## [1.12.0rc2-0.32b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.12.0rc2-0.32b0) - 2022-07-04
## [1.12.0rc2-0.32b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.12.0rc2) - 2022-07-04

- Fix instrument name and unit regexes
([#2796](https://github.com/open-telemetry/opentelemetry-python/pull/2796))
Expand Down Expand Up @@ -59,7 +63,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#2785](https://github.com/open-telemetry/opentelemetry-python/pull/2785))


## [1.12.0rc1-0.31b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.12.0rc1-0.31b0) - 2022-05-17
## [1.12.0rc1-0.31b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.12.0rc1) - 2022-05-17

- Fix LoggingHandler to handle LogRecord with exc_info=False
([#2690](https://github.com/open-telemetry/opentelemetry-python/pull/2690))
Expand All @@ -82,7 +86,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Move Metrics API behind internal package
([#2651](https://github.com/open-telemetry/opentelemetry-python/pull/2651))

## [1.11.1-0.30b1](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.11.1-0.30b1) - 2022-04-21
## [1.11.1-0.30b1](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.11.1) - 2022-04-21

- Add parameter to MetricReader constructor to select aggregation per instrument kind
([#2638](https://github.com/open-telemetry/opentelemetry-python/pull/2638))
Expand All @@ -98,7 +102,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Deprecate InstrumentationLibraryInfo and Add InstrumentationScope
([#2583](https://github.com/open-telemetry/opentelemetry-python/pull/2583))

## [1.11.0-0.30b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.11.0-0.30b0) - 2022-04-18
## [1.11.0-0.30b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.11.0) - 2022-04-18

- Rename API Measurement for async instruments to Observation
([#2617](https://github.com/open-telemetry/opentelemetry-python/pull/2617))
Expand Down Expand Up @@ -132,7 +136,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Update opentelemetry-proto to v0.16.0
([#2619](https://github.com/open-telemetry/opentelemetry-python/pull/2619))

## [1.10.0-0.29b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.10.0-0.29b0) - 2022-03-10
## [1.10.0-0.29b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.10.0) - 2022-03-10

- Docs rework: [non-API docs are
moving](https://github.com/open-telemetry/opentelemetry-python/issues/2172) to
Expand All @@ -153,12 +157,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [exporter/opentelemetry-exporter-prometheus] restore package using the new metrics API
([#2321](https://github.com/open-telemetry/opentelemetry-python/pull/2321))

## [1.9.1-0.28b1](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.9.1-0.28b1) - 2022-01-29
## [1.9.1-0.28b1](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.9.1) - 2022-01-29

- Update opentelemetry-proto to v0.12.0. Note that this update removes deprecated status codes.
([#2415](https://github.com/open-telemetry/opentelemetry-python/pull/2415))

## [1.9.0-0.28b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.9.0-0.28b0) - 2022-01-26
## [1.9.0-0.28b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.9.0) - 2022-01-26


- Fix SpanLimits global span limit defaulting when set to 0
Expand All @@ -182,7 +186,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [logs] prevent None from causing problems
([#2410](https://github.com/open-telemetry/opentelemetry-python/pull/2410))

## [1.8.0-0.27b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.8.0-0.27b0) - 2021-12-17
## [1.8.0-0.27b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.8.0) - 2021-12-17

- Adds Aggregation and instruments as part of Metrics SDK
([#2234](https://github.com/open-telemetry/opentelemetry-python/pull/2234))
Expand All @@ -201,7 +205,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Support insecure configuration for OTLP gRPC exporter
([#2350](https://github.com/open-telemetry/opentelemetry-python/pull/2350))

## [1.7.1-0.26b1](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.7.0-0.26b0) - 2021-11-11
## [1.7.1-0.26b1](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.7.0) - 2021-11-11

- Add support for Python 3.10
([#2207](https://github.com/open-telemetry/opentelemetry-python/pull/2207))
Expand All @@ -222,12 +226,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `opentelemetry-test` start releasing to pypi.org
([#2269](https://github.com/open-telemetry/opentelemetry-python/pull/2269))

## [1.6.2-0.25b2](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.6.2-0.25b2) - 2021-10-19
## [1.6.2-0.25b2](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.6.2) - 2021-10-19

- Fix parental trace relationship for opentracing `follows_from` reference
([#2180](https://github.com/open-telemetry/opentelemetry-python/pull/2180))

## [1.6.1-0.25b1](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.6.1-0.25b1) - 2021-10-18
## [1.6.1-0.25b1](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.6.1) - 2021-10-18

- Fix ReadableSpan property types attempting to create a mapping from a list
([#2215](https://github.com/open-telemetry/opentelemetry-python/pull/2215))
Expand All @@ -236,7 +240,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Propagation: only warn about oversized baggage headers when headers exist
([#2212](https://github.com/open-telemetry/opentelemetry-python/pull/2212))

## [1.6.0-0.25b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.6.0-0.25b0) - 2021-10-13
## [1.6.0-0.25b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.6.0) - 2021-10-13

- Fix race in `set_tracer_provider()`
([#2182](https://github.com/open-telemetry/opentelemetry-python/pull/2182))
Expand Down Expand Up @@ -274,7 +278,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add name to `BatchSpanProcessor` worker thread
([#2186](https://github.com/open-telemetry/opentelemetry-python/pull/2186))

## [1.5.0-0.24b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.5.0-0.24b0) - 2021-08-26
## [1.5.0-0.24b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.5.0) - 2021-08-26

- Add pre and post instrumentation entry points
([#1983](https://github.com/open-telemetry/opentelemetry-python/pull/1983))
Expand Down Expand Up @@ -307,7 +311,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix opentelemetry-bootstrap dependency script.
([#1987](https://github.com/open-telemetry/opentelemetry-python/pull/1987))

## [1.4.0-0.23b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.4.0-0.23b0) - 2021-07-21
## [1.4.0-0.23b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.4.0) - 2021-07-21

### Added

Expand Down Expand Up @@ -358,7 +362,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
opentelemetry specification format, rather than opentracing spec format.
([#1878](https://github.com/open-telemetry/opentelemetry-python/pull/1878))

## [1.3.0-0.22b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.3.0-0.22b0) - 2021-06-01
## [1.3.0-0.22b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.3.0) - 2021-06-01

### Added

Expand All @@ -380,7 +384,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Update protos to latest version release 0.9.0
([#1873](https://github.com/open-telemetry/opentelemetry-python/pull/1873))

## [1.2.0, 0.21b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.2.0-0.21b0) - 2021-05-11
## [1.2.0, 0.21b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.2.0) - 2021-05-11

### Added

Expand Down
1 change: 1 addition & 0 deletions docs/examples/views/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ These examples show how to customize the metrics that are output by the SDK usin
* change_aggregation: Shows how to configure to change the default aggregation for an instrument.
* change_name: Shows how to change the name of a metric.
* limit_num_of_attrs: Shows how to limit the number of attributes that are output for a metric.
* drop_metrics_from_instrument: Shows how to drop measurements from an instrument.

The source files of these examples are available :scm_web:`here <docs/examples/views/>`.

Expand Down
53 changes: 53 additions & 0 deletions docs/examples/views/drop_metrics_from_instrument.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright The OpenTelemetry Authors
#
# 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.

import random
import time

from opentelemetry.metrics import get_meter_provider, set_meter_provider
from opentelemetry.sdk.metrics import Counter, MeterProvider
from opentelemetry.sdk.metrics.export import (
ConsoleMetricExporter,
PeriodicExportingMetricReader,
)
from opentelemetry.sdk.metrics.view import DropAggregation, View

# Create a view matching the counter instrument `my.counter`
# and configure the view to drop the aggregation.
drop_aggregation_view = View(
instrument_type=Counter,
instrument_name="my.counter",
aggregation=DropAggregation(),
)

exporter = ConsoleMetricExporter()

reader = PeriodicExportingMetricReader(exporter, export_interval_millis=1_000)
provider = MeterProvider(
metric_readers=[
reader,
],
views=[
drop_aggregation_view,
],
)
set_meter_provider(provider)

meter = get_meter_provider().get_meter("view-drop-aggregation", "0.1.2")

my_counter = meter.create_counter("my.counter")

while 1:
my_counter.add(random.randint(1, 10))
time.sleep(random.random())
4 changes: 2 additions & 2 deletions opentelemetry-sdk/src/opentelemetry/sdk/_logs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,13 +427,13 @@ def resource(self):
def get_log_emitter(
self,
instrumenting_module_name: str,
instrumenting_module_verison: str = "",
instrumenting_module_version: str = "",
) -> LogEmitter:
return LogEmitter(
self._resource,
self._multi_log_processor,
InstrumentationScope(
instrumenting_module_name, instrumenting_module_verison
instrumenting_module_name, instrumenting_module_version
),
)

Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ def to_json(self, indent=4):
f_span["attributes"] = self._format_attributes(self._attributes)
f_span["events"] = self._format_events(self._events)
f_span["links"] = self._format_links(self._links)
f_span["resource"] = self._format_attributes(self._resource.attributes)
f_span["resource"] = json.loads(self.resource.to_json())

return json.dumps(f_span, indent=indent)

Expand Down
9 changes: 6 additions & 3 deletions opentelemetry-sdk/tests/trace/test_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -1354,12 +1354,15 @@ def test_to_json(self):
"attributes": {},
"events": [],
"links": [],
"resource": {}
"resource": {
"attributes": {},
"schema_url": ""
}
}""",
)
self.assertEqual(
span.to_json(indent=None),
'{"name": "span-name", "context": {"trace_id": "0x000000000000000000000000deadbeef", "span_id": "0x00000000deadbef0", "trace_state": "[]"}, "kind": "SpanKind.INTERNAL", "parent_id": "0x00000000deadbef0", "start_time": null, "end_time": null, "status": {"status_code": "UNSET"}, "attributes": {}, "events": [], "links": [], "resource": {}}',
'{"name": "span-name", "context": {"trace_id": "0x000000000000000000000000deadbeef", "span_id": "0x00000000deadbef0", "trace_state": "[]"}, "kind": "SpanKind.INTERNAL", "parent_id": "0x00000000deadbef0", "start_time": null, "end_time": null, "status": {"status_code": "UNSET"}, "attributes": {}, "events": [], "links": [], "resource": {"attributes": {}, "schema_url": ""}}',
)

def test_attributes_to_json(self):
Expand All @@ -1377,7 +1380,7 @@ def test_attributes_to_json(self):
span.to_json(indent=None),
'{"name": "span-name", "context": {"trace_id": "0x000000000000000000000000deadbeef", "span_id": "0x00000000deadbef0", "trace_state": "[]"}, "kind": "SpanKind.INTERNAL", "parent_id": null, "start_time": null, "end_time": null, "status": {"status_code": "UNSET"}, "attributes": {"key": "value"}, "events": [{"name": "event", "timestamp": "'
+ date_str
+ '", "attributes": {"key2": "value2"}}], "links": [], "resource": {}}',
+ '", "attributes": {"key2": "value2"}}], "links": [], "resource": {"attributes": {}, "schema_url": ""}}',
)


Expand Down
22 changes: 10 additions & 12 deletions tests/opentelemetry-test-utils/src/opentelemetry/test/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,15 @@
class TestBase(unittest.TestCase):
# pylint: disable=C0103

@classmethod
def setUpClass(cls):
result = cls.create_tracer_provider()
cls.tracer_provider, cls.memory_exporter = result
# This is done because set_tracer_provider cannot override the
# current tracer provider.
reset_trace_globals()
trace_api.set_tracer_provider(cls.tracer_provider)

@classmethod
def tearDownClass(cls):
def setUp(self):
super().setUp()
result = self.create_tracer_provider()
self.tracer_provider, self.memory_exporter = result
# This is done because set_tracer_provider cannot override the
# current tracer provider.
reset_trace_globals()
trace_api.set_tracer_provider(self.tracer_provider)

def setUp(self):
self.memory_exporter.clear()
# This is done because set_meter_provider cannot override the
# current meter provider.
Expand All @@ -60,6 +53,11 @@ def setUp(self):
) = self.create_meter_provider()
metrics_api.set_meter_provider(self.meter_provider)

def tearDown(self):
super().tearDown()
reset_trace_globals()
reset_metrics_globals()

def get_finished_spans(self):
return FinishedTestSpans(
self, self.memory_exporter.get_finished_spans()
Expand Down

0 comments on commit ba3477b

Please sign in to comment.