Skip to content

Commit

Permalink
test(otlp-exporter): add resource schema url to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hirotasoshu authored and ocelotl committed Feb 10, 2024
1 parent 34412f6 commit a46b03e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ def _get_sdk_log_data() -> List[LogData]:
severity_text="WARN",
severity_number=SeverityNumber.WARN,
body="Do not go gentle into that good night. Rage, rage against the dying of the light",
resource=SDKResource({"first_resource": "value"}),
resource=SDKResource(
{"first_resource": "value"},
"resource_schema_url",
),
attributes={"a": 1, "b": "c"},
),
instrumentation_scope=InstrumentationScope(
Expand Down Expand Up @@ -124,7 +127,10 @@ def _get_sdk_log_data() -> List[LogData]:
severity_text="INFO",
severity_number=SeverityNumber.INFO,
body="Love is the one thing that transcends time and space",
resource=SDKResource({"first_resource": "value"}),
resource=SDKResource(
{"first_resource": "value"},
"resource_schema_url",
),
attributes={"filename": "model.py", "func_name": "run_method"},
),
instrumentation_scope=InstrumentationScope(
Expand Down Expand Up @@ -206,6 +212,7 @@ def get_test_logs(
],
),
],
schema_url="resource_schema_url",
),
PB2ResourceLogs(
resource=PB2Resource(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def test_encode_sum_int(self):
expected = ExportMetricsServiceRequest(
resource_metrics=[
pb2.ResourceMetrics(
schema_url="resource_schema_url",
resource=OTLPResource(
attributes=[
KeyValue(key="a", value=AnyValue(int_value=1)),
Expand Down Expand Up @@ -178,6 +179,7 @@ def test_encode_sum_double(self):
expected = ExportMetricsServiceRequest(
resource_metrics=[
pb2.ResourceMetrics(
schema_url="resource_schema_url",
resource=OTLPResource(
attributes=[
KeyValue(key="a", value=AnyValue(int_value=1)),
Expand Down Expand Up @@ -257,6 +259,7 @@ def test_encode_gauge_int(self):
expected = ExportMetricsServiceRequest(
resource_metrics=[
pb2.ResourceMetrics(
schema_url="resource_schema_url",
resource=OTLPResource(
attributes=[
KeyValue(key="a", value=AnyValue(int_value=1)),
Expand Down Expand Up @@ -333,6 +336,7 @@ def test_encode_gauge_double(self):
expected = ExportMetricsServiceRequest(
resource_metrics=[
pb2.ResourceMetrics(
schema_url="resource_schema_url",
resource=OTLPResource(
attributes=[
KeyValue(key="a", value=AnyValue(int_value=1)),
Expand Down Expand Up @@ -409,6 +413,7 @@ def test_encode_histogram(self):
expected = ExportMetricsServiceRequest(
resource_metrics=[
pb2.ResourceMetrics(
schema_url="resource_schema_url",
resource=OTLPResource(
attributes=[
KeyValue(key="a", value=AnyValue(int_value=1)),
Expand Down Expand Up @@ -511,6 +516,7 @@ def test_encode_multiple_scope_histogram(self):
expected = ExportMetricsServiceRequest(
resource_metrics=[
pb2.ResourceMetrics(
schema_url="resource_schema_url",
resource=OTLPResource(
attributes=[
KeyValue(key="a", value=AnyValue(int_value=1)),
Expand Down Expand Up @@ -739,6 +745,7 @@ def test_encode_exponential_histogram(self):
expected = ExportMetricsServiceRequest(
resource_metrics=[
pb2.ResourceMetrics(
schema_url="resource_schema_url",
resource=OTLPResource(
attributes=[
KeyValue(key="a", value=AnyValue(int_value=1)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def get_exhaustive_otel_span_list() -> List[SDKSpan]:
links=(
SDKLink(context=other_context, attributes={"key_bool": True}),
),
resource=SDKResource({}),
resource=SDKResource({}, "resource_schema_url"),
)
span1.start(start_time=start_times[0])
span1.set_attribute("key_bool", False)
Expand Down Expand Up @@ -143,7 +143,7 @@ def get_exhaustive_otel_span_list() -> List[SDKSpan]:
name="test-span-4",
context=other_context,
parent=None,
resource=SDKResource({}),
resource=SDKResource({}, "resource_schema_url"),
instrumentation_scope=SDKInstrumentationScope(
name="name", version="version"
),
Expand All @@ -163,6 +163,7 @@ def get_exhaustive_test_spans(
pb2_service_request = PB2ExportTraceServiceRequest(
resource_spans=[
PB2ResourceSpans(
schema_url="resource_schema_url",
resource=PB2Resource(),
scope_spans=[
PB2ScopeSpans(
Expand Down

0 comments on commit a46b03e

Please sign in to comment.