Skip to content

Commit

Permalink
Update broken test
Browse files Browse the repository at this point in the history
  • Loading branch information
iamluc authored and bwoebi committed Mar 28, 2024
1 parent 54327d6 commit 55d2c44
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions tests/Integrations/Custom/Autoloaded/InstrumentationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,15 @@ public function testInstrumentation()
$this->fail("Go no response from request-dumper");
}

$this->assertCount(3, $response);
$this->assertCount(4, $response);
$payloads = $this->readTelemetryPayloads($response);

$isMetric = function (array $payload) {
return 'generate-metrics' === $payload['request_type'];
};
$metrics = array_values(array_filter($payloads, $isMetric));
$payloads = array_values(array_filter($payloads, function($p) use ($isMetric) { return !$isMetric($p); }));

$this->assertEquals("app-started", $payloads[0]["request_type"]);
$this->assertContains([
"name" => "agent_host",
Expand All @@ -70,15 +77,25 @@ public function testInstrumentation()
}));
// Not asserting app-closing, this is not expected to happen until shutdown

$this->assertCount(1, $metrics);
$this->assertEquals("generate-metrics", $metrics[0]["request_type"]);
$this->assertEquals("tracers", $metrics[0]["payload"]["series"][0]["namespace"]);
$this->assertEquals("dd.instrumentation_telemetry_data.tracers.spans_created", $metrics[0]["payload"]["series"][0]["metric"]);
$this->assertEquals(["integration_name:datadog"], $metrics[0]["payload"]["series"][0]["tags"]);

$this->call(GetSpec::create("autoloaded", "/pdo"));

$response = $this->retrieveDumpedData();
if (!$response) {
$this->fail("Go no response from request-dumper");
}

$this->assertCount(3, $response);
$this->assertCount(4, $response);
$payloads = $this->readTelemetryPayloads($response);

$metrics = array_values(array_filter($payloads, $isMetric));
$payloads = array_values(array_filter($payloads, function($p) use ($isMetric) { return !$isMetric($p); }));

$this->assertEquals("app-started", $payloads[0]["request_type"]);
$this->assertEquals("app-dependencies-loaded", $payloads[1]["request_type"]);
$this->assertEquals("app-integrations-change", $payloads[2]["request_type"]);
Expand All @@ -105,5 +122,11 @@ public function testInstrumentation()
'auto_enabled' => null,
]
], $payloads[2]["payload"]["integrations"]);

$this->assertCount(1, $metrics);
$this->assertEquals("generate-metrics", $metrics[0]["request_type"]);
$this->assertEquals("tracers", $metrics[0]["payload"]["series"][0]["namespace"]);
$this->assertEquals("dd.instrumentation_telemetry_data.tracers.spans_created", $metrics[0]["payload"]["series"][0]["metric"]);
$this->assertEquals(["integration_name:pdo"], $metrics[0]["payload"]["series"][0]["tags"]);
}
}

0 comments on commit 55d2c44

Please sign in to comment.