Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
scope
  • Loading branch information
lzchen committed Nov 1, 2023
commit 40ad2ee043c951c9ad57fe72a8653803b636f3df
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ def export(
point,
metric.name,
resource_metric.resource,
scope_metric.scope
)
if envelope is not None:
envelopes.append(envelope)
Expand Down Expand Up @@ -135,7 +134,6 @@ def _point_to_envelope(
point: DataPointT,
name: str,
resource: Optional[Resource] = None,
scope: Optional[InstrumentationScope] = None
) -> Optional[TelemetryItem]:
envelope = _convert_point_to_envelope(point, name, resource)
if name in _AUTOCOLLECTED_INSTRUMENT_NAMES:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ def test_point_to_envelope_partA_default(self):
def test_point_to_envelope_number(self):
exporter = self._exporter
resource = Resource.create(attributes={"asd":"test_resource"})
scope = InstrumentationScope("test_scope")
point=NumberDataPoint(
attributes={
"test": "attribute",
Expand All @@ -221,7 +220,7 @@ def test_point_to_envelope_number(self):
time_unix_nano=1646865018558419457,
value=10,
)
envelope = exporter._point_to_envelope(point, "test name", resource, scope)
envelope = exporter._point_to_envelope(point, "test name", resource)
self.assertEqual(envelope.instrumentation_key, exporter._instrumentation_key)
self.assertEqual(envelope.name, 'Microsoft.ApplicationInsights.Metric')
self.assertEqual(envelope.time, ns_to_iso_str(point.time_unix_nano))
Expand All @@ -236,7 +235,6 @@ def test_point_to_envelope_number(self):
def test_point_to_envelope_histogram(self):
exporter = self._exporter
resource = Resource.create(attributes={"asd":"test_resource"})
scope = InstrumentationScope("test_scope")
point=HistogramDataPoint(
attributes={
"test": "attribute",
Expand All @@ -250,7 +248,7 @@ def test_point_to_envelope_histogram(self):
time_unix_nano=1646865018558419457,
sum=31,
)
envelope = exporter._point_to_envelope(point, "test name", resource, scope)
envelope = exporter._point_to_envelope(point, "test name", resource)
self.assertEqual(envelope.instrumentation_key, exporter._instrumentation_key)
self.assertEqual(envelope.name, 'Microsoft.ApplicationInsights.Metric')
self.assertEqual(envelope.time, ns_to_iso_str(point.time_unix_nano))
Expand All @@ -268,7 +266,6 @@ def test_point_to_envelope_std_metric_client_duration(self):
{"service.name": "testServiceName",
"service.namespace": "testServiceNamespace",
"service.instance.id": "testServiceInstanceId"})
scope = InstrumentationScope("opentelemetry.instrumentation.requests")
point=NumberDataPoint(
attributes={
"http.status_code": 200,
Expand All @@ -279,7 +276,7 @@ def test_point_to_envelope_std_metric_client_duration(self):
time_unix_nano=1646865018558419457,
value=15.0,
)
envelope = exporter._point_to_envelope(point, "http.client.duration", resource, scope)
envelope = exporter._point_to_envelope(point, "http.client.duration", resource)
self.assertEqual(envelope.instrumentation_key, exporter._instrumentation_key)
self.assertEqual(envelope.name, 'Microsoft.ApplicationInsights.Metric')
self.assertEqual(envelope.time, ns_to_iso_str(point.time_unix_nano))
Expand All @@ -300,17 +297,17 @@ def test_point_to_envelope_std_metric_client_duration(self):
# target
point.attributes.pop("peer.service", None)
point.attributes["net.peer.name"] = None
envelope = exporter._point_to_envelope(point, "http.client.duration", resource, scope)
envelope = exporter._point_to_envelope(point, "http.client.duration", resource)
self.assertEqual(envelope.data.base_data.properties['dependency/target'], None)

point.attributes["net.peer.name"] = "test_peer_name"
point.attributes["net.host.port"] = "test_port"
envelope = exporter._point_to_envelope(point, "http.client.duration", resource, scope)
envelope = exporter._point_to_envelope(point, "http.client.duration", resource)
self.assertEqual(envelope.data.base_data.properties['dependency/target'], "test_peer_name:test_port")

# Success/Failure
point.attributes["http.status_code"] = 500
envelope = exporter._point_to_envelope(point, "http.client.duration", resource, scope)
envelope = exporter._point_to_envelope(point, "http.client.duration", resource)
self.assertEqual(envelope.data.base_data.properties['Dependency.Success'], "False")


Expand All @@ -320,7 +317,6 @@ def test_point_to_envelope_std_metric_server_duration(self):
{"service.name": "testServiceName",
"service.namespace": "testServiceNamespace",
"service.instance.id": "testServiceInstanceId"})
scope = InstrumentationScope("opentelemetry.instrumentation.flask")
point=NumberDataPoint(
attributes={
"http.status_code": 200,
Expand All @@ -331,7 +327,7 @@ def test_point_to_envelope_std_metric_server_duration(self):
time_unix_nano=1646865018558419457,
value=15.0,
)
envelope = exporter._point_to_envelope(point, "http.server.duration", resource, scope)
envelope = exporter._point_to_envelope(point, "http.server.duration", resource)
self.assertEqual(envelope.instrumentation_key, exporter._instrumentation_key)
self.assertEqual(envelope.name, 'Microsoft.ApplicationInsights.Metric')
self.assertEqual(envelope.time, ns_to_iso_str(point.time_unix_nano))
Expand All @@ -349,7 +345,7 @@ def test_point_to_envelope_std_metric_server_duration(self):

# Success/Failure
point.attributes["http.status_code"] = 600
envelope = exporter._point_to_envelope(point, "http.server.duration", resource, scope)
envelope = exporter._point_to_envelope(point, "http.server.duration", resource)
self.assertEqual(envelope.data.base_data.properties['Request.Success'], "False")

def test_point_to_envelope_std_metric_unsupported(self):
Expand All @@ -369,7 +365,7 @@ def test_point_to_envelope_std_metric_unsupported(self):
time_unix_nano=1646865018558419457,
value=15.0,
)
envelope = exporter._point_to_envelope(point, "http.server.request.size", resource, scope)
envelope = exporter._point_to_envelope(point, "http.server.request.size", resource)
self.assertIsNone(envelope)


Expand Down