From f05fae176b653a604588feca0489e18c500bcd62 Mon Sep 17 00:00:00 2001 From: Zach Leslie Date: Tue, 21 May 2024 15:53:39 +0000 Subject: [PATCH 1/9] Update TLS configuration to control json field names --- tracing.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tracing.go b/tracing.go index 9d085e0..e72f588 100644 --- a/tracing.go +++ b/tracing.go @@ -143,10 +143,19 @@ func (ct *TracingModule) newTemplatedGenerator(g goja.ConstructorCall, rt *goja. return rt.ToValue(generator).ToObject(rt) } +type TLSClientConfig struct { + Insecure bool `json:"insecure"` + InsecureSkipVerify bool `json:"insecure_skip_verify"` + ServerName string `json:"server_name_override"` + CAFile string `json:"ca_file"` + CertFile string `json:"cert_file"` + KeyFile string `json:"key_file"` +} + type ClientConfig struct { - Exporter exporterType `json:"type"` - Endpoint string `json:"url"` - TLS configtls.TLSClientSetting `json:"tls"` + Exporter exporterType `json:"type"` + Endpoint string `json:"url"` + TLS TLSClientConfig `json:"tls"` Authentication struct { User string `json:"user"` Password string `json:"password"` From f88092e03e1dd48f255415ee6d85b1fe41cd3828 Mon Sep 17 00:00:00 2001 From: Zach Leslie Date: Tue, 21 May 2024 15:55:25 +0000 Subject: [PATCH 2/9] Update docker examples after TLS updates --- examples/param/param.js | 5 ++++- examples/template/template.js | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/param/param.js b/examples/param/param.js index fb64ee9..ee908f6 100644 --- a/examples/param/param.js +++ b/examples/param/param.js @@ -12,6 +12,9 @@ const client = new tracing.Client({ endpoint, exporter: tracing.EXPORTER_OTLP, insecure: true, + tls: { + insecure: false, + } }); export default function () { @@ -45,4 +48,4 @@ export default function () { export function teardown() { client.shutdown(); -} \ No newline at end of file +} diff --git a/examples/template/template.js b/examples/template/template.js index c36855f..7ec0432 100644 --- a/examples/template/template.js +++ b/examples/template/template.js @@ -12,7 +12,9 @@ const orgid = __ENV.TEMPO_X_SCOPE_ORGID || "k6-test" const client = new tracing.Client({ endpoint, exporter: tracing.EXPORTER_OTLP, - insecure: true, + tls: { + insecure: false, + }, headers: { "X-Scope-Orgid": orgid } From 55279a7b8b4ed4b8b744a99644720d92cd51158a Mon Sep 17 00:00:00 2001 From: Zach Leslie Date: Tue, 21 May 2024 17:18:40 +0000 Subject: [PATCH 3/9] Include additional struct field --- tracing.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tracing.go b/tracing.go index e72f588..9dfdb0e 100644 --- a/tracing.go +++ b/tracing.go @@ -179,8 +179,9 @@ func NewClient(cfg *ClientConfig, vu modules.VU) (*Client, error) { ) tlsConfig := configtls.TLSClientSetting{ - Insecure: cfg.TLS.Insecure, - ServerName: cfg.TLS.ServerName, + Insecure: cfg.TLS.Insecure, + InsecureSkipVerify: cfg.TLS.InsecureSkipVerify, + ServerName: cfg.TLS.ServerName, TLSSetting: configtls.TLSSetting{ CAFile: cfg.TLS.CAFile, CertFile: cfg.TLS.CertFile, From 26162e84d9d2b047e579ada05fbff4704cc9e17e Mon Sep 17 00:00:00 2001 From: Zach Leslie Date: Wed, 22 May 2024 14:52:56 +0000 Subject: [PATCH 4/9] Clean up struct keys --- tracing.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tracing.go b/tracing.go index 9dfdb0e..8092b7e 100644 --- a/tracing.go +++ b/tracing.go @@ -144,23 +144,23 @@ func (ct *TracingModule) newTemplatedGenerator(g goja.ConstructorCall, rt *goja. } type TLSClientConfig struct { - Insecure bool `json:"insecure"` - InsecureSkipVerify bool `json:"insecure_skip_verify"` - ServerName string `json:"server_name_override"` - CAFile string `json:"ca_file"` - CertFile string `json:"cert_file"` - KeyFile string `json:"key_file"` + Insecure bool `js:"insecure"` + InsecureSkipVerify bool `js:"insecure_skip_verify"` + ServerName string `js:"server_name"` + CAFile string `js:"ca_file"` + CertFile string `js:"cert_file"` + KeyFile string `js:"key_file"` } type ClientConfig struct { - Exporter exporterType `json:"type"` - Endpoint string `json:"url"` - TLS TLSClientConfig `json:"tls"` + Exporter exporterType `js:"exporter"` + Endpoint string `js:"endpoint"` + TLS TLSClientConfig `js:"tls"` Authentication struct { - User string `json:"user"` - Password string `json:"password"` + User string `js:"user"` + Password string `js:"password"` } - Headers map[string]configopaque.String `json:"headers"` + Headers map[string]configopaque.String `js:"headers"` } type Client struct { From 26dae09afdb8d625f8075a89460058885e8dd124 Mon Sep 17 00:00:00 2001 From: Zach Leslie Date: Wed, 22 May 2024 14:54:06 +0000 Subject: [PATCH 5/9] Drop incorrect argument --- examples/param/param.js | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/param/param.js b/examples/param/param.js index ee908f6..0be7164 100644 --- a/examples/param/param.js +++ b/examples/param/param.js @@ -11,7 +11,6 @@ const endpoint = __ENV.ENDPOINT || "otel-collector:4317" const client = new tracing.Client({ endpoint, exporter: tracing.EXPORTER_OTLP, - insecure: true, tls: { insecure: false, } From 5a9c22a42e8ac880d8e9fe4f468ff88ae942c363 Mon Sep 17 00:00:00 2001 From: Zach Leslie Date: Thu, 23 May 2024 13:13:46 +0000 Subject: [PATCH 6/9] Update examples/param/param.js Co-authored-by: A. Stoewer --- examples/param/param.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/param/param.js b/examples/param/param.js index 0be7164..0ba6abc 100644 --- a/examples/param/param.js +++ b/examples/param/param.js @@ -12,7 +12,7 @@ const client = new tracing.Client({ endpoint, exporter: tracing.EXPORTER_OTLP, tls: { - insecure: false, + insecure: true, } }); From a808d9f4a226e4823ac57c20d3065447c53fe5dd Mon Sep 17 00:00:00 2001 From: Zach Leslie Date: Thu, 23 May 2024 13:13:52 +0000 Subject: [PATCH 7/9] Update examples/template/template.js Co-authored-by: A. Stoewer --- examples/template/template.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/template/template.js b/examples/template/template.js index 7ec0432..1f6d17f 100644 --- a/examples/template/template.js +++ b/examples/template/template.js @@ -13,7 +13,7 @@ const client = new tracing.Client({ endpoint, exporter: tracing.EXPORTER_OTLP, tls: { - insecure: false, + insecure: true, }, headers: { "X-Scope-Orgid": orgid From e8339c3ba84b69ac8c24d9134c6fb0d6a6eca649 Mon Sep 17 00:00:00 2001 From: "A. Stoewer" Date: Fri, 24 May 2024 08:54:50 +1000 Subject: [PATCH 8/9] Update docs in README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ef27f17..3fbf5c2 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,9 @@ The configuration is an object with the following schema: // The endpoint to which the traces are sent in the form of : endpoint: string, // The exporter protocol used for sending the traces: tracing.EXPORTER_OTLP or tracing.EXPORTER_JAEGER - exporter: string, + exporter: string, // Whether insecure connections are allowed (optional, default: false) - insecure: bool, + tls: { insecure: true }, // Credentials used for authentication authentication: { user: string, password: string }, // Additional headers sent by the client From 7f2d2ccef17e36f7155b3785dcbdaabe0040b6a8 Mon Sep 17 00:00:00 2001 From: "A. Stoewer" Date: Fri, 24 May 2024 09:11:34 +1000 Subject: [PATCH 9/9] Describe TLS config in README --- README.md | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3fbf5c2..2082c67 100644 --- a/README.md +++ b/README.md @@ -29,13 +29,26 @@ The configuration is an object with the following schema: // The endpoint to which the traces are sent in the form of : endpoint: string, // The exporter protocol used for sending the traces: tracing.EXPORTER_OTLP or tracing.EXPORTER_JAEGER - exporter: string, - // Whether insecure connections are allowed (optional, default: false) - tls: { insecure: true }, - // Credentials used for authentication + exporter: string, + // Credentials used for authentication (optional) authentication: { user: string, password: string }, - // Additional headers sent by the client + // Additional headers sent by the client (optional) headers: { string : string } + // TLS configuration + tls: { + // Whether insecure connections are allowed (optional, default: false) + insecure: boolean, + // Enable TLS but skip verification (optional, default: false) + insecure_skip_verify: boolean, + // The server name requested by the client (optional) + server_name: string, + // The path to the CA certificate file (optional) + ca_file: string, + // The path to the certificate file (optional) + cert_file: string, + // The path to the key file (optional) + key_file: string, + }, } ```