From e72bd0701032ff787e5aaad06d3ecb4ddb4c9ef0 Mon Sep 17 00:00:00 2001 From: Yufu Zhao Date: Fri, 21 Jul 2023 11:27:31 +0800 Subject: [PATCH] feat(opentelemetry): make endpoint field referenceable (#11220) * feat(opentelemetry): make endpoint field referenceable * docs(changelog): add an entry to the changelog (cherry picked from commit 3e52664684c1cd78c1115249464c051b1619f25a) --- CHANGELOG.md | 2 ++ kong/plugins/opentelemetry/schema.lua | 2 +- spec/03-plugins/37-opentelemetry/04-exporter_spec.lua | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dacd6bf3a05..03c237ceb3a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,8 @@ The field `header_type`now accepts the `aws` value to handle this specific propagation header. [11075](https://github.com/Kong/kong/pull/11075) +- **Opentelemetry**: Support the `endpoint` parameter as referenceable. + [#11220](https://github.com/Kong/kong/pull/11220) - **Ip-Restriction**: Add TCP support to the plugin. Thanks [@scrudge](https://github.com/scrudge) for contributing this change. [#10245](https://github.com/Kong/kong/pull/10245) diff --git a/kong/plugins/opentelemetry/schema.lua b/kong/plugins/opentelemetry/schema.lua index 40466cc65ace..375d87fa00b4 100644 --- a/kong/plugins/opentelemetry/schema.lua +++ b/kong/plugins/opentelemetry/schema.lua @@ -35,7 +35,7 @@ return { { config = { type = "record", fields = { - { endpoint = typedefs.url { required = true } }, -- OTLP/HTTP + { endpoint = typedefs.url { required = true, referenceable = true } }, -- OTLP/HTTP { headers = { description = "The custom headers to be added in the HTTP request sent to the OTLP server. This setting is useful for adding the authentication headers (token) for the APM backend.", type = "map", keys = typedefs.header_name, values = { diff --git a/spec/03-plugins/37-opentelemetry/04-exporter_spec.lua b/spec/03-plugins/37-opentelemetry/04-exporter_spec.lua index 619956ab9753..3e0cbfd2f26e 100644 --- a/spec/03-plugins/37-opentelemetry/04-exporter_spec.lua +++ b/spec/03-plugins/37-opentelemetry/04-exporter_spec.lua @@ -466,6 +466,7 @@ for _, strategy in helpers.each_strategy() do describe("#referenceable fields", function () local mock lazy_setup(function() + helpers.setenv("TEST_OTEL_ENDPOINT", "http://127.0.0.1:" .. HTTP_SERVER_PORT) helpers.setenv("TEST_OTEL_ACCESS_KEY", "secret-1") helpers.setenv("TEST_OTEL_ACCESS_SECRET", "secret-2") @@ -476,6 +477,7 @@ for _, strategy in helpers.each_strategy() do }, { "opentelemetry" })) setup_instrumentations("all", { + endpoint = "{vault://env/test_otel_endpoint}", headers = { ["X-Access-Key"] = "{vault://env/test_otel_access_key}", ["X-Access-Secret"] = "{vault://env/test_otel_access_secret}", @@ -485,6 +487,7 @@ for _, strategy in helpers.each_strategy() do end) lazy_teardown(function() + helpers.unsetenv("TEST_OTEL_ENDPOINT") helpers.unsetenv("TEST_OTEL_ACCESS_KEY") helpers.unsetenv("TEST_OTEL_ACCESS_SECRET") helpers.stop_kong()