|
16 | 16 | import pytest |
17 | 17 | import requests.exceptions |
18 | 18 | import requests_mock |
| 19 | +from dirty_equals import IsStr |
19 | 20 | from inline_snapshot import snapshot |
20 | 21 | from opentelemetry.exporter.otlp.proto.http.metric_exporter import OTLPMetricExporter |
21 | 22 | from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter |
|
62 | 63 | from logfire.propagate import NoExtractTraceContextPropagator, WarnOnExtractTraceContextPropagator |
63 | 64 | from logfire.testing import TestExporter |
64 | 65 |
|
| 66 | +PROCESS_RUNTIME_VERSION_REGEX = r'(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)' |
| 67 | +PROCESS_RUNTIME_DESCRIPTION_REGEX = r'(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+) \((?P<branch>\w+), (?P<month>[A-Za-z]{3})\s+(?P<day>\d{1,2}) (?P<year>\d{4}), (?P<hour>\d{2}):(?P<minute>\d{2}):(?P<second>\d{2})\)\s*\[\w+ (?P<clang_version>[\d.]+)\s*\]' |
| 68 | + |
65 | 69 |
|
66 | 70 | def test_propagate_config_to_tags(exporter: TestExporter) -> None: |
67 | 71 | tags1 = logfire.with_tags('tag1', 'tag2') |
@@ -673,6 +677,9 @@ def test_otel_service_name_env_var(config_kwargs: dict[str, Any], exporter: Test |
673 | 677 | 'service.name': 'potato', |
674 | 678 | 'service.version': '1.2.3', |
675 | 679 | 'service.instance.id': '00000000000000000000000000000000', |
| 680 | + 'process.runtime.name': 'cpython', |
| 681 | + 'process.runtime.version': IsStr(regex=PROCESS_RUNTIME_VERSION_REGEX), |
| 682 | + 'process.runtime.description': IsStr(regex=PROCESS_RUNTIME_DESCRIPTION_REGEX), |
676 | 683 | 'process.pid': 1234, |
677 | 684 | } |
678 | 685 | }, |
@@ -716,6 +723,9 @@ def test_otel_otel_resource_attributes_env_var(config_kwargs: dict[str, Any], ex |
716 | 723 | 'service.version': '1.2.3', |
717 | 724 | 'service.instance.id': 'instance_id', |
718 | 725 | 'process.pid': 1234, |
| 726 | + 'process.runtime.name': 'cpython', |
| 727 | + 'process.runtime.version': IsStr(regex=PROCESS_RUNTIME_VERSION_REGEX), |
| 728 | + 'process.runtime.description': IsStr(regex=PROCESS_RUNTIME_DESCRIPTION_REGEX), |
719 | 729 | } |
720 | 730 | }, |
721 | 731 | } |
@@ -760,6 +770,9 @@ def test_otel_service_name_has_priority_on_otel_resource_attributes_service_name |
760 | 770 | 'service.version': '1.2.3', |
761 | 771 | 'service.instance.id': '00000000000000000000000000000000', |
762 | 772 | 'process.pid': 1234, |
| 773 | + 'process.runtime.name': 'cpython', |
| 774 | + 'process.runtime.version': IsStr(regex=PROCESS_RUNTIME_VERSION_REGEX), |
| 775 | + 'process.runtime.description': IsStr(regex=PROCESS_RUNTIME_DESCRIPTION_REGEX), |
763 | 776 | } |
764 | 777 | }, |
765 | 778 | } |
@@ -1658,6 +1671,9 @@ def test_environment(config_kwargs: dict[str, Any], exporter: TestExporter): |
1658 | 1671 | 'telemetry.sdk.version': '0.0.0', |
1659 | 1672 | 'service.name': 'unknown_service', |
1660 | 1673 | 'process.pid': 1234, |
| 1674 | + 'process.runtime.name': 'cpython', |
| 1675 | + 'process.runtime.version': IsStr(regex=PROCESS_RUNTIME_VERSION_REGEX), |
| 1676 | + 'process.runtime.description': IsStr(regex=PROCESS_RUNTIME_DESCRIPTION_REGEX), |
1661 | 1677 | 'service.version': '1.2.3', |
1662 | 1678 | 'deployment.environment.name': 'production', |
1663 | 1679 | } |
@@ -1705,6 +1721,9 @@ def test_code_source(config_kwargs: dict[str, Any], exporter: TestExporter): |
1705 | 1721 | 'telemetry.sdk.version': '0.0.0', |
1706 | 1722 | 'service.name': 'unknown_service', |
1707 | 1723 | 'process.pid': 1234, |
| 1724 | + 'process.runtime.name': 'cpython', |
| 1725 | + 'process.runtime.version': IsStr(regex=PROCESS_RUNTIME_VERSION_REGEX), |
| 1726 | + 'process.runtime.description': IsStr(regex=PROCESS_RUNTIME_DESCRIPTION_REGEX), |
1708 | 1727 | 'logfire.code.root_path': 'logfire', |
1709 | 1728 | 'logfire.code.work_dir': os.getcwd(), |
1710 | 1729 | 'vcs.repository.url.full': 'https://github.com/pydantic/logfire', |
@@ -1754,6 +1773,9 @@ def test_code_source_without_root_path(config_kwargs: dict[str, Any], exporter: |
1754 | 1773 | 'telemetry.sdk.version': '0.0.0', |
1755 | 1774 | 'service.name': 'unknown_service', |
1756 | 1775 | 'process.pid': 1234, |
| 1776 | + 'process.runtime.name': 'cpython', |
| 1777 | + 'process.runtime.version': IsStr(regex=PROCESS_RUNTIME_VERSION_REGEX), |
| 1778 | + 'process.runtime.description': IsStr(regex=PROCESS_RUNTIME_DESCRIPTION_REGEX), |
1757 | 1779 | 'logfire.code.work_dir': os.getcwd(), |
1758 | 1780 | 'vcs.repository.url.full': 'https://github.com/pydantic/logfire', |
1759 | 1781 | 'vcs.repository.ref.revision': 'main', |
|
0 commit comments