Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge main into metrics_new #2165

Closed
wants to merge 13 commits into from
Closed
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
35 changes: 0 additions & 35 deletions .github/workflows/docs-update.yml

This file was deleted.

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: d2984f5242ed2250ad1c11b6164e2e8e11e2a804
CONTRIB_REPO_SHA: 36275f3cbf00c2021caa1d922bd98215c50b9af3

jobs:
build:
Expand Down
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ 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.5.0-0.24b0...HEAD)

- Fix race in `set_tracer_provider()`
([#2182](https://github.com/open-telemetry/opentelemetry-python/pull/2182))
- Automatically load OTEL environment variables as options for `opentelemetry-instrument`
([#1969](https://github.com/open-telemetry/opentelemetry-python/pull/1969))
- Make Measurement a concrete class
([#2153](https://github.com/open-telemetry/opentelemetry-python/pull/2153))
- Add metrics API
([#1887](https://github.com/open-telemetry/opentelemetry-python/pull/1887))
- `opentelemetry-semantic-conventions` Update to semantic conventions v1.6.1
([#2077](https://github.com/open-telemetry/opentelemetry-python/pull/2077))
- Do not count invalid attributes for dropped
Expand Down
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,16 @@ rather than conform to specific API names or argument patterns in the spec.

For a deeper discussion, see: https://github.com/open-telemetry/opentelemetry-specification/issues/165

### Environment Variables

If you are adding a component that introduces new OpenTelemetry environment variables, put them all in a module,
as it is done in `opentelemetry.environment_variables` or in `opentelemetry.sdk.environment_variables`.

Keep in mind that any new environment variable must be declared in all caps and must start with `OTEL_PYTHON_`.

Register this module with the `opentelemetry_environment_variables` entry point to make your environment variables
automatically load as options for the `opentelemetry-instrument` command.

## Style Guide

* docstrings should adhere to the [Google Python Style
Expand Down
10 changes: 0 additions & 10 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,6 @@ run eachdist once again:
./scripts/eachdist.py update_versions --versions stable,prerelease
```

## Update website docs

If the docs for the Opentelemetry [website](https://opentelemetry.io/docs/python/) was updated in this release in this [folder](https://github.com/open-telemetry/opentelemetry-python/tree/main/website_docs), submit a [PR](https://github.com/open-telemetry/opentelemetry.io/tree/main/content/en/docs/python) to update the docs on the website accordingly. To check if the new version requires updating, run the following script and compare the diff:

```bash
./scripts/generate_website_docs.sh
```

If the diff includes significant changes, create a pull request to commit the changes and once the changes are merged, click the "Run workflow" button for the Update [OpenTelemetry Website Docs](https://github.com/open-telemetry/opentelemetry-python/actions/workflows/docs-update.yml) GitHub Action.

## Hotfix procedure

A `hotfix` is defined as a small change developed to correct a bug that should be released as quickly as possible. Due to the nature of hotfixes, they usually will only affect one or a few packages. Therefore, it usually is not necessary to go through the entire release process outlined above for hotfixes. Follow the below steps how to release a hotfix:
Expand Down
1 change: 1 addition & 0 deletions docs/api/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ OpenTelemetry Python API
baggage
context
trace
metrics
environment_variables
8 changes: 8 additions & 0 deletions docs/api/metrics.instrument.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
opentelemetry.metrics.instrument
================================

.. automodule:: opentelemetry.metrics.instrument
:members:
:private-members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/api/metrics.measurement.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
opentelemetry.metrics.measurement
=================================

.. automodule:: opentelemetry.metrics.measurement
:members:
:undoc-members:
:show-inheritance:
15 changes: 15 additions & 0 deletions docs/api/metrics.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
opentelemetry.metrics package
=============================

Submodules
----------

.. toctree::

metrics.instrument
metrics.measurement

Module contents
---------------

.. automodule:: opentelemetry.metrics
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import unittest
from unittest import mock
from unittest.mock import patch

# pylint:disable=no-name-in-module
# pylint:disable=import-error
Expand All @@ -38,6 +37,7 @@
from opentelemetry.sdk.resources import SERVICE_NAME
from opentelemetry.sdk.trace import Resource, TracerProvider
from opentelemetry.sdk.util.instrumentation import InstrumentationInfo
from opentelemetry.test.globals_test import TraceGlobalsTest
from opentelemetry.test.spantestutil import (
get_span_with_dropped_attributes_events_links,
)
Expand All @@ -53,7 +53,7 @@ def _translate_spans_with_dropped_attributes():
return translate._translate(ThriftTranslator(max_tag_value_length=5))


class TestJaegerExporter(unittest.TestCase):
class TestJaegerExporter(TraceGlobalsTest, unittest.TestCase):
def setUp(self):
# create and save span to be used in tests
self.context = trace_api.SpanContext(
Expand All @@ -73,7 +73,6 @@ def setUp(self):
self._test_span.end(end_time=3)
# pylint: disable=protected-access

@patch("opentelemetry.exporter.jaeger.thrift.trace._TRACER_PROVIDER", None)
def test_constructor_default(self):
# pylint: disable=protected-access
"""Test the default values assigned by constructor."""
Expand All @@ -98,7 +97,6 @@ def test_constructor_default(self):
self.assertTrue(exporter._agent_client is not None)
self.assertIsNone(exporter._max_tag_value_length)

@patch("opentelemetry.exporter.jaeger.thrift.trace._TRACER_PROVIDER", None)
def test_constructor_explicit(self):
# pylint: disable=protected-access
"""Test the constructor passing all the options."""
Expand Down Expand Up @@ -143,7 +141,6 @@ def test_constructor_explicit(self):
self.assertTrue(exporter._collector_http_client.auth is None)
self.assertEqual(exporter._max_tag_value_length, 42)

@patch("opentelemetry.exporter.jaeger.thrift.trace._TRACER_PROVIDER", None)
def test_constructor_by_environment_variables(self):
# pylint: disable=protected-access
"""Test the constructor using Environment Variables."""
Expand Down Expand Up @@ -198,7 +195,6 @@ def test_constructor_by_environment_variables(self):
self.assertTrue(exporter._collector_http_client.auth is None)
environ_patcher.stop()

@patch("opentelemetry.exporter.jaeger.thrift.trace._TRACER_PROVIDER", None)
def test_constructor_with_no_traceprovider_resource(self):

"""Test the constructor when there is no resource attached to trace_provider"""
Expand Down Expand Up @@ -480,7 +476,6 @@ def test_translate_to_jaeger(self):

self.assertEqual(spans, expected_spans)

@patch("opentelemetry.exporter.jaeger.thrift.trace._TRACER_PROVIDER", None)
def test_export(self):

"""Test that agent and/or collector are invoked"""
Expand Down Expand Up @@ -511,9 +506,7 @@ def test_export(self):
exporter.export((self._test_span,))
self.assertEqual(agent_client_mock.emit.call_count, 1)
self.assertEqual(collector_mock.submit.call_count, 1)
# trace_api._TRACER_PROVIDER = None

@patch("opentelemetry.exporter.jaeger.thrift.trace._TRACER_PROVIDER", None)
def test_export_span_service_name(self):
trace_api.set_tracer_provider(
TracerProvider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,12 @@
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SpanExportResult
from opentelemetry.test.globals_test import TraceGlobalsTest
from opentelemetry.trace import TraceFlags


# pylint: disable=no-member
class TestCollectorSpanExporter(unittest.TestCase):
@mock.patch(
"opentelemetry.exporter.opencensus.trace_exporter.trace._TRACER_PROVIDER",
None,
)
class TestCollectorSpanExporter(TraceGlobalsTest, unittest.TestCase):
def test_constructor(self):
mock_get_node = mock.Mock()
patch = mock.patch(
Expand Down Expand Up @@ -329,10 +326,6 @@ def test_export(self):
getattr(output_identifier, "host_name"), "testHostName"
)

@mock.patch(
"opentelemetry.exporter.opencensus.trace_exporter.trace._TRACER_PROVIDER",
None,
)
def test_export_service_name(self):
trace_api.set_tracer_provider(
TracerProvider(
Expand Down
2 changes: 1 addition & 1 deletion exporter/opentelemetry-exporter-otlp-proto-http/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ url = https://github.com/open-telemetry/opentelemetry-python/tree/main/exporter/
platforms = any
license = Apache-2.0
classifiers =
Development Status :: 4 - Beta
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
License :: OSI Approved :: Apache Software License
Programming Language :: Python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@


DEFAULT_COMPRESSION = Compression.NoCompression
DEFAULT_ENDPOINT = "http://localhost:55681/v1/traces"
DEFAULT_ENDPOINT = "http://localhost:4318/v1/traces"
DEFAULT_TIMEOUT = 10 # in seconds


Expand Down
2 changes: 2 additions & 0 deletions opentelemetry-api/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ opentelemetry_tracer_provider =
opentelemetry_propagator =
tracecontext = opentelemetry.trace.propagation.tracecontext:TraceContextTextMapPropagator
baggage = opentelemetry.baggage.propagation:W3CBaggagePropagator
opentelemetry_environment_variables =
api = opentelemetry.environment_variables

[options.extras_require]
test =
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
.. envvar:: OTEL_PYTHON_CONTEXT
"""

OTEL_PYTHON_DISABLED_INSTRUMENTATIONS = "OTEL_PYTHON_DISABLED_INSTRUMENTATIONS"
"""
.. envvar:: OTEL_PYTHON_DISABLED_INSTRUMENTATIONS
"""

OTEL_PYTHON_ID_GENERATOR = "OTEL_PYTHON_ID_GENERATOR"
"""
.. envvar:: OTEL_PYTHON_ID_GENERATOR
Expand All @@ -41,3 +36,14 @@
"""
.. envvar:: OTEL_PYTHON_TRACER_PROVIDER
"""

OTEL_PYTHON_METER_PROVIDER = "OTEL_PYTHON_METER_PROVIDER"
"""
.. envvar:: OTEL_PYTHON_METER_PROVIDER
"""

OTEL_METRICS_EXPORTER = "OTEL_METRICS_EXPORTER"
"""
.. envvar:: OTEL_METRICS_EXPORTER

"""
Loading