Skip to content

Commit 426d960

Browse files
authored
Add path matching to nginx pull requests, fix nginx docker waiting (#20)
1 parent 26826fa commit 426d960

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

.github/workflows/nginx.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
- '.github/workflows/nginx.yml'
99
pull_request:
1010
branches: [ main ]
11+
paths:
12+
- 'instrumentation/nginx/**'
13+
- '.github/workflows/nginx.yml'
1114

1215
jobs:
1316
nginx-build-test:

instrumentation/nginx/test/conf/nginx.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ http {
2626
proxy_pass http://node-backend/;
2727
}
2828

29+
location = /up {
30+
opentelemetry off;
31+
return 200 "ok\n";
32+
}
33+
2934
location = /b3 {
3035
opentelemetry_operation_name test_b3;
3136
opentelemetry_propagate b3;

instrumentation/nginx/test/instrumentation/test/instrumentation_test.exs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,27 @@ defmodule InstrumentationTest do
88
Enum.find(lines, fn line -> String.match?(line, re) end) != nil
99
end
1010

11-
def wait_until_ready(_, %{:collector => true, :express => true}), do: :ready
11+
def poll_nginx(0), do: raise("Timed out waiting for nginx")
12+
13+
def poll_nginx(attempts_remaining) do
14+
case HTTPoison.get("#{@host}/up") do
15+
{:ok, %HTTPoison.Response{status_code: 200}} ->
16+
:ready
17+
18+
_ ->
19+
Process.sleep(200)
20+
poll_nginx(attempts_remaining - 1)
21+
end
22+
end
23+
24+
def wait_nginx() do
25+
poll_nginx(30)
26+
end
27+
28+
def wait_until_ready(_, %{:collector => true, :express => true, :nginx => false}) do
29+
wait_nginx()
30+
:ready
31+
end
1232

1333
def wait_until_ready(port, ctx) do
1434
receive do
@@ -23,7 +43,8 @@ defmodule InstrumentationTest do
2343
port,
2444
Map.merge(ctx, %{
2545
collector: has_collector,
26-
express: has_express
46+
express: has_express,
47+
nginx: false
2748
})
2849
)
2950
after
@@ -306,5 +327,4 @@ defmodule InstrumentationTest do
306327
assert attrib(span, "test.attrib.script") =~ ~r/\d+\.\d+/
307328
assert status == 200
308329
end
309-
310330
end

0 commit comments

Comments
 (0)