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

Bump opentelemetry to latest version #33

Merged
merged 1 commit into from
Aug 19, 2024
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release History

## Unreleased

* Upgrade OpenTelemetry Python dependencies to version 1.26.0

## 0.5.0 (2024-07-23)

* Set empty resource for Python OpenTelemetry config.
Expand Down
6 changes: 3 additions & 3 deletions anaconda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ requirements:
- setuptools >=40.0.0
run:
- python
- opentelemetry-api ==1.23.0
- opentelemetry-exporter-otlp-proto-common ==1.23.0
- opentelemetry-sdk ==1.23.0
- opentelemetry-api ==1.26.0
- opentelemetry-exporter-otlp-proto-common ==1.26.0
- opentelemetry-sdk ==1.26.0

about:
home: https://www.snowflake.com/
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
description=DESCRIPTION,
long_description=LONG_DESCRIPTION,
install_requires=[
"opentelemetry-api == 1.23.0",
"opentelemetry-exporter-otlp-proto-common == 1.23.0",
"opentelemetry-sdk == 1.23.0",
"opentelemetry-api == 1.26.0",
"opentelemetry-exporter-otlp-proto-common == 1.26.0",
"opentelemetry-sdk == 1.26.0",
],
packages=find_namespace_packages(
where='src'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ class _SnowflakeTelemetryLoggerProvider(_logs.LoggerProvider):
"""

def get_logger(
self,
name: str,
version: types.Optional[str] = None,
schema_url: types.Optional[str] = None,
self, name: str,
version: types.Optional[str] = None,
schema_url: types.Optional[str] = None,
attributes: types.Optional[types.Attributes] = None,
) -> _logs.Logger:
return _SnowflakeTelemetryLogger(
Resource.get_empty(),
Expand Down
29 changes: 17 additions & 12 deletions tests/test_log_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

import unittest
from typing import List, Tuple
from typing import Sequence, Tuple

from opentelemetry._logs import SeverityNumber
from opentelemetry.exporter.otlp.proto.common._internal import (
Expand All @@ -40,8 +40,7 @@
from opentelemetry.proto.resource.v1.resource_pb2 import (
Resource as PB2Resource,
)
from opentelemetry.sdk._logs import LogData, LogLimits
from opentelemetry.sdk._logs import LogRecord as SDKLogRecord
from opentelemetry.sdk._logs import LogData, LogLimits, LogRecord as SDKLogRecord
from opentelemetry.sdk.resources import Resource as SDKResource
from opentelemetry.sdk.util.instrumentation import InstrumentationScope
from opentelemetry.trace import TraceFlags
Expand Down Expand Up @@ -82,10 +81,11 @@ def test_dropped_attributes_count(self):
)

@staticmethod
def _get_sdk_log_data() -> List[LogData]:
def _get_sdk_log_data() -> Sequence[LogData]:
log1 = LogData(
log_record=SDKLogRecord(
timestamp=1644650195189786880,
observed_timestamp=1644660000000000000,
trace_id=89564621134313219400156819398935297684,
span_id=1312458408527513268,
trace_flags=TraceFlags(0x01),
Expand All @@ -106,6 +106,7 @@ def _get_sdk_log_data() -> List[LogData]:
log2 = LogData(
log_record=SDKLogRecord(
timestamp=1644650249738562048,
observed_timestamp=1644660000000000000,
trace_id=0,
span_id=0,
trace_flags=TraceFlags.DEFAULT,
Expand All @@ -123,6 +124,7 @@ def _get_sdk_log_data() -> List[LogData]:
log3 = LogData(
log_record=SDKLogRecord(
timestamp=1644650427658989056,
observed_timestamp=1644660000000000000,
trace_id=271615924622795969659406376515024083555,
span_id=4242561578944770265,
trace_flags=TraceFlags(0x01),
Expand All @@ -138,6 +140,7 @@ def _get_sdk_log_data() -> List[LogData]:
log4 = LogData(
log_record=SDKLogRecord(
timestamp=1644650584292683008,
observed_timestamp=1644660000000000000,
trace_id=212592107417388365804938480559624925555,
span_id=6077757853989569223,
trace_flags=TraceFlags(0x01),
Expand All @@ -159,7 +162,7 @@ def _get_sdk_log_data() -> List[LogData]:

def get_test_logs(
self,
) -> Tuple[List[SDKLogRecord], ExportLogsServiceRequest]:
) -> Tuple[Sequence[LogData], ExportLogsServiceRequest]:
sdk_logs = self._get_sdk_log_data()

pb2_service_request = ExportLogsServiceRequest(
Expand All @@ -181,13 +184,14 @@ def get_test_logs(
log_records=[
PB2LogRecord(
time_unix_nano=1644650195189786880,
observed_time_unix_nano=1644660000000000000,
trace_id=_encode_trace_id(
89564621134313219400156819398935297684
),
span_id=_encode_span_id(
1312458408527513268
),
flags=int(TraceFlags(0x01)),
flags=int(0x01),
severity_text="WARN",
severity_number=SeverityNumber.WARN.value,
body=_encode_value(
Expand All @@ -207,13 +211,14 @@ def get_test_logs(
log_records=[
PB2LogRecord(
time_unix_nano=1644650584292683008,
observed_time_unix_nano=1644660000000000000,
trace_id=_encode_trace_id(
212592107417388365804938480559624925555
),
span_id=_encode_span_id(
6077757853989569223
),
flags=int(TraceFlags(0x01)),
flags=int(0x01),
severity_text="INFO",
severity_number=SeverityNumber.INFO.value,
body=_encode_value(
Expand Down Expand Up @@ -249,9 +254,8 @@ def get_test_logs(
log_records=[
PB2LogRecord(
time_unix_nano=1644650249738562048,
trace_id=_encode_trace_id(0),
span_id=_encode_span_id(0),
flags=int(TraceFlags.DEFAULT),
observed_time_unix_nano=1644660000000000000,
flags=int(0x00),
severity_text="WARN",
severity_number=SeverityNumber.WARN.value,
body=_encode_value(
Expand All @@ -266,13 +270,14 @@ def get_test_logs(
log_records=[
PB2LogRecord(
time_unix_nano=1644650427658989056,
observed_time_unix_nano=1644660000000000000,
trace_id=_encode_trace_id(
271615924622795969659406376515024083555
),
span_id=_encode_span_id(
4242561578944770265
),
flags=int(TraceFlags(0x01)),
flags=int(0x01),
severity_text="DEBUG",
severity_number=SeverityNumber.DEBUG.value,
body=_encode_value("To our galaxy"),
Expand All @@ -290,7 +295,7 @@ def get_test_logs(
return sdk_logs, pb2_service_request

@staticmethod
def _get_test_logs_dropped_attributes() -> List[LogData]:
def _get_test_logs_dropped_attributes() -> Sequence[LogData]:
log1 = LogData(
log_record=SDKLogRecord(
timestamp=1644650195189786880,
Expand Down
6 changes: 2 additions & 4 deletions tests/test_metrics_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@
from opentelemetry.sdk.metrics.export import AggregationTemporality, Buckets
from opentelemetry.sdk.metrics.export import (
ExponentialHistogram as ExponentialHistogramType,
)
from opentelemetry.sdk.metrics.export import ExponentialHistogramDataPoint
from opentelemetry.sdk.metrics.export import Histogram as HistogramType
from opentelemetry.sdk.metrics.export import (
Histogram as HistogramType,
ExponentialHistogramDataPoint,
HistogramDataPoint,
Metric,
MetricsData,
Expand Down
33 changes: 16 additions & 17 deletions tests/test_trace_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@
from opentelemetry.proto.trace.v1.trace_pb2 import (
ResourceSpans as PB2ResourceSpans,
TracesData as PB2TracesData,
ScopeSpans as PB2ScopeSpans,
Span as PB2Span,
SpanFlags as PB2SpanFlags,
Status as PB2Status,
)
from opentelemetry.proto.trace.v1.trace_pb2 import ScopeSpans as PB2ScopeSpans
from opentelemetry.proto.trace.v1.trace_pb2 import Span as PB2SPan
from opentelemetry.proto.trace.v1.trace_pb2 import Status as PB2Status
from opentelemetry.sdk.trace import Event as SDKEvent
from opentelemetry.sdk.trace import Resource as SDKResource
from opentelemetry.sdk.trace import SpanContext as SDKSpanContext
Expand Down Expand Up @@ -97,7 +98,7 @@ def get_exhaustive_otel_span_list() -> List[SDKSpan]:
)

parent_span_context = SDKSpanContext(
trace_id, 0x1111111111111111, is_remote=False
trace_id, 0x1111111111111111, is_remote=True
)

other_context = SDKSpanContext(
Expand Down Expand Up @@ -185,15 +186,15 @@ def get_exhaustive_test_spans(
PB2ScopeSpans(
scope=PB2InstrumentationScope(),
spans=[
PB2SPan(
PB2Span(
trace_id=trace_id,
span_id=_encode_span_id(
otel_spans[0].context.span_id
),
trace_state=None,
parent_span_id=_encode_span_id(
otel_spans[0].parent.span_id
),
flags=PB2SpanFlags.SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK|PB2SpanFlags.SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK,
name=otel_spans[0].name,
kind=span_kind,
start_time_unix_nano=otel_spans[
Expand Down Expand Up @@ -221,7 +222,7 @@ def get_exhaustive_test_spans(
),
],
events=[
PB2SPan.Event(
PB2Span.Event(
name="event0",
time_unix_nano=otel_spans[0]
.events[0]
Expand Down Expand Up @@ -249,7 +250,7 @@ def get_exhaustive_test_spans(
)
],
links=[
PB2SPan.Link(
PB2Span.Link(
trace_id=_encode_trace_id(
otel_spans[0]
.links[0]
Expand All @@ -260,6 +261,7 @@ def get_exhaustive_test_spans(
.links[0]
.context.span_id
),
flags=PB2SpanFlags.SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK,
attributes=[
PB2KeyValue(
key="key_bool",
Expand All @@ -283,13 +285,12 @@ def get_exhaustive_test_spans(
version="version",
),
spans=[
PB2SPan(
PB2Span(
trace_id=trace_id,
span_id=_encode_span_id(
otel_spans[3].context.span_id
),
trace_state=None,
parent_span_id=None,
flags=PB2SpanFlags.SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK,
name=otel_spans[3].name,
kind=span_kind,
start_time_unix_nano=otel_spans[
Expand Down Expand Up @@ -320,13 +321,12 @@ def get_exhaustive_test_spans(
PB2ScopeSpans(
scope=PB2InstrumentationScope(),
spans=[
PB2SPan(
PB2Span(
trace_id=trace_id,
span_id=_encode_span_id(
otel_spans[1].context.span_id
),
trace_state=None,
parent_span_id=None,
flags=PB2SpanFlags.SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK,
name=otel_spans[1].name,
kind=span_kind,
start_time_unix_nano=otel_spans[
Expand All @@ -338,13 +338,12 @@ def get_exhaustive_test_spans(
links=None,
status={},
),
PB2SPan(
PB2Span(
trace_id=trace_id,
span_id=_encode_span_id(
otel_spans[2].context.span_id
),
trace_state=None,
parent_span_id=None,
flags=PB2SpanFlags.SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK,
name=otel_spans[2].name,
kind=span_kind,
start_time_unix_nano=otel_spans[
Expand Down
Loading